Add uptime in webgui (fixes #1501)

This commit is contained in:
ralder
2015-04-03 21:00:13 +03:00
committed by Sergey Mishin
parent a5edb6807e
commit b5d7ce8ebe
6 changed files with 54 additions and 7 deletions

View File

@@ -1069,7 +1069,7 @@ angular.module('syncthing.core')
break;
}
}
};
}
folders.sort();
return folders;

View File

@@ -0,0 +1,35 @@
/** convert amount of seconds to string format "d h m s" without zero values
* precision must be one of 'd', 'h', 'm', 's'(default)
* Example:
* {{121020003|duration}} --> 1400d 16h 40m 3s
* {{121020003|duration:"m"}} --> 1400d 16h 40m
* {{121020003|duration:"h"}} --> 1400d 16h
* {{1|duration:"h"}} --> <1h
**/
angular.module('syncthing.core')
.filter('duration', function () {
'use strict';
var SECONDS_IN = {"d": 86400, "h": 3600, "m": 60, "s": 1};
return function (input, precision) {
var result = "";
if (!precision) {
precision = "s";
}
input = parseInt(input, 10);
for (var k in SECONDS_IN) {
var t = (input/SECONDS_IN[k] | 0); // Math.floor
if (t > 0) {
result += " " + t + k;
}
if (precision == k) {
return result ? result : "<1" + k;
} else {
input %= SECONDS_IN[k];
}
}
return "[Error: incorrect usage, precision must be one of " + Object.keys(SECONDS_IN) + "]";
};
});