partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 9d0e500cd4caa02657350c384195699f6406530e
parent 0c9c46de0a9b2b6e076a9562d59aa4ecf1c77f98
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri, 23 Dec 2011 05:20:53 +0100

Added support for specifying the database port

Diffstat:
Msrc/setup/js/Cards/DatabaseParametersCard.MySQL.js | 51++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 7 deletions(-)

diff --git a/src/setup/js/Cards/DatabaseParametersCard.MySQL.js b/src/setup/js/Cards/DatabaseParametersCard.MySQL.js @@ -21,10 +21,10 @@ Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', { */ initComponent: function () { this.createHintTemplate = Ext.create("Ext.Template", [ - "<code>CREATE DATABASE {dbname} CHARACTER SET UTF8;<br/>GRANT USAGE ON *.* TO {user}@{host} IDENTIFIED BY '{password}';<br/>GRANT ALL PRIVILEGES ON {dbname}.* TO {user}@{host};<br/><br/>" + "<code>CREATE DATABASE {dbname} CHARACTER SET UTF8;<br/>GRANT USAGE ON *.* TO {user}@{localhost} IDENTIFIED BY '{password}';<br/>GRANT ALL PRIVILEGES ON {dbname}.* TO {user}@{localhost};<br/><br/>" ]); - this.masterTemplate = Ext.create("Ext.Template", ["The database must be manually created prior installation. Please note that we don't support UNIX sockets at this time - only TCP connections are supported." ]); + this.masterTemplate = Ext.create("Ext.Template", ["The database must be manually created prior installation." ]); this.hostname = Ext.create("Ext.form.field.Text", { fieldLabel: 'Database Hostname', @@ -56,8 +56,9 @@ Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', { this.databaseName.on("change", this.onUpdateParameters, this); this.port = Ext.create("Ext.form.field.Number", { - fieldLabel: 'Database Port', minValue: 0, + flex: 1, + disabled: true, value: '3306', labelWidth: this.defaults.labelWidth, validateOnBlur: true, @@ -70,6 +71,23 @@ Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', { } }); + this.portDefault = Ext.create("Ext.form.field.Checkbox", { + boxLabel: 'Default', + flex: 1, + checked: true, + listeners: { + change: function (field) { + if (field.getValue()) { + this.port.disable(); + this.port.setValue(3306); + } else { + this.port.enable(); + } + }, + scope: this + } + }); + this.showHintCheckbox = Ext.create("Ext.form.field.Checkbox", { xtype: 'checkboxfield', boxLabel: 'Show commands to create the database', @@ -91,7 +109,15 @@ Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', { this.databaseName, this.username, this.password, - this.port + { + xtype: 'fieldcontainer', + labelWidth: this.defaults.labelWidth, + layout: 'hbox', + width: 300, + fieldLabel: 'Database Port', + items: [ this.port, this.portDefault ] + } + ] },{ xtype: 'panel', @@ -125,8 +151,16 @@ Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', { */ onUpdateParameters: function () { if (this.showHintCheckbox.checked) { + var host; + + if (this.hostname.getValue() == "localhost" || this.hostname.getValue() == "127.0.0.1") { + host = this.hostname.getValue(); + } else { + host = "&lt;YOUR-CONNECTING-IP&gt;"; + } + this.createHintTemplate.overwrite(Ext.get("mysql-parameters-hint"), { - host: this.hostname.getValue(), + localhost: host, user: this.username.getValue(), password: this.password.getValue(), dbname: this.databaseName.getValue() @@ -151,8 +185,11 @@ Ext.define('PartKeeprSetup.DatabaseParametersCard.MySQL', { dbname: this.databaseName.getValue() }; - if (this.port.getValue() != 3306) { - this.paramsheet.dbparams.port = this.port.getValue(); + if (!this.portDefault.getValue()) { + if (this.port.getValue() != 3306) { + this.paramsheet.dbparams.port = this.port.getValue(); + } } + } }); \ No newline at end of file