]>
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
) {
25 let isDataStore
= PBS
.Utils
.isDataStorePath(path
);
27 xtype
= 'pbsDataStorePanel';
28 datastore
= PBS
.Utils
.getDataStoreFromPath(path
);
31 if (!Ext
.ClassManager
.getByAlias(`widget.${xtype}`)) {
32 console
.warn(`xtype ${xtype} not found`);
37 var lastpanel
= me
.lookupReference('contentpanel').getLayout().getActiveItem();
38 if (lastpanel
&& lastpanel
.xtype
=== xtype
) {
40 if (datastore
=== lastpanel
.datastore
) {
45 // we have the right component already,
46 // we just need to select the correct tab
47 // default to the first
48 subpath
= subpath
|| 0;
49 if (lastpanel
.getActiveTab
) {
50 // we assume lastpanel is a tabpanel
51 if (lastpanel
.getActiveTab().getItemId() !== subpath
) {
53 lastpanel
.setActiveTab(subpath
);
55 // else we are already there
65 changePath: function(path
, subpath
) {
67 var contentpanel
= me
.lookupReference('contentpanel');
68 var lastpanel
= contentpanel
.getLayout().getActiveItem();
71 if (PBS
.Utils
.isDataStorePath(path
)) {
72 let datastore
= PBS
.Utils
.getDataStoreFromPath(path
);
73 obj
= contentpanel
.add({
74 xtype
: 'pbsDataStorePanel',
75 nodename
: 'localhost',
79 obj
= contentpanel
.add({
81 nodename
: 'localhost',
86 var treelist
= me
.lookupReference('navtree');
88 treelist
.suspendEvents();
89 if (subpath
=== undefined) {
90 treelist
.select(path
);
92 treelist
.select(path
+ ':' + subpath
);
94 treelist
.resumeEvents();
96 if (Ext
.isFunction(obj
.setActiveTab
)) {
97 obj
.setActiveTab(subpath
|| 0);
98 obj
.addListener('tabchange', function(tabpanel
, newc
, oldc
) {
101 // only add the subpath part for the
103 if (tabpanel
.items
.findIndex('id', newc
.id
) !== 0) {
104 newpath
+= ":" + newc
.getItemId();
107 me
.redirectTo(newpath
);
111 contentpanel
.setActiveItem(obj
);
114 contentpanel
.remove(lastpanel
, { destroy
: true });
122 navigate: function(treelist
, item
) {
123 this.redirectTo(item
.get('path'));
127 '[reference=logoutButton]': {
132 init: function(view
) {
135 PBS
.data
.RunningTasksStore
.startUpdate();
136 me
.lookupReference('usernameinfo').setText(Proxmox
.UserName
);
138 // show login on requestexception
139 // fixme: what about other errors
140 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
141 if (response
.status
=== 401 || response
.status
=== '401') { // auth failure
146 // get ticket periodically
147 Ext
.TaskManager
.start({
149 var ticket
= Proxmox
.Utils
.authOK();
150 if (!ticket
|| !Proxmox
.UserName
) {
156 username
: Proxmox
.UserName
,
159 url
: '/api2/json/access/ticket',
161 failure: function() {
164 success: function(response
, opts
) {
165 var obj
= Ext
.decode(response
.responseText
);
166 PBS
.Utils
.updateLoginData(obj
.data
);
170 interval
: 15*60*1000,
174 // select treeitem and load page from url fragment, if set
175 let token
= Ext
.util
.History
.getToken() || 'pbsDashboard';
176 this.redirectTo(token
, true);
182 layout
: { type
: 'border' },
196 xtype
: 'proxmoxlogo',
201 xtype
: 'versioninfo',
205 html
: '<a href="https://bugzilla.proxmox.com" target="_blank">BETA</a>',
215 cls
: 'x-btn-default-toolbar-small proxmox-inline-button',
216 iconCls
: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
217 text
: gettext('Documentation'),
218 href
: '/docs/index.html',
222 xtype
: 'pbsTaskButton',
227 reference
: 'usernameinfo',
229 // proxmox dark grey p light grey as border
230 backgroundColor
: '#464d4d',
231 borderColor
: '#ABBABA',
234 iconCls
: 'fa fa-user',
237 reference
: 'logoutButton',
238 iconCls
: 'fa fa-sign-out',
239 text
: gettext('Logout'),
255 xtype
: 'navigationtree',
257 reference
: 'navtree',
258 // we have to define it here until extjs 6.2
259 // because of a bug where a viewcontroller does not detect
260 // the selectionchange event of a treelist
262 selectionchange
: 'navigate',
266 cls
: 'x-treelist-nav',
272 layout
: { type
: 'card' },
275 reference
: 'contentpanel',