From fba2d226efb20df3a69f2724c4f2a3e536b47890 Mon Sep 17 00:00:00 2001 From: Vaclav Valicek Date: Fri, 1 Jun 2018 09:14:59 +0200 Subject: [PATCH] Show file sizes of artifacts (#53) Show artifacts sizes in webui --- src/laminar.cpp | 1 + src/resources/index.html | 2 +- src/resources/js/app.js | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/laminar.cpp b/src/laminar.cpp index 4aa3ae6..aec1950 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -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(); } } diff --git a/src/resources/index.html b/src/resources/index.html index ad3134e..0ed94f3 100644 --- a/src/resources/index.html +++ b/src/resources/index.html @@ -222,7 +222,7 @@
Artifacts
diff --git a/src/resources/js/app.js b/src/resources/js/app.js index a9a7da4..13eb2b1 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -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);