]> git.proxmox.com Git - pmg-gui.git/blob - js/ServerStatus.js
ui: minimally increase font-size of product title and version
[pmg-gui.git] / js / ServerStatus.js
1 Ext.define('PMG.ServerStatus', {
2 extend: 'Ext.panel.Panel',
3 alias: 'widget.pmgServerStatus',
4
5 title: gettext('Status'),
6
7 border: false,
8
9 scrollable: true,
10
11 bodyPadding: '10 0 0 0',
12 defaults: {
13 width: 700,
14 padding: '0 0 10 10',
15 },
16
17 layout: 'column',
18
19 controller: {
20 xclass: 'Ext.app.ViewController',
21
22 openConsole: function() {
23 Proxmox.Utils.openXtermJsViewer('shell', 0, Proxmox.NodeName);
24 },
25
26 nodeCommand: function(cmd) {
27 var view = this.getView();
28 Proxmox.Utils.API2Request({
29 params: { command: cmd },
30 url: `/nodes/${Proxmox.NodeName}/status`,
31 method: 'POST',
32 waitMsgTarget: view,
33 failure: function(response, opts) {
34 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
35 },
36 });
37 },
38
39 nodeShutdown: function() {
40 this.nodeCommand('shutdown');
41 },
42
43 nodeReboot: function() {
44 this.nodeCommand('reboot');
45 },
46 },
47
48 tbar: [
49 {
50 text: gettext("Console"),
51 iconCls: 'fa fa-terminal',
52 handler: 'openConsole',
53 },
54 {
55 xtype: 'proxmoxButton',
56 text: gettext('Restart'),
57 dangerous: true,
58 confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Restart'),
59 handler: 'nodeReboot',
60 iconCls: 'fa fa-undo',
61 },
62 {
63 xtype: 'proxmoxButton',
64 text: gettext('Shutdown'),
65 dangerous: true,
66 confirmMsg: gettext('Node') + " '" + Proxmox.NodeName + "' - " + gettext('Shutdown'),
67 handler: 'nodeShutdown',
68 iconCls: 'fa fa-power-off',
69 },
70 '->',
71 {
72 xtype: 'proxmoxRRDTypeSelector',
73 },
74 ],
75
76 initComponent: function() {
77 var me = this;
78
79 var nodename = Proxmox.NodeName;
80 var rrdstore = Ext.create('Proxmox.data.RRDStore', {
81 rrdurl: "/api2/json/nodes/" + nodename + "/rrddata",
82 fields: [
83 { type: 'number', name: 'loadavg' },
84 { type: 'number', name: 'maxcpu' },
85 {
86 type: 'number',
87 name: 'cpu',
88 convert: function(val) {
89 return val*100;
90 },
91 },
92 {
93 type: 'number',
94 name: 'iowait',
95 convert: function(val) {
96 return val*100;
97 },
98 },
99 { type: 'number', name: 'memtotal' },
100 { type: 'number', name: 'memused' },
101 { type: 'number', name: 'swaptotal' },
102 { type: 'number', name: 'swapused' },
103 { type: 'number', name: 'roottotal' },
104 { type: 'number', name: 'rootused' },
105 { type: 'number', name: 'netin' },
106 { type: 'number', name: 'netout' },
107 { type: 'date', dateFormat: 'timestamp', name: 'time' },
108 ],
109 });
110
111 Ext.apply(me, {
112 items: [
113 {
114 xtype: 'proxmoxRRDChart',
115 title: gettext('CPU usage'),
116 unit: 'percent',
117 fields: ['cpu', 'iowait'],
118 fieldTitles: [gettext('CPU usage'), gettext('IO delay')],
119 store: rrdstore,
120 },
121 {
122 xtype: 'proxmoxRRDChart',
123 title: gettext('Server load'),
124 fields: ['loadavg'],
125 fieldTitles: [gettext('Load average')],
126 store: rrdstore,
127 },
128 {
129 xtype: 'proxmoxRRDChart',
130 title: gettext('Memory usage'),
131 unit: 'bytes',
132 fields: ['memtotal', 'memused'],
133 fieldTitles: [gettext('Total'), gettext('Used')],
134 store: rrdstore,
135 },
136 {
137 xtype: 'proxmoxRRDChart',
138 title: gettext('Swap usage'),
139 unit: 'bytes',
140 fields: ['swaptotal', 'swapused'],
141 fieldTitles: [gettext('Total'), gettext('Used')],
142 store: rrdstore,
143 },
144 {
145 xtype: 'proxmoxRRDChart',
146 title: gettext('Network traffic'),
147 unit: 'bytespersecond',
148 fields: ['netin', 'netout'],
149 fieldTitles: [gettext('Ingress'), gettext('Egress')],
150 store: rrdstore,
151 },
152 {
153 xtype: 'proxmoxRRDChart',
154 title: gettext('Disk usage'),
155 unit: 'bytes',
156 fields: ['roottotal', 'rootused'],
157 fieldTitles: [gettext('Total'), gettext('Used')],
158 store: rrdstore,
159 },
160 ],
161 listeners: {
162 activate: function() {
163 rrdstore.startUpdate();
164 },
165 destroy: function() {
166 rrdstore.stopUpdate();
167 },
168 },
169 });
170 me.callParent();
171 },
172 });
173