mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 15:38:43 +00:00
add support for asking the user to change their password if it is their first login
This commit is contained in:
parent
3e6c956ac6
commit
ae426eb0cd
2 changed files with 125 additions and 85 deletions
|
@ -244,6 +244,23 @@ Copyright:
|
||||||
this.update = this.update.createDelegate(this);
|
this.update = this.update.createDelegate(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the the web interface is currently connected
|
||||||
|
* to a Deluge Daemon and show the Connection Manager if not.
|
||||||
|
*/
|
||||||
|
checkConnected: function() {
|
||||||
|
Deluge.Client.web.connected({
|
||||||
|
success: function(connected) {
|
||||||
|
if (connected) {
|
||||||
|
Deluge.Events.fire('connect');
|
||||||
|
} else {
|
||||||
|
this.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
Deluge.Events.fire('disconnect');
|
Deluge.Events.fire('disconnect');
|
||||||
},
|
},
|
||||||
|
@ -363,16 +380,21 @@ Copyright:
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogin: function() {
|
onLogin: function() {
|
||||||
Deluge.Client.web.connected({
|
if (Deluge.config.first_login) {
|
||||||
success: function(connected) {
|
Ext.MessageBox.confirm('Change password',
|
||||||
if (connected) {
|
'As this is your first login, we recommend that you ' +
|
||||||
Deluge.Events.fire('connect');
|
'change your password. Would you like to ' +
|
||||||
} else {
|
'do this now?', function(res) {
|
||||||
this.show();
|
this.checkConnected();
|
||||||
}
|
if (res == 'yes') {
|
||||||
},
|
Deluge.Preferences.show();
|
||||||
scope: this
|
Deluge.Preferences.selectPage('Interface');
|
||||||
});
|
}
|
||||||
|
Deluge.Client.web.set_config({first_login: false});
|
||||||
|
}, this);
|
||||||
|
} else {
|
||||||
|
this.checkConnected();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogout: function() {
|
onLogout: function() {
|
||||||
|
|
|
@ -32,57 +32,65 @@ Copyright:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]);
|
||||||
|
|
||||||
Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
|
Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {String} currentPage The currently selected page.
|
||||||
|
*/
|
||||||
currentPage: null,
|
currentPage: null,
|
||||||
|
|
||||||
constructor: function(config) {
|
title: _('Preferences'),
|
||||||
config = Ext.apply({
|
layout: 'border',
|
||||||
layout: 'border',
|
width: 485,
|
||||||
width: 485,
|
height: 500,
|
||||||
height: 500,
|
|
||||||
buttonAlign: 'right',
|
|
||||||
closeAction: 'hide',
|
|
||||||
closable: true,
|
|
||||||
iconCls: 'x-deluge-preferences',
|
|
||||||
plain: true,
|
|
||||||
resizable: false,
|
|
||||||
title: _('Preferences'),
|
|
||||||
|
|
||||||
items: [{
|
buttonAlign: 'right',
|
||||||
xtype: 'grid',
|
closeAction: 'hide',
|
||||||
region: 'west',
|
closable: true,
|
||||||
title: _('Categories'),
|
iconCls: 'x-deluge-preferences',
|
||||||
store: new Ext.data.SimpleStore({
|
plain: true,
|
||||||
fields: [{name: 'name', mapping: 0}]
|
resizable: false,
|
||||||
}),
|
|
||||||
columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}],
|
|
||||||
sm: new Ext.grid.RowSelectionModel({
|
|
||||||
singleSelect: true,
|
|
||||||
listeners: {'rowselect': {fn: this.onPageSelect, scope: this}}
|
|
||||||
}),
|
|
||||||
hideHeaders: true,
|
|
||||||
autoExpandColumn: 'name',
|
|
||||||
deferredRender: false,
|
|
||||||
autoScroll: true,
|
|
||||||
margins: '5 0 5 5',
|
|
||||||
cmargins: '5 0 5 5',
|
|
||||||
width: 120,
|
|
||||||
collapsible: true
|
|
||||||
}, ]
|
|
||||||
}, config);
|
|
||||||
Ext.deluge.PreferencesWindow.superclass.constructor.call(this, config);
|
|
||||||
},
|
|
||||||
|
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);
|
Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);
|
||||||
this.categoriesGrid = this.items.get(0);
|
|
||||||
this.configPanel = this.add({
|
this.categoriesGrid = this.add({
|
||||||
region: 'center',
|
xtype: 'grid',
|
||||||
header: false,
|
region: 'west',
|
||||||
layout: 'fit',
|
title: _('Categories'),
|
||||||
height: 400,
|
store: new Ext.data.Store(),
|
||||||
|
columns: [{
|
||||||
|
id: 'name',
|
||||||
|
renderer: fplain,
|
||||||
|
dataIndex: 'name'
|
||||||
|
}],
|
||||||
|
sm: new Ext.grid.RowSelectionModel({
|
||||||
|
singleSelect: true,
|
||||||
|
listeners: {
|
||||||
|
'rowselect': {
|
||||||
|
fn: this.onPageSelect, scope: this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
hideHeaders: true,
|
||||||
|
autoExpandColumn: 'name',
|
||||||
|
deferredRender: false,
|
||||||
autoScroll: true,
|
autoScroll: true,
|
||||||
|
margins: '5 0 5 5',
|
||||||
|
cmargins: '5 0 5 5',
|
||||||
|
width: 120,
|
||||||
|
collapsible: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.configPanel = this.add({
|
||||||
|
type: 'container',
|
||||||
|
autoDestroy: false,
|
||||||
|
region: 'center',
|
||||||
|
layout: 'card',
|
||||||
|
//height: 400,
|
||||||
|
//autoScroll: true,
|
||||||
margins: '5 5 5 5',
|
margins: '5 5 5 5',
|
||||||
cmargins: '5 5 5 5'
|
cmargins: '5 5 5 5'
|
||||||
});
|
});
|
||||||
|
@ -93,6 +101,7 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
this.pages = {};
|
this.pages = {};
|
||||||
this.optionsManager = new Deluge.OptionsManager();
|
this.optionsManager = new Deluge.OptionsManager();
|
||||||
|
this.on('afterrender', this.onAfterRender, this);
|
||||||
this.on('show', this.onShow, this);
|
this.on('show', this.onShow, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,23 +119,23 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onClose: function() {
|
|
||||||
this.hide();
|
|
||||||
},
|
|
||||||
|
|
||||||
onOk: function() {
|
/**
|
||||||
Deluge.Client.core.set_config(this.optionsManager.getDirty());
|
* Return the options manager for the preferences window.
|
||||||
this.hide();
|
* @returns {Deluge.OptionsManager} the options manager
|
||||||
|
*/
|
||||||
|
getOptionsManager: function() {
|
||||||
|
return this.optionsManager;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a page to the preferences window.
|
* Adds a page to the preferences window.
|
||||||
* @param {mixed} page
|
* @param {Mixed} page
|
||||||
*/
|
*/
|
||||||
addPage: function(page) {
|
addPage: function(page) {
|
||||||
var store = this.categoriesGrid.getStore();
|
var store = this.categoriesGrid.getStore();
|
||||||
var name = page.title;
|
var name = page.title;
|
||||||
store.loadData([[name]], true);
|
store.add([new PreferencesRecord({name: name})]);
|
||||||
page['bodyStyle'] = 'margin: 5px';
|
page['bodyStyle'] = 'margin: 5px';
|
||||||
this.pages[name] = this.configPanel.add(page);
|
this.pages[name] = this.configPanel.add(page);
|
||||||
return this.pages[name];
|
return this.pages[name];
|
||||||
|
@ -145,47 +154,56 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the options manager for the preferences window.
|
* Select which preferences page is displayed.
|
||||||
* @returns {Deluge.OptionsManager} the options manager
|
* @param {String} page The page name to change to
|
||||||
*/
|
*/
|
||||||
getOptionsManager: function() {
|
selectPage: function(page) {
|
||||||
return this.optionsManager;
|
var index = this.configPanel.items.indexOf(this.pages[page]);
|
||||||
|
this.configPanel.getLayout().setActiveItem(index);
|
||||||
|
this.currentPage = page;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
onGotConfig: function(config) {
|
onGotConfig: function(config) {
|
||||||
this.getOptionsManager().set(config);
|
this.getOptionsManager().set(config);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
onPageSelect: function(selModel, rowIndex, r) {
|
onPageSelect: function(selModel, rowIndex, r) {
|
||||||
if (this.currentPage == null) {
|
this.selectPage(r.get('name'));
|
||||||
for (var page in this.pages) {
|
|
||||||
this.pages[page].hide();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.currentPage.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = r.get('name');
|
|
||||||
|
|
||||||
this.pages[name].show();
|
|
||||||
this.currentPage = this.pages[name];
|
|
||||||
this.configPanel.doLayout();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
onSetConfig: function() {
|
onSetConfig: function() {
|
||||||
this.getOptionsManager().commit();
|
this.getOptionsManager().commit();
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
// private
|
||||||
|
onAfterRender: function() {
|
||||||
if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
|
if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
|
||||||
this.categoriesGrid.getSelectionModel().selectFirstRow();
|
this.categoriesGrid.getSelectionModel().selectFirstRow();
|
||||||
}
|
}
|
||||||
|
this.configPanel.getLayout().setActiveItem(0);
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onShow: function() {
|
||||||
|
if (!Deluge.Client.core) return;
|
||||||
Deluge.Client.core.get_config({
|
Deluge.Client.core.get_config({
|
||||||
success: this.onGotConfig,
|
success: this.onGotConfig,
|
||||||
scope: this
|
scope: this
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onClose: function() {
|
||||||
|
this.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onOk: function() {
|
||||||
|
Deluge.Client.core.set_config(this.optionsManager.getDirty());
|
||||||
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Deluge.Preferences = new Ext.deluge.PreferencesWindow();
|
Deluge.Preferences = new Ext.deluge.PreferencesWindow();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue