refactor code
This commit is contained in:
parent
79246e0d78
commit
8966750ac8
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').filter('fileOrderBy', ['orderByFilter', 'ariaNgCommonService', function (orderByFilter, ariaNgCommonService) {
|
angular.module('ariaNg').filter('fileOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
|
||||||
return function (array, type) {
|
return function (array, type) {
|
||||||
if (!angular.isArray(array)) {
|
if (!angular.isArray(array)) {
|
||||||
return array;
|
return array;
|
||||||
|
@ -14,11 +14,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderType.type == 'name') {
|
if (orderType.type == 'name') {
|
||||||
return orderByFilter(array, ['fileName'], orderType.reverse);
|
return $filter('orderBy')(array, ['fileName'], orderType.reverse);
|
||||||
} else if (orderType.type == 'size') {
|
} else if (orderType.type == 'size') {
|
||||||
return orderByFilter(array, ['length'], orderType.reverse);
|
return $filter('orderBy')(array, ['length'], orderType.reverse);
|
||||||
} else if (orderType.type == 'percent') {
|
} else if (orderType.type == 'percent') {
|
||||||
return orderByFilter(array, ['completePercent'], orderType.reverse);
|
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
|
||||||
} else {
|
} else {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').filter('peerOrderBy', ['orderByFilter', 'ariaNgCommonService', function (orderByFilter, ariaNgCommonService) {
|
angular.module('ariaNg').filter('peerOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
|
||||||
return function (array, type) {
|
return function (array, type) {
|
||||||
if (!angular.isArray(array)) {
|
if (!angular.isArray(array)) {
|
||||||
return array;
|
return array;
|
||||||
|
@ -14,13 +14,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderType.type == 'address') {
|
if (orderType.type == 'address') {
|
||||||
return orderByFilter(array, ['ip', 'port'], orderType.reverse);
|
return $filter('orderBy')(array, ['ip', 'port'], orderType.reverse);
|
||||||
} else if (orderType.type == 'percent') {
|
} else if (orderType.type == 'percent') {
|
||||||
return orderByFilter(array, ['completePercent'], orderType.reverse);
|
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
|
||||||
} else if (orderType.type == 'dspeed') {
|
} else if (orderType.type == 'dspeed') {
|
||||||
return orderByFilter(array, ['downloadSpeed'], orderType.reverse);
|
return $filter('orderBy')(array, ['downloadSpeed'], orderType.reverse);
|
||||||
} else if (orderType.type == 'uspeed') {
|
} else if (orderType.type == 'uspeed') {
|
||||||
return orderByFilter(array, ['uploadSpeed'], orderType.reverse);
|
return $filter('orderBy')(array, ['uploadSpeed'], orderType.reverse);
|
||||||
} else {
|
} else {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').filter('percent', ['numberFilter', function (numberFilter) {
|
angular.module('ariaNg').filter('percent', ['$filter', function ($filter) {
|
||||||
return function (value, precision) {
|
return function (value, precision) {
|
||||||
var ratio = Math.pow(10, precision);
|
var ratio = Math.pow(10, precision);
|
||||||
var result = parseInt(value * ratio) / ratio;
|
var result = parseInt(value * ratio) / ratio;
|
||||||
|
|
||||||
return numberFilter(result, precision);
|
return $filter('number')(result, precision);
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').filter('taskOrderBy', ['orderByFilter', 'ariaNgCommonService', function (orderByFilter, ariaNgCommonService) {
|
angular.module('ariaNg').filter('taskOrderBy', ['$filter', 'ariaNgCommonService', function ($filter, ariaNgCommonService) {
|
||||||
return function (array, type) {
|
return function (array, type) {
|
||||||
if (!angular.isArray(array)) {
|
if (!angular.isArray(array)) {
|
||||||
return array;
|
return array;
|
||||||
|
@ -14,17 +14,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderType.type == 'name') {
|
if (orderType.type == 'name') {
|
||||||
return orderByFilter(array, ['taskName'], orderType.reverse);
|
return $filter('orderBy')(array, ['taskName'], orderType.reverse);
|
||||||
} else if (orderType.type == 'size') {
|
} else if (orderType.type == 'size') {
|
||||||
return orderByFilter(array, ['totalLength'], orderType.reverse);
|
return $filter('orderBy')(array, ['totalLength'], orderType.reverse);
|
||||||
} else if (orderType.type == 'percent') {
|
} else if (orderType.type == 'percent') {
|
||||||
return orderByFilter(array, ['completePercent'], orderType.reverse);
|
return $filter('orderBy')(array, ['completePercent'], orderType.reverse);
|
||||||
} else if (orderType.type == 'remain') {
|
} else if (orderType.type == 'remain') {
|
||||||
return orderByFilter(array, ['idle', 'remainTime', 'remainLength'], orderType.reverse);
|
return $filter('orderBy')(array, ['idle', 'remainTime', 'remainLength'], orderType.reverse);
|
||||||
} else if (orderType.type == 'dspeed') {
|
} else if (orderType.type == 'dspeed') {
|
||||||
return orderByFilter(array, ['downloadSpeed'], orderType.reverse);
|
return $filter('orderBy')(array, ['downloadSpeed'], orderType.reverse);
|
||||||
} else if (orderType.type == 'uspeed') {
|
} else if (orderType.type == 'uspeed') {
|
||||||
return orderByFilter(array, ['uploadSpeed'], orderType.reverse);
|
return $filter('orderBy')(array, ['uploadSpeed'], orderType.reverse);
|
||||||
} else {
|
} else {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').filter('readableVolumn', ['numberFilter', function (numberFilter) {
|
angular.module('ariaNg').filter('readableVolumn', ['$filter', function ($filter) {
|
||||||
var units = [ 'B', 'KB', 'MB', 'GB' ];
|
var units = [ 'B', 'KB', 'MB', 'GB' ];
|
||||||
var defaultFractionSize = 2;
|
var defaultFractionSize = 2;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value = numberFilter(value, fractionSize);
|
value = $filter('number')(value, fractionSize);
|
||||||
|
|
||||||
return value + ' ' + unit;
|
return value + ' ' + unit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('ariaNgMonitorService', ['$translate', 'moment', 'ariaNgConstants', 'readableVolumnFilter', function ($translate, moment, ariaNgConstants, readableVolumnFilter) {
|
angular.module('ariaNg').factory('ariaNgMonitorService', ['$filter', '$translate', 'moment', 'ariaNgConstants', function ($filter, $translate, moment, ariaNgConstants) {
|
||||||
var storagesInMemory = {};
|
var storagesInMemory = {};
|
||||||
var globalStorageKey = 'global';
|
var globalStorageKey = 'global';
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var time = moment(params[0].name, 'X').format('HH:mm:ss');
|
var time = moment(params[0].name, 'X').format('HH:mm:ss');
|
||||||
var uploadSpeed = readableVolumnFilter(params[0].value) + '/s';
|
var uploadSpeed = $filter('readableVolumn')(params[0].value) + '/s';
|
||||||
var downloadSpeed = readableVolumnFilter(params[1].value) + '/s';
|
var downloadSpeed = $filter('readableVolumn')(params[1].value) + '/s';
|
||||||
|
|
||||||
return '<div>' + time + '</div>'
|
return '<div>' + time + '</div>'
|
||||||
+ '<div><i class="icon-download fa fa-arrow-down"></i> ' + downloadSpeed +'</div>'
|
+ '<div><i class="icon-download fa fa-arrow-down"></i> ' + downloadSpeed +'</div>'
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
type: 'value',
|
type: 'value',
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
formatter: function (value) {
|
formatter: function (value) {
|
||||||
return readableVolumnFilter(value, 0);
|
return $filter('readableVolumn')(value, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue