]>
git.proxmox.com Git - proxmox-backup.git/blob - www/MainView.js
1 Ext
.define('PBS.MainView', {
2 extend
: 'Ext.container.Container',
5 title
: 'Proxmox Backup Server',
8 xclass
: 'Ext.app.ViewController',
12 before
: 'beforeChangePath',
14 ':path' : '(?:([%a-zA-Z0-9\\-\\_\\s,]+))',
15 ':subpath' : '(?:(?::)([%a-zA-Z0-9\\-\\_\\s,]+))?'
20 beforeChangePath: function(path
, subpath
, action
) {
23 if (!Ext
.ClassManager
.getByAlias('widget.'+ path
)) {
24 console
.warn('xtype "'+path
+'" not found');
29 var lastpanel
= me
.lookupReference('contentpanel').getLayout().getActiveItem();
30 if (lastpanel
&& lastpanel
.xtype
=== path
) {
31 // we have the right component already,
32 // we just need to select the correct tab
33 // default to the first
34 subpath
= subpath
|| 0;
35 if (lastpanel
.getActiveTab
) {
36 // we assume lastpanel is a tabpanel
37 if (lastpanel
.getActiveTab().getItemId() !== subpath
) {
39 lastpanel
.setActiveTab(subpath
);
41 // else we are already there
50 changePath: function(path
,subpath
) {
52 var contentpanel
= me
.lookupReference('contentpanel');
53 var lastpanel
= contentpanel
.getLayout().getActiveItem();
55 var obj
= contentpanel
.add({ xtype
: path
});
56 var treelist
= me
.lookupReference('navtree');
58 treelist
.suspendEvents();
59 treelist
.select(path
);
60 treelist
.resumeEvents();
62 if (Ext
.isFunction(obj
.setActiveTab
)) {
63 obj
.setActiveTab(subpath
|| 0);
64 obj
.addListener('tabchange', function(tabpanel
, newc
, oldc
) {
67 // only add the subpath part for the
69 if (tabpanel
.items
.findIndex('id', newc
.id
) !== 0) {
70 newpath
+= ":" + newc
.getItemId();
73 me
.redirectTo(newpath
);
77 contentpanel
.setActiveItem(obj
);
80 contentpanel
.remove(lastpanel
, { destroy
: true });
89 navigate: function(treelist
, item
) {
90 this.redirectTo(item
.get('path'));
94 'button[reference=logoutButton]': {
99 init: function(view
) {
108 layout
: { type
: 'border' },
132 reference
: 'usernameinfo',
134 tpl
: Ext
.String
.format(gettext("You are logged in as {0}"), "'{username}'")
139 cls
: 'x-btn-default-toolbar-small proxmox-inline-button',
140 iconCls
: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
141 text
: gettext('Documentation'),
142 href
: '/docs/index.html',
146 reference
: 'logoutButton',
148 iconCls
: 'fa fa-sign-out',
149 text
: gettext('Logout')
163 xtype
: 'navigationtree',
165 reference
: 'navtree',
166 // we have to define it here until extjs 6.2
167 // because of a bug where a viewcontroller does not detect
168 // the selectionchange event of a treelist
170 selectionchange
: 'navigate'
174 cls
: 'x-treelist-nav',
180 layout
: { type
: 'card' },
183 reference
: 'contentpanel'