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