From 27184adc6d6d271968ea3a6baa91f095436b9c33 Mon Sep 17 00:00:00 2001 From: Floran Brutel Date: Tue, 14 Mar 2017 20:31:45 +0100 Subject: [PATCH 01/30] Init big refactoring of the web ui to move to components --- glances/outputs/static/gulpfile.js | 4 +- .../outputs/static/html/plugins/alert.html | 7 - .../outputs/static/html/plugins/alerts.html | 2 - glances/outputs/static/html/plugins/amps.html | 7 - .../outputs/static/html/plugins/cloud.html | 1 - .../outputs/static/html/plugins/diskio.html | 16 - .../outputs/static/html/plugins/docker.html | 26 - .../outputs/static/html/plugins/folders.html | 8 - glances/outputs/static/html/plugins/fs.html | 16 - glances/outputs/static/html/plugins/gpu.html | 25 - glances/outputs/static/html/plugins/ip.html | 1 - glances/outputs/static/html/plugins/irq.html | 10 - glances/outputs/static/html/plugins/load.html | 24 - glances/outputs/static/html/plugins/mem.html | 20 - .../outputs/static/html/plugins/memswap.html | 20 - .../outputs/static/html/plugins/network.html | 28 - .../outputs/static/html/plugins/per_cpu.html | 34 - .../outputs/static/html/plugins/ports.html | 10 - .../static/html/plugins/processcount.html | 6 - .../static/html/plugins/processlist.html | 33 - .../static/html/plugins/quicklook.html | 57 - glances/outputs/static/html/plugins/raid.html | 19 - .../outputs/static/html/plugins/sensors.html | 9 - .../outputs/static/html/plugins/system.html | 4 - .../outputs/static/html/plugins/uptime.html | 1 - glances/outputs/static/html/plugins/wifi.html | 10 - glances/outputs/static/html/stats.html | 89 +- .../static/js/components/glances/component.js | 12 + .../js/components/glances/controller.js | 183 ++ .../static/js/components/glances/view.html | 24 + .../js/components/plugin-ip/component.js | 10 + .../js/components/plugin-ip/controller.js | 26 + .../static/js/components/plugin-ip/view.html | 3 + .../js/components/plugin-system/component.js | 11 + .../js/components/plugin-system/controller.js | 45 + .../js/components/plugin-system/view.html | 6 + .../js/components/plugin-uptime/component.js | 10 + .../js/components/plugin-uptime/controller.js | 16 + .../js/components/plugin-uptime/view.html | 3 + glances/outputs/static/js/controllers.js | 213 +-- .../static/js/{services/core => }/favicon.js | 0 .../outputs/static/js/services/core/stats.js | 106 -- .../static/js/services/plugins/alert.js | 58 - .../static/js/services/plugins/amps.js | 34 - .../static/js/services/plugins/cloud.js | 22 - .../outputs/static/js/services/plugins/cpu.js | 55 - .../static/js/services/plugins/diskio.js | 30 - .../static/js/services/plugins/docker.js | 39 - .../static/js/services/plugins/folders.js | 40 - .../outputs/static/js/services/plugins/fs.js | 40 - .../outputs/static/js/services/plugins/gpu.js | 56 - .../outputs/static/js/services/plugins/ip.js | 19 - .../outputs/static/js/services/plugins/irq.js | 21 - .../static/js/services/plugins/load.js | 27 - .../outputs/static/js/services/plugins/mem.js | 36 - .../static/js/services/plugins/memswap.js | 27 - .../static/js/services/plugins/network.js | 25 - .../static/js/services/plugins/percpu.js | 30 - .../static/js/services/plugins/plugin.js | 42 - .../static/js/services/plugins/ports.js | 29 - .../js/services/plugins/processcount.js | 19 - .../static/js/services/plugins/quicklook.js | 40 - .../static/js/services/plugins/raid.js | 50 - .../static/js/services/plugins/sensors.js | 21 - .../static/js/services/plugins/system.js | 37 - .../static/js/services/plugins/uptime.js | 7 - .../static/js/services/plugins/wifi.js | 36 - glances/outputs/static/js/stats.js | 60 + glances/outputs/static/public/js/main.min.js | 1481 ++++------------- .../outputs/static/public/js/templates.min.js | 31 +- glances/outputs/static/public/stats.html | 89 +- 71 files changed, 760 insertions(+), 2896 deletions(-) delete mode 100644 glances/outputs/static/html/plugins/alert.html delete mode 100644 glances/outputs/static/html/plugins/alerts.html delete mode 100644 glances/outputs/static/html/plugins/amps.html delete mode 100644 glances/outputs/static/html/plugins/cloud.html delete mode 100644 glances/outputs/static/html/plugins/diskio.html delete mode 100644 glances/outputs/static/html/plugins/docker.html delete mode 100644 glances/outputs/static/html/plugins/folders.html delete mode 100644 glances/outputs/static/html/plugins/fs.html delete mode 100644 glances/outputs/static/html/plugins/gpu.html delete mode 100644 glances/outputs/static/html/plugins/ip.html delete mode 100644 glances/outputs/static/html/plugins/irq.html delete mode 100644 glances/outputs/static/html/plugins/load.html delete mode 100644 glances/outputs/static/html/plugins/mem.html delete mode 100644 glances/outputs/static/html/plugins/memswap.html delete mode 100644 glances/outputs/static/html/plugins/network.html delete mode 100644 glances/outputs/static/html/plugins/per_cpu.html delete mode 100644 glances/outputs/static/html/plugins/ports.html delete mode 100644 glances/outputs/static/html/plugins/processcount.html delete mode 100644 glances/outputs/static/html/plugins/processlist.html delete mode 100644 glances/outputs/static/html/plugins/quicklook.html delete mode 100644 glances/outputs/static/html/plugins/raid.html delete mode 100644 glances/outputs/static/html/plugins/sensors.html delete mode 100644 glances/outputs/static/html/plugins/system.html delete mode 100644 glances/outputs/static/html/plugins/uptime.html delete mode 100644 glances/outputs/static/html/plugins/wifi.html create mode 100644 glances/outputs/static/js/components/glances/component.js create mode 100644 glances/outputs/static/js/components/glances/controller.js create mode 100644 glances/outputs/static/js/components/glances/view.html create mode 100644 glances/outputs/static/js/components/plugin-ip/component.js create mode 100644 glances/outputs/static/js/components/plugin-ip/controller.js create mode 100644 glances/outputs/static/js/components/plugin-ip/view.html create mode 100644 glances/outputs/static/js/components/plugin-system/component.js create mode 100644 glances/outputs/static/js/components/plugin-system/controller.js create mode 100644 glances/outputs/static/js/components/plugin-system/view.html create mode 100644 glances/outputs/static/js/components/plugin-uptime/component.js create mode 100644 glances/outputs/static/js/components/plugin-uptime/controller.js create mode 100644 glances/outputs/static/js/components/plugin-uptime/view.html rename glances/outputs/static/js/{services/core => }/favicon.js (100%) delete mode 100644 glances/outputs/static/js/services/core/stats.js delete mode 100644 glances/outputs/static/js/services/plugins/alert.js delete mode 100644 glances/outputs/static/js/services/plugins/amps.js delete mode 100644 glances/outputs/static/js/services/plugins/cloud.js delete mode 100644 glances/outputs/static/js/services/plugins/cpu.js delete mode 100644 glances/outputs/static/js/services/plugins/diskio.js delete mode 100644 glances/outputs/static/js/services/plugins/docker.js delete mode 100644 glances/outputs/static/js/services/plugins/folders.js delete mode 100644 glances/outputs/static/js/services/plugins/fs.js delete mode 100644 glances/outputs/static/js/services/plugins/gpu.js delete mode 100644 glances/outputs/static/js/services/plugins/ip.js delete mode 100644 glances/outputs/static/js/services/plugins/irq.js delete mode 100644 glances/outputs/static/js/services/plugins/load.js delete mode 100644 glances/outputs/static/js/services/plugins/mem.js delete mode 100644 glances/outputs/static/js/services/plugins/memswap.js delete mode 100644 glances/outputs/static/js/services/plugins/network.js delete mode 100644 glances/outputs/static/js/services/plugins/percpu.js delete mode 100644 glances/outputs/static/js/services/plugins/plugin.js delete mode 100644 glances/outputs/static/js/services/plugins/ports.js delete mode 100644 glances/outputs/static/js/services/plugins/processcount.js delete mode 100644 glances/outputs/static/js/services/plugins/quicklook.js delete mode 100644 glances/outputs/static/js/services/plugins/raid.js delete mode 100644 glances/outputs/static/js/services/plugins/sensors.js delete mode 100644 glances/outputs/static/js/services/plugins/system.js delete mode 100644 glances/outputs/static/js/services/plugins/uptime.js delete mode 100644 glances/outputs/static/js/services/plugins/wifi.js create mode 100644 glances/outputs/static/js/stats.js diff --git a/glances/outputs/static/gulpfile.js b/glances/outputs/static/gulpfile.js index 615a9c8c..8be5788d 100644 --- a/glances/outputs/static/gulpfile.js +++ b/glances/outputs/static/gulpfile.js @@ -41,8 +41,8 @@ gulp.task('build-js', function() { }); gulp.task('template', function () { - return gulp.src('./html/plugins/*.html') - .pipe(templateCache('templates.js', {'root': 'plugins/', 'module': 'glancesApp'})) + return gulp.src('./js/components/**/*.html') + .pipe(templateCache('templates.js', {'root': 'components/', 'module': 'glancesApp'})) .pipe(rename({suffix: '.min'})) .pipe(gulp.dest('./public/js')); }); diff --git a/glances/outputs/static/html/plugins/alert.html b/glances/outputs/static/html/plugins/alert.html deleted file mode 100644 index f4fe2f2f..00000000 --- a/glances/outputs/static/html/plugins/alert.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
-{{alert.begin | date : 'yyyy-MM-dd H:mm:ss'}} ({{ alert.ongoing ? 'ongoing' : alert.duration }}) - {{alert.level}} on {{alert.name}} ({{alert.max}}) -
-
-
diff --git a/glances/outputs/static/html/plugins/alerts.html b/glances/outputs/static/html/plugins/alerts.html deleted file mode 100644 index 1c0a1b42..00000000 --- a/glances/outputs/static/html/plugins/alerts.html +++ /dev/null @@ -1,2 +0,0 @@ -No warning or critical alert detected -Warning or critical alerts (lasts {{statsAlert.count()}} entries) diff --git a/glances/outputs/static/html/plugins/amps.html b/glances/outputs/static/html/plugins/amps.html deleted file mode 100644 index bd149629..00000000 --- a/glances/outputs/static/html/plugins/amps.html +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
{{ process.name }}
-
{{ process.count }}
-
{{ process.result }}
-
-
diff --git a/glances/outputs/static/html/plugins/cloud.html b/glances/outputs/static/html/plugins/cloud.html deleted file mode 100644 index 781cc814..00000000 --- a/glances/outputs/static/html/plugins/cloud.html +++ /dev/null @@ -1 +0,0 @@ -{{ statsCloud.getProvider() }} {{ statsCloud.getInstance() }} diff --git a/glances/outputs/static/html/plugins/diskio.html b/glances/outputs/static/html/plugins/diskio.html deleted file mode 100644 index a136c5d6..00000000 --- a/glances/outputs/static/html/plugins/diskio.html +++ /dev/null @@ -1,16 +0,0 @@ -
-
DISK I/O
-
R/s
-
W/s
- -
IOR/s
-
IOW/s
-
-
-
{{(disk.alias ? disk.alias : disk.name) | min_size}}
-
{{disk.bitrate.txps }}
-
{{disk.bitrate.rxps }}
- -
{{disk.count.txps }}
-
{{disk.count.rxps }}
-
diff --git a/glances/outputs/static/html/plugins/docker.html b/glances/outputs/static/html/plugins/docker.html deleted file mode 100644 index b0ae92ae..00000000 --- a/glances/outputs/static/html/plugins/docker.html +++ /dev/null @@ -1,26 +0,0 @@ -CONTAINERS {{ statsDocker.containers.length }} (served by Docker {{ statsDocker.version }}) - -
-
-
Name
-
Status
-
CPU%
-
MEM
-
IOR/s
-
IOW/s
-
RX/s
-
TX/s
-
Command
-
-
-
{{ container.name }}
-
{{ container.status }}
-
{{ container.cpu | number:1 }}
-
{{ container.memory | bytes }}
-
{{ container.ior / container.io_time_since_update | bits }}
-
{{ container.iow / container.io_time_since_update | bits }}
-
{{ container.rx / container.net_time_since_update | bits }}
-
{{ container.tx / container.net_time_since_update | bits }}
-
{{ container.command }}
-
-
diff --git a/glances/outputs/static/html/plugins/folders.html b/glances/outputs/static/html/plugins/folders.html deleted file mode 100644 index b43db8ad..00000000 --- a/glances/outputs/static/html/plugins/folders.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
FOLDERS
-
Size
-
-
-
{{ folder.path }}
-
{{ folder.size | bytes }}
-
diff --git a/glances/outputs/static/html/plugins/fs.html b/glances/outputs/static/html/plugins/fs.html deleted file mode 100644 index 4c0ed16f..00000000 --- a/glances/outputs/static/html/plugins/fs.html +++ /dev/null @@ -1,16 +0,0 @@ -
-
FILE SYS
-
- Used - Free -
-
Total
-
-
-
{{ fs.shortMountPoint }} ({{ fs.name }})
-
- {{ fs.used | bytes }} - {{ fs.free | bytes }} -
-
{{ fs.size | bytes }}
-
diff --git a/glances/outputs/static/html/plugins/gpu.html b/glances/outputs/static/html/plugins/gpu.html deleted file mode 100644 index 731ad73a..00000000 --- a/glances/outputs/static/html/plugins/gpu.html +++ /dev/null @@ -1,25 +0,0 @@ -
- {{ statsGpu.name }} -
-
-
-
proc:
-
{{ statsGpu.mean.proc | number : 0 }}%
-
N/A
-
-
-
mem:
-
{{ statsGpu.mean.mem | number : 0 }}%
-
N/A
-
-
-
- {{ gpu.gpu_id }}: - {{ gpu.proc | number : 0 }}% - N/A - mem: - {{ gpu.mem | number : 0 }}% - N/A -
-
-
diff --git a/glances/outputs/static/html/plugins/ip.html b/glances/outputs/static/html/plugins/ip.html deleted file mode 100644 index bfcbf643..00000000 --- a/glances/outputs/static/html/plugins/ip.html +++ /dev/null @@ -1 +0,0 @@ - - IP {{ statsIp.address }}/{{ statsIp.maskCidr }} Pub {{ statsIp.publicAddress }} diff --git a/glances/outputs/static/html/plugins/irq.html b/glances/outputs/static/html/plugins/irq.html deleted file mode 100644 index 8b2aa606..00000000 --- a/glances/outputs/static/html/plugins/irq.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
IRQ
-
-
Rate/s
-
-
-
{{irq.irq_line}}
-
-
{{irq.irq_rate}}
-
diff --git a/glances/outputs/static/html/plugins/load.html b/glances/outputs/static/html/plugins/load.html deleted file mode 100644 index 1d90b6e3..00000000 --- a/glances/outputs/static/html/plugins/load.html +++ /dev/null @@ -1,24 +0,0 @@ -
-
-
LOAD
-
{{ statsLoad.cpucore }}-core
-
-
-
1 min:
-
- {{ statsLoad.min1 | number : 2}} -
-
-
-
5 min:
-
- {{ statsLoad.min5 | number : 2}} -
-
-
-
15 min:
-
- {{ statsLoad.min15 | number : 2}} -
-
-
diff --git a/glances/outputs/static/html/plugins/mem.html b/glances/outputs/static/html/plugins/mem.html deleted file mode 100644 index 9f6f869d..00000000 --- a/glances/outputs/static/html/plugins/mem.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
-
MEM
-
{{ statsMem.percent }}%
-
-
-
total:
-
{{ statsMem.total | bytes }}
-
-
-
used:
-
- {{ statsMem.used | bytes:2 }} -
-
-
-
free:
-
{{ statsMem.free | bytes }}
-
-
diff --git a/glances/outputs/static/html/plugins/memswap.html b/glances/outputs/static/html/plugins/memswap.html deleted file mode 100644 index 3d566a51..00000000 --- a/glances/outputs/static/html/plugins/memswap.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
-
SWAP
-
{{ statsMemSwap.percent }}%
-
-
-
total:
-
{{ statsMemSwap.total | bytes }}
-
-
-
used:
-
- {{ statsMemSwap.used | bytes }} -
-
-
-
free:
-
{{ statsMemSwap.free | bytes }}
-
-
diff --git a/glances/outputs/static/html/plugins/network.html b/glances/outputs/static/html/plugins/network.html deleted file mode 100644 index 6030f263..00000000 --- a/glances/outputs/static/html/plugins/network.html +++ /dev/null @@ -1,28 +0,0 @@ -
-
NETWORK
-
Rx/s
-
Tx/s
- -
-
Rx+Tx/s
- -
Rx
-
Tx
- -
-
Rx+Tx
-
-
-
{{ network.interfaceName | min_size }}
-
{{ arguments.byte ? (network.rx / network.time_since_update | bytes) : (network.rx / network.time_since_update | bits) }}
-
{{ arguments.byte ? (network.tx / network.time_since_update | bytes) : (network.tx / network.time_since_update | bits) }}
- -
-
{{ arguments.byte ? (network.cx / network.time_since_update | bytes) : (network.cx / network.time_since_update | bits) }}
- -
{{ arguments.byte ? (network.cumulativeRx | bytes) : (network.cumulativeRx | bits) }}
-
{{ arguments.byte ? (network.cumulativeTx | bytes) : (network.cumulativeTx | bits) }}
- -
-
{{ arguments.byte ? (network.cumulativeCx | bytes) : (network.cumulativeCx | bits) }}
-
diff --git a/glances/outputs/static/html/plugins/per_cpu.html b/glances/outputs/static/html/plugins/per_cpu.html deleted file mode 100644 index 552fc017..00000000 --- a/glances/outputs/static/html/plugins/per_cpu.html +++ /dev/null @@ -1,34 +0,0 @@ -
-
-
PER CPU
-
{{ percpu.total }}%
-
-
-
user:
-
- {{ percpu.user }}% -
-
-
-
system:
-
- {{ percpu.system }}% -
-
-
-
idle:
-
{{ percpu.idle }}%
-
-
-
iowait:
-
- {{ percpu.iowait }}% -
-
-
-
steal:
-
- {{ percpu.steal }}% -
-
-
diff --git a/glances/outputs/static/html/plugins/ports.html b/glances/outputs/static/html/plugins/ports.html deleted file mode 100644 index 3d29cb9e..00000000 --- a/glances/outputs/static/html/plugins/ports.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
{{(port.description ? port.description : port.host + ' ' + port.port) | min_size: 20}}
-
-
- Scanning - Timeout - Open - {{port.status * 1000.0 | number:0}}ms -
-
diff --git a/glances/outputs/static/html/plugins/processcount.html b/glances/outputs/static/html/plugins/processcount.html deleted file mode 100644 index 82e29ae6..00000000 --- a/glances/outputs/static/html/plugins/processcount.html +++ /dev/null @@ -1,6 +0,0 @@ -TASKS -{{ statsProcessCount.total }} ({{ statsProcessCount.thread }} thr), -{{ statsProcessCount.running }} run, -{{ statsProcessCount.sleeping }} slp, -{{ statsProcessCount.stopped }} oth - sorted {{ sorter.auto ? 'automatically' : '' }} by {{ sorter.getColumnLabel(sorter.column) }}, flat view diff --git a/glances/outputs/static/html/plugins/processlist.html b/glances/outputs/static/html/plugins/processlist.html deleted file mode 100644 index 8dba824f..00000000 --- a/glances/outputs/static/html/plugins/processlist.html +++ /dev/null @@ -1,33 +0,0 @@ -
-
-
CPU%
-
MEM%
- - -
PID
-
USER
-
NI
-
S
- - - -
Command
-
-
-
{{process.cpu_percent | number:1}}
-
{{process.memory_percent | number:1}}
- - -
{{process.pid}}
-
{{process.username}}
-
{{process.nice | exclamation}}
-
{{process.status}}
- - - -
{{process.name}}
-
{{process.cmdline}}
-
-
diff --git a/glances/outputs/static/html/plugins/quicklook.html b/glances/outputs/static/html/plugins/quicklook.html deleted file mode 100644 index a64523e0..00000000 --- a/glances/outputs/static/html/plugins/quicklook.html +++ /dev/null @@ -1,57 +0,0 @@ -
- {{ statsQuicklook.cpu_name }} -
-
-
-
CPU
-
-
-
-   -
-
-
-
- {{ statsQuicklook.cpu }}% -
-
-
-
CPU{{ percpu.number }}
-
-
-
-   -
-
-
-
- {{ percpu.total }}% -
-
-
-
MEM
-
-
-
-   -
-
-
-
- {{ statsQuicklook.mem }}% -
-
-
-
SWAP
-
-
-
-   -
-
-
-
- {{ statsQuicklook.swap }}% -
-
-
diff --git a/glances/outputs/static/html/plugins/raid.html b/glances/outputs/static/html/plugins/raid.html deleted file mode 100644 index a6e0ab30..00000000 --- a/glances/outputs/static/html/plugins/raid.html +++ /dev/null @@ -1,19 +0,0 @@ -
-
RAID disks
-
Used
-
Total
-
-
-
- {{ disk.type | uppercase }} {{ disk.name }} -
└─ Degraded mode
-
   └─ {{ disk.config }}
- -
└─ Status {{ disk.status }}
-
-    {{ $last ? '└─' : '├─' }} disk {{ component.number }}: {{ component.name }} -
-
-
{{ disk.used }}
-
{{ disk.available }}
-
\ No newline at end of file diff --git a/glances/outputs/static/html/plugins/sensors.html b/glances/outputs/static/html/plugins/sensors.html deleted file mode 100644 index 5288f879..00000000 --- a/glances/outputs/static/html/plugins/sensors.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
SENSORS
-
- -
-
{{ sensor.label }}
-
{{ sensor.unit }}
-
{{ sensor.value }}
-
diff --git a/glances/outputs/static/html/plugins/system.html b/glances/outputs/static/html/plugins/system.html deleted file mode 100644 index 5e700b91..00000000 --- a/glances/outputs/static/html/plugins/system.html +++ /dev/null @@ -1,4 +0,0 @@ -Disconnected from -{{ statsSystem.hostname }} - - \ No newline at end of file diff --git a/glances/outputs/static/html/plugins/uptime.html b/glances/outputs/static/html/plugins/uptime.html deleted file mode 100644 index 1fc9238c..00000000 --- a/glances/outputs/static/html/plugins/uptime.html +++ /dev/null @@ -1 +0,0 @@ -Uptime: {{ statsUptime.uptime }} diff --git a/glances/outputs/static/html/plugins/wifi.html b/glances/outputs/static/html/plugins/wifi.html deleted file mode 100644 index 6c46c938..00000000 --- a/glances/outputs/static/html/plugins/wifi.html +++ /dev/null @@ -1,10 +0,0 @@ -
-
WIFI
-
-
dBm
-
-
-
{{ hotspot.ssid|limitTo:20 }} {{ hotspot.encryption_type }}
-
-
{{ hotspot.signal }}
-
diff --git a/glances/outputs/static/html/stats.html b/glances/outputs/static/html/stats.html index 7982ad15..ad2c1531 100644 --- a/glances/outputs/static/html/stats.html +++ b/glances/outputs/static/html/stats.html @@ -1,88 +1 @@ -
- -
Loading...
-
- -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCESSES DISABLED (press 'z' to display)
-
-
-
+ diff --git a/glances/outputs/static/js/components/glances/component.js b/glances/outputs/static/js/components/glances/component.js new file mode 100644 index 00000000..f797774a --- /dev/null +++ b/glances/outputs/static/js/components/glances/component.js @@ -0,0 +1,12 @@ +'use strict'; + +glancesApp.component('glances', { + controller: GlancesController, + bindings: { + arguments: '<', + config: '<', + help: '<' + }, + controllerAs: 'vm', + templateUrl: 'components/glances/view.html' +}); diff --git a/glances/outputs/static/js/components/glances/controller.js b/glances/outputs/static/js/components/glances/controller.js new file mode 100644 index 00000000..092c19ec --- /dev/null +++ b/glances/outputs/static/js/components/glances/controller.js @@ -0,0 +1,183 @@ +'use strict'; + +function GlancesController($interval, GlancesStats, favicoService) { + var vm = this; + + vm.sorter = { + column: "cpu_percent", + auto: true, + isReverseColumn: function (column) { + return !(column == 'username' || column == 'name'); + }, + getColumnLabel: function (column) { + if (_.isEqual(column, ['io_read', 'io_write'])) { + return 'io_counters'; + } else { + return column; + } + } + }; + + vm.dataLoaded = false; + vm.stats = {}; + vm.refreshData = function () { + GlancesStats.getData().then(function (data) { + vm.stats = data; + vm.is_disconnected = false; + vm.dataLoaded = true; + }, function() { + vm.is_disconnected = true; + }); + }; + + vm.refreshData(); + var refreshTime = 60; // arguments.time + $interval(function () { + vm.refreshData(); + }, refreshTime * 1000); // in milliseconds + + vm.onKeyDown = function ($event) { + + switch (true) { + case !$event.shiftKey && $event.keyCode == keycodes.a: + // a => Sort processes automatically + vm.sorter.column = "cpu_percent"; + vm.sorter.auto = true; + break; + case $event.shiftKey && $event.keyCode == keycodes.A: + // A => Enable/disable AMPs + vm.arguments.disable_amps = !vm.arguments.disable_amps; + break; + case !$event.shiftKey && $event.keyCode == keycodes.c: + // c => Sort processes by CPU% + vm.sorter.column = "cpu_percent"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.m: + // m => Sort processes by MEM% + vm.sorter.column = "memory_percent"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.u: + // u => Sort processes by user + vm.sorter.column = "username"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.p: + // p => Sort processes by name + vm.sorter.column = "name"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.i: + // i => Sort processes by I/O rate + vm.sorter.column = ['io_read', 'io_write']; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.t: + // t => Sort processes by time + vm.sorter.column = "timemillis"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.d: + // d => Show/hide disk I/O stats + vm.arguments.disable_diskio = !vm.arguments.disable_diskio; + break; + case $event.shiftKey && $event.keyCode == keycodes.Q: + // Q => Show/hide IRQ + vm.arguments.enable_irq = !vm.arguments.enable_irq; + break; + case !$event.shiftKey && $event.keyCode == keycodes.f: + // f => Show/hide filesystem stats + vm.arguments.disable_fs = !vm.arguments.disable_fs; + break; + case !$event.shiftKey && $event.keyCode == keycodes.n: + // n => Show/hide network stats + vm.arguments.disable_network = !vm.arguments.disable_network; + break; + case !$event.shiftKey && $event.keyCode == keycodes.s: + // s => Show/hide sensors stats + vm.arguments.disable_sensors = !vm.arguments.disable_sensors; + break; + case $event.shiftKey && $event.keyCode == keycodes.TWO: + // 2 => Show/hide left sidebar + vm.arguments.disable_left_sidebar = !vm.arguments.disable_left_sidebar; + break; + case !$event.shiftKey && $event.keyCode == keycodes.z: + // z => Enable/disable processes stats + vm.arguments.disable_process = !vm.arguments.disable_process; + break; + case $event.keyCode == keycodes.SLASH: + // SLASH => Enable/disable short processes name + vm.arguments.process_short_name = !vm.arguments.process_short_name; + break; + case $event.shiftKey && $event.keyCode == keycodes.D: + // D => Enable/disable Docker stats + vm.arguments.disable_docker = !vm.arguments.disable_docker; + break; + case !$event.shiftKey && $event.keyCode == keycodes.b: + // b => Bytes or bits for network I/O + vm.arguments.byte = !vm.arguments.byte; + break; + case $event.shiftKey && $event.keyCode == keycodes.b: + // 'B' => Switch between bit/s and IO/s for Disk IO + vm.arguments.diskio_iops = !vm.arguments.diskio_iops; + break; + case !$event.shiftKey && $event.keyCode == keycodes.l: + // l => Show/hide alert logs + vm.arguments.disable_alert = !vm.arguments.disable_alert; + break; + case $event.shiftKey && $event.keyCode == keycodes.ONE: + // 1 => Global CPU or per-CPU stats + vm.arguments.percpu = !vm.arguments.percpu; + break; + case !$event.shiftKey && $event.keyCode == keycodes.h: + // h => Show/hide this help screen + vm.arguments.help_tag = !vm.arguments.help_tag; + break; + case $event.shiftKey && $event.keyCode == keycodes.T: + // T => View network I/O as combination + vm.arguments.network_sum = !vm.arguments.network_sum; + break; + case $event.shiftKey && $event.keyCode == keycodes.u: + // U => View cumulative network I/O + vm.arguments.network_cumul = !vm.arguments.network_cumul; + break; + case $event.shiftKey && $event.keyCode == keycodes.f: + // F => Show filesystem free space + vm.arguments.fs_free_space = !vm.arguments.fs_free_space; + break; + case $event.shiftKey && $event.keyCode == keycodes.THREE: + // 3 => Enable/disable quick look plugin + vm.arguments.disable_quicklook = !vm.arguments.disable_quicklook; + break; + case $event.shiftKey && $event.keyCode == keycodes.SIX: + // 6 => Enable/disable mean gpu + vm.arguments.meangpu = !vm.arguments.meangpu; + break; + case $event.shiftKey && $event.keyCode == keycodes.g: + // G => Enable/disable gpu + vm.arguments.disable_gpu = !vm.arguments.disable_gpu; + break; + case $event.shiftKey && $event.keyCode == keycodes.FIVE: + vm.arguments.disable_quicklook = !vm.arguments.disable_quicklook; + vm.arguments.disable_cpu = !vm.arguments.disable_cpu; + vm.arguments.disable_mem = !vm.arguments.disable_mem; + vm.arguments.disable_memswap = !vm.arguments.disable_memswap; + vm.arguments.disable_load = !vm.arguments.disable_load; + vm.arguments.disable_gpu = !vm.arguments.disable_gpu; + break; + case $event.shiftKey && $event.keyCode == keycodes.i: + // I => Show/hide IP module + vm.arguments.disable_ip = !vm.arguments.disable_ip; + break; + case $event.shiftKey && $event.keyCode == keycodes.p: + // I => Enable/disable ports module + vm.arguments.disable_ports = !vm.arguments.disable_ports; + break; + case $event.shiftKey && $event.keyCode == keycodes.w: + // 'W' > Enable/Disable Wifi plugin + vm.arguments.disable_wifi = !vm.arguments.disable_wifi; + break; + } + }; +} diff --git a/glances/outputs/static/js/components/glances/view.html b/glances/outputs/static/js/components/glances/view.html new file mode 100644 index 00000000..1102d7e9 --- /dev/null +++ b/glances/outputs/static/js/components/glances/view.html @@ -0,0 +1,24 @@ +
+ +
Loading...
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
diff --git a/glances/outputs/static/js/components/plugin-ip/component.js b/glances/outputs/static/js/components/plugin-ip/component.js new file mode 100644 index 00000000..7cc0684f --- /dev/null +++ b/glances/outputs/static/js/components/plugin-ip/component.js @@ -0,0 +1,10 @@ +'use strict'; + +glancesApp.component('glancesPluginIp', { + controller: GlancesPluginIpController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-ip/view.html' +}); diff --git a/glances/outputs/static/js/components/plugin-ip/controller.js b/glances/outputs/static/js/components/plugin-ip/controller.js new file mode 100644 index 00000000..d5cbf976 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-ip/controller.js @@ -0,0 +1,26 @@ +'use strict'; + +function GlancesPluginIpController() { + var vm = this; + + this.address = null; + this.gateway = null; + this.mask = null; + this.maskCidr = null; + this.publicAddress = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['ip']; + + vm.address = data.address; + vm.gateway = data.gateway; + vm.mask = data.mask; + vm.maskCidr = data.mask_cidr; + vm.publicAddress = data.public_address + }; +} diff --git a/glances/outputs/static/js/components/plugin-ip/view.html b/glances/outputs/static/js/components/plugin-ip/view.html new file mode 100644 index 00000000..f4a72c0a --- /dev/null +++ b/glances/outputs/static/js/components/plugin-ip/view.html @@ -0,0 +1,3 @@ +
+  - IP {{ vm.address }}/{{ vm.maskCidr }} Pub {{ vm.publicAddress }} +
diff --git a/glances/outputs/static/js/components/plugin-system/component.js b/glances/outputs/static/js/components/plugin-system/component.js new file mode 100644 index 00000000..1826ce8b --- /dev/null +++ b/glances/outputs/static/js/components/plugin-system/component.js @@ -0,0 +1,11 @@ +'use strict'; + +glancesApp.component('glancesPluginSystem', { + controller: GlancesPluginSystemController, + controllerAs: 'vm', + bindings: { + stats: '<', + isDisconnected: '<' + }, + templateUrl: 'components/plugin-system/view.html' +}); diff --git a/glances/outputs/static/js/components/plugin-system/controller.js b/glances/outputs/static/js/components/plugin-system/controller.js new file mode 100644 index 00000000..2567a02a --- /dev/null +++ b/glances/outputs/static/js/components/plugin-system/controller.js @@ -0,0 +1,45 @@ +'use strict'; + +function GlancesPluginSystemController() { + var vm = this; + var _pluginName = "system"; + + vm.hostname = null; + vm.platform = null; + vm.humanReadableName = null; + vm.os = { + 'name': null, + 'version': null + }; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats[_pluginName]; + + vm.hostname = data['hostname']; + vm.platform = data['platform']; + vm.os.name = data['os_name']; + vm.os.version = data['os_version']; + vm.humanReadableName = data['hr_name']; + }; + + vm.isBsd = function() { + return this.os.name === 'FreeBSD'; + }; + + vm.isLinux = function() { + return this.os.name === 'Linux'; + }; + + vm.isMac = function() { + return this.os.name === 'Darwin'; + }; + + vm.isWindows = function() { + return this.os.name === 'Windows'; + }; +} diff --git a/glances/outputs/static/js/components/plugin-system/view.html b/glances/outputs/static/js/components/plugin-system/view.html new file mode 100644 index 00000000..f1866ae6 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-system/view.html @@ -0,0 +1,6 @@ +
+ Disconnected from + {{ vm.hostname }} + + +
diff --git a/glances/outputs/static/js/components/plugin-uptime/component.js b/glances/outputs/static/js/components/plugin-uptime/component.js new file mode 100644 index 00000000..3859054b --- /dev/null +++ b/glances/outputs/static/js/components/plugin-uptime/component.js @@ -0,0 +1,10 @@ +'use strict'; + +glancesApp.component('glancesPluginUptime', { + controller: GlancesPluginUptimeController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-uptime/view.html' +}); diff --git a/glances/outputs/static/js/components/plugin-uptime/controller.js b/glances/outputs/static/js/components/plugin-uptime/controller.js new file mode 100644 index 00000000..9cdc0850 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-uptime/controller.js @@ -0,0 +1,16 @@ +'use strict'; + +function GlancesPluginUptimeController() { + var vm = this; + + this.value = null + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + vm.value = stats.stats['uptime']; + }; +} diff --git a/glances/outputs/static/js/components/plugin-uptime/view.html b/glances/outputs/static/js/components/plugin-uptime/view.html new file mode 100644 index 00000000..3f602d2b --- /dev/null +++ b/glances/outputs/static/js/components/plugin-uptime/view.html @@ -0,0 +1,3 @@ +
+ Uptime: {{ vm.value }} +
diff --git a/glances/outputs/static/js/controllers.js b/glances/outputs/static/js/controllers.js index a369c3ba..b1ea157c 100644 --- a/glances/outputs/static/js/controllers.js +++ b/glances/outputs/static/js/controllers.js @@ -1,214 +1,5 @@ -glancesApp.controller('statsController', function ($scope, $rootScope, $interval, GlancesStats, help, config, arguments, favicoService) { +glancesApp.controller('statsController', function ($scope, help, config, arguments) { $scope.help = help; + $scope.config = config; $scope.arguments = arguments; - - $scope.sorter = { - column: "cpu_percent", - auto: true, - isReverseColumn: function (column) { - return !(column == 'username' || column == 'name'); - }, - getColumnLabel: function (column) { - if (_.isEqual(column, ['io_read', 'io_write'])) { - return 'io_counters'; - } else { - return column; - } - } - }; - - $scope.dataLoaded = false; - $scope.refreshData = function () { - GlancesStats.getData().then(function (data) { - - $scope.statsAlert = GlancesStats.getPlugin('alert'); - $scope.statsCloud = GlancesStats.getPlugin('cloud'); - $scope.statsCpu = GlancesStats.getPlugin('cpu'); - $scope.statsDiskio = GlancesStats.getPlugin('diskio'); - $scope.statsIrq = GlancesStats.getPlugin('irq'); - $scope.statsDocker = GlancesStats.getPlugin('docker'); - $scope.statsFs = GlancesStats.getPlugin('fs'); - $scope.statsFolders = GlancesStats.getPlugin('folders'); - $scope.statsGpu = GlancesStats.getPlugin('gpu'); - $scope.statsIp = GlancesStats.getPlugin('ip'); - $scope.statsLoad = GlancesStats.getPlugin('load'); - $scope.statsMem = GlancesStats.getPlugin('mem'); - $scope.statsMemSwap = GlancesStats.getPlugin('memswap'); - $scope.statsAmps = GlancesStats.getPlugin('amps'); - $scope.statsNetwork = GlancesStats.getPlugin('network'); - $scope.statsPerCpu = GlancesStats.getPlugin('percpu'); - $scope.statsProcessCount = GlancesStats.getPlugin('processcount'); - $scope.statsProcessList = GlancesStats.getPlugin('processlist'); - $scope.statsQuicklook = GlancesStats.getPlugin('quicklook'); - $scope.statsRaid = GlancesStats.getPlugin('raid'); - $scope.statsSensors = GlancesStats.getPlugin('sensors'); - $scope.statsSystem = GlancesStats.getPlugin('system'); - $scope.statsUptime = GlancesStats.getPlugin('uptime'); - $scope.statsPorts = GlancesStats.getPlugin('ports'); - $scope.statsWifi = GlancesStats.getPlugin('wifi'); - - $rootScope.title = $scope.statsSystem.hostname + ' - Glances'; - - if ($scope.statsAlert.hasOngoingAlerts()) { - favicoService.badge($scope.statsAlert.countOngoingAlerts()); - } else { - favicoService.reset(); - } - - $scope.is_disconnected = false; - $scope.dataLoaded = true; - }, function() { - $scope.is_disconnected = true; - }); - }; - - $scope.refreshData(); - $interval(function () { - $scope.refreshData(); - }, arguments.time * 1000); // in milliseconds - - $scope.onKeyDown = function ($event) { - - switch (true) { - case !$event.shiftKey && $event.keyCode == keycodes.a: - // a => Sort processes automatically - $scope.sorter.column = "cpu_percent"; - $scope.sorter.auto = true; - break; - case $event.shiftKey && $event.keyCode == keycodes.A: - // A => Enable/disable AMPs - $scope.arguments.disable_amps = !$scope.arguments.disable_amps; - break; - case !$event.shiftKey && $event.keyCode == keycodes.c: - // c => Sort processes by CPU% - $scope.sorter.column = "cpu_percent"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.m: - // m => Sort processes by MEM% - $scope.sorter.column = "memory_percent"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.u: - // u => Sort processes by user - $scope.sorter.column = "username"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.p: - // p => Sort processes by name - $scope.sorter.column = "name"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.i: - // i => Sort processes by I/O rate - $scope.sorter.column = ['io_read', 'io_write']; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.t: - // t => Sort processes by time - $scope.sorter.column = "timemillis"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.d: - // d => Show/hide disk I/O stats - $scope.arguments.disable_diskio = !$scope.arguments.disable_diskio; - break; - case $event.shiftKey && $event.keyCode == keycodes.Q: - // Q => Show/hide IRQ - $scope.arguments.enable_irq = !$scope.arguments.enable_irq; - break; - case !$event.shiftKey && $event.keyCode == keycodes.f: - // f => Show/hide filesystem stats - $scope.arguments.disable_fs = !$scope.arguments.disable_fs; - break; - case !$event.shiftKey && $event.keyCode == keycodes.n: - // n => Show/hide network stats - $scope.arguments.disable_network = !$scope.arguments.disable_network; - break; - case !$event.shiftKey && $event.keyCode == keycodes.s: - // s => Show/hide sensors stats - $scope.arguments.disable_sensors = !$scope.arguments.disable_sensors; - break; - case $event.shiftKey && $event.keyCode == keycodes.TWO: - // 2 => Show/hide left sidebar - $scope.arguments.disable_left_sidebar = !$scope.arguments.disable_left_sidebar; - break; - case !$event.shiftKey && $event.keyCode == keycodes.z: - // z => Enable/disable processes stats - $scope.arguments.disable_process = !$scope.arguments.disable_process; - break; - case $event.keyCode == keycodes.SLASH: - // SLASH => Enable/disable short processes name - $scope.arguments.process_short_name = !$scope.arguments.process_short_name; - break; - case $event.shiftKey && $event.keyCode == keycodes.D: - // D => Enable/disable Docker stats - $scope.arguments.disable_docker = !$scope.arguments.disable_docker; - break; - case !$event.shiftKey && $event.keyCode == keycodes.b: - // b => Bytes or bits for network I/O - $scope.arguments.byte = !$scope.arguments.byte; - break; - case $event.shiftKey && $event.keyCode == keycodes.b: - // 'B' => Switch between bit/s and IO/s for Disk IO - $scope.arguments.diskio_iops = !$scope.arguments.diskio_iops; - break; - case !$event.shiftKey && $event.keyCode == keycodes.l: - // l => Show/hide alert logs - $scope.arguments.disable_alert = !$scope.arguments.disable_alert; - break; - case $event.shiftKey && $event.keyCode == keycodes.ONE: - // 1 => Global CPU or per-CPU stats - $scope.arguments.percpu = !$scope.arguments.percpu; - break; - case !$event.shiftKey && $event.keyCode == keycodes.h: - // h => Show/hide this help screen - $scope.arguments.help_tag = !$scope.arguments.help_tag; - break; - case $event.shiftKey && $event.keyCode == keycodes.T: - // T => View network I/O as combination - $scope.arguments.network_sum = !$scope.arguments.network_sum; - break; - case $event.shiftKey && $event.keyCode == keycodes.u: - // U => View cumulative network I/O - $scope.arguments.network_cumul = !$scope.arguments.network_cumul; - break; - case $event.shiftKey && $event.keyCode == keycodes.f: - // F => Show filesystem free space - $scope.arguments.fs_free_space = !$scope.arguments.fs_free_space; - break; - case $event.shiftKey && $event.keyCode == keycodes.THREE: - // 3 => Enable/disable quick look plugin - $scope.arguments.disable_quicklook = !$scope.arguments.disable_quicklook; - break; - case $event.shiftKey && $event.keyCode == keycodes.SIX: - // 6 => Enable/disable mean gpu - $scope.arguments.meangpu = !$scope.arguments.meangpu; - break; - case $event.shiftKey && $event.keyCode == keycodes.g: - // G => Enable/disable gpu - $scope.arguments.disable_gpu = !$scope.arguments.disable_gpu; - break; - case $event.shiftKey && $event.keyCode == keycodes.FIVE: - $scope.arguments.disable_quicklook = !$scope.arguments.disable_quicklook; - $scope.arguments.disable_cpu = !$scope.arguments.disable_cpu; - $scope.arguments.disable_mem = !$scope.arguments.disable_mem; - $scope.arguments.disable_memswap = !$scope.arguments.disable_memswap; - $scope.arguments.disable_load = !$scope.arguments.disable_load; - $scope.arguments.disable_gpu = !$scope.arguments.disable_gpu; - break; - case $event.shiftKey && $event.keyCode == keycodes.i: - // I => Show/hide IP module - $scope.arguments.disable_ip = !$scope.arguments.disable_ip; - break; - case $event.shiftKey && $event.keyCode == keycodes.p: - // I => Enable/disable ports module - $scope.arguments.disable_ports = !$scope.arguments.disable_ports; - break; - case $event.shiftKey && $event.keyCode == keycodes.w: - // 'W' > Enable/Disable Wifi plugin - $scope.arguments.disable_wifi = !$scope.arguments.disable_wifi; - break; - } - }; }); diff --git a/glances/outputs/static/js/services/core/favicon.js b/glances/outputs/static/js/favicon.js similarity index 100% rename from glances/outputs/static/js/services/core/favicon.js rename to glances/outputs/static/js/favicon.js diff --git a/glances/outputs/static/js/services/core/stats.js b/glances/outputs/static/js/services/core/stats.js deleted file mode 100644 index 1b63525b..00000000 --- a/glances/outputs/static/js/services/core/stats.js +++ /dev/null @@ -1,106 +0,0 @@ -glancesApp.service('GlancesStats', function($http, $injector, $q, GlancesPlugin) { - var _stats = [], _views = [], _limits = [], _config = {}; - - var _plugins = { - 'alert': 'GlancesPluginAlert', - 'cloud': 'GlancesPluginCloud', - 'cpu': 'GlancesPluginCpu', - 'diskio': 'GlancesPluginDiskio', - 'irq' : 'GlancesPluginIrq', - 'docker': 'GlancesPluginDocker', - 'ip': 'GlancesPluginIp', - 'fs': 'GlancesPluginFs', - 'folders': 'GlancesPluginFolders', - 'gpu': 'GlancesPluginGpu', - 'load': 'GlancesPluginLoad', - 'mem': 'GlancesPluginMem', - 'memswap': 'GlancesPluginMemSwap', - 'amps': 'GlancesPluginAmps', - 'network': 'GlancesPluginNetwork', - 'percpu': 'GlancesPluginPerCpu', - 'processcount': 'GlancesPluginProcessCount', - 'processlist': 'GlancesPluginProcessList', - 'quicklook': 'GlancesPluginQuicklook', - 'raid': 'GlancesPluginRaid', - 'sensors': 'GlancesPluginSensors', - 'system': 'GlancesPluginSystem', - 'uptime': 'GlancesPluginUptime', - 'ports': 'GlancesPluginPorts', - 'wifi': 'GlancesPluginWifi' - }; - - this.getData = function() { - return $q.all([ - this.getAllStats(), - this.getAllViews() - ]).then(function(results) { - return { - 'stats': results[0], - 'view': results[1] - }; - }); - }; - - this.getAllStats = function() { - return $http.get('/api/2/all').then(function (response) { - _stats = response.data; - - return response.data; - }); - }; - - this.getAllLimits = function() { - return $http.get('/api/2/all/limits').then(function (response) { - _limits = response.data; - - return response.data; - }); - }; - - this.getAllViews = function() { - return $http.get('/api/2/all/views').then(function (response) { - _views = response.data; - - return response.data; - }); - }; - - this.getHelp = function() { - return $http.get('/api/2/help').then(function (response) { - return response.data; - }); - }; - - this.getConfig = function() { - return $http.get('/api/2/config').then(function (response) { - _config = response.data; - - return _config; - }); - }; - - this.getArguments = function() { - return $http.get('/api/2/args').then(function (response) { - return response.data; - }); - }; - - this.getPlugin = function(name) { - var plugin = _plugins[name]; - - if (plugin === undefined) { - throw "Plugin '" + name + "' not found"; - } - - plugin = $injector.get(plugin); - plugin.setData(_stats, _views, _config); - - return plugin; - }; - - // load limits to init GlancePlugin helper - this.getAllLimits().then(function(limits) { - GlancesPlugin.setLimits(limits); - }); - -}); diff --git a/glances/outputs/static/js/services/plugins/alert.js b/glances/outputs/static/js/services/plugins/alert.js deleted file mode 100644 index 9df6db89..00000000 --- a/glances/outputs/static/js/services/plugins/alert.js +++ /dev/null @@ -1,58 +0,0 @@ -glancesApp.service('GlancesPluginAlert', function () { - var _pluginName = "alert"; - var _alerts = []; - - this.setData = function (data, views) { - data = data[_pluginName]; - _alerts = []; - - if(!_.isArray(data)) { - data = []; - } - - for (var i = 0; i < data.length; i++) { - var alertData = data[i]; - var alert = {}; - - alert.name = alertData[3]; - alert.level = alertData[2]; - alert.begin = alertData[0] * 1000; - alert.end = alertData[1] * 1000; - alert.ongoing = alertData[1] == -1; - alert.min = alertData[6]; - alert.mean = alertData[5]; - alert.max = alertData[4]; - - if (!alert.ongoing) { - var duration = alert.end - alert.begin; - var seconds = parseInt((duration / 1000) % 60) - , minutes = parseInt((duration / (1000 * 60)) % 60) - , hours = parseInt((duration / (1000 * 60 * 60)) % 24); - - alert.duration = _.padStart(hours, 2, '0') + ":" + _.padStart(minutes, 2, '0') + ":" + _.padStart(seconds, 2, '0'); - } - - _alerts.push(alert); - } - }; - - this.hasAlerts = function () { - return _alerts.length > 0; - }; - - this.getAlerts = function () { - return _alerts; - }; - - this.count = function () { - return _alerts.length; - }; - - this.hasOngoingAlerts = function () { - return _.filter(_alerts, { 'ongoing': true }).length > 0; - }; - - this.countOngoingAlerts = function () { - return _.filter(_alerts, { 'ongoing': true }).length; - } -}); diff --git a/glances/outputs/static/js/services/plugins/amps.js b/glances/outputs/static/js/services/plugins/amps.js deleted file mode 100644 index 3d37814e..00000000 --- a/glances/outputs/static/js/services/plugins/amps.js +++ /dev/null @@ -1,34 +0,0 @@ -glancesApp.service('GlancesPluginAmps', function() { - var _pluginName = "amps"; - this.processes = []; - - this.setData = function(data, views) { - var processes = data[_pluginName]; - - this.processes = []; - angular.forEach(processes, function(process) { - if (process.result !== null) { - this.processes.push(process); - } - }, this); - }; - - this.getDescriptionDecoration = function(process) { - var count = process.count; - var countMin = process.countmin; - var countMax = process.countmax; - var decoration = "ok"; - - if (count > 0) { - if ((countMin == null || count >= countMin) && (countMax == null || count <= countMax)) { - decoration = 'ok'; - } else { - decoration = 'careful'; - } - } else { - decoration = countMin == null ? 'ok' : 'critical'; - } - - return decoration; - } -}); diff --git a/glances/outputs/static/js/services/plugins/cloud.js b/glances/outputs/static/js/services/plugins/cloud.js deleted file mode 100644 index ae6957c3..00000000 --- a/glances/outputs/static/js/services/plugins/cloud.js +++ /dev/null @@ -1,22 +0,0 @@ -glancesApp.service('GlancesPluginCloud', function() { - var _pluginName = "cloud"; - var _provider = null; - var _instance = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - - if (data['ami-id'] !== undefined) { - _provider = 'AWS EC2'; - _instance = data['instance-type'] + ' instance ' + data['instance-id'] + ' (' + data['region'] + ')'; - } - } - - this.getProvider = function() { - return _provider; - } - - this.getInstance = function() { - return _instance; - } -}); diff --git a/glances/outputs/static/js/services/plugins/cpu.js b/glances/outputs/static/js/services/plugins/cpu.js deleted file mode 100644 index 5353a311..00000000 --- a/glances/outputs/static/js/services/plugins/cpu.js +++ /dev/null @@ -1,55 +0,0 @@ -glancesApp.service('GlancesPluginCpu', function() { - var _pluginName = "cpu"; - var _view = {}; - - this.total = null; - this.user = null; - this.system = null; - this.idle = null; - this.nice = null; - this.irq = null; - this.iowait = null; - this.steal = null; - this.ctx_switches = null; - this.interrupts = null; - this.soft_interrupts = null; - this.syscalls = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - this.total = data.total; - this.user = data.user; - this.system = data.system; - this.idle = data.idle; - this.nice = data.nice; - this.irq = data.irq; - this.iowait = data.iowait; - this.steal = data.steal; - - if (data.ctx_switches) { - this.ctx_switches = Math.floor(data.ctx_switches / data.time_since_update); - } - - if (data.interrupts) { - this.interrupts = Math.floor(data.interrupts / data.time_since_update); - } - - if (data.soft_interrupts) { - this.soft_interrupts = Math.floor(data.soft_interrupts / data.time_since_update); - } - - if (data.syscalls) { - this.syscalls = Math.floor(data.syscalls / data.time_since_update); - } - } - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - } -}); diff --git a/glances/outputs/static/js/services/plugins/diskio.js b/glances/outputs/static/js/services/plugins/diskio.js deleted file mode 100644 index 5e0aacf2..00000000 --- a/glances/outputs/static/js/services/plugins/diskio.js +++ /dev/null @@ -1,30 +0,0 @@ -glancesApp.service('GlancesPluginDiskio', function($filter) { - var _pluginName = "diskio"; - this.disks = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - data = $filter('orderBy')(data,'disk_name'); - this.disks = []; - - for (var i = 0; i < data.length; i++) { - var diskioData = data[i]; - var timeSinceUpdate = diskioData['time_since_update']; - - var diskio = { - 'name': diskioData['disk_name'], - 'bitrate': { - 'txps': $filter('bytes')(diskioData['read_bytes'] / timeSinceUpdate), - 'rxps': $filter('bytes')(diskioData['write_bytes'] / timeSinceUpdate) - }, - 'count': { - 'txps': $filter('bytes')(diskioData['read_count'] / timeSinceUpdate), - 'rxps': $filter('bytes')(diskioData['write_count'] / timeSinceUpdate) - }, - 'alias': diskioData['alias'] !== undefined ? diskioData['alias'] : null - }; - - this.disks.push(diskio); - } - }; -}); diff --git a/glances/outputs/static/js/services/plugins/docker.js b/glances/outputs/static/js/services/plugins/docker.js deleted file mode 100644 index 06895e68..00000000 --- a/glances/outputs/static/js/services/plugins/docker.js +++ /dev/null @@ -1,39 +0,0 @@ -glancesApp.service('GlancesPluginDocker', function(GlancesPlugin) { - - var _pluginName = "docker"; - this.containers = []; - this.version = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.containers = []; - - if(_.isEmpty(data)) { - return; - } - - for (var i = 0; i < data['containers'].length; i++) { - var containerData = data['containers'][i]; - - var container = { - 'id': containerData.Id, - 'name': containerData.Names[0].split('/').splice(-1)[0], - 'status': containerData.Status, - 'cpu': containerData.cpu.total, - 'memory': containerData.memory.usage != undefined ? containerData.memory.usage : '?', - 'ior': containerData.io.ior != undefined ? containerData.io.ior : '?', - 'iow': containerData.io.iow != undefined ? containerData.io.iow : '?', - 'io_time_since_update': containerData.io.time_since_update, - 'rx': containerData.network.rx != undefined ? containerData.network.rx : '?', - 'tx': containerData.network.tx != undefined ? containerData.network.tx : '?', - 'net_time_since_update': containerData.network.time_since_update, - 'command': containerData.Command, - 'image': containerData.Image - }; - - this.containers.push(container); - } - - this.version = data['version']['Version']; - }; -}); diff --git a/glances/outputs/static/js/services/plugins/folders.js b/glances/outputs/static/js/services/plugins/folders.js deleted file mode 100644 index 6b3660c5..00000000 --- a/glances/outputs/static/js/services/plugins/folders.js +++ /dev/null @@ -1,40 +0,0 @@ -glancesApp.service('GlancesPluginFolders', function() { - var _pluginName = "folders"; - this.folders = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.folders = []; - - for (var i = 0; i < data.length; i++) { - var folderData = data[i]; - - var folder = { - 'path': folderData['path'], - 'size': folderData['size'], - 'careful': folderData['careful'], - 'warning': folderData['warning'], - 'critical': folderData['critical'] - }; - - this.folders.push(folder); - } - }; - - this.getDecoration = function(folder) { - - if (!Number.isInteger(folder.size)) { - return; - } - - if (folder.critical !== null && folder.size > (folder.critical * 1000000)) { - return 'critical'; - } else if (folder.warning !== null && folder.size > (folder.warning * 1000000)) { - return 'warning'; - } else if (folder.careful !== null && folder.size > (folder.careful * 1000000)) { - return 'careful'; - } - - return 'ok'; - }; -}); diff --git a/glances/outputs/static/js/services/plugins/fs.js b/glances/outputs/static/js/services/plugins/fs.js deleted file mode 100644 index 07f9b9e2..00000000 --- a/glances/outputs/static/js/services/plugins/fs.js +++ /dev/null @@ -1,40 +0,0 @@ -glancesApp.service('GlancesPluginFs', function() { - var _pluginName = "fs"; - var _view = {}; - this.fileSystems = []; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - this.fileSystems = []; - - for (var i = 0; i < data.length; i++) { - var fsData = data[i]; - - var shortMountPoint = fsData['mnt_point']; - if (shortMountPoint.length > 9) { - shortMountPoint = '_' + fsData['mnt_point'].slice(-8); - } - - var fs = { - 'name': fsData['device_name'], - 'mountPoint': fsData['mnt_point'], - 'shortMountPoint': shortMountPoint, - 'percent': fsData['percent'], - 'size': fsData['size'], - 'used': fsData['used'], - 'free': fsData['free'] - }; - - this.fileSystems.push(fs); - } - }; - - this.getDecoration = function(mountPoint, field) { - if(_view[mountPoint][field] == undefined) { - return; - } - - return _view[mountPoint][field].decoration.toLowerCase(); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/gpu.js b/glances/outputs/static/js/services/plugins/gpu.js deleted file mode 100644 index f84fc953..00000000 --- a/glances/outputs/static/js/services/plugins/gpu.js +++ /dev/null @@ -1,56 +0,0 @@ -glancesApp.service('GlancesPluginGpu', function() { - var _pluginName = "gpu"; - var _view = {}; - this.gpus = []; - this.name = "GPU"; - this.mean = {}; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - if (data.length === 0) { - return; - } - - this.gpus = []; - this.name = "GPU"; - this.mean = { - proc: null, - mem: null - }; - var sameName = true; - - for (var i = 0; i < data.length; i++) { - var gpuData = data[i]; - - var gpu = gpuData; - - this.mean.proc += gpu.proc; - this.mean.mem += gpu.mem; - - this.gpus.push(gpu); - } - - if (data.length === 1 ) { - this.name = data[0].name; - } else if (sameName) { - this.name = data.length + ' GPU ' + data[0].name; - } - - this.mean.proc = this.mean.proc / data.length; - this.mean.mem = this.mean.mem / data.length; - }; - - this.getDecoration = function(gpuId, value) { - if(_view[gpuId][value] == undefined) { - return; - } - - return _view[gpuId][value].decoration.toLowerCase(); - }; - - this.getMeanDecoration = function(value) { - return this.getDecoration(0, value); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/ip.js b/glances/outputs/static/js/services/plugins/ip.js deleted file mode 100644 index a13add6c..00000000 --- a/glances/outputs/static/js/services/plugins/ip.js +++ /dev/null @@ -1,19 +0,0 @@ -glancesApp.service('GlancesPluginIp', function() { - var _pluginName = "ip"; - - this.address = null; - this.gateway = null; - this.mask = null; - this.maskCidr = null; - this.publicAddress = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - - this.address = data.address; - this.gateway = data.gateway; - this.mask = data.mask; - this.maskCidr = data.mask_cidr; - this.publicAddress = data.public_address - }; -}); diff --git a/glances/outputs/static/js/services/plugins/irq.js b/glances/outputs/static/js/services/plugins/irq.js deleted file mode 100644 index 8e71c8ed..00000000 --- a/glances/outputs/static/js/services/plugins/irq.js +++ /dev/null @@ -1,21 +0,0 @@ -glancesApp.service('GlancesPluginIrq', function() { - var _pluginName = "irq"; - this.irqs = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.irqs = []; - - for (var i = 0; i < data.length; i++) { - var IrqData = data[i]; - var timeSinceUpdate = IrqData['time_since_update']; - - var irq = { - 'irq_line': IrqData['irq_line'], - 'irq_rate': IrqData['irq_rate'] - }; - - this.irqs.push(irq); - } - }; -}); diff --git a/glances/outputs/static/js/services/plugins/load.js b/glances/outputs/static/js/services/plugins/load.js deleted file mode 100644 index 7a9993f1..00000000 --- a/glances/outputs/static/js/services/plugins/load.js +++ /dev/null @@ -1,27 +0,0 @@ -glancesApp.service('GlancesPluginLoad', function() { - var _pluginName = "load"; - var _view = {}; - - this.cpucore = null; - this.min1 = null; - this.min5 = null; - this.min15 = null; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - - this.cpucore = data['cpucore']; - this.min1 = data['min1']; - this.min5 = data['min5']; - this.min15 = data['min15']; - }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/mem.js b/glances/outputs/static/js/services/plugins/mem.js deleted file mode 100644 index 93b0d599..00000000 --- a/glances/outputs/static/js/services/plugins/mem.js +++ /dev/null @@ -1,36 +0,0 @@ -glancesApp.service('GlancesPluginMem', function() { - var _pluginName = "mem"; - var _view = {}; - - this.percent = null; - this.total = null; - this.used = null; - this.free = null; - this.version = null; - this.active = null; - this.inactive = null; - this.buffers = null; - this.cached = null; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - - this.percent = data['percent']; - this.total = data['total']; - this.used = data['used']; - this.free = data['free']; - this.active = data['active']; - this.inactive = data['inactive']; - this.buffers = data['buffers']; - this.cached = data['cached']; - }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/memswap.js b/glances/outputs/static/js/services/plugins/memswap.js deleted file mode 100644 index 7ac1684b..00000000 --- a/glances/outputs/static/js/services/plugins/memswap.js +++ /dev/null @@ -1,27 +0,0 @@ -glancesApp.service('GlancesPluginMemSwap', function() { - var _pluginName = "memswap"; - var _view = {}; - - this.percent = null; - this.total = null; - this.used = null; - this.free = null; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - - this.percent = data['percent']; - this.total = data['total']; - this.used = data['used']; - this.free = data['free']; - }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/network.js b/glances/outputs/static/js/services/plugins/network.js deleted file mode 100644 index d52d3c01..00000000 --- a/glances/outputs/static/js/services/plugins/network.js +++ /dev/null @@ -1,25 +0,0 @@ -glancesApp.service('GlancesPluginNetwork', function() { - var _pluginName = "network"; - this.networks = []; - - this.setData = function(data, views) { - this.networks = []; - - for (var i = 0; i < data[_pluginName].length; i++) { - var networkData = data[_pluginName][i]; - - var network = { - 'interfaceName': networkData['interface_name'], - 'rx': networkData['rx'], - 'tx': networkData['tx'], - 'cx': networkData['cx'], - 'time_since_update': networkData['time_since_update'], - 'cumulativeRx': networkData['cumulative_rx'], - 'cumulativeTx': networkData['cumulative_tx'], - 'cumulativeCx': networkData['cumulative_cx'] - }; - - this.networks.push(network); - } - }; -}); diff --git a/glances/outputs/static/js/services/plugins/percpu.js b/glances/outputs/static/js/services/plugins/percpu.js deleted file mode 100644 index 83b28f6a..00000000 --- a/glances/outputs/static/js/services/plugins/percpu.js +++ /dev/null @@ -1,30 +0,0 @@ -glancesApp.service('GlancesPluginPerCpu', function($filter, GlancesPlugin) { - var _pluginName = "percpu"; - this.cpus = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.cpus = []; - - for (var i = 0; i < data.length; i++) { - var cpuData = data[i]; - - this.cpus.push({ - 'total': cpuData.total, - 'user': cpuData.user, - 'system': cpuData.system, - 'idle': cpuData.idle, - 'iowait': cpuData.iowait, - 'steal': cpuData.steal - }); - } - }; - - this.getUserAlert = function(cpu) { - return GlancesPlugin.getAlert(_pluginName, 'percpu_user_', cpu.user) - }; - - this.getSystemAlert = function(cpu) { - return GlancesPlugin.getAlert(_pluginName, 'percpu_system_', cpu.system); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/plugin.js b/glances/outputs/static/js/services/plugins/plugin.js deleted file mode 100644 index a2fbc91c..00000000 --- a/glances/outputs/static/js/services/plugins/plugin.js +++ /dev/null @@ -1,42 +0,0 @@ -glancesApp.service('GlancesPlugin', function () { - - var plugin = { - 'limits': {}, - 'limitSuffix': ['critical', 'careful', 'warning'] - }; - - plugin.setLimits = function(limits){ - this.limits = limits; - }; - - plugin.getAlert = function (pluginName, limitNamePrefix, current, maximum, log) { - current = current || 0; - maximum = maximum || 100; - log = log || false; - - var log_str = log ? '_log' : ''; - var value = (current * 100) / maximum; - - if (this.limits[pluginName] != undefined) { - for (var i = 0; i < this.limitSuffix.length; i++) { - var limitName = limitNamePrefix + this.limitSuffix[i]; - var limit = this.limits[pluginName][limitName]; - - if (value >= limit) { - var pos = limitName.lastIndexOf("_"); - var className = limitName.substring(pos + 1); - - return className + log_str; - } - } - } - - return "ok" + log_str; - }; - - plugin.getAlertLog = function (pluginName, limitNamePrefix, current, maximum) { - return this.getAlert(pluginName, limitNamePrefix, current, maximum, true); - }; - - return plugin; -}); diff --git a/glances/outputs/static/js/services/plugins/ports.js b/glances/outputs/static/js/services/plugins/ports.js deleted file mode 100644 index 96fd57e5..00000000 --- a/glances/outputs/static/js/services/plugins/ports.js +++ /dev/null @@ -1,29 +0,0 @@ -glancesApp.service('GlancesPluginPorts', function() { - var _pluginName = "ports"; - this.ports = []; - - this.setData = function(data, views) { - var ports = data[_pluginName]; - this.ports = []; - - angular.forEach(ports, function(port) { - this.ports.push(port); - }, this); - }; - - this.getDecoration = function(port) { - if (port.status === null) { - return 'careful'; - } - - if (port.status === false) { - return 'critical'; - } - - if (port.rtt_warning !== null && port.status > port.rtt_warning) { - return 'warning'; - } - - return 'ok'; - }; -}); diff --git a/glances/outputs/static/js/services/plugins/processcount.js b/glances/outputs/static/js/services/plugins/processcount.js deleted file mode 100644 index 163f6b49..00000000 --- a/glances/outputs/static/js/services/plugins/processcount.js +++ /dev/null @@ -1,19 +0,0 @@ -glancesApp.service('GlancesPluginProcessCount', function() { - var _pluginName = "processcount"; - - this.total = null; - this.running = null; - this.sleeping = null; - this.stopped = null; - this.thread = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - - this.total = data['total'] || 0; - this.running = data['running'] || 0; - this.sleeping = data['sleeping'] || 0; - this.stopped = data['stopped'] || 0; - this.thread = data['thread'] || 0; - }; -}); diff --git a/glances/outputs/static/js/services/plugins/quicklook.js b/glances/outputs/static/js/services/plugins/quicklook.js deleted file mode 100644 index 37345b52..00000000 --- a/glances/outputs/static/js/services/plugins/quicklook.js +++ /dev/null @@ -1,40 +0,0 @@ -glancesApp.service('GlancesPluginQuicklook', function() { - var _pluginName = "quicklook"; - var _view = {}; - - this.mem = null; - this.cpu = null; - this.cpu_name = null; - this.cpu_hz_current = null; - this.cpu_hz = null; - this.swap = null; - this.percpus = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - this.mem = data.mem; - this.cpu = data.cpu; - this.cpu_name = data.cpu_name; - this.cpu_hz_current = data.cpu_hz_current; - this.cpu_hz = data.cpu_hz; - this.swap = data.swap; - this.percpus = []; - - angular.forEach(data.percpu, function(cpu) { - this.percpus.push({ - 'number': cpu.cpu_number, - 'total': cpu.total - }); - }, this); - } - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - } -}); diff --git a/glances/outputs/static/js/services/plugins/raid.js b/glances/outputs/static/js/services/plugins/raid.js deleted file mode 100644 index 900b2a5d..00000000 --- a/glances/outputs/static/js/services/plugins/raid.js +++ /dev/null @@ -1,50 +0,0 @@ -glancesApp.service('GlancesPluginRaid', function () { - var _pluginName = "raid"; - this.disks = []; - - this.setData = function (data, views) { - var disks = []; - data = data[_pluginName]; - - _.forIn(data, function(diskData, diskKey) { - var disk = { - 'name': diskKey, - 'type': diskData.type == null ? 'UNKNOWN' : diskData.type, - 'used': diskData.used, - 'available': diskData.available, - 'status': diskData.status, - 'degraded': diskData.used < diskData.available, - 'config': diskData.config == null ? '' : diskData.config.replace('_', 'A'), - 'inactive': diskData.status == 'inactive', - 'components': [] - }; - - _.forEach(diskData.components, function(number, name) { - disk.components.push({ - 'number': number, - 'name': name - }); - }); - - disks.push(disk); - }); - - this.disks = disks; - }; - - this.hasDisks = function() { - return this.disks.length > 0; - } - - this.getAlert = function(disk) { - if (disk.inactive) { - return 'critical'; - } - - if (disk.degraded) { - return 'warning'; - } - - return 'ok' - } -}); diff --git a/glances/outputs/static/js/services/plugins/sensors.js b/glances/outputs/static/js/services/plugins/sensors.js deleted file mode 100644 index e553505a..00000000 --- a/glances/outputs/static/js/services/plugins/sensors.js +++ /dev/null @@ -1,21 +0,0 @@ -glancesApp.service('GlancesPluginSensors', function(GlancesPlugin) { - - var _pluginName = "sensors"; - this.sensors = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - - _.remove(data, function(sensor) { - return (_.isArray(sensor.value) && _.isEmpty(sensor.value)) || sensor.value === 0; - }); - - this.sensors = data; - }; - - this.getAlert = function(sensor) { - var current = sensor.type == 'battery' ? 100 - sensor.value : sensor.value; - - return GlancesPlugin.getAlert(_pluginName, 'sensors_' + sensor.type + '_', current); - }; -}); diff --git a/glances/outputs/static/js/services/plugins/system.js b/glances/outputs/static/js/services/plugins/system.js deleted file mode 100644 index ecf4f0f8..00000000 --- a/glances/outputs/static/js/services/plugins/system.js +++ /dev/null @@ -1,37 +0,0 @@ -glancesApp.service('GlancesPluginSystem', function() { - var _pluginName = "system"; - - this.hostname = null; - this.platform = null; - this.humanReadableName = null; - this.os = { - 'name': null, - 'version': null - }; - - this.setData = function(data, views) { - data = data[_pluginName]; - - this.hostname = data['hostname']; - this.platform = data['platform']; - this.os.name = data['os_name']; - this.os.version = data['os_version']; - this.humanReadableName = data['hr_name']; - }; - - this.isBsd = function() { - return this.os.name === 'FreeBSD'; - }; - - this.isLinux = function() { - return this.os.name === 'Linux'; - }; - - this.isMac = function() { - return this.os.name === 'Darwin'; - }; - - this.isWindows = function() { - return this.os.name === 'Windows'; - }; -}); diff --git a/glances/outputs/static/js/services/plugins/uptime.js b/glances/outputs/static/js/services/plugins/uptime.js deleted file mode 100644 index 4a008bde..00000000 --- a/glances/outputs/static/js/services/plugins/uptime.js +++ /dev/null @@ -1,7 +0,0 @@ -glancesApp.service('GlancesPluginUptime', function() { - this.uptime = null; - - this.setData = function(data, views) { - this.uptime = data['uptime']; - }; -}); diff --git a/glances/outputs/static/js/services/plugins/wifi.js b/glances/outputs/static/js/services/plugins/wifi.js deleted file mode 100644 index 2defd931..00000000 --- a/glances/outputs/static/js/services/plugins/wifi.js +++ /dev/null @@ -1,36 +0,0 @@ -glancesApp.service('GlancesPluginWifi', function() { - var _pluginName = "wifi"; - var _view = {}; - this.hotspots = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - this.hotspots = []; - for (var i = 0; i < data.length; i++) { - var hotspotData = data[i]; - - if (hotspotData['ssid'] === '') { - continue; - } - - var hotspot = { - 'ssid': hotspotData['ssid'], - 'encrypted': hotspotData['encrypted'], - 'signal': hotspotData['signal'], - 'encryption_type': hotspotData['encryption_type'], - }; - - this.hotspots.push(hotspot); - } - }; - - this.getDecoration = function(hotpost, field) { - if(_view[hotpost.ssid][field] == undefined) { - return; - } - - return _view[hotpost.ssid][field].decoration.toLowerCase(); - }; -}); diff --git a/glances/outputs/static/js/stats.js b/glances/outputs/static/js/stats.js new file mode 100644 index 00000000..fe2d26cb --- /dev/null +++ b/glances/outputs/static/js/stats.js @@ -0,0 +1,60 @@ +glancesApp.service('GlancesStats', function($http, $q) { + var _stats = [], _views = [], _limits = [], _config = {}; + + this.getData = function() { + return $q.all([ + this.getAllStats(), + this.getAllViews() + ]).then(function(results) { + return { + 'stats': results[0], + 'view': results[1] + }; + }); + }; + + this.getAllStats = function() { + return $http.get('/api/2/all').then(function (response) { + _stats = response.data; + + return response.data; + }); + }; + + this.getAllLimits = function() { + return $http.get('/api/2/all/limits').then(function (response) { + _limits = response.data; + + return response.data; + }); + }; + + this.getAllViews = function() { + return $http.get('/api/2/all/views').then(function (response) { + _views = response.data; + + return response.data; + }); + }; + + this.getHelp = function() { + return $http.get('/api/2/help').then(function (response) { + return response.data; + }); + }; + + this.getConfig = function() { + return $http.get('/api/2/config').then(function (response) { + _config = response.data; + + return _config; + }); + }; + + this.getArguments = function() { + return $http.get('/api/2/args').then(function (response) { + return response.data; + }); + }; + +}); diff --git a/glances/outputs/static/public/js/main.min.js b/glances/outputs/static/public/js/main.min.js index 03555ecd..b6df56c0 100644 --- a/glances/outputs/static/public/js/main.min.js +++ b/glances/outputs/static/public/js/main.min.js @@ -30,219 +30,10 @@ var glancesApp = angular.module('glancesApp', ['ngRoute']) $rootScope.title = "Glances"; }]); -glancesApp.controller('statsController', ["$scope", "$rootScope", "$interval", "GlancesStats", "help", "config", "arguments", "favicoService", function ($scope, $rootScope, $interval, GlancesStats, help, config, arguments, favicoService) { +glancesApp.controller('statsController', ["$scope", "help", "config", "arguments", function ($scope, help, config, arguments) { $scope.help = help; + $scope.config = config; $scope.arguments = arguments; - - $scope.sorter = { - column: "cpu_percent", - auto: true, - isReverseColumn: function (column) { - return !(column == 'username' || column == 'name'); - }, - getColumnLabel: function (column) { - if (_.isEqual(column, ['io_read', 'io_write'])) { - return 'io_counters'; - } else { - return column; - } - } - }; - - $scope.dataLoaded = false; - $scope.refreshData = function () { - GlancesStats.getData().then(function (data) { - - $scope.statsAlert = GlancesStats.getPlugin('alert'); - $scope.statsCloud = GlancesStats.getPlugin('cloud'); - $scope.statsCpu = GlancesStats.getPlugin('cpu'); - $scope.statsDiskio = GlancesStats.getPlugin('diskio'); - $scope.statsIrq = GlancesStats.getPlugin('irq'); - $scope.statsDocker = GlancesStats.getPlugin('docker'); - $scope.statsFs = GlancesStats.getPlugin('fs'); - $scope.statsFolders = GlancesStats.getPlugin('folders'); - $scope.statsGpu = GlancesStats.getPlugin('gpu'); - $scope.statsIp = GlancesStats.getPlugin('ip'); - $scope.statsLoad = GlancesStats.getPlugin('load'); - $scope.statsMem = GlancesStats.getPlugin('mem'); - $scope.statsMemSwap = GlancesStats.getPlugin('memswap'); - $scope.statsAmps = GlancesStats.getPlugin('amps'); - $scope.statsNetwork = GlancesStats.getPlugin('network'); - $scope.statsPerCpu = GlancesStats.getPlugin('percpu'); - $scope.statsProcessCount = GlancesStats.getPlugin('processcount'); - $scope.statsProcessList = GlancesStats.getPlugin('processlist'); - $scope.statsQuicklook = GlancesStats.getPlugin('quicklook'); - $scope.statsRaid = GlancesStats.getPlugin('raid'); - $scope.statsSensors = GlancesStats.getPlugin('sensors'); - $scope.statsSystem = GlancesStats.getPlugin('system'); - $scope.statsUptime = GlancesStats.getPlugin('uptime'); - $scope.statsPorts = GlancesStats.getPlugin('ports'); - $scope.statsWifi = GlancesStats.getPlugin('wifi'); - - $rootScope.title = $scope.statsSystem.hostname + ' - Glances'; - - if ($scope.statsAlert.hasOngoingAlerts()) { - favicoService.badge($scope.statsAlert.countOngoingAlerts()); - } else { - favicoService.reset(); - } - - $scope.is_disconnected = false; - $scope.dataLoaded = true; - }, function() { - $scope.is_disconnected = true; - }); - }; - - $scope.refreshData(); - $interval(function () { - $scope.refreshData(); - }, arguments.time * 1000); // in milliseconds - - $scope.onKeyDown = function ($event) { - - switch (true) { - case !$event.shiftKey && $event.keyCode == keycodes.a: - // a => Sort processes automatically - $scope.sorter.column = "cpu_percent"; - $scope.sorter.auto = true; - break; - case $event.shiftKey && $event.keyCode == keycodes.A: - // A => Enable/disable AMPs - $scope.arguments.disable_amps = !$scope.arguments.disable_amps; - break; - case !$event.shiftKey && $event.keyCode == keycodes.c: - // c => Sort processes by CPU% - $scope.sorter.column = "cpu_percent"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.m: - // m => Sort processes by MEM% - $scope.sorter.column = "memory_percent"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.u: - // u => Sort processes by user - $scope.sorter.column = "username"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.p: - // p => Sort processes by name - $scope.sorter.column = "name"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.i: - // i => Sort processes by I/O rate - $scope.sorter.column = ['io_read', 'io_write']; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.t: - // t => Sort processes by time - $scope.sorter.column = "timemillis"; - $scope.sorter.auto = false; - break; - case !$event.shiftKey && $event.keyCode == keycodes.d: - // d => Show/hide disk I/O stats - $scope.arguments.disable_diskio = !$scope.arguments.disable_diskio; - break; - case $event.shiftKey && $event.keyCode == keycodes.Q: - // Q => Show/hide IRQ - $scope.arguments.enable_irq = !$scope.arguments.enable_irq; - break; - case !$event.shiftKey && $event.keyCode == keycodes.f: - // f => Show/hide filesystem stats - $scope.arguments.disable_fs = !$scope.arguments.disable_fs; - break; - case !$event.shiftKey && $event.keyCode == keycodes.n: - // n => Show/hide network stats - $scope.arguments.disable_network = !$scope.arguments.disable_network; - break; - case !$event.shiftKey && $event.keyCode == keycodes.s: - // s => Show/hide sensors stats - $scope.arguments.disable_sensors = !$scope.arguments.disable_sensors; - break; - case $event.shiftKey && $event.keyCode == keycodes.TWO: - // 2 => Show/hide left sidebar - $scope.arguments.disable_left_sidebar = !$scope.arguments.disable_left_sidebar; - break; - case !$event.shiftKey && $event.keyCode == keycodes.z: - // z => Enable/disable processes stats - $scope.arguments.disable_process = !$scope.arguments.disable_process; - break; - case $event.keyCode == keycodes.SLASH: - // SLASH => Enable/disable short processes name - $scope.arguments.process_short_name = !$scope.arguments.process_short_name; - break; - case $event.shiftKey && $event.keyCode == keycodes.D: - // D => Enable/disable Docker stats - $scope.arguments.disable_docker = !$scope.arguments.disable_docker; - break; - case !$event.shiftKey && $event.keyCode == keycodes.b: - // b => Bytes or bits for network I/O - $scope.arguments.byte = !$scope.arguments.byte; - break; - case $event.shiftKey && $event.keyCode == keycodes.b: - // 'B' => Switch between bit/s and IO/s for Disk IO - $scope.arguments.diskio_iops = !$scope.arguments.diskio_iops; - break; - case !$event.shiftKey && $event.keyCode == keycodes.l: - // l => Show/hide alert logs - $scope.arguments.disable_alert = !$scope.arguments.disable_alert; - break; - case $event.shiftKey && $event.keyCode == keycodes.ONE: - // 1 => Global CPU or per-CPU stats - $scope.arguments.percpu = !$scope.arguments.percpu; - break; - case !$event.shiftKey && $event.keyCode == keycodes.h: - // h => Show/hide this help screen - $scope.arguments.help_tag = !$scope.arguments.help_tag; - break; - case $event.shiftKey && $event.keyCode == keycodes.T: - // T => View network I/O as combination - $scope.arguments.network_sum = !$scope.arguments.network_sum; - break; - case $event.shiftKey && $event.keyCode == keycodes.u: - // U => View cumulative network I/O - $scope.arguments.network_cumul = !$scope.arguments.network_cumul; - break; - case $event.shiftKey && $event.keyCode == keycodes.f: - // F => Show filesystem free space - $scope.arguments.fs_free_space = !$scope.arguments.fs_free_space; - break; - case $event.shiftKey && $event.keyCode == keycodes.THREE: - // 3 => Enable/disable quick look plugin - $scope.arguments.disable_quicklook = !$scope.arguments.disable_quicklook; - break; - case $event.shiftKey && $event.keyCode == keycodes.SIX: - // 6 => Enable/disable mean gpu - $scope.arguments.meangpu = !$scope.arguments.meangpu; - break; - case $event.shiftKey && $event.keyCode == keycodes.g: - // G => Enable/disable gpu - $scope.arguments.disable_gpu = !$scope.arguments.disable_gpu; - break; - case $event.shiftKey && $event.keyCode == keycodes.FIVE: - $scope.arguments.disable_quicklook = !$scope.arguments.disable_quicklook; - $scope.arguments.disable_cpu = !$scope.arguments.disable_cpu; - $scope.arguments.disable_mem = !$scope.arguments.disable_mem; - $scope.arguments.disable_memswap = !$scope.arguments.disable_memswap; - $scope.arguments.disable_load = !$scope.arguments.disable_load; - $scope.arguments.disable_gpu = !$scope.arguments.disable_gpu; - break; - case $event.shiftKey && $event.keyCode == keycodes.i: - // I => Show/hide IP module - $scope.arguments.disable_ip = !$scope.arguments.disable_ip; - break; - case $event.shiftKey && $event.keyCode == keycodes.p: - // I => Enable/disable ports module - $scope.arguments.disable_ports = !$scope.arguments.disable_ports; - break; - case $event.shiftKey && $event.keyCode == keycodes.w: - // 'W' > Enable/Disable Wifi plugin - $scope.arguments.disable_wifi = !$scope.arguments.disable_wifi; - break; - } - }; }]); glancesApp.directive("sortableTh", function() { @@ -284,6 +75,21 @@ glancesApp.directive("sortableTh", function() { } }; }); +glancesApp.service('favicoService', function() { + + var favico = new Favico({ + animation : 'none' + }); + + this.badge = function(nb) { + favico.badge(nb); + }; + + this.reset = function() { + favico.reset(); + }; +}); + glancesApp.filter('min_size', function() { return function(input, max) { var max = max || 8; @@ -395,88 +201,9 @@ glancesApp.filter('timedelta', ["$filter", function($filter) { } }]); -var keycodes = { - 'a' : '65', - 'c' : '67', - 'm' : '77', - 'p' : '80', - 'i' : '73', - 't' : '84', - 'u' : '85', - 'd' : '68', - 'f' : '70', - 'n' : '78', - 's' : '83', - 'z' : '90', - 'e' : '69', - 'SLASH': '191', - 'D' : '68', - 'b' : '66', - 'l' : '76', - 'w' : '87', - 'x' : '88', - 'ONE': '49', - 'TWO': '50', - 'THREE': '51', - 'FOUR': '52', - 'FIVE': '53', - 'SIX': '54', - 'h' : '72', - 'T' : '84', - 'F' : '70', - 'g' : '71', - 'r' : '82', - 'q' : '81', - 'A' : '65', - 'Q' : '81' -} - -glancesApp.service('favicoService', function() { - - var favico = new Favico({ - animation : 'none' - }); - - this.badge = function(nb) { - favico.badge(nb); - }; - - this.reset = function() { - favico.reset(); - }; -}); - -glancesApp.service('GlancesStats', ["$http", "$injector", "$q", "GlancesPlugin", function($http, $injector, $q, GlancesPlugin) { +glancesApp.service('GlancesStats', ["$http", "$q", function($http, $q) { var _stats = [], _views = [], _limits = [], _config = {}; - var _plugins = { - 'alert': 'GlancesPluginAlert', - 'cloud': 'GlancesPluginCloud', - 'cpu': 'GlancesPluginCpu', - 'diskio': 'GlancesPluginDiskio', - 'irq' : 'GlancesPluginIrq', - 'docker': 'GlancesPluginDocker', - 'ip': 'GlancesPluginIp', - 'fs': 'GlancesPluginFs', - 'folders': 'GlancesPluginFolders', - 'gpu': 'GlancesPluginGpu', - 'load': 'GlancesPluginLoad', - 'mem': 'GlancesPluginMem', - 'memswap': 'GlancesPluginMemSwap', - 'amps': 'GlancesPluginAmps', - 'network': 'GlancesPluginNetwork', - 'percpu': 'GlancesPluginPerCpu', - 'processcount': 'GlancesPluginProcessCount', - 'processlist': 'GlancesPluginProcessList', - 'quicklook': 'GlancesPluginQuicklook', - 'raid': 'GlancesPluginRaid', - 'sensors': 'GlancesPluginSensors', - 'system': 'GlancesPluginSystem', - 'uptime': 'GlancesPluginUptime', - 'ports': 'GlancesPluginPorts', - 'wifi': 'GlancesPluginWifi' - }; - this.getData = function() { return $q.all([ this.getAllStats(), @@ -533,411 +260,256 @@ glancesApp.service('GlancesStats', ["$http", "$injector", "$q", "GlancesPlugin", }); }; - this.getPlugin = function(name) { - var plugin = _plugins[name]; - - if (plugin === undefined) { - throw "Plugin '" + name + "' not found"; - } - - plugin = $injector.get(plugin); - plugin.setData(_stats, _views, _config); - - return plugin; - }; - - // load limits to init GlancePlugin helper - this.getAllLimits().then(function(limits) { - GlancesPlugin.setLimits(limits); - }); - }]); -glancesApp.service('GlancesPluginAlert', function () { - var _pluginName = "alert"; - var _alerts = []; +var keycodes = { + 'a' : '65', + 'c' : '67', + 'm' : '77', + 'p' : '80', + 'i' : '73', + 't' : '84', + 'u' : '85', + 'd' : '68', + 'f' : '70', + 'n' : '78', + 's' : '83', + 'z' : '90', + 'e' : '69', + 'SLASH': '191', + 'D' : '68', + 'b' : '66', + 'l' : '76', + 'w' : '87', + 'x' : '88', + 'ONE': '49', + 'TWO': '50', + 'THREE': '51', + 'FOUR': '52', + 'FIVE': '53', + 'SIX': '54', + 'h' : '72', + 'T' : '84', + 'F' : '70', + 'g' : '71', + 'r' : '82', + 'q' : '81', + 'A' : '65', + 'Q' : '81' +} - this.setData = function (data, views) { - data = data[_pluginName]; - _alerts = []; +'use strict'; - if(!_.isArray(data)) { - data = []; - } - - for (var i = 0; i < data.length; i++) { - var alertData = data[i]; - var alert = {}; - - alert.name = alertData[3]; - alert.level = alertData[2]; - alert.begin = alertData[0] * 1000; - alert.end = alertData[1] * 1000; - alert.ongoing = alertData[1] == -1; - alert.min = alertData[6]; - alert.mean = alertData[5]; - alert.max = alertData[4]; - - if (!alert.ongoing) { - var duration = alert.end - alert.begin; - var seconds = parseInt((duration / 1000) % 60) - , minutes = parseInt((duration / (1000 * 60)) % 60) - , hours = parseInt((duration / (1000 * 60 * 60)) % 24); - - alert.duration = _.padStart(hours, 2, '0') + ":" + _.padStart(minutes, 2, '0') + ":" + _.padStart(seconds, 2, '0'); - } - - _alerts.push(alert); - } - }; - - this.hasAlerts = function () { - return _alerts.length > 0; - }; - - this.getAlerts = function () { - return _alerts; - }; - - this.count = function () { - return _alerts.length; - }; - - this.hasOngoingAlerts = function () { - return _.filter(_alerts, { 'ongoing': true }).length > 0; - }; - - this.countOngoingAlerts = function () { - return _.filter(_alerts, { 'ongoing': true }).length; - } +glancesApp.component('glances', { + controller: GlancesController, + bindings: { + arguments: '<', + config: '<', + help: '<' + }, + controllerAs: 'vm', + templateUrl: 'components/glances/view.html' }); -glancesApp.service('GlancesPluginAmps', function() { - var _pluginName = "amps"; - this.processes = []; +'use strict'; - this.setData = function(data, views) { - var processes = data[_pluginName]; +function GlancesController($interval, GlancesStats, favicoService) { + var vm = this; - this.processes = []; - angular.forEach(processes, function(process) { - if (process.result !== null) { - this.processes.push(process); - } - }, this); - }; - - this.getDescriptionDecoration = function(process) { - var count = process.count; - var countMin = process.countmin; - var countMax = process.countmax; - var decoration = "ok"; - - if (count > 0) { - if ((countMin == null || count >= countMin) && (countMax == null || count <= countMax)) { - decoration = 'ok'; + vm.sorter = { + column: "cpu_percent", + auto: true, + isReverseColumn: function (column) { + return !(column == 'username' || column == 'name'); + }, + getColumnLabel: function (column) { + if (_.isEqual(column, ['io_read', 'io_write'])) { + return 'io_counters'; } else { - decoration = 'careful'; + return column; } - } else { - decoration = countMin == null ? 'ok' : 'critical'; } + }; - return decoration; - } + vm.dataLoaded = false; + vm.stats = {}; + vm.refreshData = function () { + GlancesStats.getData().then(function (data) { + vm.stats = data; + vm.is_disconnected = false; + vm.dataLoaded = true; + }, function() { + vm.is_disconnected = true; + }); + }; + + vm.refreshData(); + var refreshTime = 60; // arguments.time + $interval(function () { + vm.refreshData(); + }, refreshTime * 1000); // in milliseconds + + vm.onKeyDown = function ($event) { + + switch (true) { + case !$event.shiftKey && $event.keyCode == keycodes.a: + // a => Sort processes automatically + vm.sorter.column = "cpu_percent"; + vm.sorter.auto = true; + break; + case $event.shiftKey && $event.keyCode == keycodes.A: + // A => Enable/disable AMPs + vm.arguments.disable_amps = !vm.arguments.disable_amps; + break; + case !$event.shiftKey && $event.keyCode == keycodes.c: + // c => Sort processes by CPU% + vm.sorter.column = "cpu_percent"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.m: + // m => Sort processes by MEM% + vm.sorter.column = "memory_percent"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.u: + // u => Sort processes by user + vm.sorter.column = "username"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.p: + // p => Sort processes by name + vm.sorter.column = "name"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.i: + // i => Sort processes by I/O rate + vm.sorter.column = ['io_read', 'io_write']; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.t: + // t => Sort processes by time + vm.sorter.column = "timemillis"; + vm.sorter.auto = false; + break; + case !$event.shiftKey && $event.keyCode == keycodes.d: + // d => Show/hide disk I/O stats + vm.arguments.disable_diskio = !vm.arguments.disable_diskio; + break; + case $event.shiftKey && $event.keyCode == keycodes.Q: + // Q => Show/hide IRQ + vm.arguments.enable_irq = !vm.arguments.enable_irq; + break; + case !$event.shiftKey && $event.keyCode == keycodes.f: + // f => Show/hide filesystem stats + vm.arguments.disable_fs = !vm.arguments.disable_fs; + break; + case !$event.shiftKey && $event.keyCode == keycodes.n: + // n => Show/hide network stats + vm.arguments.disable_network = !vm.arguments.disable_network; + break; + case !$event.shiftKey && $event.keyCode == keycodes.s: + // s => Show/hide sensors stats + vm.arguments.disable_sensors = !vm.arguments.disable_sensors; + break; + case $event.shiftKey && $event.keyCode == keycodes.TWO: + // 2 => Show/hide left sidebar + vm.arguments.disable_left_sidebar = !vm.arguments.disable_left_sidebar; + break; + case !$event.shiftKey && $event.keyCode == keycodes.z: + // z => Enable/disable processes stats + vm.arguments.disable_process = !vm.arguments.disable_process; + break; + case $event.keyCode == keycodes.SLASH: + // SLASH => Enable/disable short processes name + vm.arguments.process_short_name = !vm.arguments.process_short_name; + break; + case $event.shiftKey && $event.keyCode == keycodes.D: + // D => Enable/disable Docker stats + vm.arguments.disable_docker = !vm.arguments.disable_docker; + break; + case !$event.shiftKey && $event.keyCode == keycodes.b: + // b => Bytes or bits for network I/O + vm.arguments.byte = !vm.arguments.byte; + break; + case $event.shiftKey && $event.keyCode == keycodes.b: + // 'B' => Switch between bit/s and IO/s for Disk IO + vm.arguments.diskio_iops = !vm.arguments.diskio_iops; + break; + case !$event.shiftKey && $event.keyCode == keycodes.l: + // l => Show/hide alert logs + vm.arguments.disable_alert = !vm.arguments.disable_alert; + break; + case $event.shiftKey && $event.keyCode == keycodes.ONE: + // 1 => Global CPU or per-CPU stats + vm.arguments.percpu = !vm.arguments.percpu; + break; + case !$event.shiftKey && $event.keyCode == keycodes.h: + // h => Show/hide this help screen + vm.arguments.help_tag = !vm.arguments.help_tag; + break; + case $event.shiftKey && $event.keyCode == keycodes.T: + // T => View network I/O as combination + vm.arguments.network_sum = !vm.arguments.network_sum; + break; + case $event.shiftKey && $event.keyCode == keycodes.u: + // U => View cumulative network I/O + vm.arguments.network_cumul = !vm.arguments.network_cumul; + break; + case $event.shiftKey && $event.keyCode == keycodes.f: + // F => Show filesystem free space + vm.arguments.fs_free_space = !vm.arguments.fs_free_space; + break; + case $event.shiftKey && $event.keyCode == keycodes.THREE: + // 3 => Enable/disable quick look plugin + vm.arguments.disable_quicklook = !vm.arguments.disable_quicklook; + break; + case $event.shiftKey && $event.keyCode == keycodes.SIX: + // 6 => Enable/disable mean gpu + vm.arguments.meangpu = !vm.arguments.meangpu; + break; + case $event.shiftKey && $event.keyCode == keycodes.g: + // G => Enable/disable gpu + vm.arguments.disable_gpu = !vm.arguments.disable_gpu; + break; + case $event.shiftKey && $event.keyCode == keycodes.FIVE: + vm.arguments.disable_quicklook = !vm.arguments.disable_quicklook; + vm.arguments.disable_cpu = !vm.arguments.disable_cpu; + vm.arguments.disable_mem = !vm.arguments.disable_mem; + vm.arguments.disable_memswap = !vm.arguments.disable_memswap; + vm.arguments.disable_load = !vm.arguments.disable_load; + vm.arguments.disable_gpu = !vm.arguments.disable_gpu; + break; + case $event.shiftKey && $event.keyCode == keycodes.i: + // I => Show/hide IP module + vm.arguments.disable_ip = !vm.arguments.disable_ip; + break; + case $event.shiftKey && $event.keyCode == keycodes.p: + // I => Enable/disable ports module + vm.arguments.disable_ports = !vm.arguments.disable_ports; + break; + case $event.shiftKey && $event.keyCode == keycodes.w: + // 'W' > Enable/Disable Wifi plugin + vm.arguments.disable_wifi = !vm.arguments.disable_wifi; + break; + } + }; +} + +'use strict'; + +glancesApp.component('glancesPluginIp', { + controller: GlancesPluginIpController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-ip/view.html' }); -glancesApp.service('GlancesPluginCloud', function() { - var _pluginName = "cloud"; - var _provider = null; - var _instance = null; +'use strict'; - this.setData = function(data, views) { - data = data[_pluginName]; - - if (data['ami-id'] !== undefined) { - _provider = 'AWS EC2'; - _instance = data['instance-type'] + ' instance ' + data['instance-id'] + ' (' + data['region'] + ')'; - } - } - - this.getProvider = function() { - return _provider; - } - - this.getInstance = function() { - return _instance; - } -}); - -glancesApp.service('GlancesPluginCpu', function() { - var _pluginName = "cpu"; - var _view = {}; - - this.total = null; - this.user = null; - this.system = null; - this.idle = null; - this.nice = null; - this.irq = null; - this.iowait = null; - this.steal = null; - this.ctx_switches = null; - this.interrupts = null; - this.soft_interrupts = null; - this.syscalls = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - this.total = data.total; - this.user = data.user; - this.system = data.system; - this.idle = data.idle; - this.nice = data.nice; - this.irq = data.irq; - this.iowait = data.iowait; - this.steal = data.steal; - - if (data.ctx_switches) { - this.ctx_switches = Math.floor(data.ctx_switches / data.time_since_update); - } - - if (data.interrupts) { - this.interrupts = Math.floor(data.interrupts / data.time_since_update); - } - - if (data.soft_interrupts) { - this.soft_interrupts = Math.floor(data.soft_interrupts / data.time_since_update); - } - - if (data.syscalls) { - this.syscalls = Math.floor(data.syscalls / data.time_since_update); - } - } - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - } -}); - -glancesApp.service('GlancesPluginDiskio', ["$filter", function($filter) { - var _pluginName = "diskio"; - this.disks = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - data = $filter('orderBy')(data,'disk_name'); - this.disks = []; - - for (var i = 0; i < data.length; i++) { - var diskioData = data[i]; - var timeSinceUpdate = diskioData['time_since_update']; - - var diskio = { - 'name': diskioData['disk_name'], - 'bitrate': { - 'txps': $filter('bytes')(diskioData['read_bytes'] / timeSinceUpdate), - 'rxps': $filter('bytes')(diskioData['write_bytes'] / timeSinceUpdate) - }, - 'count': { - 'txps': $filter('bytes')(diskioData['read_count'] / timeSinceUpdate), - 'rxps': $filter('bytes')(diskioData['write_count'] / timeSinceUpdate) - }, - 'alias': diskioData['alias'] !== undefined ? diskioData['alias'] : null - }; - - this.disks.push(diskio); - } - }; -}]); - -glancesApp.service('GlancesPluginDocker', ["GlancesPlugin", function(GlancesPlugin) { - - var _pluginName = "docker"; - this.containers = []; - this.version = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.containers = []; - - if(_.isEmpty(data)) { - return; - } - - for (var i = 0; i < data['containers'].length; i++) { - var containerData = data['containers'][i]; - - var container = { - 'id': containerData.Id, - 'name': containerData.Names[0].split('/').splice(-1)[0], - 'status': containerData.Status, - 'cpu': containerData.cpu.total, - 'memory': containerData.memory.usage != undefined ? containerData.memory.usage : '?', - 'ior': containerData.io.ior != undefined ? containerData.io.ior : '?', - 'iow': containerData.io.iow != undefined ? containerData.io.iow : '?', - 'io_time_since_update': containerData.io.time_since_update, - 'rx': containerData.network.rx != undefined ? containerData.network.rx : '?', - 'tx': containerData.network.tx != undefined ? containerData.network.tx : '?', - 'net_time_since_update': containerData.network.time_since_update, - 'command': containerData.Command, - 'image': containerData.Image - }; - - this.containers.push(container); - } - - this.version = data['version']['Version']; - }; -}]); - -glancesApp.service('GlancesPluginFolders', function() { - var _pluginName = "folders"; - this.folders = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.folders = []; - - for (var i = 0; i < data.length; i++) { - var folderData = data[i]; - - var folder = { - 'path': folderData['path'], - 'size': folderData['size'], - 'careful': folderData['careful'], - 'warning': folderData['warning'], - 'critical': folderData['critical'] - }; - - this.folders.push(folder); - } - }; - - this.getDecoration = function(folder) { - - if (!Number.isInteger(folder.size)) { - return; - } - - if (folder.critical !== null && folder.size > (folder.critical * 1000000)) { - return 'critical'; - } else if (folder.warning !== null && folder.size > (folder.warning * 1000000)) { - return 'warning'; - } else if (folder.careful !== null && folder.size > (folder.careful * 1000000)) { - return 'careful'; - } - - return 'ok'; - }; -}); - -glancesApp.service('GlancesPluginFs', function() { - var _pluginName = "fs"; - var _view = {}; - this.fileSystems = []; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - this.fileSystems = []; - - for (var i = 0; i < data.length; i++) { - var fsData = data[i]; - - var shortMountPoint = fsData['mnt_point']; - if (shortMountPoint.length > 9) { - shortMountPoint = '_' + fsData['mnt_point'].slice(-8); - } - - var fs = { - 'name': fsData['device_name'], - 'mountPoint': fsData['mnt_point'], - 'shortMountPoint': shortMountPoint, - 'percent': fsData['percent'], - 'size': fsData['size'], - 'used': fsData['used'], - 'free': fsData['free'] - }; - - this.fileSystems.push(fs); - } - }; - - this.getDecoration = function(mountPoint, field) { - if(_view[mountPoint][field] == undefined) { - return; - } - - return _view[mountPoint][field].decoration.toLowerCase(); - }; -}); - -glancesApp.service('GlancesPluginGpu', function() { - var _pluginName = "gpu"; - var _view = {}; - this.gpus = []; - this.name = "GPU"; - this.mean = {}; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - if (data.length === 0) { - return; - } - - this.gpus = []; - this.name = "GPU"; - this.mean = { - proc: null, - mem: null - }; - var sameName = true; - - for (var i = 0; i < data.length; i++) { - var gpuData = data[i]; - - var gpu = gpuData; - - this.mean.proc += gpu.proc; - this.mean.mem += gpu.mem; - - this.gpus.push(gpu); - } - - if (data.length === 1 ) { - this.name = data[0].name; - } else if (sameName) { - this.name = data.length + ' GPU ' + data[0].name; - } - - this.mean.proc = this.mean.proc / data.length; - this.mean.mem = this.mean.mem / data.length; - }; - - this.getDecoration = function(gpuId, value) { - if(_view[gpuId][value] == undefined) { - return; - } - - return _view[gpuId][value].decoration.toLowerCase(); - }; - - this.getMeanDecoration = function(value) { - return this.getDecoration(0, value); - }; -}); - -glancesApp.service('GlancesPluginIp', function() { - var _pluginName = "ip"; +function GlancesPluginIpController() { + var vm = this; this.address = null; this.gateway = null; @@ -945,281 +517,107 @@ glancesApp.service('GlancesPluginIp', function() { this.maskCidr = null; this.publicAddress = null; - this.setData = function(data, views) { - data = data[_pluginName]; + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } - this.address = data.address; - this.gateway = data.gateway; - this.mask = data.mask; - this.maskCidr = data.mask_cidr; - this.publicAddress = data.public_address + var data = stats.stats['ip']; + + vm.address = data.address; + vm.gateway = data.gateway; + vm.mask = data.mask; + vm.maskCidr = data.mask_cidr; + vm.publicAddress = data.public_address }; +} + +'use strict'; + +glancesApp.component('glancesPluginSystem', { + controller: GlancesPluginSystemController, + controllerAs: 'vm', + bindings: { + stats: '<', + isDisconnected: '<' + }, + templateUrl: 'components/plugin-system/view.html' }); -glancesApp.service('GlancesPluginIrq', function() { - var _pluginName = "irq"; - this.irqs = []; +'use strict'; - this.setData = function(data, views) { - data = data[_pluginName]; - this.irqs = []; +function GlancesPluginSystemController() { + var vm = this; + var _pluginName = "system"; - for (var i = 0; i < data.length; i++) { - var IrqData = data[i]; - var timeSinceUpdate = IrqData['time_since_update']; - - var irq = { - 'irq_line': IrqData['irq_line'], - 'irq_rate': IrqData['irq_rate'] - }; - - this.irqs.push(irq); - } + vm.hostname = null; + vm.platform = null; + vm.humanReadableName = null; + vm.os = { + 'name': null, + 'version': null }; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats[_pluginName]; + + vm.hostname = data['hostname']; + vm.platform = data['platform']; + vm.os.name = data['os_name']; + vm.os.version = data['os_version']; + vm.humanReadableName = data['hr_name']; + }; + + vm.isBsd = function() { + return this.os.name === 'FreeBSD'; + }; + + vm.isLinux = function() { + return this.os.name === 'Linux'; + }; + + vm.isMac = function() { + return this.os.name === 'Darwin'; + }; + + vm.isWindows = function() { + return this.os.name === 'Windows'; + }; +} + +'use strict'; + +glancesApp.component('glancesPluginUptime', { + controller: GlancesPluginUptimeController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-uptime/view.html' }); -glancesApp.service('GlancesPluginLoad', function() { - var _pluginName = "load"; - var _view = {}; +'use strict'; - this.cpucore = null; - this.min1 = null; - this.min5 = null; - this.min15 = null; +function GlancesPluginUptimeController() { + var vm = this; - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; + this.value = null - this.cpucore = data['cpucore']; - this.min1 = data['min1']; - this.min5 = data['min5']; - this.min15 = data['min15']; + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + vm.value = stats.stats['uptime']; }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - }; -}); - -glancesApp.service('GlancesPluginMem', function() { - var _pluginName = "mem"; - var _view = {}; - - this.percent = null; - this.total = null; - this.used = null; - this.free = null; - this.version = null; - this.active = null; - this.inactive = null; - this.buffers = null; - this.cached = null; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - - this.percent = data['percent']; - this.total = data['total']; - this.used = data['used']; - this.free = data['free']; - this.active = data['active']; - this.inactive = data['inactive']; - this.buffers = data['buffers']; - this.cached = data['cached']; - }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - }; -}); - -glancesApp.service('GlancesPluginMemSwap', function() { - var _pluginName = "memswap"; - var _view = {}; - - this.percent = null; - this.total = null; - this.used = null; - this.free = null; - - this.setData = function(data, views) { - _view = views[_pluginName]; - data = data[_pluginName]; - - this.percent = data['percent']; - this.total = data['total']; - this.used = data['used']; - this.free = data['free']; - }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - }; -}); - -glancesApp.service('GlancesPluginNetwork', function() { - var _pluginName = "network"; - this.networks = []; - - this.setData = function(data, views) { - this.networks = []; - - for (var i = 0; i < data[_pluginName].length; i++) { - var networkData = data[_pluginName][i]; - - var network = { - 'interfaceName': networkData['interface_name'], - 'rx': networkData['rx'], - 'tx': networkData['tx'], - 'cx': networkData['cx'], - 'time_since_update': networkData['time_since_update'], - 'cumulativeRx': networkData['cumulative_rx'], - 'cumulativeTx': networkData['cumulative_tx'], - 'cumulativeCx': networkData['cumulative_cx'] - }; - - this.networks.push(network); - } - }; -}); - -glancesApp.service('GlancesPluginPerCpu', ["$filter", "GlancesPlugin", function($filter, GlancesPlugin) { - var _pluginName = "percpu"; - this.cpus = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - this.cpus = []; - - for (var i = 0; i < data.length; i++) { - var cpuData = data[i]; - - this.cpus.push({ - 'total': cpuData.total, - 'user': cpuData.user, - 'system': cpuData.system, - 'idle': cpuData.idle, - 'iowait': cpuData.iowait, - 'steal': cpuData.steal - }); - } - }; - - this.getUserAlert = function(cpu) { - return GlancesPlugin.getAlert(_pluginName, 'percpu_user_', cpu.user) - }; - - this.getSystemAlert = function(cpu) { - return GlancesPlugin.getAlert(_pluginName, 'percpu_system_', cpu.system); - }; -}]); - -glancesApp.service('GlancesPlugin', function () { - - var plugin = { - 'limits': {}, - 'limitSuffix': ['critical', 'careful', 'warning'] - }; - - plugin.setLimits = function(limits){ - this.limits = limits; - }; - - plugin.getAlert = function (pluginName, limitNamePrefix, current, maximum, log) { - current = current || 0; - maximum = maximum || 100; - log = log || false; - - var log_str = log ? '_log' : ''; - var value = (current * 100) / maximum; - - if (this.limits[pluginName] != undefined) { - for (var i = 0; i < this.limitSuffix.length; i++) { - var limitName = limitNamePrefix + this.limitSuffix[i]; - var limit = this.limits[pluginName][limitName]; - - if (value >= limit) { - var pos = limitName.lastIndexOf("_"); - var className = limitName.substring(pos + 1); - - return className + log_str; - } - } - } - - return "ok" + log_str; - }; - - plugin.getAlertLog = function (pluginName, limitNamePrefix, current, maximum) { - return this.getAlert(pluginName, limitNamePrefix, current, maximum, true); - }; - - return plugin; -}); - -glancesApp.service('GlancesPluginPorts', function() { - var _pluginName = "ports"; - this.ports = []; - - this.setData = function(data, views) { - var ports = data[_pluginName]; - this.ports = []; - - angular.forEach(ports, function(port) { - this.ports.push(port); - }, this); - }; - - this.getDecoration = function(port) { - if (port.status === null) { - return 'careful'; - } - - if (port.status === false) { - return 'critical'; - } - - if (port.rtt_warning !== null && port.status > port.rtt_warning) { - return 'warning'; - } - - return 'ok'; - }; -}); - -glancesApp.service('GlancesPluginProcessCount', function() { - var _pluginName = "processcount"; - - this.total = null; - this.running = null; - this.sleeping = null; - this.stopped = null; - this.thread = null; - - this.setData = function(data, views) { - data = data[_pluginName]; - - this.total = data['total'] || 0; - this.running = data['running'] || 0; - this.sleeping = data['sleeping'] || 0; - this.stopped = data['stopped'] || 0; - this.thread = data['thread'] || 0; - }; -}); +} glancesApp.service('GlancesPluginProcessList', ["$filter", "GlancesPlugin", function($filter, GlancesPlugin) { var _pluginName = "processlist"; @@ -1285,200 +683,3 @@ glancesApp.service('GlancesPluginProcessList', ["$filter", "GlancesPlugin", func return _maxProcessesToDisplay; }; }]); - -glancesApp.service('GlancesPluginQuicklook', function() { - var _pluginName = "quicklook"; - var _view = {}; - - this.mem = null; - this.cpu = null; - this.cpu_name = null; - this.cpu_hz_current = null; - this.cpu_hz = null; - this.swap = null; - this.percpus = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - this.mem = data.mem; - this.cpu = data.cpu; - this.cpu_name = data.cpu_name; - this.cpu_hz_current = data.cpu_hz_current; - this.cpu_hz = data.cpu_hz; - this.swap = data.swap; - this.percpus = []; - - angular.forEach(data.percpu, function(cpu) { - this.percpus.push({ - 'number': cpu.cpu_number, - 'total': cpu.total - }); - }, this); - } - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); - } -}); - -glancesApp.service('GlancesPluginRaid', function () { - var _pluginName = "raid"; - this.disks = []; - - this.setData = function (data, views) { - var disks = []; - data = data[_pluginName]; - - _.forIn(data, function(diskData, diskKey) { - var disk = { - 'name': diskKey, - 'type': diskData.type == null ? 'UNKNOWN' : diskData.type, - 'used': diskData.used, - 'available': diskData.available, - 'status': diskData.status, - 'degraded': diskData.used < diskData.available, - 'config': diskData.config == null ? '' : diskData.config.replace('_', 'A'), - 'inactive': diskData.status == 'inactive', - 'components': [] - }; - - _.forEach(diskData.components, function(number, name) { - disk.components.push({ - 'number': number, - 'name': name - }); - }); - - disks.push(disk); - }); - - this.disks = disks; - }; - - this.hasDisks = function() { - return this.disks.length > 0; - } - - this.getAlert = function(disk) { - if (disk.inactive) { - return 'critical'; - } - - if (disk.degraded) { - return 'warning'; - } - - return 'ok' - } -}); - -glancesApp.service('GlancesPluginSensors', ["GlancesPlugin", function(GlancesPlugin) { - - var _pluginName = "sensors"; - this.sensors = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - - _.remove(data, function(sensor) { - return (_.isArray(sensor.value) && _.isEmpty(sensor.value)) || sensor.value === 0; - }); - - this.sensors = data; - }; - - this.getAlert = function(sensor) { - var current = sensor.type == 'battery' ? 100 - sensor.value : sensor.value; - - return GlancesPlugin.getAlert(_pluginName, 'sensors_' + sensor.type + '_', current); - }; -}]); - -glancesApp.service('GlancesPluginSystem', function() { - var _pluginName = "system"; - - this.hostname = null; - this.platform = null; - this.humanReadableName = null; - this.os = { - 'name': null, - 'version': null - }; - - this.setData = function(data, views) { - data = data[_pluginName]; - - this.hostname = data['hostname']; - this.platform = data['platform']; - this.os.name = data['os_name']; - this.os.version = data['os_version']; - this.humanReadableName = data['hr_name']; - }; - - this.isBsd = function() { - return this.os.name === 'FreeBSD'; - }; - - this.isLinux = function() { - return this.os.name === 'Linux'; - }; - - this.isMac = function() { - return this.os.name === 'Darwin'; - }; - - this.isWindows = function() { - return this.os.name === 'Windows'; - }; -}); - -glancesApp.service('GlancesPluginUptime', function() { - this.uptime = null; - - this.setData = function(data, views) { - this.uptime = data['uptime']; - }; -}); - -glancesApp.service('GlancesPluginWifi', function() { - var _pluginName = "wifi"; - var _view = {}; - this.hotspots = []; - - this.setData = function(data, views) { - data = data[_pluginName]; - _view = views[_pluginName]; - - this.hotspots = []; - for (var i = 0; i < data.length; i++) { - var hotspotData = data[i]; - - if (hotspotData['ssid'] === '') { - continue; - } - - var hotspot = { - 'ssid': hotspotData['ssid'], - 'encrypted': hotspotData['encrypted'], - 'signal': hotspotData['signal'], - 'encryption_type': hotspotData['encryption_type'], - }; - - this.hotspots.push(hotspot); - } - }; - - this.getDecoration = function(hotpost, field) { - if(_view[hotpost.ssid][field] == undefined) { - return; - } - - return _view[hotpost.ssid][field].decoration.toLowerCase(); - }; -}); diff --git a/glances/outputs/static/public/js/templates.min.js b/glances/outputs/static/public/js/templates.min.js index 3c0c4f24..86740b2e 100644 --- a/glances/outputs/static/public/js/templates.min.js +++ b/glances/outputs/static/public/js/templates.min.js @@ -1,27 +1,4 @@ -angular.module('glancesApp').run(['$templateCache', function($templateCache) {$templateCache.put('plugins/alert.html','
\n
\n
\n{{alert.begin | date : \'yyyy-MM-dd H:mm:ss\'}} ({{ alert.ongoing ? \'ongoing\' : alert.duration }}) - {{alert.level}} on {{alert.name}} ({{alert.max}})\n\t\t
\n
\n
\n'); -$templateCache.put('plugins/alerts.html','No warning or critical alert detected\nWarning or critical alerts (lasts {{statsAlert.count()}} entries)\n'); -$templateCache.put('plugins/amps.html','
\n
\n
{{ process.name }}
\n
{{ process.count }}
\n
{{ process.result }}
\n
\n
\n'); -$templateCache.put('plugins/cloud.html','{{ statsCloud.getProvider() }} {{ statsCloud.getInstance() }}\n'); -$templateCache.put('plugins/cpu.html','
\n
\n
\n
\n
CPU
\n
{{ statsCpu.total }}%
\n
\n
\n
user:
\n
\n {{ statsCpu.user }}%\n
\n
\n
\n
system:
\n
\n {{ statsCpu.system }}%\n
\n
\n
\n
idle:
\n
{{ statsCpu.idle }}%
\n
\n
\n
\n \n \n
\n'); -$templateCache.put('plugins/diskio.html','
\n
DISK I/O
\n
R/s
\n
W/s
\n\n
IOR/s
\n
IOW/s
\n
\n
\n
{{(disk.alias ? disk.alias : disk.name) | min_size}}
\n
{{disk.bitrate.txps }}
\n
{{disk.bitrate.rxps }}
\n\n
{{disk.count.txps }}
\n
{{disk.count.rxps }}
\n
\n'); -$templateCache.put('plugins/docker.html','CONTAINERS {{ statsDocker.containers.length }} (served by Docker {{ statsDocker.version }})\n\n
\n
\n
Name
\n
Status
\n
CPU%
\n
MEM
\n
IOR/s
\n
IOW/s
\n
RX/s
\n
TX/s
\n
Command
\n
\n
\n
{{ container.name }}
\n
{{ container.status }}
\n
{{ container.cpu | number:1 }}
\n
{{ container.memory | bytes }}
\n
{{ container.ior / container.io_time_since_update | bits }}
\n
{{ container.iow / container.io_time_since_update | bits }}
\n
{{ container.rx / container.net_time_since_update | bits }}
\n
{{ container.tx / container.net_time_since_update | bits }}
\n
{{ container.command }}
\n
\n
\n'); -$templateCache.put('plugins/folders.html','
\n
FOLDERS
\n
Size
\n
\n
\n
{{ folder.path }}
\n
{{ folder.size | bytes }}
\n
\n'); -$templateCache.put('plugins/fs.html','
\n
FILE SYS
\n
\n Used\n Free\n
\n
Total
\n
\n
\n
{{ fs.shortMountPoint }} ({{ fs.name }})
\n
\n {{ fs.used | bytes }}\n {{ fs.free | bytes }}\n
\n
{{ fs.size | bytes }}
\n
\n'); -$templateCache.put('plugins/gpu.html','
\n {{ statsGpu.name }}\n
\n
\n
\n
proc:
\n
{{ statsGpu.mean.proc | number : 0 }}%
\n
N/A
\n
\n
\n
mem:
\n
{{ statsGpu.mean.mem | number : 0 }}%
\n
N/A
\n
\n
\n
\n {{ gpu.gpu_id }}:\n {{ gpu.proc | number : 0 }}%\n N/A\n mem:\n {{ gpu.mem | number : 0 }}%\n N/A\n
\n
\n
\n'); -$templateCache.put('plugins/ip.html',' - IP {{ statsIp.address }}/{{ statsIp.maskCidr }} Pub {{ statsIp.publicAddress }}\n'); -$templateCache.put('plugins/irq.html','
\n
IRQ
\n
\n
Rate/s
\n
\n
\n
{{irq.irq_line}}
\n
\n
{{irq.irq_rate}}
\n
\n'); -$templateCache.put('plugins/load.html','
\n
\n
LOAD
\n
{{ statsLoad.cpucore }}-core
\n
\n
\n
1 min:
\n
\n {{ statsLoad.min1 | number : 2}}\n
\n
\n
\n
5 min:
\n
\n {{ statsLoad.min5 | number : 2}}\n
\n
\n
\n
15 min:
\n
\n {{ statsLoad.min15 | number : 2}}\n
\n
\n
\n'); -$templateCache.put('plugins/mem.html','
\n
\n
MEM
\n
{{ statsMem.percent }}%
\n
\n
\n
total:
\n
{{ statsMem.total | bytes }}
\n
\n
\n
used:
\n
\n {{ statsMem.used | bytes:2 }}\n
\n
\n
\n
free:
\n
{{ statsMem.free | bytes }}
\n
\n
\n'); -$templateCache.put('plugins/mem_more.html','
\n
\n
active:
\n
{{ statsMem.active | bytes }}
\n
\n
\n
inactive:
\n
{{ statsMem.inactive | bytes }}
\n
\n
\n
buffers:
\n
{{ statsMem.buffers | bytes }}
\n
\n
\n
cached:
\n
{{ statsMem.cached | bytes }}
\n
\n
\n'); -$templateCache.put('plugins/memswap.html','
\n
\n
SWAP
\n
{{ statsMemSwap.percent }}%
\n
\n
\n
total:
\n
{{ statsMemSwap.total | bytes }}
\n
\n
\n
used:
\n
\n {{ statsMemSwap.used | bytes }}\n
\n
\n
\n
free:
\n
{{ statsMemSwap.free | bytes }}
\n
\n
\n'); -$templateCache.put('plugins/network.html','
\n
NETWORK
\n
Rx/s
\n
Tx/s
\n\n
\n
Rx+Tx/s
\n\n
Rx
\n
Tx
\n\n
\n
Rx+Tx
\n
\n
\n
{{ network.interfaceName | min_size }}
\n
{{ arguments.byte ? (network.rx / network.time_since_update | bytes) : (network.rx / network.time_since_update | bits) }}
\n
{{ arguments.byte ? (network.tx / network.time_since_update | bytes) : (network.tx / network.time_since_update | bits) }}
\n\n
\n
{{ arguments.byte ? (network.cx / network.time_since_update | bytes) : (network.cx / network.time_since_update | bits) }}
\n\n
{{ arguments.byte ? (network.cumulativeRx | bytes) : (network.cumulativeRx | bits) }}
\n
{{ arguments.byte ? (network.cumulativeTx | bytes) : (network.cumulativeTx | bits) }}
\n\n
\n
{{ arguments.byte ? (network.cumulativeCx | bytes) : (network.cumulativeCx | bits) }}
\n
\n'); -$templateCache.put('plugins/per_cpu.html','
\n
\n
PER CPU
\n
{{ percpu.total }}%
\n
\n
\n
user:
\n
\n {{ percpu.user }}%\n
\n
\n
\n
system:
\n
\n {{ percpu.system }}%\n
\n
\n
\n
idle:
\n
{{ percpu.idle }}%
\n
\n
\n
iowait:
\n
\n {{ percpu.iowait }}%\n
\n
\n
\n
steal:
\n
\n {{ percpu.steal }}%\n
\n
\n
\n'); -$templateCache.put('plugins/ports.html','
\n
{{(port.description ? port.description : port.host + \' \' + port.port) | min_size: 20}}
\n
\n
\n Scanning\n Timeout\n Open\n {{port.status * 1000.0 | number:0}}ms\n
\n
\n'); -$templateCache.put('plugins/processcount.html','TASKS\n{{ statsProcessCount.total }} ({{ statsProcessCount.thread }} thr),\n{{ statsProcessCount.running }} run,\n{{ statsProcessCount.sleeping }} slp,\n{{ statsProcessCount.stopped }} oth\n sorted {{ sorter.auto ? \'automatically\' : \'\' }} by {{ sorter.getColumnLabel(sorter.column) }}, flat view\n'); -$templateCache.put('plugins/processlist.html','
\n
\n
CPU%
\n
MEM%
\n \n \n
PID
\n
USER
\n
NI
\n
S
\n \n \n \n
Command
\n
\n
\n
{{process.cpu_percent | number:1}}
\n
{{process.memory_percent | number:1}}
\n \n \n
{{process.pid}}
\n
{{process.username}}
\n
{{process.nice | exclamation}}
\n
{{process.status}}
\n \n \n \n
{{process.name}}
\n
{{process.cmdline}}
\n
\n
\n'); -$templateCache.put('plugins/quicklook.html','
\n {{ statsQuicklook.cpu_name }}\n
\n
\n
\n
CPU
\n
\n
\n
\n  \n
\n
\n
\n
\n {{ statsQuicklook.cpu }}%\n
\n
\n
\n
CPU{{ percpu.number }}
\n
\n
\n
\n  \n
\n
\n
\n
\n {{ percpu.total }}%\n
\n
\n
\n
MEM
\n
\n
\n
\n  \n
\n
\n
\n
\n {{ statsQuicklook.mem }}%\n
\n
\n
\n
SWAP
\n
\n
\n
\n  \n
\n
\n
\n
\n {{ statsQuicklook.swap }}%\n
\n
\n
\n'); -$templateCache.put('plugins/raid.html','
\n
RAID disks
\n
Used
\n
Total
\n
\n
\n
\n {{ disk.type | uppercase }} {{ disk.name }}\n
\u2514\u2500 Degraded mode
\n
   \u2514\u2500 {{ disk.config }}
\n\n
\u2514\u2500 Status {{ disk.status }}
\n
\n    {{ $last ? \'\u2514\u2500\' : \'\u251C\u2500\' }} disk {{ component.number }}: {{ component.name }}\n
\n
\n
{{ disk.used }}
\n
{{ disk.available }}
\n
'); -$templateCache.put('plugins/sensors.html','
\n
SENSORS
\n
\n\n
\n
{{ sensor.label }}
\n
{{ sensor.unit }}
\n
{{ sensor.value }}
\n
\n'); -$templateCache.put('plugins/system.html','Disconnected from\n{{ statsSystem.hostname }}\n\n'); -$templateCache.put('plugins/uptime.html','Uptime: {{ statsUptime.uptime }}\n'); -$templateCache.put('plugins/wifi.html','
\n
WIFI
\n
\n
dBm
\n
\n
\n
{{ hotspot.ssid|limitTo:20 }} {{ hotspot.encryption_type }}
\n
\n
{{ hotspot.signal }}
\n
\n');}]); \ No newline at end of file +angular.module('glancesApp').run(['$templateCache', function($templateCache) {$templateCache.put('components/glances/view.html','
\n \n
Loading...
\n
\n\n
\n\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n\n
\n'); +$templateCache.put('components/plugin-ip/view.html','
\n  - IP {{ vm.address }}/{{ vm.maskCidr }} Pub {{ vm.publicAddress }}\n
\n'); +$templateCache.put('components/plugin-system/view.html','
\n Disconnected from\n {{ vm.hostname }}\n \n \n
\n'); +$templateCache.put('components/plugin-uptime/view.html','
\n Uptime: {{ vm.value }}\n
\n');}]); \ No newline at end of file diff --git a/glances/outputs/static/public/stats.html b/glances/outputs/static/public/stats.html index 7982ad15..ad2c1531 100644 --- a/glances/outputs/static/public/stats.html +++ b/glances/outputs/static/public/stats.html @@ -1,88 +1 @@ -
- -
Loading...
-
- -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
PROCESSES DISABLED (press 'z' to display)
-
-
-
+ From 014a6534174998861531354fa75d7140e821dae5 Mon Sep 17 00:00:00 2001 From: Floran Brutel Date: Tue, 14 Mar 2017 20:50:40 +0100 Subject: [PATCH 02/30] migrate the load plugin --- .../static/js/components/glances/view.html | 42 ++++ .../js/components/plugin-load/component.js | 10 + .../js/components/plugin-load/controller.js | 34 +++ .../js/components/plugin-load/view.html | 26 ++ glances/outputs/static/public/js/main.min.js | 238 +++++++++++------- .../outputs/static/public/js/templates.min.js | 5 +- 6 files changed, 257 insertions(+), 98 deletions(-) create mode 100644 glances/outputs/static/js/components/plugin-load/component.js create mode 100644 glances/outputs/static/js/components/plugin-load/controller.js create mode 100644 glances/outputs/static/js/components/plugin-load/view.html diff --git a/glances/outputs/static/js/components/glances/view.html b/glances/outputs/static/js/components/glances/view.html index 1102d7e9..076283fd 100644 --- a/glances/outputs/static/js/components/glances/view.html +++ b/glances/outputs/static/js/components/glances/view.html @@ -19,6 +19,48 @@
+
+
+
+ +
+
+
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+
+ +
+
+
diff --git a/glances/outputs/static/js/components/plugin-load/component.js b/glances/outputs/static/js/components/plugin-load/component.js new file mode 100644 index 00000000..744b4f36 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-load/component.js @@ -0,0 +1,10 @@ +'use strict'; + +glancesApp.component('glancesPluginLoad', { + controller: GlancesPluginLoadController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-load/view.html' +}); diff --git a/glances/outputs/static/js/components/plugin-load/controller.js b/glances/outputs/static/js/components/plugin-load/controller.js new file mode 100644 index 00000000..2d8c91cc --- /dev/null +++ b/glances/outputs/static/js/components/plugin-load/controller.js @@ -0,0 +1,34 @@ +'use strict'; + +function GlancesPluginLoadController() { + var vm = this; + var _view = {}; + + this.cpucore = null; + this.min1 = null; + this.min5 = null; + this.min15 = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['load']; + _view = stats.view['load']; + + vm.cpucore = data['cpucore']; + vm.min1 = data['min1']; + vm.min5 = data['min5']; + vm.min15 = data['min15']; + }; + + this.getDecoration = function(value) { + if(_view[value] == undefined) { + return; + } + + return _view[value].decoration.toLowerCase(); +}; +} diff --git a/glances/outputs/static/js/components/plugin-load/view.html b/glances/outputs/static/js/components/plugin-load/view.html new file mode 100644 index 00000000..14cff65d --- /dev/null +++ b/glances/outputs/static/js/components/plugin-load/view.html @@ -0,0 +1,26 @@ +
+
+
+
LOAD
+
{{ vm.cpucore }}-core
+
+
+
1 min:
+
+ {{ vm.min1 | number : 2}} +
+
+
+
5 min:
+
+ {{ vm.min5 | number : 2}} +
+
+
+
15 min:
+
+ {{ vm.min15 | number : 2}} +
+
+
+
diff --git a/glances/outputs/static/public/js/main.min.js b/glances/outputs/static/public/js/main.min.js index b6df56c0..c3c0bd1b 100644 --- a/glances/outputs/static/public/js/main.min.js +++ b/glances/outputs/static/public/js/main.min.js @@ -300,6 +300,148 @@ var keycodes = { 'use strict'; +glancesApp.component('glancesPluginIp', { + controller: GlancesPluginIpController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-ip/view.html' +}); + +'use strict'; + +function GlancesPluginIpController() { + var vm = this; + + this.address = null; + this.gateway = null; + this.mask = null; + this.maskCidr = null; + this.publicAddress = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['ip']; + + vm.address = data.address; + vm.gateway = data.gateway; + vm.mask = data.mask; + vm.maskCidr = data.mask_cidr; + vm.publicAddress = data.public_address + }; +} + +'use strict'; + +glancesApp.component('glancesPluginLoad', { + controller: GlancesPluginLoadController, + controllerAs: 'vm', + bindings: { + stats: '<', + }, + templateUrl: 'components/plugin-load/view.html' +}); + +'use strict'; + +function GlancesPluginLoadController() { + var vm = this; + var _view = {}; + + this.cpucore = null; + this.min1 = null; + this.min5 = null; + this.min15 = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['load']; + _view = stats.view['load']; + + vm.cpucore = data['cpucore']; + vm.min1 = data['min1']; + vm.min5 = data['min5']; + vm.min15 = data['min15']; + }; + + this.getDecoration = function(value) { + if(_view[value] == undefined) { + return; + } + + return _view[value].decoration.toLowerCase(); +}; +} + +'use strict'; + +glancesApp.component('glancesPluginSystem', { + controller: GlancesPluginSystemController, + controllerAs: 'vm', + bindings: { + stats: '<', + isDisconnected: '<' + }, + templateUrl: 'components/plugin-system/view.html' +}); + +'use strict'; + +function GlancesPluginSystemController() { + var vm = this; + var _pluginName = "system"; + + vm.hostname = null; + vm.platform = null; + vm.humanReadableName = null; + vm.os = { + 'name': null, + 'version': null + }; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats[_pluginName]; + + vm.hostname = data['hostname']; + vm.platform = data['platform']; + vm.os.name = data['os_name']; + vm.os.version = data['os_version']; + vm.humanReadableName = data['hr_name']; + }; + + vm.isBsd = function() { + return this.os.name === 'FreeBSD'; + }; + + vm.isLinux = function() { + return this.os.name === 'Linux'; + }; + + vm.isMac = function() { + return this.os.name === 'Darwin'; + }; + + vm.isWindows = function() { + return this.os.name === 'Windows'; + }; +} + +'use strict'; + glancesApp.component('glances', { controller: GlancesController, bindings: { @@ -497,102 +639,6 @@ function GlancesController($interval, GlancesStats, favicoService) { 'use strict'; -glancesApp.component('glancesPluginIp', { - controller: GlancesPluginIpController, - controllerAs: 'vm', - bindings: { - stats: '<', - }, - templateUrl: 'components/plugin-ip/view.html' -}); - -'use strict'; - -function GlancesPluginIpController() { - var vm = this; - - this.address = null; - this.gateway = null; - this.mask = null; - this.maskCidr = null; - this.publicAddress = null; - - vm.$onChanges = function (changes) { - var stats = changes.stats.currentValue; - if (stats === undefined || stats.stats === undefined) { - return; - } - - var data = stats.stats['ip']; - - vm.address = data.address; - vm.gateway = data.gateway; - vm.mask = data.mask; - vm.maskCidr = data.mask_cidr; - vm.publicAddress = data.public_address - }; -} - -'use strict'; - -glancesApp.component('glancesPluginSystem', { - controller: GlancesPluginSystemController, - controllerAs: 'vm', - bindings: { - stats: '<', - isDisconnected: '<' - }, - templateUrl: 'components/plugin-system/view.html' -}); - -'use strict'; - -function GlancesPluginSystemController() { - var vm = this; - var _pluginName = "system"; - - vm.hostname = null; - vm.platform = null; - vm.humanReadableName = null; - vm.os = { - 'name': null, - 'version': null - }; - - vm.$onChanges = function (changes) { - var stats = changes.stats.currentValue; - if (stats === undefined || stats.stats === undefined) { - return; - } - - var data = stats.stats[_pluginName]; - - vm.hostname = data['hostname']; - vm.platform = data['platform']; - vm.os.name = data['os_name']; - vm.os.version = data['os_version']; - vm.humanReadableName = data['hr_name']; - }; - - vm.isBsd = function() { - return this.os.name === 'FreeBSD'; - }; - - vm.isLinux = function() { - return this.os.name === 'Linux'; - }; - - vm.isMac = function() { - return this.os.name === 'Darwin'; - }; - - vm.isWindows = function() { - return this.os.name === 'Windows'; - }; -} - -'use strict'; - glancesApp.component('glancesPluginUptime', { controller: GlancesPluginUptimeController, controllerAs: 'vm', diff --git a/glances/outputs/static/public/js/templates.min.js b/glances/outputs/static/public/js/templates.min.js index 86740b2e..a3748583 100644 --- a/glances/outputs/static/public/js/templates.min.js +++ b/glances/outputs/static/public/js/templates.min.js @@ -1,4 +1,5 @@ -angular.module('glancesApp').run(['$templateCache', function($templateCache) {$templateCache.put('components/glances/view.html','
\n \n
Loading...
\n
\n\n
\n\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n\n
\n'); -$templateCache.put('components/plugin-ip/view.html','
\n  - IP {{ vm.address }}/{{ vm.maskCidr }} Pub {{ vm.publicAddress }}\n
\n'); +angular.module('glancesApp').run(['$templateCache', function($templateCache) {$templateCache.put('components/plugin-ip/view.html','
\n  - IP {{ vm.address }}/{{ vm.maskCidr }} Pub {{ vm.publicAddress }}\n
\n'); +$templateCache.put('components/plugin-load/view.html','
\n
\n
\n
LOAD
\n
{{ vm.cpucore }}-core
\n
\n
\n
1 min:
\n
\n {{ vm.min1 | number : 2}}\n
\n
\n
\n
5 min:
\n
\n {{ vm.min5 | number : 2}}\n
\n
\n
\n
15 min:
\n
\n {{ vm.min15 | number : 2}}\n
\n
\n
\n
\n'); $templateCache.put('components/plugin-system/view.html','
\n Disconnected from\n {{ vm.hostname }}\n \n \n
\n'); +$templateCache.put('components/glances/view.html','
\n \n
Loading...
\n
\n\n
\n\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n \n
\n \n
\n
\n \n
\n \n
\n \n
\n \n
\n \n
\n
\n \n
\n
\n
\n \n
\n\n
\n
\n
\n'); $templateCache.put('components/plugin-uptime/view.html','
\n Uptime: {{ vm.value }}\n
\n');}]); \ No newline at end of file From e4324eb84c74a7756715dce28fc44a436e6e9a5e Mon Sep 17 00:00:00 2001 From: Floran Brutel Date: Sun, 19 Mar 2017 11:53:52 +0100 Subject: [PATCH 03/30] WebUi : Create components for help / cpu and cloud --- glances/outputs/static/html/help.html | 76 ---- glances/outputs/static/html/index.html | 2 +- .../js/components/glances/controller.js | 9 +- .../static/js/components/glances/view.html | 116 ++--- .../static/js/components/help/component.js | 10 + .../static/js/components/help/controller.js | 5 + .../static/js/components/help/view.html | 79 ++++ .../js/components/plugin-cloud/component.js | 10 + .../js/components/plugin-cloud/controller.js | 22 + .../js/components/plugin-cloud/view.html | 3 + .../js/components/plugin-cpu/component.js | 10 + .../js/components/plugin-cpu/controller.js | 62 +++ .../static/js/components/plugin-cpu/view.html | 84 ++++ .../js/components/plugin-ip/component.js | 2 +- .../js/components/plugin-load/component.js | 2 +- .../js/components/plugin-load/controller.js | 10 +- .../js/components/plugin-system/component.js | 4 +- .../js/components/plugin-system/controller.js | 19 +- .../js/components/plugin-system/view.html | 4 +- .../js/components/plugin-uptime/component.js | 2 +- glances/outputs/static/public/help.html | 76 ---- glances/outputs/static/public/index.html | 2 +- glances/outputs/static/public/js/main.min.js | 403 +++++++++++------- .../outputs/static/public/js/templates.min.js | 9 +- 24 files changed, 632 insertions(+), 389 deletions(-) delete mode 100644 glances/outputs/static/html/help.html create mode 100644 glances/outputs/static/js/components/help/component.js create mode 100644 glances/outputs/static/js/components/help/controller.js create mode 100644 glances/outputs/static/js/components/help/view.html create mode 100644 glances/outputs/static/js/components/plugin-cloud/component.js create mode 100644 glances/outputs/static/js/components/plugin-cloud/controller.js create mode 100644 glances/outputs/static/js/components/plugin-cloud/view.html create mode 100644 glances/outputs/static/js/components/plugin-cpu/component.js create mode 100644 glances/outputs/static/js/components/plugin-cpu/controller.js create mode 100644 glances/outputs/static/js/components/plugin-cpu/view.html delete mode 100644 glances/outputs/static/public/help.html diff --git a/glances/outputs/static/html/help.html b/glances/outputs/static/html/help.html deleted file mode 100644 index f42a36ed..00000000 --- a/glances/outputs/static/html/help.html +++ /dev/null @@ -1,76 +0,0 @@ -
-
{{help.version}} {{help.psutil_version}}
-
-
 
-
-
{{help.configuration_file}}
-
-
 
-
-
{{help.sort_auto}}
-
{{help.sort_network}}
-
-
-
{{help.sort_cpu}}
-
{{help.show_hide_alert}}
-
-
-
{{help.sort_mem}}
-
{{help.percpu}}
-
-
-
{{help.sort_user}}
-
{{help.show_hide_ip}}
-
-
-
{{help.sort_proc}}
-
{{help.enable_disable_docker}}
-
-
-
{{help.sort_io}}
-
{{help.view_network_io_combination}}
-
-
-
{{help.sort_cpu_times}}
-
{{help.view_cumulative_network}}
-
-
-
{{help.show_hide_diskio}}
-
{{help.show_hide_filesytem_freespace}}
-
-
-
{{help.show_hide_filesystem}}
-
{{help.show_hide_help}}
-
-
-
{{help.show_hide_network}}
-
{{help.diskio_iops}}
-
-
-
{{help.show_hide_sensors}}
-
{{help.show_hide_top_menu}}
-
-
-
{{help.show_hide_left_sidebar}}
-
{{help.show_hide_amp}}
-
-
-
{{help.enable_disable_process_stats}}
-
{{help.show_hide_irq}}
-
-
-
{{help.enable_disable_gpu}}
-
{{help.enable_disable_mean_gpu}}
-
-
-
{{help.enable_disable_quick_look}}
-
-
-
-
{{help.enable_disable_short_processname}}
-
-
-
-
{{help.enable_disable_ports}}
-
-
diff --git a/glances/outputs/static/html/index.html b/glances/outputs/static/html/index.html index eec4fb70..d8bb08a0 100644 --- a/glances/outputs/static/html/index.html +++ b/glances/outputs/static/html/index.html @@ -17,7 +17,7 @@ - + diff --git a/glances/outputs/static/js/components/glances/controller.js b/glances/outputs/static/js/components/glances/controller.js index 092c19ec..a7c08f8f 100644 --- a/glances/outputs/static/js/components/glances/controller.js +++ b/glances/outputs/static/js/components/glances/controller.js @@ -1,6 +1,6 @@ 'use strict'; -function GlancesController($interval, GlancesStats, favicoService) { +function GlancesController($interval, GlancesStats) { var vm = this; vm.sorter = { @@ -22,6 +22,12 @@ function GlancesController($interval, GlancesStats, favicoService) { vm.stats = {}; vm.refreshData = function () { GlancesStats.getData().then(function (data) { + + data.isBsd = data.stats['system']['os_name'] === 'FreeBSD'; + data.isLinux = data.stats['system']['os_name'] === 'Linux'; + data.isMac = data.stats['system']['os_name'] === 'Darwin'; + data.isWindows = data.stats['system']['os_name'] === 'Windows'; + vm.stats = data; vm.is_disconnected = false; vm.dataLoaded = true; @@ -37,7 +43,6 @@ function GlancesController($interval, GlancesStats, favicoService) { }, refreshTime * 1000); // in milliseconds vm.onKeyDown = function ($event) { - switch (true) { case !$event.shiftKey && $event.keyCode == keycodes.a: // a => Sort processes automatically diff --git a/glances/outputs/static/js/components/glances/view.html b/glances/outputs/static/js/components/glances/view.html index 076283fd..b5b2a8d5 100644 --- a/glances/outputs/static/js/components/glances/view.html +++ b/glances/outputs/static/js/components/glances/view.html @@ -1,66 +1,72 @@ -
- -
Loading...
-
+
+
+ +
Loading...
+
-
+ + +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+
-
-
-
-
- -
-
- -
-
- + +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
-
-
-
- +
+ -
-
-
- -
- -
-
- -
- -
- -
- -
- -
-
- -
-
-
- -
+
+
diff --git a/glances/outputs/static/js/components/help/component.js b/glances/outputs/static/js/components/help/component.js new file mode 100644 index 00000000..c91fcd7c --- /dev/null +++ b/glances/outputs/static/js/components/help/component.js @@ -0,0 +1,10 @@ +'use strict'; + +glancesApp.component('glancesHelp', { + controller: GlancesHelpController, + controllerAs: 'vm', + bindings: { + help: '<', + }, + templateUrl: 'components/help/view.html' +}); diff --git a/glances/outputs/static/js/components/help/controller.js b/glances/outputs/static/js/components/help/controller.js new file mode 100644 index 00000000..ff346a82 --- /dev/null +++ b/glances/outputs/static/js/components/help/controller.js @@ -0,0 +1,5 @@ +'use strict'; + +function GlancesHelpController() { + var vm = this; +} diff --git a/glances/outputs/static/js/components/help/view.html b/glances/outputs/static/js/components/help/view.html new file mode 100644 index 00000000..618935a2 --- /dev/null +++ b/glances/outputs/static/js/components/help/view.html @@ -0,0 +1,79 @@ +
+
+
{{vm.help.version}} {{vm.help.psutil_version}}
+
+
 
+
+
{{vm.help.configuration_file}}
+
+
 
+
+
{{vm.help.sort_auto}}
+
{{vm.help.sort_network}}
+
+
+
{{vm.help.sort_cpu}}
+
{{vm.help.show_hide_alert}}
+
+
+
{{vm.help.sort_mem}}
+
{{vm.help.percpu}}
+
+
+
{{vm.help.sort_user}}
+
{{vm.help.show_hide_ip}}
+
+
+
{{vm.help.sort_proc}}
+
{{vm.help.enable_disable_docker}}
+
+
+
{{vm.help.sort_io}}
+
{{vm.help.view_network_io_combination}}
+
+
+
{{vm.help.sort_cpu_times}}
+
{{vm.help.view_cumulative_network}}
+
+
+
{{vm.help.show_hide_diskio}}
+
{{vm.help.show_hide_filesytem_freespace}}
+
+
+
{{vm.help.show_hide_filesystem}}
+
{{vm.help.show_hide_vm.help}}
+
+
+
{{vm.help.show_hide_network}}
+
{{vm.help.diskio_iops}}
+
+
+
{{vm.help.show_hide_sensors}}
+
{{vm.help.show_hide_top_menu}}
+
+
+
{{vm.help.show_hide_left_sidebar}}
+
{{vm.help.show_hide_amp}}
+
+
+
{{vm.help.enable_disable_process_stats}}
+
{{vm.help.show_hide_irq}}
+
+
+
{{vm.help.enable_disable_gpu}}
+
{{vm.help.enable_disable_mean_gpu}}
+
+
+
{{vm.help.enable_disable_quick_look}}
+
+
+
+
{{vm.help.enable_disable_short_processname}}
+
+
+
+
{{vm.help.enable_disable_ports}}
+
+
+ +
diff --git a/glances/outputs/static/js/components/plugin-cloud/component.js b/glances/outputs/static/js/components/plugin-cloud/component.js new file mode 100644 index 00000000..307b1b91 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-cloud/component.js @@ -0,0 +1,10 @@ +'use strict'; + +glancesApp.component('glancesPluginCloud', { + controller: GlancesPluginCloudController, + controllerAs: 'vm', + bindings: { + stats: '<' + }, + templateUrl: 'components/plugin-cloud/view.html' +}); diff --git a/glances/outputs/static/js/components/plugin-cloud/controller.js b/glances/outputs/static/js/components/plugin-cloud/controller.js new file mode 100644 index 00000000..5518eb12 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-cloud/controller.js @@ -0,0 +1,22 @@ +'use strict'; + +function GlancesPluginCloudController() { + var vm = this; + + vm.provider = null; + vm.instance = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['cloud']; + + if (data['ami-id'] !== undefined) { + vm.provider = 'AWS EC2'; + vm.instance = data['instance-type'] + ' instance ' + data['instance-id'] + ' (' + data['region'] + ')'; + } + }; +} diff --git a/glances/outputs/static/js/components/plugin-cloud/view.html b/glances/outputs/static/js/components/plugin-cloud/view.html new file mode 100644 index 00000000..4a09ef91 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-cloud/view.html @@ -0,0 +1,3 @@ +
+ {{ vm.provider }} {{ vm.instance }} +
diff --git a/glances/outputs/static/js/components/plugin-cpu/component.js b/glances/outputs/static/js/components/plugin-cpu/component.js new file mode 100644 index 00000000..b372d413 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-cpu/component.js @@ -0,0 +1,10 @@ +'use strict'; + +glancesApp.component('glancesPluginCpu', { + controller: GlancesPluginCpuController, + controllerAs: 'vm', + bindings: { + stats: '<' + }, + templateUrl: 'components/plugin-cpu/view.html' +}); diff --git a/glances/outputs/static/js/components/plugin-cpu/controller.js b/glances/outputs/static/js/components/plugin-cpu/controller.js new file mode 100644 index 00000000..d066a65e --- /dev/null +++ b/glances/outputs/static/js/components/plugin-cpu/controller.js @@ -0,0 +1,62 @@ +'use strict'; + +function GlancesPluginCpuController() { + var vm = this; + var _view = {}; + + vm.total = null; + vm.user = null; + vm.system = null; + vm.idle = null; + vm.nice = null; + vm.irq = null; + vm.iowait = null; + vm.steal = null; + vm.ctx_switches = null; + vm.interrupts = null; + vm.soft_interrupts = null; + vm.syscalls = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['cpu']; + _view = stats.view['cpu']; + + vm.total = data.total; + vm.user = data.user; + vm.system = data.system; + vm.idle = data.idle; + vm.nice = data.nice; + vm.irq = data.irq; + vm.iowait = data.iowait; + vm.steal = data.steal; + + if (data.ctx_switches) { + vm.ctx_switches = Math.floor(data.ctx_switches / data.time_since_update); + } + + if (data.interrupts) { + vm.interrupts = Math.floor(data.interrupts / data.time_since_update); + } + + if (data.soft_interrupts) { + vm.soft_interrupts = Math.floor(data.soft_interrupts / data.time_since_update); + } + + if (data.syscalls) { + vm.syscalls = Math.floor(data.syscalls / data.time_since_update); + } + }; + + this.getDecoration = function (value) { + if (_view[value] === undefined) { + return; + } + + return _view[value].decoration.toLowerCase(); + }; +} diff --git a/glances/outputs/static/js/components/plugin-cpu/view.html b/glances/outputs/static/js/components/plugin-cpu/view.html new file mode 100644 index 00000000..750ddbd4 --- /dev/null +++ b/glances/outputs/static/js/components/plugin-cpu/view.html @@ -0,0 +1,84 @@ +
+
+
+
+
+
CPU
+
{{ vm.total }}%
+
+
+
user:
+
+ {{ vm.user }}% +
+
+
+
system:
+
+ {{ vm.system }}% +
+
+
+
idle:
+
{{ vm.idle }}%
+
+
+
+ + +
+
diff --git a/glances/outputs/static/js/components/plugin-ip/component.js b/glances/outputs/static/js/components/plugin-ip/component.js index 7cc0684f..cb70a6c0 100644 --- a/glances/outputs/static/js/components/plugin-ip/component.js +++ b/glances/outputs/static/js/components/plugin-ip/component.js @@ -4,7 +4,7 @@ glancesApp.component('glancesPluginIp', { controller: GlancesPluginIpController, controllerAs: 'vm', bindings: { - stats: '<', + stats: '<' }, templateUrl: 'components/plugin-ip/view.html' }); diff --git a/glances/outputs/static/js/components/plugin-load/component.js b/glances/outputs/static/js/components/plugin-load/component.js index 744b4f36..268bde0c 100644 --- a/glances/outputs/static/js/components/plugin-load/component.js +++ b/glances/outputs/static/js/components/plugin-load/component.js @@ -4,7 +4,7 @@ glancesApp.component('glancesPluginLoad', { controller: GlancesPluginLoadController, controllerAs: 'vm', bindings: { - stats: '<', + stats: '<' }, templateUrl: 'components/plugin-load/view.html' }); diff --git a/glances/outputs/static/js/components/plugin-load/controller.js b/glances/outputs/static/js/components/plugin-load/controller.js index 2d8c91cc..4ac09903 100644 --- a/glances/outputs/static/js/components/plugin-load/controller.js +++ b/glances/outputs/static/js/components/plugin-load/controller.js @@ -4,10 +4,10 @@ function GlancesPluginLoadController() { var vm = this; var _view = {}; - this.cpucore = null; - this.min1 = null; - this.min5 = null; - this.min15 = null; + vm.cpucore = null; + vm.min1 = null; + vm.min5 = null; + vm.min15 = null; vm.$onChanges = function (changes) { var stats = changes.stats.currentValue; @@ -25,7 +25,7 @@ function GlancesPluginLoadController() { }; this.getDecoration = function(value) { - if(_view[value] == undefined) { + if(_view[value] === undefined) { return; } diff --git a/glances/outputs/static/js/components/plugin-system/component.js b/glances/outputs/static/js/components/plugin-system/component.js index 1826ce8b..6c81d762 100644 --- a/glances/outputs/static/js/components/plugin-system/component.js +++ b/glances/outputs/static/js/components/plugin-system/component.js @@ -4,8 +4,8 @@ glancesApp.component('glancesPluginSystem', { controller: GlancesPluginSystemController, controllerAs: 'vm', bindings: { - stats: '<', - isDisconnected: '<' + stats: '<', + isDisconnected: '<' }, templateUrl: 'components/plugin-system/view.html' }); diff --git a/glances/outputs/static/js/components/plugin-system/controller.js b/glances/outputs/static/js/components/plugin-system/controller.js index 2567a02a..1d0bb457 100644 --- a/glances/outputs/static/js/components/plugin-system/controller.js +++ b/glances/outputs/static/js/components/plugin-system/controller.js @@ -2,7 +2,6 @@ function GlancesPluginSystemController() { var vm = this; - var _pluginName = "system"; vm.hostname = null; vm.platform = null; @@ -18,7 +17,7 @@ function GlancesPluginSystemController() { return; } - var data = stats.stats[_pluginName]; + var data = stats.stats['system']; vm.hostname = data['hostname']; vm.platform = data['platform']; @@ -26,20 +25,4 @@ function GlancesPluginSystemController() { vm.os.version = data['os_version']; vm.humanReadableName = data['hr_name']; }; - - vm.isBsd = function() { - return this.os.name === 'FreeBSD'; - }; - - vm.isLinux = function() { - return this.os.name === 'Linux'; - }; - - vm.isMac = function() { - return this.os.name === 'Darwin'; - }; - - vm.isWindows = function() { - return this.os.name === 'Windows'; - }; } diff --git a/glances/outputs/static/js/components/plugin-system/view.html b/glances/outputs/static/js/components/plugin-system/view.html index f1866ae6..33f65139 100644 --- a/glances/outputs/static/js/components/plugin-system/view.html +++ b/glances/outputs/static/js/components/plugin-system/view.html @@ -1,6 +1,6 @@
Disconnected from {{ vm.hostname }} - - + +
diff --git a/glances/outputs/static/js/components/plugin-uptime/component.js b/glances/outputs/static/js/components/plugin-uptime/component.js index 3859054b..801a90d1 100644 --- a/glances/outputs/static/js/components/plugin-uptime/component.js +++ b/glances/outputs/static/js/components/plugin-uptime/component.js @@ -4,7 +4,7 @@ glancesApp.component('glancesPluginUptime', { controller: GlancesPluginUptimeController, controllerAs: 'vm', bindings: { - stats: '<', + stats: '<' }, templateUrl: 'components/plugin-uptime/view.html' }); diff --git a/glances/outputs/static/public/help.html b/glances/outputs/static/public/help.html deleted file mode 100644 index f42a36ed..00000000 --- a/glances/outputs/static/public/help.html +++ /dev/null @@ -1,76 +0,0 @@ -
-
{{help.version}} {{help.psutil_version}}
-
-
 
-
-
{{help.configuration_file}}
-
-
 
-
-
{{help.sort_auto}}
-
{{help.sort_network}}
-
-
-
{{help.sort_cpu}}
-
{{help.show_hide_alert}}
-
-
-
{{help.sort_mem}}
-
{{help.percpu}}
-
-
-
{{help.sort_user}}
-
{{help.show_hide_ip}}
-
-
-
{{help.sort_proc}}
-
{{help.enable_disable_docker}}
-
-
-
{{help.sort_io}}
-
{{help.view_network_io_combination}}
-
-
-
{{help.sort_cpu_times}}
-
{{help.view_cumulative_network}}
-
-
-
{{help.show_hide_diskio}}
-
{{help.show_hide_filesytem_freespace}}
-
-
-
{{help.show_hide_filesystem}}
-
{{help.show_hide_help}}
-
-
-
{{help.show_hide_network}}
-
{{help.diskio_iops}}
-
-
-
{{help.show_hide_sensors}}
-
{{help.show_hide_top_menu}}
-
-
-
{{help.show_hide_left_sidebar}}
-
{{help.show_hide_amp}}
-
-
-
{{help.enable_disable_process_stats}}
-
{{help.show_hide_irq}}
-
-
-
{{help.enable_disable_gpu}}
-
{{help.enable_disable_mean_gpu}}
-
-
-
{{help.enable_disable_quick_look}}
-
-
-
-
{{help.enable_disable_short_processname}}
-
-
-
-
{{help.enable_disable_ports}}
-
-
diff --git a/glances/outputs/static/public/index.html b/glances/outputs/static/public/index.html index eec4fb70..d8bb08a0 100644 --- a/glances/outputs/static/public/index.html +++ b/glances/outputs/static/public/index.html @@ -17,7 +17,7 @@ - + diff --git a/glances/outputs/static/public/js/main.min.js b/glances/outputs/static/public/js/main.min.js index c3c0bd1b..81a3f487 100644 --- a/glances/outputs/static/public/js/main.min.js +++ b/glances/outputs/static/public/js/main.min.js @@ -300,148 +300,6 @@ var keycodes = { 'use strict'; -glancesApp.component('glancesPluginIp', { - controller: GlancesPluginIpController, - controllerAs: 'vm', - bindings: { - stats: '<', - }, - templateUrl: 'components/plugin-ip/view.html' -}); - -'use strict'; - -function GlancesPluginIpController() { - var vm = this; - - this.address = null; - this.gateway = null; - this.mask = null; - this.maskCidr = null; - this.publicAddress = null; - - vm.$onChanges = function (changes) { - var stats = changes.stats.currentValue; - if (stats === undefined || stats.stats === undefined) { - return; - } - - var data = stats.stats['ip']; - - vm.address = data.address; - vm.gateway = data.gateway; - vm.mask = data.mask; - vm.maskCidr = data.mask_cidr; - vm.publicAddress = data.public_address - }; -} - -'use strict'; - -glancesApp.component('glancesPluginLoad', { - controller: GlancesPluginLoadController, - controllerAs: 'vm', - bindings: { - stats: '<', - }, - templateUrl: 'components/plugin-load/view.html' -}); - -'use strict'; - -function GlancesPluginLoadController() { - var vm = this; - var _view = {}; - - this.cpucore = null; - this.min1 = null; - this.min5 = null; - this.min15 = null; - - vm.$onChanges = function (changes) { - var stats = changes.stats.currentValue; - if (stats === undefined || stats.stats === undefined) { - return; - } - - var data = stats.stats['load']; - _view = stats.view['load']; - - vm.cpucore = data['cpucore']; - vm.min1 = data['min1']; - vm.min5 = data['min5']; - vm.min15 = data['min15']; - }; - - this.getDecoration = function(value) { - if(_view[value] == undefined) { - return; - } - - return _view[value].decoration.toLowerCase(); -}; -} - -'use strict'; - -glancesApp.component('glancesPluginSystem', { - controller: GlancesPluginSystemController, - controllerAs: 'vm', - bindings: { - stats: '<', - isDisconnected: '<' - }, - templateUrl: 'components/plugin-system/view.html' -}); - -'use strict'; - -function GlancesPluginSystemController() { - var vm = this; - var _pluginName = "system"; - - vm.hostname = null; - vm.platform = null; - vm.humanReadableName = null; - vm.os = { - 'name': null, - 'version': null - }; - - vm.$onChanges = function (changes) { - var stats = changes.stats.currentValue; - if (stats === undefined || stats.stats === undefined) { - return; - } - - var data = stats.stats[_pluginName]; - - vm.hostname = data['hostname']; - vm.platform = data['platform']; - vm.os.name = data['os_name']; - vm.os.version = data['os_version']; - vm.humanReadableName = data['hr_name']; - }; - - vm.isBsd = function() { - return this.os.name === 'FreeBSD'; - }; - - vm.isLinux = function() { - return this.os.name === 'Linux'; - }; - - vm.isMac = function() { - return this.os.name === 'Darwin'; - }; - - vm.isWindows = function() { - return this.os.name === 'Windows'; - }; -} - -'use strict'; - glancesApp.component('glances', { controller: GlancesController, bindings: { @@ -455,7 +313,7 @@ glancesApp.component('glances', { 'use strict'; -function GlancesController($interval, GlancesStats, favicoService) { +function GlancesController($interval, GlancesStats) { var vm = this; vm.sorter = { @@ -477,6 +335,12 @@ function GlancesController($interval, GlancesStats, favicoService) { vm.stats = {}; vm.refreshData = function () { GlancesStats.getData().then(function (data) { + + data.isBsd = data.stats['system']['os_name'] === 'FreeBSD'; + data.isLinux = data.stats['system']['os_name'] === 'Linux'; + data.isMac = data.stats['system']['os_name'] === 'Darwin'; + data.isWindows = data.stats['system']['os_name'] === 'Windows'; + vm.stats = data; vm.is_disconnected = false; vm.dataLoaded = true; @@ -492,7 +356,6 @@ function GlancesController($interval, GlancesStats, favicoService) { }, refreshTime * 1000); // in milliseconds vm.onKeyDown = function ($event) { - switch (true) { case !$event.shiftKey && $event.keyCode == keycodes.a: // a => Sort processes automatically @@ -639,11 +502,261 @@ function GlancesController($interval, GlancesStats, favicoService) { 'use strict'; +glancesApp.component('glancesPluginCloud', { + controller: GlancesPluginCloudController, + controllerAs: 'vm', + bindings: { + stats: '<' + }, + templateUrl: 'components/plugin-cloud/view.html' +}); + +'use strict'; + +function GlancesPluginCloudController() { + var vm = this; + + vm.provider = null; + vm.instance = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['cloud']; + + if (data['ami-id'] !== undefined) { + vm.provider = 'AWS EC2'; + vm.instance = data['instance-type'] + ' instance ' + data['instance-id'] + ' (' + data['region'] + ')'; + } + }; +} + +'use strict'; + +glancesApp.component('glancesHelp', { + controller: GlancesHelpController, + controllerAs: 'vm', + bindings: { + help: '<', + }, + templateUrl: 'components/help/view.html' +}); + +'use strict'; + +function GlancesHelpController() { + var vm = this; +} + +'use strict'; + +glancesApp.component('glancesPluginCpu', { + controller: GlancesPluginCpuController, + controllerAs: 'vm', + bindings: { + stats: '<' + }, + templateUrl: 'components/plugin-cpu/view.html' +}); + +'use strict'; + +function GlancesPluginCpuController() { + var vm = this; + var _view = {}; + + vm.total = null; + vm.user = null; + vm.system = null; + vm.idle = null; + vm.nice = null; + vm.irq = null; + vm.iowait = null; + vm.steal = null; + vm.ctx_switches = null; + vm.interrupts = null; + vm.soft_interrupts = null; + vm.syscalls = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['cpu']; + _view = stats.view['cpu']; + + vm.total = data.total; + vm.user = data.user; + vm.system = data.system; + vm.idle = data.idle; + vm.nice = data.nice; + vm.irq = data.irq; + vm.iowait = data.iowait; + vm.steal = data.steal; + + if (data.ctx_switches) { + vm.ctx_switches = Math.floor(data.ctx_switches / data.time_since_update); + } + + if (data.interrupts) { + vm.interrupts = Math.floor(data.interrupts / data.time_since_update); + } + + if (data.soft_interrupts) { + vm.soft_interrupts = Math.floor(data.soft_interrupts / data.time_since_update); + } + + if (data.syscalls) { + vm.syscalls = Math.floor(data.syscalls / data.time_since_update); + } + }; + + this.getDecoration = function (value) { + if (_view[value] === undefined) { + return; + } + + return _view[value].decoration.toLowerCase(); + }; +} + +'use strict'; + +glancesApp.component('glancesPluginLoad', { + controller: GlancesPluginLoadController, + controllerAs: 'vm', + bindings: { + stats: '<' + }, + templateUrl: 'components/plugin-load/view.html' +}); + +'use strict'; + +function GlancesPluginLoadController() { + var vm = this; + var _view = {}; + + vm.cpucore = null; + vm.min1 = null; + vm.min5 = null; + vm.min15 = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['load']; + _view = stats.view['load']; + + vm.cpucore = data['cpucore']; + vm.min1 = data['min1']; + vm.min5 = data['min5']; + vm.min15 = data['min15']; + }; + + this.getDecoration = function(value) { + if(_view[value] === undefined) { + return; + } + + return _view[value].decoration.toLowerCase(); +}; +} + +'use strict'; + +glancesApp.component('glancesPluginSystem', { + controller: GlancesPluginSystemController, + controllerAs: 'vm', + bindings: { + stats: '<', + isDisconnected: '<' + }, + templateUrl: 'components/plugin-system/view.html' +}); + +'use strict'; + +function GlancesPluginSystemController() { + var vm = this; + + vm.hostname = null; + vm.platform = null; + vm.humanReadableName = null; + vm.os = { + 'name': null, + 'version': null + }; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['system']; + + vm.hostname = data['hostname']; + vm.platform = data['platform']; + vm.os.name = data['os_name']; + vm.os.version = data['os_version']; + vm.humanReadableName = data['hr_name']; + }; +} + +'use strict'; + +glancesApp.component('glancesPluginIp', { + controller: GlancesPluginIpController, + controllerAs: 'vm', + bindings: { + stats: '<' + }, + templateUrl: 'components/plugin-ip/view.html' +}); + +'use strict'; + +function GlancesPluginIpController() { + var vm = this; + + this.address = null; + this.gateway = null; + this.mask = null; + this.maskCidr = null; + this.publicAddress = null; + + vm.$onChanges = function (changes) { + var stats = changes.stats.currentValue; + if (stats === undefined || stats.stats === undefined) { + return; + } + + var data = stats.stats['ip']; + + vm.address = data.address; + vm.gateway = data.gateway; + vm.mask = data.mask; + vm.maskCidr = data.mask_cidr; + vm.publicAddress = data.public_address + }; +} + +'use strict'; + glancesApp.component('glancesPluginUptime', { controller: GlancesPluginUptimeController, controllerAs: 'vm', bindings: { - stats: '<', + stats: '<' }, templateUrl: 'components/plugin-uptime/view.html' }); diff --git a/glances/outputs/static/public/js/templates.min.js b/glances/outputs/static/public/js/templates.min.js index a3748583..a1b2abf3 100644 --- a/glances/outputs/static/public/js/templates.min.js +++ b/glances/outputs/static/public/js/templates.min.js @@ -1,5 +1,8 @@ -angular.module('glancesApp').run(['$templateCache', function($templateCache) {$templateCache.put('components/plugin-ip/view.html','
\n  - IP {{ vm.address }}/{{ vm.maskCidr }} Pub {{ vm.publicAddress }}\n
\n'); +angular.module('glancesApp').run(['$templateCache', function($templateCache) {$templateCache.put('components/glances/view.html','
\n
\n \n
Loading...
\n
\n\n \n\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n\n
\n \n
\n \n
\n
\n \n
\n \n
\n \n
\n \n
\n \n
\n
\n \n
\n
\n
\n \n
\n\n
\n
\n
\n
\n'); +$templateCache.put('components/plugin-cloud/view.html','
\n {{ vm.provider }} {{ vm.instance }}\n
\n'); +$templateCache.put('components/help/view.html','
\n
\n
{{vm.help.version}} {{vm.help.psutil_version}}
\n
\n
 
\n
\n
{{vm.help.configuration_file}}
\n
\n
 
\n
\n
{{vm.help.sort_auto}}
\n
{{vm.help.sort_network}}
\n
\n
\n
{{vm.help.sort_cpu}}
\n
{{vm.help.show_hide_alert}}
\n
\n
\n
{{vm.help.sort_mem}}
\n
{{vm.help.percpu}}
\n
\n
\n
{{vm.help.sort_user}}
\n
{{vm.help.show_hide_ip}}
\n
\n
\n
{{vm.help.sort_proc}}
\n
{{vm.help.enable_disable_docker}}
\n
\n
\n
{{vm.help.sort_io}}
\n
{{vm.help.view_network_io_combination}}
\n
\n
\n
{{vm.help.sort_cpu_times}}
\n
{{vm.help.view_cumulative_network}}
\n
\n
\n
{{vm.help.show_hide_diskio}}
\n
{{vm.help.show_hide_filesytem_freespace}}
\n
\n
\n
{{vm.help.show_hide_filesystem}}
\n
{{vm.help.show_hide_vm.help}}
\n
\n
\n
{{vm.help.show_hide_network}}
\n
{{vm.help.diskio_iops}}
\n
\n
\n
{{vm.help.show_hide_sensors}}
\n
{{vm.help.show_hide_top_menu}}
\n
\n
\n
{{vm.help.show_hide_left_sidebar}}
\n
{{vm.help.show_hide_amp}}
\n
\n
\n
{{vm.help.enable_disable_process_stats}}
\n
{{vm.help.show_hide_irq}}
\n
\n
\n
{{vm.help.enable_disable_gpu}}
\n
{{vm.help.enable_disable_mean_gpu}}
\n
\n
\n
{{vm.help.enable_disable_quick_look}}
\n
\n
\n
\n
{{vm.help.enable_disable_short_processname}}
\n
\n
\n
\n
{{vm.help.enable_disable_ports}}
\n
\n
\n\n
\n'); +$templateCache.put('components/plugin-cpu/view.html','
\n
\n
\n
\n
\n
CPU
\n
{{ vm.total }}%
\n
\n
\n
user:
\n
\n {{ vm.user }}%\n
\n
\n
\n
system:
\n
\n {{ vm.system }}%\n
\n
\n
\n
idle:
\n
{{ vm.idle }}%
\n
\n
\n
\n \n \n
\n
\n'); $templateCache.put('components/plugin-load/view.html','
\n
\n
\n
LOAD
\n
{{ vm.cpucore }}-core
\n
\n
\n
1 min:
\n
\n {{ vm.min1 | number : 2}}\n
\n
\n
\n
5 min:
\n
\n {{ vm.min5 | number : 2}}\n
\n
\n
\n
15 min:
\n
\n {{ vm.min15 | number : 2}}\n
\n
\n
\n
\n'); -$templateCache.put('components/plugin-system/view.html','
\n Disconnected from\n {{ vm.hostname }}\n \n \n
\n'); -$templateCache.put('components/glances/view.html','
\n \n
Loading...
\n
\n\n
\n\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n \n
\n \n
\n
\n \n
\n \n
\n \n
\n \n
\n \n
\n
\n \n
\n
\n
\n \n
\n\n
\n
\n
\n'); +$templateCache.put('components/plugin-system/view.html','
\n Disconnected from\n {{ vm.hostname }}\n \n \n
\n'); +$templateCache.put('components/plugin-ip/view.html','
\n  - IP {{ vm.address }}/{{ vm.maskCidr }} Pub {{ vm.publicAddress }}\n
\n'); $templateCache.put('components/plugin-uptime/view.html','
\n Uptime: {{ vm.value }}\n
\n');}]); \ No newline at end of file From 98d7a0b18ee0ad88860203c3200684669f6fe777 Mon Sep 17 00:00:00 2001 From: Floran Brutel Date: Mon, 20 Mar 2017 12:28:41 +0100 Subject: [PATCH 04/30] WebUI: move mem/mem-more, network,percpu and quicklook to component --- .../js/components/glances/controller.js | 2 +- .../static/js/components/glances/view.html | 36 +- .../js/components/plugin-ip/component.js | 3 +- .../js/components/plugin-ip/controller.js | 30 +- .../components/plugin-mem-more/component.js | 10 + .../components/plugin-mem-more/controller.js | 24 + .../js/components/plugin-mem-more/view.html | 20 + .../js/components/plugin-mem/component.js | 10 + .../js/components/plugin-mem/controller.js | 34 ++ .../static/js/components/plugin-mem/view.html | 22 + .../js/components/plugin-network/component.js | 11 + .../components/plugin-network/controller.js | 36 ++ .../js/components/plugin-network/view.html | 30 + .../js/components/plugin-percpu/component.js | 10 + .../js/components/plugin-percpu/controller.js | 38 ++ .../js/components/plugin-percpu/view.html | 36 ++ .../components/plugin-quicklook/component.js | 11 + .../components/plugin-quicklook/controller.js | 47 ++ .../js/components/plugin-quicklook/view.html | 59 ++ glances/outputs/static/js/filters.js | 2 +- glances/outputs/static/js/services.js | 2 + .../static/js/{ => services}/favicon.js | 0 .../static/js/services/plugin_helper.js | 42 ++ .../outputs/static/js/{ => services}/stats.js | 9 +- glances/outputs/static/public/js/main.min.js | 514 ++++++++++++++---- .../outputs/static/public/js/templates.min.js | 13 +- 26 files changed, 898 insertions(+), 153 deletions(-) create mode 100644 glances/outputs/static/js/components/plugin-mem-more/component.js create mode 100644 glances/outputs/static/js/components/plugin-mem-more/controller.js create mode 100644 glances/outputs/static/js/components/plugin-mem-more/view.html create mode 100644 glances/outputs/static/js/components/plugin-mem/component.js create mode 100644 glances/outputs/static/js/components/plugin-mem/controller.js create mode 100644 glances/outputs/static/js/components/plugin-mem/view.html create mode 100644 glances/outputs/static/js/components/plugin-network/component.js create mode 100644 glances/outputs/static/js/components/plugin-network/controller.js create mode 100644 glances/outputs/static/js/components/plugin-network/view.html create mode 100644 glances/outputs/static/js/components/plugin-percpu/component.js create mode 100644 glances/outputs/static/js/components/plugin-percpu/controller.js create mode 100644 glances/outputs/static/js/components/plugin-percpu/view.html create mode 100644 glances/outputs/static/js/components/plugin-quicklook/component.js create mode 100644 glances/outputs/static/js/components/plugin-quicklook/controller.js create mode 100644 glances/outputs/static/js/components/plugin-quicklook/view.html create mode 100644 glances/outputs/static/js/services.js rename glances/outputs/static/js/{ => services}/favicon.js (100%) create mode 100644 glances/outputs/static/js/services/plugin_helper.js rename glances/outputs/static/js/{ => services}/stats.js (86%) diff --git a/glances/outputs/static/js/components/glances/controller.js b/glances/outputs/static/js/components/glances/controller.js index a7c08f8f..1ab67dd9 100644 --- a/glances/outputs/static/js/components/glances/controller.js +++ b/glances/outputs/static/js/components/glances/controller.js @@ -37,7 +37,7 @@ function GlancesController($interval, GlancesStats) { }; vm.refreshData(); - var refreshTime = 60; // arguments.time + var refreshTime = 5; // arguments.time $interval(function () { vm.refreshData(); }, refreshTime * 1000); // in milliseconds diff --git a/glances/outputs/static/js/components/glances/view.html b/glances/outputs/static/js/components/glances/view.html index b5b2a8d5..5a3b408b 100644 --- a/glances/outputs/static/js/components/glances/view.html +++ b/glances/outputs/static/js/components/glances/view.html @@ -4,9 +4,9 @@
Loading...
- + -
+
@@ -31,37 +31,37 @@
-