1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 00:12:30 +01:00
Sonarr/UI/Settings/SettingsLayout.js

178 lines
6.1 KiB
JavaScript
Raw Normal View History

"use strict";
define([
2013-03-04 01:09:43 +01:00
'app',
'Settings/Naming/NamingView',
'Settings/Quality/QualityLayout',
2013-05-01 02:01:54 +02:00
'Settings/Indexers/CollectionView',
2013-03-04 01:09:43 +01:00
'Settings/DownloadClient/DownloadClientView',
'Settings/Notifications/NotificationsView',
'Settings/System/SystemView',
'Settings/Misc/MiscView'
],
function () {
2013-03-04 01:09:43 +01:00
NzbDrone.Settings.SettingsLayout = Backbone.Marionette.Layout.extend({
template: 'Settings/SettingsLayoutTemplate',
regions: {
naming : '#naming',
quality : '#quality',
indexers : '#indexers',
2013-03-04 01:09:43 +01:00
downloadClient: '#download-client',
notifications : '#notifications',
system : '#system',
misc : '#misc'
2013-03-04 01:09:43 +01:00
},
ui: {
namingTab : '.x-naming-tab',
qualityTab : '.x-quality-tab',
indexersTab : '.x-indexers-tab',
2013-03-04 01:09:43 +01:00
downloadClientTab: '.x-download-client-tab',
notificationsTab : '.x-notifications-tab',
systemTab : '.x-system-tab',
miscTab : '.x-misc-tab'
2013-03-04 01:09:43 +01:00
},
events: {
'click .x-naming-tab' : 'showNaming',
'click .x-quality-tab' : 'showQuality',
'click .x-indexers-tab' : 'showIndexers',
2013-03-04 01:09:43 +01:00
'click .x-download-client-tab': 'showDownloadClient',
'click .x-notifications-tab' : 'showNotifications',
'click .x-system-tab' : 'showSystem',
'click .x-misc-tab' : 'showMisc',
'click .x-save-settings' : 'save'
2013-03-04 01:09:43 +01:00
},
showNaming: function (e) {
if (e) {
e.preventDefault();
}
this.ui.namingTab.tab('show');
NzbDrone.Router.navigate('settings/naming');
},
showQuality: function (e) {
if (e) {
e.preventDefault();
}
this.ui.qualityTab.tab('show');
NzbDrone.Router.navigate('settings/quality');
},
showIndexers: function (e) {
if (e) {
e.preventDefault();
}
this.ui.indexersTab.tab('show');
NzbDrone.Router.navigate('settings/indexers');
},
showDownloadClient: function (e) {
if (e) {
e.preventDefault();
}
this.ui.downloadClientTab.tab('show');
NzbDrone.Router.navigate('settings/downloadclient');
},
showNotifications: function (e) {
if (e) {
e.preventDefault();
}
this.ui.notificationsTab.tab('show');
NzbDrone.Router.navigate('settings/notifications');
},
showSystem: function (e) {
if (e) {
e.preventDefault();
}
this.ui.systemTab.tab('show');
NzbDrone.Router.navigate('settings/system');
},
showMisc: function (e) {
if (e) {
e.preventDefault();
}
this.ui.miscTab.tab('show');
NzbDrone.Router.navigate('settings/misc');
},
initialize: function (options) {
this.settings = options.settings;
2013-04-26 17:31:56 +02:00
this.namingSettings = new NzbDrone.Settings.Naming.NamingModel();
this.namingSettings.fetch();
2013-05-01 02:01:54 +02:00
this.indexerSettings = new NzbDrone.Settings.Indexers.Collection();
this.indexerSettings.fetch();
if (options.action) {
this.action = options.action.toLowerCase();
2013-03-04 01:09:43 +01:00
}
},
onRender: function () {
2013-04-26 17:31:56 +02:00
this.naming.show(new NzbDrone.Settings.Naming.NamingView());
this.quality.show(new NzbDrone.Settings.Quality.QualityLayout({settings: this.settings}));
2013-05-01 02:01:54 +02:00
this.indexers.show(new NzbDrone.Settings.Indexers.CollectionView({collection: this.indexerSettings}));
2013-03-04 01:09:43 +01:00
this.downloadClient.show(new NzbDrone.Settings.DownloadClient.DownloadClientView({model: this.settings}));
this.notifications.show(new NzbDrone.Settings.Notifications.NotificationsView({model: this.settings}));
this.system.show(new NzbDrone.Settings.System.SystemView({model: this.settings}));
this.misc.show(new NzbDrone.Settings.Misc.MiscView({model: this.settings}));
},
onShow: function () {
switch (this.action) {
case 'quality':
this.showQuality();
break;
case 'indexers':
this.showIndexers();
break;
case 'downloadclient':
this.showDownloadClient();
break;
case 'notifications':
this.showNotifications();
break;
case 'system':
this.showSystem();
break;
case 'misc':
this.showMisc();
break;
default:
this.showNaming();
}
},
save: function () {
2013-04-25 06:27:49 +02:00
NzbDrone.vent.trigger(NzbDrone.Commands.SaveSettings);
this.settings.save(undefined,
{
success: function () {
window.alert('Saved');
},
error : function () {
window.alert("couldn't save settings");
}
});
2013-03-04 01:09:43 +01:00
}
2013-04-25 06:27:49 +02:00
})
;
})
;
2013-03-04 01:09:43 +01:00