ui: content: fix various tree-checks from action handlers
they all still used some odd side effects of the tree structure to decided what record type they operated on, just move them over to the new `ty` record. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
08982a3746
commit
e30a2e9058
|
@ -168,7 +168,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
map[`${group["backup-type"]}/${group["backup-id"]}`] = group.comment;
|
map[`${group["backup-type"]}/${group["backup-id"]}`] = group.comment;
|
||||||
}
|
}
|
||||||
view.getRootNode().cascade(node => {
|
view.getRootNode().cascade(node => {
|
||||||
if (node.parentNode && node.parentNode.id === 'root') {
|
if (node.data.ty === 'group') {
|
||||||
let group = `${node.data.backup_type}/${node.data.backup_id}`;
|
let group = `${node.data.backup_type}/${node.data.backup_id}`;
|
||||||
node.set('comment', map[group], { dirty: false });
|
node.set('comment', map[group], { dirty: false });
|
||||||
}
|
}
|
||||||
|
@ -393,15 +393,13 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onChangeOwner: function(view, rI, cI, item, e, rec) {
|
onChangeOwner: function(table, rI, cI, item, e, { data }) {
|
||||||
view = this.getView();
|
let view = this.getView();
|
||||||
|
|
||||||
if (!rec || !rec.data || rec.parentNode.id !== 'root' || !view.datastore) {
|
if (data.ty !== 'group' || !view.datastore) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = rec.data;
|
|
||||||
|
|
||||||
let win = Ext.create('PBS.BackupGroupChangeOwner', {
|
let win = Ext.create('PBS.BackupGroupChangeOwner', {
|
||||||
datastore: view.datastore,
|
datastore: view.datastore,
|
||||||
ns: view.namespace,
|
ns: view.namespace,
|
||||||
|
@ -410,19 +408,19 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
owner: data.owner,
|
owner: data.owner,
|
||||||
autoShow: true,
|
autoShow: true,
|
||||||
});
|
});
|
||||||
|
// FIXME: don't reload all, use the record and query only its info, then update it
|
||||||
|
// directly in the tree
|
||||||
win.on('destroy', this.reload, this);
|
win.on('destroy', this.reload, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
onPrune: function(view, rI, cI, item, e, rec) {
|
onPrune: function(table, rI, cI, item, e, rec) {
|
||||||
let me = this;
|
let me = this;
|
||||||
view = me.getView();
|
let view = me.getView();
|
||||||
|
|
||||||
if (!(rec && rec.data)) return;
|
if (rec.data.ty !== 'group' || !view.datastore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let data = rec.data;
|
let data = rec.data;
|
||||||
if (rec.parentNode.id !== 'root') return;
|
|
||||||
|
|
||||||
if (!view.datastore) return;
|
|
||||||
|
|
||||||
Ext.create('PBS.DataStorePrune', {
|
Ext.create('PBS.DataStorePrune', {
|
||||||
autoShow: true,
|
autoShow: true,
|
||||||
datastore: view.datastore,
|
datastore: view.datastore,
|
||||||
|
@ -430,6 +428,8 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
backup_type: data.backup_type,
|
backup_type: data.backup_type,
|
||||||
backup_id: data.backup_id,
|
backup_id: data.backup_id,
|
||||||
listeners: {
|
listeners: {
|
||||||
|
// FIXME: don't reload all, use the record and query only its info, then update
|
||||||
|
// it directly in the tree
|
||||||
destroy: () => me.reload(),
|
destroy: () => me.reload(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -490,19 +490,16 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onVerify: function(view, rI, cI, item, e, { data }) {
|
||||||
onVerify: function(view, rI, cI, item, e, rec) {
|
|
||||||
let me = this;
|
let me = this;
|
||||||
view = me.getView();
|
view = me.getView();
|
||||||
|
|
||||||
if (!view.datastore) return;
|
if ((data.ty !== 'group' && data.ty !== 'dir') || !view.datastore) {
|
||||||
|
return;
|
||||||
if (!(rec && rec.data)) return;
|
}
|
||||||
let data = rec.data;
|
|
||||||
|
|
||||||
let params;
|
let params;
|
||||||
|
if (data.ty === 'dir') {
|
||||||
if (rec.parentNode.id !== 'root') {
|
|
||||||
params = {
|
params = {
|
||||||
"backup-type": data["backup-type"],
|
"backup-type": data["backup-type"],
|
||||||
"backup-id": data["backup-id"],
|
"backup-id": data["backup-id"],
|
||||||
|
@ -536,11 +533,10 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onNotesEdit: function(view, data, isGroup) {
|
onNotesEdit: function(view, data) {
|
||||||
let me = this;
|
let me = this;
|
||||||
|
|
||||||
let url = `/admin/datastore/${view.datastore}/`;
|
let isGroup = data.ty === 'group';
|
||||||
url += isGroup ? 'group-notes' : 'notes';
|
|
||||||
|
|
||||||
let params;
|
let params;
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
|
@ -560,7 +556,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.create('PBS.window.NotesEdit', {
|
Ext.create('PBS.window.NotesEdit', {
|
||||||
url: url,
|
url: `/admin/datastore/${view.datastore}/${isGroup ? 'group-notes' : 'notes'}`,
|
||||||
autoShow: true,
|
autoShow: true,
|
||||||
apiCallDone: () => me.reload(), // FIXME: do something more efficient?
|
apiCallDone: () => me.reload(), // FIXME: do something more efficient?
|
||||||
extraRequestParams: params,
|
extraRequestParams: params,
|
||||||
|
@ -695,15 +691,14 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onForget: function(view, rI, cI, item, e, rec) {
|
onForget: function(table, rI, cI, item, e, { data }) {
|
||||||
let me = this;
|
let me = this;
|
||||||
view = this.getView();
|
let view = this.getView();
|
||||||
|
if ((data.ty !== 'group' && data.ty !== 'dir') || !view.datastore) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(rec && rec.data)) return;
|
if (data.ty === 'dir') {
|
||||||
let data = rec.data;
|
|
||||||
if (!view.datastore) return;
|
|
||||||
|
|
||||||
if (rec.parentNode.id !== 'root') {
|
|
||||||
me.forgetSnapshot(data);
|
me.forgetSnapshot(data);
|
||||||
} else {
|
} else {
|
||||||
me.forgetGroup(data);
|
me.forgetGroup(data);
|
||||||
|
@ -713,15 +708,14 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
downloadFile: function(tV, rI, cI, item, e, rec) {
|
downloadFile: function(tV, rI, cI, item, e, rec) {
|
||||||
let me = this;
|
let me = this;
|
||||||
let view = me.getView();
|
let view = me.getView();
|
||||||
|
if (rec.data.ty !== 'file') return;
|
||||||
|
|
||||||
if (!(rec && rec.data)) return;
|
let snapshot = rec.parentNode.data;
|
||||||
let data = rec.parentNode.data;
|
|
||||||
|
|
||||||
let file = rec.data.filename;
|
let file = rec.data.filename;
|
||||||
let params = {
|
let params = {
|
||||||
'backup-id': data['backup-id'],
|
'backup-id': snapshot['backup-id'],
|
||||||
'backup-type': data['backup-type'],
|
'backup-type': snapshot['backup-type'],
|
||||||
'backup-time': (data['backup-time'].getTime()/1000).toFixed(0),
|
'backup-time': (snapshot['backup-time'].getTime()/1000).toFixed(0),
|
||||||
'file-name': file,
|
'file-name': file,
|
||||||
};
|
};
|
||||||
if (view.namespace && view.namespace !== '') {
|
if (view.namespace && view.namespace !== '') {
|
||||||
|
@ -731,7 +725,6 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
let idx = file.lastIndexOf('.');
|
let idx = file.lastIndexOf('.');
|
||||||
let filename = file.slice(0, idx);
|
let filename = file.slice(0, idx);
|
||||||
let atag = document.createElement('a');
|
let atag = document.createElement('a');
|
||||||
params['file-name'] = file;
|
|
||||||
atag.download = filename;
|
atag.download = filename;
|
||||||
let url = new URL(
|
let url = new URL(
|
||||||
`/api2/json/admin/datastore/${view.datastore}/download-decoded`,
|
`/api2/json/admin/datastore/${view.datastore}/download-decoded`,
|
||||||
|
@ -753,14 +746,13 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
me.nsChange(null, rec.data.ns);
|
me.nsChange(null, rec.data.ns);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (rec?.data?.ty !== 'file') return;
|
||||||
|
let snapshot = rec.parentNode.data;
|
||||||
|
|
||||||
if (!(rec && rec.data)) return;
|
let id = snapshot['backup-id'];
|
||||||
let data = rec.parentNode.data;
|
let time = snapshot['backup-time'];
|
||||||
|
let type = snapshot['backup-type'];
|
||||||
let id = data['backup-id'];
|
let timetext = PBS.Utils.render_datetime_utc(snapshot["backup-time"]);
|
||||||
let time = data['backup-time'];
|
|
||||||
let type = data['backup-type'];
|
|
||||||
let timetext = PBS.Utils.render_datetime_utc(data["backup-time"]);
|
|
||||||
let extraParams = {
|
let extraParams = {
|
||||||
'backup-id': id,
|
'backup-id': id,
|
||||||
'backup-time': (time.getTime()/1000).toFixed(0),
|
'backup-time': (time.getTime()/1000).toFixed(0),
|
||||||
|
@ -908,7 +900,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
}
|
}
|
||||||
let view = tree.up();
|
let view = tree.up();
|
||||||
let controller = view.controller;
|
let controller = view.controller;
|
||||||
controller.onNotesEdit(view, rec.data, rec.parentNode?.id === 'root');
|
controller.onNotesEdit(view, rec.data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
dblclick: function(tree, el, row, col, ev, rec) {
|
dblclick: function(tree, el, row, col, ev, rec) {
|
||||||
|
@ -918,7 +910,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
}
|
}
|
||||||
let view = tree.up();
|
let view = tree.up();
|
||||||
let controller = view.controller;
|
let controller = view.controller;
|
||||||
controller.onNotesEdit(view, rec.data, rec.parentNode?.id === 'root');
|
controller.onNotesEdit(view, rec.data);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1047,7 +1039,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
tip = "Key: " + PBS.Utils.renderKeyID(record.data.fingerprint);
|
tip = "Key: " + PBS.Utils.renderKeyID(record.data.fingerprint);
|
||||||
}
|
}
|
||||||
let txt = (iconTxt + PBS.Utils.cryptText[v]) || Proxmox.Utils.unknownText;
|
let txt = (iconTxt + PBS.Utils.cryptText[v]) || Proxmox.Utils.unknownText;
|
||||||
if (record.parentNode.id === 'root' || tip === undefined) {
|
if (record.data.ty === 'group' || tip === undefined) {
|
||||||
return txt;
|
return txt;
|
||||||
} else {
|
} else {
|
||||||
return `<span data-qtip="${tip}">${txt}</span>`;
|
return `<span data-qtip="${tip}">${txt}</span>`;
|
||||||
|
@ -1085,7 +1077,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
return record.data.leaf ? '' : i('question-circle-o warning', gettext('None'));
|
return record.data.leaf ? '' : i('question-circle-o warning', gettext('None'));
|
||||||
}
|
}
|
||||||
let tip, iconCls, txt;
|
let tip, iconCls, txt;
|
||||||
if (record.parentNode.id === 'root') {
|
if (record.data.ty === 'group') {
|
||||||
if (v.failed === 0) {
|
if (v.failed === 0) {
|
||||||
if (v.none === 0) {
|
if (v.none === 0) {
|
||||||
if (v.outdated > 0) {
|
if (v.outdated > 0) {
|
||||||
|
|
Loading…
Reference in New Issue