support save session and shutdown arai2

This commit is contained in:
MaysWind 2016-06-06 00:01:11 +08:00
parent 5027707dec
commit 3f4c66a14e
9 changed files with 183 additions and 1 deletions

View file

@ -253,6 +253,7 @@
<script src="../bower_components/angular-base64/angular-base64.min.js"></script> <script src="../bower_components/angular-base64/angular-base64.min.js"></script>
<script src="../bower_components/angular-local-storage/dist/angular-local-storage.min.js"></script> <script src="../bower_components/angular-local-storage/dist/angular-local-storage.min.js"></script>
<script src="../bower_components/angular-busy/dist/angular-busy.min.js"></script> <script src="../bower_components/angular-busy/dist/angular-busy.min.js"></script>
<script src="../bower_components/angular-promise-buttons/dist/angular-promise-buttons.min.js"></script>
<script src="../bower_components/angular-dragula/dist/angular-dragula.min.js"></script> <script src="../bower_components/angular-dragula/dist/angular-dragula.min.js"></script>
<script src="../bower_components/angular-bootstrap-slider/slider.js"></script> <script src="../bower_components/angular-bootstrap-slider/slider.js"></script>
<script src="../bower_components/ngSweetAlert/SweetAlert.js"></script> <script src="../bower_components/ngSweetAlert/SweetAlert.js"></script>

View file

@ -1,5 +1,6 @@
{ {
"Simplified Chinese": "简体中文", "Simplified Chinese": "简体中文",
"Operation Succeeded": "操作成功",
"Error": "错误", "Error": "错误",
"OK": "确定", "OK": "确定",
"Cancel": "取消", "Cancel": "取消",
@ -79,6 +80,15 @@
"Download Task Refresh Interval": "下载任务刷新间隔", "Download Task Refresh Interval": "下载任务刷新间隔",
"Aria2 Version": "Aria2 版本", "Aria2 Version": "Aria2 版本",
"Enabled Features": "已启用的功能", "Enabled Features": "已启用的功能",
"Functions": "方法",
"Save Session": "保存会话",
"Shutdown Aria2": "关闭 Aria2",
"Confirm Shutdown": "确认关闭",
"Are you sure you want to shutdown aria2?": "您是否要关闭 Aria2?",
"Session has been saved successfully.": "会话已经成功保存.",
"Failed to save session.": "会话保存失败.",
"Aria2 has been shutdown successfully.": "Aria2 已经成功关闭.",
"Failed to shutdown aria2.": "关闭 Aria2 失败.",
"Toggle Navigation": "切换导航", "Toggle Navigation": "切换导航",
"Loading": "正在加载...", "Loading": "正在加载...",
"More Than One Day": "超过1天", "More Than One Day": "超过1天",

View file

@ -4,6 +4,7 @@
angular.module('ariaNg').config(['$translateProvider', function ($translateProvider) { angular.module('ariaNg').config(['$translateProvider', function ($translateProvider) {
$translateProvider.translations('en-US', { $translateProvider.translations('en-US', {
'English': 'English', 'English': 'English',
'Operation Succeeded': 'Operation Succeeded',
'Error': 'Error', 'Error': 'Error',
'OK': 'OK', 'OK': 'OK',
'Cancel': 'Cancel', 'Cancel': 'Cancel',
@ -83,6 +84,15 @@
'Download Task Refresh Interval': 'Download Task Refresh Interval', 'Download Task Refresh Interval': 'Download Task Refresh Interval',
'Aria2 Version': 'Aria2 Version', 'Aria2 Version': 'Aria2 Version',
'Enabled Features': 'Enabled Features', 'Enabled Features': 'Enabled Features',
'Functions': 'Functions',
'Save Session': 'Save Session',
'Shutdown Aria2': 'Shutdown Aria2',
'Confirm Shutdown': 'Confirm Shutdown',
'Are you sure you want to shutdown aria2?': 'Are you sure you want to shutdown aria2?',
'Session has been saved successfully.': 'Session has been saved successfully.',
'Failed to save session.': 'Failed to save session.',
'Aria2 has been shutdown successfully.': 'Aria2 has been shutdown successfully.',
'Failed to shutdown aria2.': 'Failed to shutdown aria2.',
'Toggle Navigation': 'Toggle Navigation', 'Toggle Navigation': 'Toggle Navigation',
'Loading': 'Loading...', 'Loading': 'Loading...',
'More Than One Day': 'More than 1 day', 'More Than One Day': 'More than 1 day',

View file

@ -1,11 +1,33 @@
(function () { (function () {
'use strict'; 'use strict';
angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', 'aria2SettingService', function ($rootScope, $scope, aria2SettingService) { angular.module('ariaNg').controller('Aria2StatusController', ['$rootScope', '$scope', 'ariaNgCommonService', 'aria2SettingService', function ($rootScope, $scope, ariaNgCommonService, aria2SettingService) {
$rootScope.loadPromise = (function () { $rootScope.loadPromise = (function () {
return aria2SettingService.getServerStatus(function (result) { return aria2SettingService.getServerStatus(function (result) {
$scope.serverStatus = result; $scope.serverStatus = result;
}); });
})(); })();
$scope.saveSession = function () {
return aria2SettingService.saveSession(function (result) {
if (result == 'OK') {
ariaNgCommonService.showOperationSucceeded('Session has been saved successfully.');
} else {
ariaNgCommonService.showError('Failed to save session.');
}
});
};
$scope.shutdown = function () {
ariaNgCommonService.confirm('Confirm Shutdown', 'Are you sure you want to shutdown aria2?', 'warning', function (status) {
return aria2SettingService.shutdown(function (result) {
if (result == 'OK') {
ariaNgCommonService.showOperationSucceeded('Aria2 has been shutdown successfully.');
} else {
ariaNgCommonService.showError('Failed to shutdown aria2.');
}
});
}, true);
};
}]); }]);
})(); })();

View file

@ -14,6 +14,7 @@
'base64', 'base64',
'LocalStorageModule', 'LocalStorageModule',
'cgBusy', 'cgBusy',
'angularPromiseButtons',
'ui.bootstrap-slider', 'ui.bootstrap-slider',
'oitozero.ngSweetAlert', 'oitozero.ngSweetAlert',
angularDragula(angular) angularDragula(angular)

View file

@ -104,6 +104,16 @@
callback(stat); callback(stat);
} }
}); });
},
saveSession: function (callback) {
return aria2RpcService.saveSession({
callback: callback
})
},
shutdown: function (callback) {
return aria2RpcService.shutdown({
callback: callback
})
} }
}; };
}]); }]);

View file

@ -408,6 +408,120 @@ td {
border-color: #208fe5; border-color: #208fe5;
} }
/* angular-promise-buttons */
@-webkit-keyframes three-quarters {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-moz-keyframes three-quarters {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-o-keyframes three-quarters {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes three-quarters {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.btn-spinner {
font-family: sans-serif;
font-weight: 100;
}
.btn-spinner:not(:required) {
-webkit-animation: three-quarters 1250ms infinite linear;
-moz-animation: three-quarters 1250ms infinite linear;
-ms-animation: three-quarters 1250ms infinite linear;
-o-animation: three-quarters 1250ms infinite linear;
animation: three-quarters 1250ms infinite linear;
border: 3px solid #8c8c8c;
border-right-color: transparent;
border-radius: 100%;
box-sizing: border-box;
display: inline-block;
position: relative;
vertical-align: middle;
overflow: hidden;
text-indent: -9999px;
width: 18px;
height: 18px;
}
.btn-primary .btn-spinner:not(:required), .btn-danger .btn-spinner:not(:required) {
border: 3px solid #efefef;
border-right-color: transparent;
}
.btn-spinner:not(:required) {
margin-left: -22px;
opacity: 0;
transition: 0.4s margin ease-out, 0.2s opacity ease-out;
}
.is-loading .btn-spinner {
transition: 0.2s margin ease-in, 0.4s opacity ease-in;
margin-left: 5px;
opacity: 1;
}
/* angular-dragula extend */ /* angular-dragula extend */
.gu-mirror { .gu-mirror {
cursor: grabbing; cursor: grabbing;

View file

@ -16,5 +16,18 @@
<span class="wholeline" ng-repeat="feature in serverStatus.enabledFeatures" ng-bind="feature"></span> <span class="wholeline" ng-repeat="feature in serverStatus.enabledFeatures" ng-bind="feature"></span>
</div> </div>
</div> </div>
<div class="row ng-cloak" ng-if="serverStatus">
<div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Functions</span>
</div>
<div class="setting-value col-sm-8">
<button class="btn btn-primary" ng-click="saveSession()" promise-btn>
<span translate>Save Session</span>
</button>
<button class="btn btn-danger" ng-click="shutdown()">
<span translate>Shutdown Aria2</span>
</button>
</div>
</div>
</div> </div>
</section> </section>

View file

@ -46,6 +46,7 @@
"angular-base64": "^2.0.5", "angular-base64": "^2.0.5",
"angular-local-storage": "^0.2.7", "angular-local-storage": "^0.2.7",
"angular-busy": "^4.1.3", "angular-busy": "^4.1.3",
"angular-promise-buttons": "^0.1.14",
"angular-dragula": "^1.2.7", "angular-dragula": "^1.2.7",
"angular-bootstrap-slider": "^0.1.28", "angular-bootstrap-slider": "^0.1.28",
"ngSweetAlert": "https://github.com/oitozero/ngSweetAlert.git#8df6c30b0996f09cb4cf5e90a41115a6c09fa852" "ngSweetAlert": "https://github.com/oitozero/ngSweetAlert.git#8df6c30b0996f09cb4cf5e90a41115a6c09fa852"