mirror of
https://github.com/ohwgiles/laminar.git
synced 2025-06-13 12:54:29 +00:00
Show artifacts sizes in webui
This commit is contained in:
parent
568435cc8e
commit
4acf4fddf6
@ -133,6 +133,7 @@ void Laminar::populateArtifacts(Json &j, std::string job, uint num) const {
|
||||
j.StartObject();
|
||||
j.set("url", archiveUrl + it->path().string().substr(prefixLen));
|
||||
j.set("filename", it->path().string().substr(scopeLen+1));
|
||||
j.set("size", fs::file_size(it->path()));
|
||||
j.EndObject();
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@
|
||||
<div class="panel-heading">Artifacts</div>
|
||||
<div class="panel-body">
|
||||
<ul class="list-unstyled" style="margin-bottom: 0">
|
||||
<li v-for="art in job.artifacts"><a :href="art.url" target="_self">{{art.filename}}</a></li>
|
||||
<li v-for="art in job.artifacts"><a :href="art.url" target="_self">{{art.filename}}</a> [{{ art.size | prettyBytes }}]</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,6 +2,37 @@
|
||||
* frontend application for Laminar Continuous Integration
|
||||
* https://laminar.ohwg.net
|
||||
*/
|
||||
|
||||
;;;
|
||||
// usage: {{ file.size | prettyBytes }}
|
||||
// source: https://gist.github.com/james2doyle/4aba55c22f084800c199
|
||||
Vue.filter('prettyBytes', function (num) {
|
||||
// jacked from: https://github.com/sindresorhus/pretty-bytes
|
||||
if (typeof num !== 'number' || isNaN(num)) {
|
||||
throw new TypeError('Expected a number');
|
||||
}
|
||||
|
||||
var exponent;
|
||||
var unit;
|
||||
var neg = num < 0;
|
||||
var units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
if (neg) {
|
||||
num = -num;
|
||||
}
|
||||
|
||||
if (num < 1) {
|
||||
return (neg ? '-' : '') + num + ' B';
|
||||
}
|
||||
|
||||
exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1);
|
||||
num = (num / Math.pow(1000, exponent)).toFixed(2) * 1;
|
||||
unit = units[exponent];
|
||||
|
||||
return (neg ? '-' : '') + num + ' ' + unit;
|
||||
});
|
||||
|
||||
|
||||
const wsp = function(path) {
|
||||
return new WebSocket((location.protocol === 'https:'?'wss://':'ws://')
|
||||
+ location.host + path);
|
||||
|
Loading…
Reference in New Issue
Block a user