]>
git.proxmox.com Git - proxmox-backup.git/blob - www/DataStoreContent.js
1 Ext
.define('pbs-data-store-snapshots', {
2 extend
: 'Ext.data.Model',
9 dateFormat
: 'timestamp'
13 { name
: 'size', type
: 'int' },
17 Ext
.define('PBS.DataStoreContent', {
18 extend
: 'Ext.tree.Panel',
19 alias
: 'widget.pbsDataStoreContent',
23 title
: gettext('Content'),
26 xclass
: 'Ext.app.ViewController',
28 init: function(view
) {
29 if (!view
.datastore
) {
30 throw "no datastore specified";
33 this.store
= Ext
.create('Ext.data.Store', {
34 model
: 'pbs-data-store-snapshots',
35 sorters
: 'backup-group',
36 groupField
: 'backup-group',
38 this.store
.on('load', this.onLoad
, this);
40 Proxmox
.Utils
.monStoreErrors(view
, view
.store
, true);
41 this.reload(); // initial load
45 let view
= this.getView();
47 if (!view
.store
|| !this.store
) {
48 console
.warn('cannot reload, no store(s)');
52 let url
= `/api2/json/admin/datastore/${view.datastore}/snapshots`;
61 getRecordGroups: function(records
) {
64 for (const item
of records
) {
65 var btype
= item
.data
["backup-type"];
66 let group
= btype
+ "/" + item
.data
["backup-id"];
68 if (groups
[group
] !== undefined) {
75 } else if (btype
=== 'ct') {
77 } else if (btype
=== 'host') {
80 console
.warn(`got unkown backup-type '${btype}'`);
81 continue; // FIXME: auto render? what do?
89 backup_type
: item
.data
["backup-type"],
90 backup_id
: item
.data
["backup-id"],
98 onLoad: function(store
, records
, success
) {
99 let view
= this.getView();
105 let groups
= this.getRecordGroups(records
);
107 for (const item
of records
) {
108 let group
= item
.data
["backup-type"] + "/" + item
.data
["backup-id"];
109 let children
= groups
[group
].children
;
111 let data
= item
.data
;
113 data
.text
= group
+ '/' + PBS
.Utils
.render_datetime_utc(data
["backup-time"]);
115 data
.cls
= 'no-leaf-icons';
121 for (const [_key
, group
] of Object
.entries(groups
)) {
123 for (const item
of group
.children
) {
124 if (item
["backup-time"] > last_backup
) {
125 last_backup
= item
["backup-time"];
126 group
["backup-time"] = last_backup
;
127 group
.files
= item
.files
;
128 group
.size
= item
.size
;
129 group
.owner
= item
.owner
;
132 group
.count
= group
.children
.length
;
133 children
.push(group
);
142 onPrune: function() {
143 var view
= this.getView();
145 let rec
= view
.selModel
.getSelection()[0];
146 if (!(rec
&& rec
.data
)) return;
148 if (data
.leaf
) return;
150 if (!view
.datastore
) return;
152 let win
= Ext
.create('PBS.DataStorePrune', {
153 datastore
: view
.datastore
,
154 backup_type
: data
.backup_type
,
155 backup_id
: data
.backup_id
,
157 win
.on('destroy', this.reload
, this);
165 header
: gettext("Backup Group"),
171 header
: gettext('Backup Time'),
173 dataIndex
: 'backup-time',
174 format
: 'Y-m-d H:i:s',
178 header
: gettext("Size"),
181 renderer
: Proxmox
.Utils
.format_size
,
184 xtype
: 'numbercolumn',
186 header
: gettext("Count"),
191 header
: gettext("Owner"),
196 header
: gettext("Files"),
205 text
: gettext('Reload'),
206 iconCls
: 'fa fa-refresh',
210 xtype
: 'proxmoxButton',
211 text
: gettext('Prune'),
213 enableFn: function(record
) { return !record
.data
.leaf
; },