src/static/css/site.css
static_js_DATA = \
- src/static/js/builders-stats.min.js \
src/static/js/jquery.min.js \
src/static/js/job-log-stream.min.js \
src/static/js/notification-worker.min.js \
static_jsdir = $(staticdir)/js
EXTRA_DIST += \
- src/static/js/builders-stats.js \
src/static/js/job-log-stream.js \
src/static/js/notification-worker.js \
src/static/js/pbs.js
+++ /dev/null
-$(".builders-stats").each(function() {
- // Fetch the name of the builder
- const name = $(this).data("name");
-
- const cpu_usage = $(this).find("#cpu-usage");
- const mem_usage = $(this).find("#mem-usage");
- const swap_usage = $(this).find("#swap-usage");
-
- // Make the URL
- const url = "wss://" + window.location.host + "/builders/" + name + "/stats";
-
- // Try to connect to the stream
- const stream = new WebSocket(url);
-
- // Updates the progressbar and sets a colour
- updateProgressBar = function(e, percentage) {
- // Set the value
- e.val(percentage * 100);
-
- // Remove all classes
- e.removeClass("is-dark is-light is-danger is-warning is-success");
-
- if (percentage >= 0.9) {
- e.addClass("is-danger");
-
- } else if (percentage >= 0.75) {
- e.addClass("is-warning");
-
- } else {
- e.addClass("is-success");
- }
- }
-
- stream.addEventListener("message", (event) => {
- // Parse message as JSON
- const data = JSON.parse(event.data);
-
- console.debug("Message from server: ", data);
-
- // Set CPU usage
- if (cpu_usage)
- updateProgressBar(cpu_usage, data.cpu_usage);
-
- // Set memory usage
- if (mem_usage)
- updateProgressBar(mem_usage, data.mem_usage);
-
- // Set swap usage
- if (swap_usage)
- updateProgressBar(swap_usage, data.swap_usage);
- });
-});
return subscription;
});
});
+
+/*
+ * Builder Stats
+ */
+
+$(".builders-stats").each(function() {
+ // Fetch the name of the builder
+ const name = $(this).data("name");
+
+ const cpu_usage = $(this).find("#cpu-usage");
+ const mem_usage = $(this).find("#mem-usage");
+ const swap_usage = $(this).find("#swap-usage");
+
+ // Make the URL
+ const url = "wss://" + window.location.host + "/builders/" + name + "/stats";
+
+ // Try to connect to the stream
+ const stream = new WebSocket(url);
+
+ // Updates the progressbar and sets a colour
+ updateProgressBar = function(e, percentage) {
+ // Set the value
+ e.val(percentage * 100);
+
+ // Remove all classes
+ e.removeClass("is-dark is-light is-danger is-warning is-success");
+
+ if (percentage >= 0.9) {
+ e.addClass("is-danger");
+
+ } else if (percentage >= 0.75) {
+ e.addClass("is-warning");
+
+ } else {
+ e.addClass("is-success");
+ }
+ }
+
+ stream.addEventListener("message", (event) => {
+ // Parse message as JSON
+ const data = JSON.parse(event.data);
+
+ console.debug("Message from server: ", data);
+
+ // Set CPU usage
+ if (cpu_usage)
+ updateProgressBar(cpu_usage, data.cpu_usage);
+
+ // Set memory usage
+ if (mem_usage)
+ updateProgressBar(mem_usage, data.mem_usage);
+
+ // Set swap usage
+ if (swap_usage)
+ updateProgressBar(swap_usage, data.swap_usage);
+ });
+});
##############################################################################}
{% macro BuilderStats(builder) %}
- {# XXX Not sure if this is a good place to load the JS #}
- <script src="{{ "js/builders-stats.min.js" | static_url }}"></script>
-
<div class="builders-stats" data-name="{{ builder.name }}">
<div class="columns is-vcentered">
<div class="column is-2">