]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - src/data/ProxmoxProxy.js
ProxmoxProxy: add duration fields for proxmox-tasks
[proxmox-widget-toolkit.git] / src / data / ProxmoxProxy.js
CommitLineData
0bb29d35
DM
1Ext.define('Proxmox.RestProxy', {
2 extend: 'Ext.data.RestProxy',
01031528 3 alias: 'proxy.proxmox',
09d64465 4
01031528 5 pageParam: null,
0bb29d35
DM
6 startParam: null,
7 limitParam: null,
8 groupParam: null,
9 sortParam: null,
10 filterParam: null,
01031528 11 noCache: false,
0bb29d35
DM
12
13 afterRequest: function(request, success) {
14 this.fireEvent('afterload', this, request, success);
0bb29d35
DM
15 },
16
17 constructor: function(config) {
09d64465 18 Ext.applyIf(config, {
0bb29d35
DM
19 reader: {
20 type: 'json',
01031528
TL
21 rootProperty: config.root || 'data',
22 },
0bb29d35
DM
23 });
24
09d64465 25 this.callParent([config]);
01031528 26 },
06694509 27}, function() {
06694509
DM
28 Ext.define('KeyValue', {
29 extend: "Ext.data.Model",
01031528
TL
30 fields: ['key', 'value'],
31 idProperty: 'key',
06694509
DM
32 });
33
40d43a39
DM
34 Ext.define('KeyValuePendingDelete', {
35 extend: "Ext.data.Model",
01031528
TL
36 fields: ['key', 'value', 'pending', 'delete'],
37 idProperty: 'key',
40d43a39
DM
38 });
39
09d64465
DM
40 Ext.define('proxmox-tasks', {
41 extend: 'Ext.data.Model',
01031528
TL
42 fields: [
43 { name: 'starttime', type: 'date', dateFormat: 'timestamp' },
44 { name: 'endtime', type: 'date', dateFormat: 'timestamp' },
09d64465 45 { name: 'pid', type: 'int' },
66be1b8a
DC
46 {
47 name: 'duration',
48 sortType: 'asInt',
49 calculate: function(data) {
50 let endtime = data.endtime;
51 let starttime = data.starttime;
52 if (endtime !== undefined) {
53 return (endtime - starttime)/1000;
54 }
55 return 0;
56 },
57 },
01031528 58 'node', 'upid', 'user', 'status', 'type', 'id',
09d64465 59 ],
01031528 60 idProperty: 'upid',
09d64465
DM
61 });
62
63 Ext.define('proxmox-cluster-log', {
64 extend: 'Ext.data.Model',
01031528
TL
65 fields: [
66 { name: 'uid', type: 'int' },
67 { name: 'time', type: 'date', dateFormat: 'timestamp' },
09d64465
DM
68 { name: 'pri', type: 'int' },
69 { name: 'pid', type: 'int' },
70 'node', 'user', 'tag', 'msg',
71 {
72 name: 'id',
73 convert: function(value, record) {
05a977a2 74 let info = record.data;
09d64465
DM
75
76 if (value) {
77 return value;
78 }
79 // compute unique ID
80 return info.uid + ':' + info.node;
01031528
TL
81 },
82 },
09d64465 83 ],
01031528 84 idProperty: 'id',
09d64465 85 });
0bb29d35 86});