AuthKeyCard.js (2080B)
1 /** 2 * This card displays the input field for the authentication key. 3 */ 4 Ext.define('PartKeeprSetup.AuthKeyCard', { 5 extend: 'Ext.form.Panel', 6 7 /** 8 * Various Style Settings 9 */ 10 margin: 20, 11 autoScroll: true, 12 breadCrumbTitle: 'Authentication Key', 13 14 defaults: { 15 labelWidth: 120 16 }, 17 border: false, 18 bodyStyle: 'background: none;', 19 20 /** 21 * Inits the component 22 */ 23 initComponent: function () 24 { 25 this.authKey = Ext.create("Ext.form.field.Text", { 26 fieldLabel: 'Authentication Key', 27 labelWidth: this.defaults.labelWidth, 28 allowBlank: false, 29 minLength: 32, 30 maxLength: 32, 31 minLengthText: "The authentication key must be 32 characters", 32 maxLengthText: "The authentication key must be 32 characters", 33 value: PartKeeprSetup.getApplication().getSetupConfig().authKey 34 }); 35 36 this.authKey.on("change", this.onUpdateParameters, this); 37 38 this.items = [ 39 { 40 border: false, 41 bodyStyle: 'background:none;padding-bottom: 10px;', 42 html: 'In order to protect unauthorized users to re-run setup, please open the file <strong>app/authkey.php</strong> and paste the authentication key in the field below:' 43 }, 44 this.authKey 45 ]; 46 47 this.callParent(); 48 this.on("activate", this.onActivate, this); 49 }, 50 /** 51 * Gets called when the card is activated 52 */ 53 onActivate: function () 54 { 55 Ext.ComponentQuery.query('#nextBtn')[0].disable(); 56 this.authKey.focus(); 57 this.onUpdateParameters(); 58 }, 59 onUpdateParameters: function () 60 { 61 if (this.authKey.isValid()) { 62 var config = PartKeeprSetup.getApplication().getSetupConfig(); 63 64 Ext.merge(config, {authKey: this.authKey.getValue()}); 65 66 Ext.ComponentQuery.query('#nextBtn')[0].enable(); 67 } else { 68 Ext.ComponentQuery.query('#nextBtn')[0].disable(); 69 } 70 71 } 72 });