]>
Commit | Line | Data |
---|---|---|
402991a7 DC |
1 | Ext.define('Proxmox.window.DiskSmart', { |
2 | extend: 'Ext.window.Window', | |
3 | alias: 'widget.pmxSmartWindow', | |
4 | ||
5 | modal: true, | |
6 | ||
7 | items: [ | |
8 | { | |
9 | xtype: 'gridpanel', | |
10 | layout: { | |
11 | type: 'fit', | |
12 | }, | |
13 | emptyText: gettext('No S.M.A.R.T. Values'), | |
14 | scrollable: true, | |
15 | flex: 1, | |
16 | itemId: 'smarts', | |
17 | reserveScrollbar: true, | |
18 | columns: [ | |
19 | { text: 'ID', dataIndex: 'id', width: 50 }, | |
20 | { text: gettext('Attribute'), flex: 1, dataIndex: 'name', renderer: Ext.String.htmlEncode }, | |
21 | { text: gettext('Value'), dataIndex: 'raw', renderer: Ext.String.htmlEncode }, | |
22 | { text: gettext('Normalized'), dataIndex: 'value', width: 60 }, | |
23 | { text: gettext('Threshold'), dataIndex: 'threshold', width: 60 }, | |
24 | { text: gettext('Worst'), dataIndex: 'worst', width: 60 }, | |
25 | { text: gettext('Flags'), dataIndex: 'flags' }, | |
26 | { text: gettext('Failing'), dataIndex: 'fail', renderer: Ext.String.htmlEncode }, | |
27 | ], | |
28 | }, | |
29 | { | |
30 | xtype: 'component', | |
31 | itemId: 'text', | |
32 | layout: { | |
33 | type: 'fit', | |
34 | }, | |
35 | hidden: true, | |
36 | style: { | |
37 | 'background-color': 'white', | |
38 | 'white-space': 'pre', | |
39 | 'font-family': 'monospace', | |
40 | }, | |
41 | }, | |
42 | ], | |
43 | ||
44 | buttons: [ | |
45 | { | |
46 | text: gettext('Reload'), | |
47 | name: 'reload', | |
48 | handler: function() { | |
49 | var me = this; | |
50 | me.up('window').store.reload(); | |
51 | }, | |
52 | }, | |
53 | { | |
54 | text: gettext('Close'), | |
55 | name: 'close', | |
56 | handler: function() { | |
57 | var me = this; | |
58 | me.up('window').close(); | |
59 | }, | |
60 | }, | |
61 | ], | |
62 | ||
63 | layout: { | |
64 | type: 'vbox', | |
65 | align: 'stretch', | |
66 | }, | |
67 | width: 800, | |
68 | height: 500, | |
69 | minWidth: 600, | |
70 | minHeight: 400, | |
71 | bodyPadding: 5, | |
72 | title: gettext('S.M.A.R.T. Values'), | |
73 | ||
74 | initComponent: function() { | |
75 | var me = this; | |
76 | ||
77 | if (!me.baseurl) { | |
78 | throw "no baseurl specified"; | |
79 | } | |
80 | ||
81 | var dev = me.dev; | |
82 | if (!dev) { | |
83 | throw "no device specified"; | |
84 | } | |
85 | ||
86 | me.store = Ext.create('Ext.data.Store', { | |
87 | model: 'pmx-disk-smart', | |
88 | proxy: { | |
89 | type: 'proxmox', | |
90 | url: `${me.baseurl}/smart?disk=${dev}`, | |
91 | }, | |
92 | }); | |
93 | ||
94 | me.callParent(); | |
95 | var grid = me.down('#smarts'); | |
96 | var text = me.down('#text'); | |
97 | ||
98 | Proxmox.Utils.monStoreErrors(grid, me.store); | |
99 | me.mon(me.store, 'load', function(s, records, success) { | |
100 | if (success && records.length > 0) { | |
101 | var rec = records[0]; | |
102 | if (rec.data.type === 'text') { | |
103 | grid.setVisible(false); | |
104 | text.setVisible(true); | |
105 | text.setHtml(Ext.String.htmlEncode(rec.data.text)); | |
106 | } else { | |
107 | grid.setVisible(true); | |
108 | text.setVisible(false); | |
109 | grid.setStore(rec.attributes()); | |
110 | } | |
111 | } | |
112 | }); | |
113 | ||
114 | me.store.load(); | |
115 | }, | |
116 | }, function() { | |
117 | Ext.define('pmx-disk-smart', { | |
118 | extend: 'Ext.data.Model', | |
119 | fields: [ | |
120 | { name: 'health' }, | |
121 | { name: 'type' }, | |
122 | { name: 'text' }, | |
123 | ], | |
124 | hasMany: { model: 'pmx-smart-attribute', name: 'attributes' }, | |
125 | }); | |
126 | Ext.define('pmx-smart-attribute', { | |
127 | extend: 'Ext.data.Model', | |
128 | fields: [ | |
129 | { name: 'id', type: 'number' }, 'name', 'value', 'worst', 'threshold', 'flags', 'fail', 'raw', | |
130 | ], | |
131 | idProperty: 'name', | |
132 | }); | |
133 | }); |