]> git.proxmox.com Git - pve-manager.git/blob - www/manager/node/Config.js
92af5279e78dce7aa58b9f85112153dcc7906d25
[pve-manager.git] / www / manager / node / Config.js
1 Ext.define('PVE.node.Config', {
2 extend: 'PVE.panel.Config',
3 alias: 'widget.PVE.node.Config',
4
5 initComponent: function() {
6 var me = this;
7
8 var nodename = me.pveSelNode.data.node;
9 if (!nodename) {
10 throw "no node name specified";
11 }
12
13 me.statusStore = Ext.create('PVE.data.ObjectStore', {
14 url: "/api2/json/nodes/" + nodename + "/status",
15 interval: 1000
16 });
17
18 var node_command = function(cmd) {
19 PVE.Utils.API2Request({
20 params: { command: cmd },
21 url: '/nodes/' + nodename + '/status',
22 method: 'POST',
23 waitMsgTarget: me,
24 failure: function(response, opts) {
25 Ext.Msg.alert('Error', response.htmlStatus);
26 }
27 });
28 };
29
30 var restartBtn = Ext.create('PVE.button.Button', {
31 text: gettext('Restart'),
32 confirmMsg: Ext.String.format(gettext("Do you really want to restart node {0}?"), nodename),
33 handler: function() {
34 node_command('reboot');
35 }
36 });
37
38 var shutdownBtn = Ext.create('PVE.button.Button', {
39 text: gettext('Shutdown'),
40 confirmMsg: Ext.String.format(gettext("Do you really want to shutdown node {0}?"), nodename),
41 handler: function() {
42 node_command('shutdown');
43 }
44 });
45
46 var shellBtn = Ext.create('Ext.Button', {
47 text: gettext('Shell'),
48 handler: function() {
49 var url = Ext.urlEncode({
50 console: 'shell',
51 node: nodename
52 });
53 var nw = window.open("?" + url, '_blank',
54 "innerWidth=745,innerheight=427");
55 nw.focus();
56 }
57 });
58
59 Ext.apply(me, {
60 title: gettext('Node') + " '" + nodename + "'",
61 hstateid: 'nodetab',
62 defaults: { statusStore: me.statusStore },
63 tbar: [ restartBtn, shutdownBtn, shellBtn ],
64 items: [
65 {
66 title: gettext('Summary'),
67 itemId: 'summary',
68 xtype: 'pveNodeSummary'
69 },
70 {
71 title: gettext('Services'),
72 itemId: 'services',
73 xtype: 'pveNodeServiceView'
74 },
75 {
76 title: gettext('Network'),
77 itemId: 'network',
78 xtype: 'pveNodeNetworkView'
79 },
80 {
81 title: 'DNS',
82 itemId: 'dns',
83 xtype: 'pveNodeDNSView'
84 },
85 {
86 title: gettext('Time'),
87 itemId: 'time',
88 xtype: 'pveNodeTimeView'
89 },
90 {
91 title: 'Syslog',
92 itemId: 'syslog',
93 xtype: 'pveLogView',
94 url: "/api2/extjs/nodes/" + nodename + "/syslog"
95 },
96 {
97 title: 'Task History',
98 itemId: 'tasks',
99 xtype: 'pveNodeTasks'
100 },
101 {
102 title: 'UBC',
103 itemId: 'ubc',
104 xtype: 'pveNodeBCFailCnt'
105 }
106 ]
107 });
108
109 me.callParent();
110
111 me.statusStore.on('load', function(s, records, success) {
112 var uptimerec = s.data.get('uptime');
113 var uptime = uptimerec ? uptimerec.data.value : false;
114
115 restartBtn.setDisabled(!uptime);
116 shutdownBtn.setDisabled(!uptime);
117 shellBtn.setDisabled(!uptime);
118 });
119
120 me.on('afterrender', function() {
121 me.statusStore.startUpdate();
122 });
123
124 me.on('destroy', function() {
125 me.statusStore.stopUpdate();
126 });
127 }
128 });