mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Merge remote-tracking branch 'syncthing/pr/1577'
* syncthing/pr/1577: Add uptime in webgui (fixes #1501) Conflicts: cmd/syncthing/gui.go internal/auto/gui.files.go
This commit is contained in:
commit
207b43499c
0
cmd/syncthing/.stfolder
Normal file
0
cmd/syncthing/.stfolder
Normal file
@ -47,6 +47,7 @@ var (
|
||||
configInSync = true
|
||||
guiErrors = []guiError{}
|
||||
guiErrorsMut sync.Mutex
|
||||
startTime = time.Now()
|
||||
eventSub *events.BufferedSubscription
|
||||
)
|
||||
|
||||
@ -519,6 +520,7 @@ func restGetSystem(w http.ResponseWriter, r *http.Request) {
|
||||
cpuUsageLock.RUnlock()
|
||||
res["cpuPercent"] = cpusum / float64(len(cpuUsagePercent)) / float64(runtime.NumCPU())
|
||||
res["pathSeparator"] = string(filepath.Separator)
|
||||
res["uptime"] = int(time.Since(startTime).Seconds())
|
||||
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
json.NewEncoder(w).Encode(res)
|
||||
|
@ -158,6 +158,7 @@
|
||||
"Upgrade To {%version%}": "Upgrade To {{version}}",
|
||||
"Upgrading": "Upgrading",
|
||||
"Upload Rate": "Upload Rate",
|
||||
"Uptime": "Uptime",
|
||||
"Use HTTPS for GUI": "Use HTTPS for GUI",
|
||||
"Version": "Version",
|
||||
"Versions Path": "Versions Path",
|
||||
|
@ -320,6 +320,10 @@
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="glyphicon glyphicon-time"></span> <span translate>Uptime</span></th>
|
||||
<td class="text-right">{{system.uptime | duration:"m"}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span class="glyphicon glyphicon-tag"></span> <span translate>Version</span></th>
|
||||
<td class="text-right">{{version}}</td>
|
||||
@ -1038,6 +1042,7 @@
|
||||
<script src="scripts/syncthing/core/filters/alwaysNumberFilter.js"></script>
|
||||
<script src="scripts/syncthing/core/filters/basenameFilter.js"></script>
|
||||
<script src="scripts/syncthing/core/filters/binaryFilter.js"></script>
|
||||
<script src="scripts/syncthing/core/filters/durationFilter.js"></script>
|
||||
<script src="scripts/syncthing/core/filters/naturalFilter.js"></script>
|
||||
<script src="scripts/syncthing/core/services/localeService.js"></script>
|
||||
|
||||
|
@ -1069,7 +1069,7 @@ angular.module('syncthing.core')
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
folders.sort();
|
||||
return folders;
|
||||
|
35
gui/scripts/syncthing/core/filters/durationFilter.js
Normal file
35
gui/scripts/syncthing/core/filters/durationFilter.js
Normal 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) + "]";
|
||||
};
|
||||
});
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user