17417: remove the coffee-rails gem dependency in wb1, and convert the
[arvados.git] / apps / workbench / app / assets / javascripts / keep_disks.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 (function() {
6   var cache_age_axis_label, cache_age_hover, cache_age_in_days, float_as_percentage;
7
8   cache_age_in_days = function(milliseconds_age) {
9     var ONE_DAY;
10     ONE_DAY = 1000 * 60 * 60 * 24;
11     return milliseconds_age / ONE_DAY;
12   };
13
14   cache_age_hover = function(milliseconds_age) {
15     return 'Cache age ' + cache_age_in_days(milliseconds_age).toFixed(1) + ' days.';
16   };
17
18   cache_age_axis_label = function(milliseconds_age) {
19     return cache_age_in_days(milliseconds_age).toFixed(0) + ' days';
20   };
21
22   float_as_percentage = function(proportion) {
23     return (proportion.toFixed(4) * 100) + '%';
24   };
25
26   $.renderHistogram = function(histogram_data) {
27     return Morris.Area({
28       element: 'cache-age-vs-disk-histogram',
29       pointSize: 0,
30       lineWidth: 0,
31       data: histogram_data,
32       xkey: 'age',
33       ykeys: ['persisted', 'cache'],
34       labels: ['Persisted Storage Disk Utilization', 'Cached Storage Disk Utilization'],
35       ymax: 1,
36       ymin: 0,
37       xLabelFormat: cache_age_axis_label,
38       yLabelFormat: float_as_percentage,
39       dateFormat: cache_age_hover
40     });
41   };
42
43 }).call(this);