2018-12-04 16:53:10 +00:00
|
|
|
Ext.define('PBS.MainView', {
|
|
|
|
extend: 'Ext.container.Container',
|
|
|
|
xtype: 'mainview',
|
|
|
|
|
|
|
|
title: 'Proxmox Backup Server',
|
|
|
|
|
|
|
|
controller: {
|
|
|
|
xclass: 'Ext.app.ViewController',
|
|
|
|
routes: {
|
|
|
|
':path:subpath': {
|
|
|
|
action: 'changePath',
|
|
|
|
before: 'beforeChangePath',
|
|
|
|
conditions : {
|
|
|
|
':path' : '(?:([%a-zA-Z0-9\\-\\_\\s,]+))',
|
|
|
|
':subpath' : '(?:(?::)([%a-zA-Z0-9\\-\\_\\s,]+))?'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeChangePath: function(path, subpath, action) {
|
|
|
|
var me = this;
|
|
|
|
|
2019-01-22 10:48:00 +00:00
|
|
|
if (!Ext.ClassManager.getByAlias('widget.'+ path)) {
|
|
|
|
console.warn('xtype "'+path+'" not found');
|
|
|
|
action.stop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var lastpanel = me.lookupReference('contentpanel').getLayout().getActiveItem();
|
|
|
|
if (lastpanel && lastpanel.xtype === path) {
|
|
|
|
// we have the right component already,
|
|
|
|
// we just need to select the correct tab
|
|
|
|
// default to the first
|
|
|
|
subpath = subpath || 0;
|
|
|
|
if (lastpanel.getActiveTab) {
|
|
|
|
// we assume lastpanel is a tabpanel
|
|
|
|
if (lastpanel.getActiveTab().getItemId() !== subpath) {
|
|
|
|
// set the active tab
|
|
|
|
lastpanel.setActiveTab(subpath);
|
|
|
|
}
|
|
|
|
// else we are already there
|
|
|
|
}
|
|
|
|
action.stop();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-04 16:53:10 +00:00
|
|
|
action.resume();
|
|
|
|
},
|
|
|
|
|
2019-01-22 10:48:00 +00:00
|
|
|
changePath: function(path,subpath) {
|
2018-12-04 16:53:10 +00:00
|
|
|
var me = this;
|
|
|
|
var contentpanel = me.lookupReference('contentpanel');
|
|
|
|
var lastpanel = contentpanel.getLayout().getActiveItem();
|
|
|
|
|
2019-01-22 10:48:00 +00:00
|
|
|
var obj = contentpanel.add({ xtype: path });
|
|
|
|
var treelist = me.lookupReference('navtree');
|
|
|
|
|
|
|
|
treelist.suspendEvents();
|
|
|
|
treelist.select(path);
|
|
|
|
treelist.resumeEvents();
|
|
|
|
|
|
|
|
if (Ext.isFunction(obj.setActiveTab)) {
|
|
|
|
obj.setActiveTab(subpath || 0);
|
|
|
|
obj.addListener('tabchange', function(tabpanel, newc, oldc) {
|
|
|
|
var newpath = path;
|
|
|
|
|
|
|
|
// only add the subpath part for the
|
|
|
|
// non-default tabs
|
|
|
|
if (tabpanel.items.findIndex('id', newc.id) !== 0) {
|
|
|
|
newpath += ":" + newc.getItemId();
|
|
|
|
}
|
|
|
|
|
|
|
|
me.redirectTo(newpath);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
contentpanel.setActiveItem(obj);
|
|
|
|
|
|
|
|
if (lastpanel) {
|
|
|
|
contentpanel.remove(lastpanel, { destroy: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2019-01-30 14:14:20 +00:00
|
|
|
logout: function() {
|
|
|
|
PBS.app.logout();
|
|
|
|
},
|
|
|
|
|
2019-01-22 10:48:00 +00:00
|
|
|
navigate: function(treelist, item) {
|
|
|
|
this.redirectTo(item.get('path'));
|
2018-12-04 16:53:10 +00:00
|
|
|
},
|
|
|
|
|
2019-01-30 14:14:20 +00:00
|
|
|
control: {
|
|
|
|
'button[reference=logoutButton]': {
|
|
|
|
click: 'logout'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-12-04 16:53:10 +00:00
|
|
|
init: function(view) {
|
|
|
|
var me = this;
|
|
|
|
|
2019-12-17 12:00:17 +00:00
|
|
|
me.lookupReference('usernameinfo').update({username:Proxmox.UserName});
|
2018-12-04 16:53:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: 'viewport',
|
|
|
|
|
|
|
|
layout: { type: 'border' },
|
|
|
|
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
region: 'north',
|
|
|
|
xtype: 'container',
|
|
|
|
layout: {
|
|
|
|
type: 'hbox',
|
|
|
|
align: 'middle'
|
|
|
|
},
|
|
|
|
margin: '2 5 2 5',
|
|
|
|
height: 38,
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
xtype: 'proxmoxlogo'
|
|
|
|
},
|
|
|
|
{
|
2018-12-04 16:58:40 +00:00
|
|
|
xtype: 'versioninfo'
|
2018-12-04 16:53:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
baseCls: 'x-plain',
|
|
|
|
reference: 'usernameinfo',
|
|
|
|
padding: '0 5',
|
|
|
|
tpl: Ext.String.format(gettext("You are logged in as {0}"), "'{username}'")
|
|
|
|
},
|
2019-12-16 17:16:06 +00:00
|
|
|
{
|
|
|
|
xtype: 'button',
|
|
|
|
baseCls: 'x-btn',
|
|
|
|
cls: 'x-btn-default-toolbar-small proxmox-inline-button',
|
|
|
|
iconCls: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
|
|
|
|
text: gettext('Documentation'),
|
|
|
|
href: '/docs/index.html',
|
|
|
|
margin: '0 5 0 0',
|
|
|
|
},
|
2018-12-04 16:53:10 +00:00
|
|
|
{
|
|
|
|
reference: 'logoutButton',
|
|
|
|
xtype: 'button',
|
|
|
|
iconCls: 'fa fa-sign-out',
|
|
|
|
text: gettext('Logout')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'panel',
|
|
|
|
scrollable: 'y',
|
|
|
|
border: false,
|
|
|
|
region: 'west',
|
|
|
|
layout: {
|
|
|
|
type: 'vbox',
|
|
|
|
align: 'stretch'
|
|
|
|
},
|
2019-01-22 10:48:00 +00:00
|
|
|
items: [{
|
|
|
|
xtype: 'navigationtree',
|
|
|
|
minWidth: 180,
|
|
|
|
reference: 'navtree',
|
|
|
|
// we have to define it here until extjs 6.2
|
|
|
|
// because of a bug where a viewcontroller does not detect
|
|
|
|
// the selectionchange event of a treelist
|
|
|
|
listeners: {
|
|
|
|
selectionchange: 'navigate'
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
xtype: 'box',
|
|
|
|
cls: 'x-treelist-nav',
|
|
|
|
flex: 1
|
|
|
|
}]
|
2018-12-04 16:53:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
xtype: 'panel',
|
|
|
|
layout: { type: 'card' },
|
|
|
|
region: 'center',
|
|
|
|
border: false,
|
|
|
|
reference: 'contentpanel'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
|