1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

Show file sizes of artifacts (#53)

Show artifacts sizes in webui
This commit is contained in:
Vaclav Valicek 2018-06-01 09:14:59 +02:00 committed by Oliver Giles
parent bbbef11304
commit fba2d226ef
3 changed files with 9 additions and 1 deletions

View File

@ -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();
}
}

View File

@ -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 | iecFileSize }}]</li>
</ul>
</div>
</div>

View File

@ -2,6 +2,13 @@
* frontend application for Laminar Continuous Integration
* https://laminar.ohwg.net
*/
Vue.filter('iecFileSize', function(bytes) {
var exp = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, exp)).toFixed(1) + ' ' +
['B', 'KiB', 'MiB', 'GiB', 'TiB'][exp];
});
const wsp = function(path) {
return new WebSocket((location.protocol === 'https:'?'wss://':'ws://')
+ location.host + path);