]>
Commit | Line | Data |
---|---|---|
9940ea01 DM |
1 | Ext.define('PVE.ClusterInfo', { |
2 | extend: 'Ext.Component', | |
3 | alias: 'widget.pveClusterInfo', | |
4 | ||
5 | config: { | |
6 | style: 'background-color: white;', | |
7 | styleHtmlContent: true, | |
8 | tpl: [ | |
9 | '<table style="margin-bottom:0px;">', | |
10 | '<tr><td>Node:</td><td><b>{local_node}</large></b></tr>', | |
11 | '<tpl if="cluster_name">', | |
12 | '<tr><td>Cluster:</td><td>{cluster_name}</td></tr>', | |
13 | '<tr><td>Members:</td><td>{nodes}</td></tr>', | |
14 | '<tr><td>Quorate:</td><td>{quorate}</td></tr>', | |
15 | '</tpl>', | |
16 | '<tr><td>Version:</td><td>{version}</td></tr>', | |
17 | '</table>', | |
f3b18589 | 18 | ], |
9940ea01 DM |
19 | }, |
20 | }); | |
21 | ||
22 | Ext.define('PVE.Datacenter', { | |
23 | extend: 'PVE.Page', | |
24 | alias: 'widget.pveDatacenter', | |
25 | ||
26 | statics: { | |
27 | pathMatch: function(loc) { | |
28 | if (loc === '') { | |
29 | return ['']; | |
30 | } | |
f3b18589 | 31 | }, |
9940ea01 DM |
32 | }, |
33 | ||
34 | config: { | |
35 | appUrl: '', | |
36 | items: [ | |
988a1af8 TL |
37 | { |
38 | xtype: 'pveTitleBar', | |
9940ea01 | 39 | title: gettext('Datacenter'), |
f3b18589 | 40 | pveBackButton: false, |
9940ea01 DM |
41 | }, |
42 | { | |
f3b18589 | 43 | xtype: 'pveClusterInfo', |
9940ea01 DM |
44 | }, |
45 | { | |
46 | xtype: 'component', | |
47 | cls: 'dark', | |
48 | padding: 5, | |
f3b18589 | 49 | html: gettext('Nodes'), |
9940ea01 DM |
50 | }, |
51 | { | |
52 | xtype: 'list', | |
53 | flex: 1, | |
54 | disableSelection: true, | |
03a2d0a1 | 55 | sorters: 'name', |
9940ea01 DM |
56 | listeners: { |
57 | itemsingletap: function(list, index, target, record) { | |
58 | PVE.Workspace.gotoPage('nodes/' + record.get('name')); | |
f3b18589 | 59 | }, |
9940ea01 DM |
60 | }, |
61 | itemTpl: '{name}' + | |
42ec1872 | 62 | '<br><small>Online: {[Proxmox.Utils.format_boolean(values.online)]}</small>' + |
f3b18589 TL |
63 | '<br><small>Support: {[PVE.Utils.render_support_level(values.level)]}</small>', |
64 | }, | |
65 | ], | |
9940ea01 DM |
66 | }, |
67 | ||
68 | reload: function() { | |
69 | var me = this; | |
70 | ||
71 | var ci = me.down('pveClusterInfo'); | |
72 | ||
7e365988 DM |
73 | me.setMasked(false); |
74 | ||
9940ea01 DM |
75 | me.summary = {}; |
76 | ||
51d8307e | 77 | Proxmox.Utils.API2Request({ |
9940ea01 DM |
78 | url: '/version', |
79 | method: 'GET', | |
80 | success: function(response) { | |
81 | var d = response.result.data; | |
77bcdf54 | 82 | me.summary.version = d.version; |
9940ea01 | 83 | ci.setData(me.summary); |
f3b18589 | 84 | }, |
9940ea01 DM |
85 | }); |
86 | ||
87 | var list = me.down('list'); | |
88 | ||
51d8307e | 89 | Proxmox.Utils.API2Request({ |
9940ea01 DM |
90 | url: '/cluster/status', |
91 | method: 'GET', | |
92 | success: function(response) { | |
93 | var d = response.result.data; | |
f3b18589 | 94 | list.setData(d.filter(function(el) { return el.type === "node"; })); |
9940ea01 | 95 | |
9940ea01 DM |
96 | d.forEach(function(el) { |
97 | if (el.type === "node") { | |
9940ea01 DM |
98 | if (el.local) { |
99 | me.summary.local_node = el.name; | |
100 | } | |
101 | } else if (el.type === "cluster") { | |
03a2d0a1 | 102 | me.summary.nodes = el.nodes; |
42ec1872 | 103 | me.summary.quorate = Proxmox.Utils.format_boolean(el.quorate); |
9940ea01 | 104 | me.summary.cluster_name = el.name; |
9940ea01 DM |
105 | } |
106 | }); | |
107 | ||
9940ea01 | 108 | ci.setData(me.summary); |
7e365988 DM |
109 | }, |
110 | failure: function(response) { | |
f3b18589 TL |
111 | me.setMasked({ xtype: 'loadmask', message: response.htmlStatus }); |
112 | }, | |
9940ea01 DM |
113 | }); |
114 | }, | |
115 | ||
116 | initialize: function() { | |
117 | var me = this; | |
118 | ||
988a1af8 TL |
119 | me.down('pveMenuButton').setMenuItems([ |
120 | { | |
121 | text: gettext('Tasks'), | |
122 | handler: function() { | |
123 | PVE.Workspace.gotoPage('tasks'); | |
f3b18589 TL |
124 | }, |
125 | }, | |
988a1af8 TL |
126 | ]); |
127 | ||
9940ea01 | 128 | me.reload(); |
f3b18589 | 129 | }, |
9940ea01 DM |
130 | |
131 | }); | |
132 |