]>
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();
70 let tabChangeListener = function(tp
, newc
, oldc
) {
73 // only add the subpath part for the
75 if (tp
.items
.findIndex('id', newc
.id
) !== 0) {
76 newpath
+= `:${newc.getItemId()}`;
79 me
.redirectTo(newpath
);
85 if (PBS
.Utils
.isDataStorePath(path
)) {
86 datastore
= PBS
.Utils
.getDataStoreFromPath(path
);
87 if (lastpanel
&& lastpanel
.xtype
=== 'pbsDataStorePanel' && !subpath
) {
88 let activeTab
= lastpanel
.getActiveTab();
90 if (lastpanel
.items
.indexOf(activeTab
) !== 0) {
91 subpath
= activeTab
.getItemId();
92 newpath
+= `:${subpath}`;
94 me
.redirectTo(newpath
);
96 xtype
= 'pbsDataStorePanel';
98 obj
= contentpanel
.add({
101 nodename
: 'localhost',
103 activeTab
: subpath
|| 0,
105 tabchange
: tabChangeListener
,
109 var treelist
= me
.lookupReference('navtree');
111 treelist
.select(path
, true);
113 contentpanel
.setActiveItem(obj
);
116 contentpanel
.remove(lastpanel
, { destroy
: true });
124 navigate: function(treelist
, item
) {
125 this.redirectTo(item
.get('path'));
129 '[reference=logoutButton]': {
134 init: function(view
) {
137 PBS
.data
.RunningTasksStore
.startUpdate();
138 me
.lookupReference('usernameinfo').setText(Proxmox
.UserName
);
140 // show login on requestexception
141 // fixme: what about other errors
142 Ext
.Ajax
.on('requestexception', function(conn
, response
, options
) {
143 if (response
.status
=== 401 || response
.status
=== '401') { // auth failure
148 // get ticket periodically
149 Ext
.TaskManager
.start({
151 var ticket
= Proxmox
.Utils
.authOK();
152 if (!ticket
|| !Proxmox
.UserName
) {
158 username
: Proxmox
.UserName
,
161 url
: '/api2/json/access/ticket',
163 failure: function() {
166 success: function(response
, opts
) {
167 var obj
= Ext
.decode(response
.responseText
);
168 PBS
.Utils
.updateLoginData(obj
.data
);
172 interval
: 15*60*1000,
176 // select treeitem and load page from url fragment, if set
177 let token
= Ext
.util
.History
.getToken() || 'pbsDashboard';
178 this.redirectTo(token
, true);
184 layout
: { type
: 'border' },
198 xtype
: 'proxmoxlogo',
203 xtype
: 'versioninfo',
207 html
: '<a href="https://bugzilla.proxmox.com" target="_blank">BETA</a>',
217 cls
: 'x-btn-default-toolbar-small proxmox-inline-button',
218 iconCls
: 'fa fa-book x-btn-icon-el-default-toolbar-small ',
219 text
: gettext('Documentation'),
220 href
: '/docs/index.html',
224 xtype
: 'pbsTaskButton',
229 reference
: 'usernameinfo',
231 // proxmox dark grey p light grey as border
232 backgroundColor
: '#464d4d',
233 borderColor
: '#ABBABA',
236 iconCls
: 'fa fa-user',
239 reference
: 'logoutButton',
240 iconCls
: 'fa fa-sign-out',
241 text
: gettext('Logout'),
257 xtype
: 'navigationtree',
259 reference
: 'navtree',
260 // we have to define it here until extjs 6.2
261 // because of a bug where a viewcontroller does not detect
262 // the selectionchange event of a treelist
264 selectionchange
: 'navigate',
268 cls
: 'x-treelist-nav',
274 layout
: { type
: 'card' },
277 reference
: 'contentpanel',