diff --git a/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs b/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs index 82c20cc07..6f0324c6a 100644 --- a/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs +++ b/src/NzbDrone.Core/Lifecycle/Commands/RestartCommand.cs @@ -4,5 +4,12 @@ namespace NzbDrone.Core.Lifecycle.Commands { public class RestartCommand : Command { + public override bool SendUpdatesToClient + { + get + { + return true; + } + } } } diff --git a/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs b/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs index b0fffd8e5..f1d20c46e 100644 --- a/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs +++ b/src/NzbDrone.Core/Lifecycle/Commands/ShutdownCommand.cs @@ -4,5 +4,12 @@ namespace NzbDrone.Core.Lifecycle.Commands { public class ShutdownCommand : Command { + public override bool SendUpdatesToClient + { + get + { + return true; + } + } } } diff --git a/src/NzbDrone.Core/Lifecycle/LifestyleService.cs b/src/NzbDrone.Core/Lifecycle/LifestyleService.cs index bc09bf877..f051e723b 100644 --- a/src/NzbDrone.Core/Lifecycle/LifestyleService.cs +++ b/src/NzbDrone.Core/Lifecycle/LifestyleService.cs @@ -1,7 +1,9 @@ using System.IO; +using NLog; using NzbDrone.Common; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Processes; +using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Lifecycle.Commands; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; @@ -16,23 +18,27 @@ namespace NzbDrone.Core.Lifecycle private readonly IAppFolderInfo _appFolderInfo; private readonly IServiceProvider _serviceProvider; private readonly IProcessProvider _processProvider; + private readonly Logger _logger; public LifestyleService(IEventAggregator eventAggregator, IRuntimeInfo runtimeInfo, IAppFolderInfo appFolderInfo, IServiceProvider serviceProvider, - IProcessProvider processProvider) + IProcessProvider processProvider, + Logger logger) { _eventAggregator = eventAggregator; _runtimeInfo = runtimeInfo; _appFolderInfo = appFolderInfo; _serviceProvider = serviceProvider; _processProvider = processProvider; + _logger = logger; } public void Execute(ShutdownCommand message) { + _logger.ProgressInfo("Shutdown requested, goodbye."); _eventAggregator.PublishEvent(new ApplicationShutdownRequested()); if (_runtimeInfo.IsWindowsService) @@ -43,6 +49,7 @@ namespace NzbDrone.Core.Lifecycle public void Execute(RestartCommand message) { + _logger.ProgressInfo("Restart requested, brb."); _eventAggregator.PublishEvent(new ApplicationShutdownRequested(true)); if (_runtimeInfo.IsWindowsService) diff --git a/src/UI/Content/icons.less b/src/UI/Content/icons.less index 3a648cf33..6b1d51aca 100644 --- a/src/UI/Content/icons.less +++ b/src/UI/Content/icons.less @@ -167,3 +167,12 @@ .icon(@cloud-download); color: @errorText; } + +.icon-nd-shutdown:before { + .icon(@off); + color: @errorText; +} + +.icon-nd-restart:before { + .icon(@repeat); +} \ No newline at end of file diff --git a/src/UI/Content/theme.less b/src/UI/Content/theme.less index e5916eb0c..68581bead 100644 --- a/src/UI/Content/theme.less +++ b/src/UI/Content/theme.less @@ -218,4 +218,27 @@ body { width: 100%; height: 55px; opacity: 0; +} + +.lifecycle-controls { + font-size: 20px; + + i { + cursor: pointer; + } + + .drone-button { + height: .8em; + margin-left: -8px; + + &:hover { + .icon-stack-base:before { + .icon(@sign-blank) + } + + .icon-nd-restart:before { + color: white; + } + } + } } \ No newline at end of file diff --git a/src/UI/System/SystemLayout.js b/src/UI/System/SystemLayout.js index d4a34ae12..7a5d51368 100644 --- a/src/UI/System/SystemLayout.js +++ b/src/UI/System/SystemLayout.js @@ -5,12 +5,14 @@ define( 'marionette', 'System/Info/SystemInfoLayout', 'System/Logs/LogsLayout', - 'System/Update/UpdateLayout' + 'System/Update/UpdateLayout', + 'Commands/CommandController' ], function (Backbone, Marionette, SystemInfoLayout, LogsLayout, - UpdateLayout) { + UpdateLayout, + CommandController) { return Marionette.Layout.extend({ template: 'System/SystemLayoutTemplate', @@ -27,9 +29,11 @@ define( }, events: { - 'click .x-info-tab' : '_showInfo', + 'click .x-info-tab' : '_showInfo', 'click .x-logs-tab' : '_showLogs', - 'click .x-updates-tab': '_showUpdates' + 'click .x-updates-tab': '_showUpdates', + 'click .x-shutdown' : '_shutdown', + 'click .x-restart' : '_restart' }, initialize: function (options) { @@ -83,6 +87,18 @@ define( this.updates.show(new UpdateLayout()); this.ui.updatesTab.tab('show'); this._navigate('system/updates'); + }, + + _shutdown: function () { + CommandController.Execute('shutdown', { + name : 'shutdown' + }); + }, + + _restart: function () { + CommandController.Execute('restart', { + name : 'restart' + }); } }); }); diff --git a/src/UI/System/SystemLayoutTemplate.html b/src/UI/System/SystemLayoutTemplate.html index d95a3996b..2d3e45480 100644 --- a/src/UI/System/SystemLayoutTemplate.html +++ b/src/UI/System/SystemLayoutTemplate.html @@ -2,6 +2,19 @@