code refactor
This commit is contained in:
parent
62b678c914
commit
f8e3a7e424
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('ariaNgCommonService', ['$location', '$timeout', 'base64', 'SweetAlert', '$translate', 'ariaNgConstants', function ($location, $timeout, base64, SweetAlert, $translate, ariaNgConstants) {
|
angular.module('ariaNg').factory('ariaNgCommonService', ['$location', '$timeout', 'base64', 'moment', 'SweetAlert', '$translate', 'ariaNgConstants', function ($location, $timeout, base64, moment, SweetAlert, $translate, ariaNgConstants) {
|
||||||
return {
|
return {
|
||||||
generateUniqueId: function () {
|
generateUniqueId: function () {
|
||||||
var sourceId = ariaNgConstants.appPrefix + '_' + Math.round(new Date().getTime() / 1000) + '_' + Math.random();
|
var sourceId = ariaNgConstants.appPrefix + '_' + Math.round(new Date().getTime() / 1000) + '_' + Math.random();
|
||||||
|
@ -215,6 +215,12 @@
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
getCurrentUnixTime: function () {
|
||||||
|
return moment().format('X');
|
||||||
|
},
|
||||||
|
getLongTimeFronUnixTime: function (unixTime) {
|
||||||
|
return moment(unixTime, 'X').format('HH:mm:ss');
|
||||||
|
},
|
||||||
getTimeOptions: function (timeList, withDisabled) {
|
getTimeOptions: function (timeList, withDisabled) {
|
||||||
var options = [];
|
var options = [];
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('ariaNgLogService', ['$log', 'moment', 'ariaNgConstants', function ($log, moment, ariaNgConstants) {
|
angular.module('ariaNg').factory('ariaNgLogService', ['$log', 'ariaNgConstants', function ($log, ariaNgConstants) {
|
||||||
var enableDebugLog = false;
|
var enableDebugLog = false;
|
||||||
var cachedDebugLogs = [];
|
var cachedDebugLogs = [];
|
||||||
|
|
||||||
var createNewCacheLogItem = function (msg, level, obj) {
|
var createNewCacheLogItem = function (msg, level, obj) {
|
||||||
return {
|
return {
|
||||||
time: moment(),
|
time: new Date(),
|
||||||
level: level,
|
level: level,
|
||||||
content: msg,
|
content: msg,
|
||||||
attachment: obj
|
attachment: obj
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('ariaNgMonitorService', ['$filter', '$translate', 'moment', 'ariaNgConstants', function ($filter, $translate, moment, ariaNgConstants) {
|
angular.module('ariaNg').factory('ariaNgMonitorService', ['$filter', '$translate', 'ariaNgConstants', 'ariaNgCommonService', function ($filter, $translate, ariaNgConstants, ariaNgCommonService) {
|
||||||
var currentGlobalStat = {};
|
var currentGlobalStat = {};
|
||||||
var storagesInMemory = {};
|
var storagesInMemory = {};
|
||||||
var globalStorageKey = 'global';
|
var globalStorageKey = 'global';
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
return '<div>' + $translate.instant('No Data') + '</div>';
|
return '<div>' + $translate.instant('No Data') + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
var time = moment(params[0].name, 'X').format('HH:mm:ss');
|
var time = ariaNgCommonService.getLongTimeFronUnixTime(params[0].name);
|
||||||
var uploadSpeed = $filter('readableVolume')(params[0].value) + '/s';
|
var uploadSpeed = $filter('readableVolume')(params[0].value) + '/s';
|
||||||
var downloadSpeed = $filter('readableVolume')(params[1].value) + '/s';
|
var downloadSpeed = $filter('readableVolume')(params[1].value) + '/s';
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
initStorage(key);
|
initStorage(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
stat.time = moment().format('X');
|
stat.time = ariaNgCommonService.getCurrentUnixTime();
|
||||||
pushToStorage(key, stat);
|
pushToStorage(key, stat);
|
||||||
},
|
},
|
||||||
getStatsData: function (key) {
|
getStatsData: function (key) {
|
||||||
|
|
Reference in a new issue