Show file sizes of artifacts (#53)

Show artifacts sizes in webui
pull/70/head
Vaclav Valicek 6 years ago committed by Oliver Giles
parent bbbef11304
commit fba2d226ef

@ -133,6 +133,7 @@ void Laminar::populateArtifacts(Json &j, std::string job, uint num) const {
j.StartObject(); j.StartObject();
j.set("url", archiveUrl + it->path().string().substr(prefixLen)); j.set("url", archiveUrl + it->path().string().substr(prefixLen));
j.set("filename", it->path().string().substr(scopeLen+1)); j.set("filename", it->path().string().substr(scopeLen+1));
j.set("size", fs::file_size(it->path()));
j.EndObject(); j.EndObject();
} }
} }

@ -222,7 +222,7 @@
<div class="panel-heading">Artifacts</div> <div class="panel-heading">Artifacts</div>
<div class="panel-body"> <div class="panel-body">
<ul class="list-unstyled" style="margin-bottom: 0"> <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> </ul>
</div> </div>
</div> </div>

@ -2,6 +2,13 @@
* frontend application for Laminar Continuous Integration * frontend application for Laminar Continuous Integration
* https://laminar.ohwg.net * 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) { const wsp = function(path) {
return new WebSocket((location.protocol === 'https:'?'wss://':'ws://') return new WebSocket((location.protocol === 'https:'?'wss://':'ws://')
+ location.host + path); + location.host + path);

Loading…
Cancel
Save