1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-29 11:44:34 +00:00
seahub/static/scripts/sysadmin-app/router.js

100 lines
3.1 KiB
JavaScript
Raw Normal View History

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',
'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,
AccountView) {
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-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-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) {
current_page = page[1];
} else {
current_page = null;
}
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-03-16 05:30:00 +00:00
}
});
return Router;
});