2016-03-16 05:30:00 +00:00
|
|
|
/*global define*/
|
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'backbone',
|
|
|
|
'common',
|
|
|
|
'sysadmin-app/views/side-nav',
|
2016-04-23 10:07:09 +00:00
|
|
|
'sysadmin-app/views/dashboard',
|
|
|
|
'sysadmin-app/views/desktop-devices',
|
|
|
|
'sysadmin-app/views/mobile-devices',
|
2016-04-29 02:19:28 +00:00
|
|
|
'sysadmin-app/views/device-errors',
|
2016-05-27 08:42:40 +00:00
|
|
|
'sysadmin-app/views/repos',
|
|
|
|
'sysadmin-app/views/dir',
|
|
|
|
'sysadmin-app/views/system-repo',
|
|
|
|
'sysadmin-app/views/trash-repos',
|
2016-04-29 02:19:28 +00:00
|
|
|
'app/views/account'
|
2016-04-23 10:07:09 +00:00
|
|
|
], function($, Backbone, Common, SideNavView, DashboardView,
|
2016-04-29 02:19:28 +00:00
|
|
|
DesktopDevicesView, MobileDevicesView, DeviceErrorsView,
|
2016-05-27 08:42:40 +00:00
|
|
|
ReposView, DirView, SystemReposView,
|
|
|
|
TrashReposView, AccountView) {
|
2016-05-25 02:45:22 +00:00
|
|
|
|
2016-03-16 05:30:00 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Router = Backbone.Router.extend({
|
|
|
|
routes: {
|
|
|
|
'': 'showDashboard',
|
|
|
|
'dashboard/': 'showDashboard',
|
2016-04-23 10:07:09 +00:00
|
|
|
'desktop-devices/': 'showDesktopDevices',
|
|
|
|
'mobile-devices/': 'showMobileDevices',
|
|
|
|
'device-errors/': 'showDeviceErrors',
|
2016-05-25 02:45:22 +00:00
|
|
|
'libraries/': 'showLibraries',
|
|
|
|
'libraries/:repo_id/dirents(/*path)': 'showLibraryDir',
|
|
|
|
'libraries/system/': 'showSystemLibrary',
|
|
|
|
'libraries/trash/': 'showTrashLibraries',
|
2016-03-16 05:30:00 +00:00
|
|
|
// Default
|
|
|
|
'*actions': 'showDashboard'
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function() {
|
2016-04-23 10:07:09 +00:00
|
|
|
$('#initial-loading-view').hide();
|
|
|
|
|
2016-03-16 05:30:00 +00:00
|
|
|
Common.prepareApiCsrf();
|
2016-04-23 10:07:09 +00:00
|
|
|
Common.initLocale();
|
2016-03-16 05:30:00 +00:00
|
|
|
|
|
|
|
this.sideNavView = new SideNavView();
|
|
|
|
app.ui = {
|
|
|
|
sideNavView: this.sideNavView
|
|
|
|
};
|
|
|
|
|
|
|
|
this.dashboardView = new DashboardView();
|
2016-04-23 10:07:09 +00:00
|
|
|
this.desktopDevicesView = new DesktopDevicesView();
|
|
|
|
this.mobileDevicesView = new MobileDevicesView();
|
|
|
|
this.deviceErrorsView = new DeviceErrorsView();
|
2016-05-27 08:42:40 +00:00
|
|
|
this.reposView = new ReposView();
|
|
|
|
this.systemReposView = new SystemReposView();
|
|
|
|
this.trashReposView = new TrashReposView();
|
|
|
|
this.dirView = new DirView();
|
2016-04-23 10:07:09 +00:00
|
|
|
|
2016-04-29 02:19:28 +00:00
|
|
|
app.ui.accountView = this.accountView = new AccountView();
|
|
|
|
|
2016-03-16 05:30:00 +00:00
|
|
|
this.currentView = this.dashboardView;
|
|
|
|
|
|
|
|
$('#info-bar .close').click(Common.closeTopNoticeBar);
|
|
|
|
},
|
|
|
|
|
|
|
|
switchCurrentView: function(newView) {
|
|
|
|
if (this.currentView != newView) {
|
|
|
|
this.currentView.hide();
|
|
|
|
this.currentView = newView;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
showDashboard: function() {
|
|
|
|
this.switchCurrentView(this.dashboardView);
|
|
|
|
this.sideNavView.setCurTab('dashboard');
|
2016-03-16 08:21:53 +00:00
|
|
|
this.dashboardView.show();
|
2016-04-23 10:07:09 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
showDesktopDevices: function(current_page) {
|
|
|
|
var url = window.location.href;
|
|
|
|
var page = url.match(/.*?page=(\d+)/);
|
|
|
|
if (page) {
|
2016-05-25 02:45:22 +00:00
|
|
|
var current_page = page[1];
|
2016-04-23 10:07:09 +00:00
|
|
|
} else {
|
2016-05-25 02:45:22 +00:00
|
|
|
var current_page = null;
|
2016-04-23 10:07:09 +00:00
|
|
|
}
|
|
|
|
this.switchCurrentView(this.desktopDevicesView);
|
|
|
|
this.sideNavView.setCurTab('devices');
|
|
|
|
this.desktopDevicesView.show({'current_page': current_page});
|
|
|
|
},
|
|
|
|
|
|
|
|
showMobileDevices: function(current_page) {
|
|
|
|
var url = window.location.href;
|
|
|
|
var page = url.match(/.*?page=(\d+)/);
|
|
|
|
if (page) {
|
|
|
|
current_page = page[1];
|
|
|
|
} else {
|
|
|
|
current_page = null;
|
|
|
|
}
|
|
|
|
this.switchCurrentView(this.mobileDevicesView);
|
|
|
|
this.sideNavView.setCurTab('devices');
|
|
|
|
this.mobileDevicesView.show({'current_page': current_page});
|
|
|
|
},
|
|
|
|
|
|
|
|
showDeviceErrors: function() {
|
|
|
|
this.switchCurrentView(this.deviceErrorsView);
|
|
|
|
this.sideNavView.setCurTab('devices');
|
|
|
|
this.deviceErrorsView.show();
|
2016-05-25 02:45:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
showLibraries: function() {
|
|
|
|
var url = window.location.href;
|
|
|
|
var page = url.match(/.*?page=(\d+)/);
|
|
|
|
if (page) {
|
|
|
|
var current_page = page[1];
|
|
|
|
} else {
|
|
|
|
var current_page = null;
|
|
|
|
}
|
2016-05-27 08:42:40 +00:00
|
|
|
this.switchCurrentView(this.reposView);
|
2016-05-25 02:45:22 +00:00
|
|
|
this.sideNavView.setCurTab('libraries');
|
2016-05-27 08:42:40 +00:00
|
|
|
this.reposView.show({'current_page': current_page});
|
2016-05-25 02:45:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
showLibraryDir: function(repo_id, path) {
|
|
|
|
if (path) {
|
|
|
|
path = '/' + path;
|
|
|
|
} else {
|
|
|
|
path = '/';
|
|
|
|
}
|
2016-05-27 08:42:40 +00:00
|
|
|
this.switchCurrentView(this.dirView);
|
|
|
|
this.dirView.show(repo_id, path);
|
2016-05-25 02:45:22 +00:00
|
|
|
this.sideNavView.setCurTab('libraries');
|
|
|
|
},
|
|
|
|
|
|
|
|
showSystemLibrary: function() {
|
2016-05-27 08:42:40 +00:00
|
|
|
this.switchCurrentView(this.systemReposView);
|
2016-05-25 02:45:22 +00:00
|
|
|
this.sideNavView.setCurTab('libraries');
|
2016-05-27 08:42:40 +00:00
|
|
|
this.systemReposView.show();
|
2016-05-25 02:45:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
showTrashLibraries: function() {
|
2016-05-27 08:42:40 +00:00
|
|
|
this.switchCurrentView(this.trashReposView);
|
2016-05-25 02:45:22 +00:00
|
|
|
this.sideNavView.setCurTab('libraries');
|
2016-05-27 08:42:40 +00:00
|
|
|
this.trashReposView.show();
|
2016-03-16 05:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return Router;
|
|
|
|
});
|