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