]>
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
) {
102 me
.lookupReference('usernameinfo').update({username
:Proxmox
.UserName
});
104 // get ticket periodically
105 Ext
.TaskManager
.start({
107 var ticket
= Proxmox
.Utils
.authOK();
108 if (!ticket
|| !Proxmox
.UserName
) {
114 username
: Proxmox
.UserName
,
117 url
: '/api2/json/access/ticket',
119 failure: function() {
122 success: function(response
, opts
) {
123 var obj
= Ext
.decode(response
.responseText
);
124 PMG
.Utils
.updateLoginData(obj
.data
);
135 layout
: { type
: 'border' },
159 reference
: 'usernameinfo',
161 tpl
: Ext
.String
.format(gettext("You are logged in as {0}"), "'{username}'")
166 cls
: 'x-btn-default-toolbar-small proxmox-inline-button',
167 iconCls
: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
168 text
: gettext('Documentation'),
169 href
: '/docs/index.html',
173 reference
: 'logoutButton',
175 iconCls
: 'fa fa-sign-out',
176 text
: gettext('Logout')
190 xtype
: 'navigationtree',
192 reference
: 'navtree',
193 // we have to define it here until extjs 6.2
194 // because of a bug where a viewcontroller does not detect
195 // the selectionchange event of a treelist
197 selectionchange
: 'navigate'
201 cls
: 'x-treelist-nav',
207 layout
: { type
: 'card' },
210 reference
: 'contentpanel'