ui: tape: only add tapestore and nav element once

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-03-03 15:00:51 +01:00 committed by Dietmar Maurer
parent f46573f8c3
commit 7d6f03a7fe
1 changed files with 20 additions and 17 deletions

View File

@ -119,14 +119,19 @@ Ext.define('PBS.view.main.NavigationTree', {
view.on('destroy', view.rstore.stopUpdate); view.on('destroy', view.rstore.stopUpdate);
if (PBS.enableTapeUI) { if (PBS.enableTapeUI) {
if (view.tapestore === undefined) {
view.tapestore = Ext.create('Proxmox.data.UpdateStore', { view.tapestore = Ext.create('Proxmox.data.UpdateStore', {
autoStart: true, autoStart: true,
interval: 2 * 1000, interval: 2 * 1000,
storeid: 'pbs-tape-drive-list', storeid: 'pbs-tape-drive-list',
model: 'pbs-tape-drive-list', model: 'pbs-tape-drive-list',
}); });
view.tapestore.on('load', this.onTapeDriveLoad, this);
view.on('destroy', view.tapestore.stopUpdate);
}
let root = view.getStore().getRoot(); let root = view.getStore().getRoot();
if (root.findChild('id', 'tape_management', false) === null) {
root.insertChild(3, { root.insertChild(3, {
text: "Tape Backup", text: "Tape Backup",
iconCls: 'pbs-icon-tape', iconCls: 'pbs-icon-tape',
@ -135,9 +140,7 @@ Ext.define('PBS.view.main.NavigationTree', {
expanded: true, expanded: true,
children: [], children: [],
}); });
}
view.tapestore.on('load', this.onTapeDriveLoad, this);
view.on('destroy', view.tapestore.stopUpdate);
} }
}, },