move the code that updates the buttons in the CM depending on the host status into a single method
This commit is contained in:
parent
eae452dbe4
commit
a0a8c598da
|
@ -265,6 +265,39 @@ Copyright:
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the buttons in the Connection Manager UI according to the
|
||||||
|
* passed in records host state.
|
||||||
|
* @param {Ext.data.Record} record The hosts record to update the UI for
|
||||||
|
*/
|
||||||
|
updateButtons: function(record) {
|
||||||
|
var button = this.buttons[1], status = record.get('status');
|
||||||
|
|
||||||
|
// Update the Connect/Disconnect button
|
||||||
|
if (status == _('Connected')) {
|
||||||
|
button.enable();
|
||||||
|
button.setText(_('Disconnect'));
|
||||||
|
} else if (status == _('Offline')) {
|
||||||
|
button.disable();
|
||||||
|
} else {
|
||||||
|
button.enable();
|
||||||
|
button.setText(_('Connect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the Stop/Start Daemon button
|
||||||
|
if (status == _('Offline')) {
|
||||||
|
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
||||||
|
this.stopHostButton.enable();
|
||||||
|
this.stopHostButton.setText(_('Start Daemon'));
|
||||||
|
} else {
|
||||||
|
this.stopHostButton.disable();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.stopHostButton.enable();
|
||||||
|
this.stopHostButton.setText(_('Stop Daemon'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onAdd: function(button, e) {
|
onAdd: function(button, e) {
|
||||||
if (!this.addWindow) {
|
if (!this.addWindow) {
|
||||||
this.addWindow = new Ext.deluge.AddConnectionWindow();
|
this.addWindow = new Ext.deluge.AddConnectionWindow();
|
||||||
|
@ -324,22 +357,7 @@ Copyright:
|
||||||
record.set('status', host[3])
|
record.set('status', host[3])
|
||||||
record.set('version', host[4])
|
record.set('version', host[4])
|
||||||
record.commit();
|
record.commit();
|
||||||
|
if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record);
|
||||||
var button = this.buttons[1], status = record.get('status');
|
|
||||||
if (this.grid.getSelectionModel().getSelected() == record) {
|
|
||||||
var status = record.get('status');
|
|
||||||
if (status == _('Offline')) {
|
|
||||||
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
|
||||||
this.stopHostButton.enable();
|
|
||||||
this.stopHostButton.setText(_('Start Daemon'));
|
|
||||||
} else {
|
|
||||||
this.stopHostButton.disable();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.stopHostButton.enable();
|
|
||||||
this.stopHostButton.setText(_('Stop Daemon'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onLogin: function() {
|
onLogin: function() {
|
||||||
|
@ -399,22 +417,7 @@ Copyright:
|
||||||
this.removeHostButton.disable();
|
this.removeHostButton.disable();
|
||||||
this.stopHostButton.disable();
|
this.stopHostButton.disable();
|
||||||
}
|
}
|
||||||
|
this.updateButtons(record);
|
||||||
var button = this.buttons[1], status = record.get('status');
|
|
||||||
if (status == _('Connected')) {
|
|
||||||
button.enable();
|
|
||||||
button.setText(_('Disconnect'));
|
|
||||||
} else if (status == _('Offline')) {
|
|
||||||
button.disable();
|
|
||||||
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
|
||||||
this.stopHostButton.setText(_('Start Daemon'));
|
|
||||||
} else {
|
|
||||||
this.stopHostButton.disable();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
button.enable();
|
|
||||||
button.setText(_('Connect'));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
|
|
Loading…
Reference in New Issue