support drag to change waiting task order when display order is set default

This commit is contained in:
MaysWind 2016-06-01 00:09:11 +08:00
parent e5a9454ae2
commit 2004ec6c9b
8 changed files with 65 additions and 6 deletions

View file

@ -21,6 +21,7 @@
<link rel="stylesheet" href="../bower_components/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"/> <link rel="stylesheet" href="../bower_components/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"/>
<link rel="stylesheet" href="../bower_components/angular/angular-csp.css"/> <link rel="stylesheet" href="../bower_components/angular/angular-csp.css"/>
<link rel="stylesheet" href="../bower_components/angular-busy/dist/angular-busy.min.css"/> <link rel="stylesheet" href="../bower_components/angular-busy/dist/angular-busy.min.css"/>
<link rel="stylesheet" href="../bower_components/angular-dragula/dist/dragula.min.css"/>
<!-- endbuild --> <!-- endbuild -->
<!-- build:css css/aria-ng.min.css --> <!-- build:css css/aria-ng.min.css -->
<link rel="stylesheet" href="styles/aria-ng.css"> <link rel="stylesheet" href="styles/aria-ng.css">
@ -252,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-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>
<!-- endbuild --> <!-- endbuild -->

View file

@ -1,12 +1,17 @@
(function () { (function () {
'use strict'; 'use strict';
angular.module('ariaNg').controller('DownloadListController', ['$rootScope', '$scope', '$window', '$location', '$interval', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgTaskService', function ($rootScope, $scope, $window, $location, $interval, ariaNgCommonService, ariaNgSettingService, ariaNgTaskService) { angular.module('ariaNg').controller('DownloadListController', ['$rootScope', '$scope', '$window', '$location', '$route', '$interval', 'dragulaService', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgTaskService', function ($rootScope, $scope, $window, $location, $route, $interval, dragulaService, ariaNgCommonService, ariaNgSettingService, ariaNgTaskService) {
var location = $location.path().substring(1); var location = $location.path().substring(1);
var downloadTaskRefreshPromise = null; var downloadTaskRefreshPromise = null;
var pauseDownloadTaskRefresh = false;
var needRequestWholeInfo = true; var needRequestWholeInfo = true;
var refreshDownloadTask = function () { var refreshDownloadTask = function () {
if (pauseDownloadTaskRefresh) {
return;
}
return ariaNgTaskService.getTaskList(location, needRequestWholeInfo, function (result) { return ariaNgTaskService.getTaskList(location, needRequestWholeInfo, function (result) {
if (!ariaNgCommonService.extendArray(result, $rootScope.taskContext.list, 'gid')) { if (!ariaNgCommonService.extendArray(result, $rootScope.taskContext.list, 'gid')) {
if (needRequestWholeInfo) { if (needRequestWholeInfo) {
@ -42,12 +47,37 @@
return ariaNgSettingService.getDisplayOrder(); return ariaNgSettingService.getDisplayOrder();
}; };
$scope.isSupportDragTask = function () {
var displayOrder = ariaNgCommonService.parseOrderType(ariaNgSettingService.getDisplayOrder());
return location == 'waiting' && displayOrder.type == 'default';
};
if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) { if (ariaNgSettingService.getDownloadTaskRefreshInterval() > 0) {
downloadTaskRefreshPromise = $interval(function () { downloadTaskRefreshPromise = $interval(function () {
refreshDownloadTask(); refreshDownloadTask();
}, ariaNgSettingService.getDownloadTaskRefreshInterval()); }, ariaNgSettingService.getDownloadTaskRefreshInterval());
} }
dragulaService.options($scope, 'task-list', {
revertOnSpill: true,
moves: function (el, container, handle) {
return $scope.isSupportDragTask();
}
});
$scope.$on('task-list.drop-model', function (el, target, source) {
var element = angular.element(target);
var gid = element.attr('data-gid');
var index = element.index();
pauseDownloadTaskRefresh = true;
ariaNgTaskService.changeTaskPosition(gid, index, function (result) {
pauseDownloadTaskRefresh = false;
});
});
$scope.$on('$destroy', function () { $scope.$on('$destroy', function () {
if (downloadTaskRefreshPromise) { if (downloadTaskRefreshPromise) {
$interval.cancel(downloadTaskRefreshPromise); $interval.cancel(downloadTaskRefreshPromise);

View file

@ -15,6 +15,7 @@
'LocalStorageModule', 'LocalStorageModule',
'cgBusy', 'cgBusy',
'ui.bootstrap-slider', 'ui.bootstrap-slider',
'oitozero.ngSweetAlert' 'oitozero.ngSweetAlert',
angularDragula(angular)
]); ]);
})(); })();

View file

@ -234,9 +234,12 @@
return invoke('tellStopped', requestContext); return invoke('tellStopped', requestContext);
}, },
// changePosition: function (context) { changePosition: function (context) {
// return invoke('changePosition', context); return invoke('changePosition', {
// }, params: [context.gid, context.pos, context.how],
callback: context.callback
});
},
// changeUri: function (context) { // changeUri: function (context) {
// return invoke('changeUri', context); // return invoke('changeUri', context);
// }, // },

View file

@ -169,6 +169,14 @@
callback: callback callback: callback
}); });
}, },
changeTaskPosition: function (gid, position, callback) {
return aria2RpcService.changePosition({
gid: gid,
pos: position,
how: 'POS_SET',
callback: callback
})
},
processDownloadTasks: function (tasks) { processDownloadTasks: function (tasks) {
if (!angular.isArray(tasks)) { if (!angular.isArray(tasks)) {
return; return;

View file

@ -408,6 +408,13 @@ td {
border-color: #208fe5; border-color: #208fe5;
} }
/* angular-dragula extend */
.gu-mirror {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}
/* task-table */ /* task-table */
.task-table { .task-table {
margin-left: 15px; margin-left: 15px;
@ -429,6 +436,13 @@ td {
cursor: pointer; cursor: pointer;
} }
.task-table > .task-table-body.draggable {
cursor: move;
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}
.task-table > .task-table-body > div.row { .task-table > .task-table-body > div.row {
padding-top: 8px; padding-top: 8px;
padding-bottom: 8px; padding-bottom: 8px;

View file

@ -32,7 +32,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="task-table-body"> <div class="task-table-body" ng-class="{'draggable': isSupportDragTask()}" dragula="'task-list'" dragula-model="taskContext.list">
<div class="row" ng-repeat="task in taskContext.list | filter: filterByTaskName | taskOrderBy: getOrderType()" data-gid="{{task.gid}}"> <div class="row" ng-repeat="task in taskContext.list | filter: filterByTaskName | taskOrderBy: getOrderType()" data-gid="{{task.gid}}">
<div class="col-sm-8"> <div class="col-sm-8">
<div class="checkbox checkbox-primary" ng-class="{'checkbox-hide': !taskContext.selected[task.gid]}"> <div class="checkbox checkbox-primary" ng-class="{'checkbox-hide': !taskContext.selected[task.gid]}">

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-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"
} }