This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
technical_discussions:click_to_connect_extra [2021/10/24 19:02] – [CakePHP3 App Side] admin | technical_discussions:click_to_connect_extra [2021/10/24 19:28] (current) – [Modify the Login Pages for the Extra Options] admin | ||
---|---|---|---|
Line 184: | Line 184: | ||
}, | }, | ||
</ | </ | ||
- | * Next we will see what we need to modify on the CakePHP3 App Side | + | |
+ | * There is a dedicated Wiki Page in this site for it. | ||
+ | | ||
==== CakePHP3 App Side ==== | ==== CakePHP3 App Side ==== | ||
Line 358: | Line 360: | ||
==== Modify the Login Pages for the Extra Options ==== | ==== Modify the Login Pages for the Extra Options ==== | ||
+ | * Locate the file rdConnect.js. | ||
+ | * It is typically under /// | ||
+ | * We need to add a flag to set if we created the pop-up window (**ctcFormDone**) | ||
+ | <code javascript> | ||
+ | cMinWidth | ||
+ | scrollHeight | ||
+ | |||
+ | var ctcFormDone | ||
+ | |||
+ | fDebug | ||
+ | if(cDebug){ | ||
+ | console.log(message) | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | </ | ||
+ | * Next we have to add some **OR** coonditions when the user click on the **Click To Connect** button | ||
+ | <code javascript> | ||
+ | var email_check = location.protocol+'//' | ||
+ | |||
+ | webix.ajax().timeout(3000).post( | ||
+ | email_check, | ||
+ | error : function(text, | ||
+ | console.log(" | ||
+ | }, | ||
+ | success : function(text, | ||
+ | if(data.json().success == true){ | ||
+ | if((data.json().data.ctc_require_email == true)||(data.json().data.ctc_require_phone == true)||(data.json().data.ctc_require_dn == true)){ | ||
+ | if(ctcFormDone == false){ //If not already done | ||
+ | buildClickToConnectForm(data.json().data); | ||
+ | } | ||
+ | showForm(" | ||
+ | }else{ | ||
+ | onBtnClickToConnectClick(); | ||
+ | } | ||
+ | }else{ | ||
+ | console.log(" | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
+ | * Lets then see the function that is called **buildClickToConnectForm**. | ||
+ | * This is called only once. | ||
+ | * We also include validation rules for those fields. | ||
+ | <code javascript> | ||
+ | var buildClickToConnectForm = function(data){ | ||
+ | |||
+ | console.log(" | ||
+ | console.log(data); | ||
+ | var e1 = { | ||
+ | view : " | ||
+ | template | ||
+ | }; | ||
+ | var e2 = { view:" | ||
+ | var e3 = { view:" | ||
+ | var e4 = { view:" | ||
+ | var b1 = { view:" | ||
+ | if (this.getParentView().validate()){ //validate form | ||
+ | var button | ||
+ | var formData | ||
+ | var mac_address = getParameterByName(' | ||
+ | formData.append(" | ||
+ | | ||
+ | var values | ||
+ | console.log(values); | ||
+ | if(values.email){ | ||
+ | formData.append(" | ||
+ | } | ||
+ | if(values.phone){ | ||
+ | formData.append(" | ||
+ | } | ||
+ | if(values.dn){ | ||
+ | formData.append(" | ||
+ | } | ||
+ | | ||
+ | |||
+ | //We also add the following | ||
+ | var called | ||
+ | formData.append(" | ||
+ | |||
+ | var nasid = getParameterByName(' | ||
+ | formData.append(" | ||
+ | |||
+ | //This might not always be included | ||
+ | var ssid = getParameterByName(' | ||
+ | if(ssid !== '' | ||
+ | formData.append(" | ||
+ | } | ||
+ | | ||
+ | var add_mac | ||
+ | webix.ajax().timeout(3000).post( | ||
+ | add_mac, | ||
+ | formData, | ||
+ | { | ||
+ | error : function(text, | ||
+ | console.log(" | ||
+ | }, | ||
+ | success : function(text, | ||
+ | if(data.json().success == true){ | ||
+ | // | ||
+ | webix.message(" | ||
+ | button.getTopParentView().hide(); | ||
+ | onBtnClickToConnectClick(); | ||
+ | | ||
+ | }else{ | ||
+ | // | ||
+ | webix.message({ type:" | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | | ||
+ | } | ||
+ | else | ||
+ | webix.message({ type:" | ||
+ | }}; | ||
+ | | ||
+ | var elements = [e1]; | ||
+ | var height | ||
+ | var rules = {}; | ||
+ | | ||
+ | if(data.ctc_require_email == true){ | ||
+ | elements.push(e2); | ||
+ | height = height+60; | ||
+ | rules.email = webix.rules.isEmail; | ||
+ | } | ||
+ | if(data.ctc_require_phone == true){ | ||
+ | elements.push(e3); | ||
+ | height | ||
+ | rules.phone = function(value){ | ||
+ | if (! / | ||
+ | webix.message(" | ||
+ | return false; | ||
+ | } | ||
+ | return true; | ||
+ | }; | ||
+ | } | ||
+ | if(data.ctc_require_dn == true){ | ||
+ | elements.push(e4); | ||
+ | height = height+60; | ||
+ | rules.dn = function(value){ | ||
+ | if (! / | ||
+ | webix.message(" | ||
+ | return false; | ||
+ | } | ||
+ | return true; | ||
+ | }; | ||
+ | } | ||
+ | elements.push(b1); | ||
+ | | ||
+ | frmEmail = { | ||
+ | view :" | ||
+ | borderless | ||
+ | elements | ||
+ | rules : | ||
+ | elementsConfig: | ||
+ | labelPosition:" | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | | ||
+ | view : " | ||
+ | id : " | ||
+ | head : false, | ||
+ | height | ||
+ | body : | ||
+ | }); | ||
+ | | ||
+ | ctcFormDone = true; | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | * That brings us to the totality of the changes required. | ||
+ | * These login pages does not need any further optimization. (They are done using Webix) | ||
+ | |||