From ef6831d651e8e2509508d83bd0d24b71a234ebca Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 5 Aug 2021 11:09:41 +0545 Subject: [PATCH] update domain id --- app/views/console/settings/index.phtml | 10 ++++++++++ public/dist/scripts/app-all.js | 7 ++++--- public/dist/scripts/app.js | 7 ++++--- public/scripts/views/forms/custom-id.js | 9 ++++++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/views/console/settings/index.phtml b/app/views/console/settings/index.phtml index e7f1282bb9..b1fb3bd5bd 100644 --- a/app/views/console/settings/index.phtml +++ b/app/views/console/settings/index.phtml @@ -427,6 +427,16 @@ $smtpEnabled = $this->getParam('smtpEnabled', false); + + + diff --git a/public/dist/scripts/app-all.js b/public/dist/scripts/app-all.js index e4fdb4e6e0..4f13a9de63 100644 --- a/public/dist/scripts/app-all.js +++ b/public/dist/scripts/app-all.js @@ -2390,13 +2390,14 @@ function syncB(){picker.value=element.value;} element.parentNode.insertBefore(preview,element);update();syncB();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-copy",controller:function(element,alerts,document,window){var button=window.document.createElement("i");button.type="button";button.className="icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);var copy=function(event){let disabled=element.disabled;element.disabled=false;element.focus();element.select();document.execCommand("Copy");if(document.selection){document.selection.empty();}else if(window.getSelection){window.getSelection().removeAllRanges();} element.disabled=disabled;element.blur();alerts.add({text:"Copied to clipboard",class:""},3000);};button.addEventListener("click",copy);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-custom-id",controller:function(element,sdk,console){let prevData="";let idType=element.dataset["id-type"];const div=window.document.createElement("div");div.className="input-copy";const button=window.document.createElement("i");button.type="button";button.style.cursor="pointer";const writer=document.createElement("input");writer.type="text";writer.className="";writer.setAttribute("maxlength",element.getAttribute("maxlength"));const placeholder=element.getAttribute("placeholder");if(placeholder){writer.setAttribute("placeholder",placeholder);} const info=document.createElement("div");info.className="text-fade text-size-xs margin-top-negative-small margin-bottom";div.appendChild(writer);div.appendChild(button);element.parentNode.insertBefore(div,element);element.parentNode.insertBefore(info,div.nextSibling);const switchType=function(event){if(idType=="custom"){idType="auto";setIdType(idType);}else{idType="custom";setIdType(idType);}} -const validate=function(event){const[service,method]=element.dataset["validator"].split('.');const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{switch(service){case'projects':if(method=='getPlatform'){const projectId=element.form.elements.namedItem("projectId").value;setValidity(console[service][method](projectId,value),event.target);}else{setValidity(console[service][method](value),event.target);} +const validate=function(event){const[service,method]=element.dataset["validator"].split('.');const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{switch(service){case'projects':if(method=='getPlatform'||method=='getDomain'){const projectId=element.form.elements.namedItem("projectId").value;setValidity(console[service][method](projectId,value),event.target);}else{setValidity(console[service][method](value),event.target);} break;case'teams':if(method=='getMembership'){const teamId=element.form.elements.namedItem("teamId").value;setValidity(sdk[service][method](teamId,value),event.target);}else{setValidity(sdk[service][method](teamId,value),event.target);} break;default:setValidity(sdk[service][method](value),event.target);}}} const setValidity=async function(promise,target){try{await promise;target.setCustomValidity("ID already exists");}catch(e){target.setCustomValidity("");}} -const setIdType=function(idType){element.setAttribute("data-id-type",idType);if(idType=="custom"){info.innerHTML="Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="Appwrite will generate a unique ID";prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';} +const setIdType=function(idType){element.setAttribute("data-id-type",idType);if(idType=="custom"){info.innerHTML="Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="Appwrite will generate an unique ID";prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';} button.className=idType=="custom"?"icon-shuffle copy":"icon-edit copy";} -const syncEditorWithID=function(event){if(element.value!=='unique()'){writer.value=element.value;}} +const syncEditorWithID=function(event){if(element.value!=='unique()'||idType!='auto'){writer.value=element.value;} +if(idType=='auto'){element.value='unique()';}} const keypress=function(e){const key=e.which||e.keyCode;const ZERO=48;const NINE=57;const SMALL_A=97;const SMALL_Z=122;const CAPITAL_A=65;const CAPITAL_Z=90;const UNDERSCORE=95;const isNotValidDigit=keyNINE;const isNotValidSmallAlphabet=keySMALL_Z;const isNotValidCapitalAlphabet=keyCAPITAL_Z;if(key==UNDERSCORE&&e.target.value.length==0){e.preventDefault();} if(key!=UNDERSCORE&&isNotValidDigit&&isNotValidSmallAlphabet&&isNotValidCapitalAlphabet){e.preventDefault();}} syncEditorWithID();setIdType(idType);writer.addEventListener("change",function(event){element.value=writer.value;});writer.addEventListener('keypress',keypress);button.addEventListener("click",switchType);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-document",controller:function(element,container,search){var formsDocument=(element.dataset["formsDocument"]||'');var searchButton=(element.dataset["search"]||0);let path=container.scope(searchButton);element.addEventListener('click',function(){search.selected=element.value;search.path=path;document.dispatchEvent(new CustomEvent(formsDocument,{bubbles:false,cancelable:true}));});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-document-preview",controller:function(element,container,search){element.addEventListener('change',function(){console.log(element.value);});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-forms-filter",controller:function(document,container,expression,element,form,di){let name=element.dataset["formsFilter"]||"";let events=element.dataset["event"]||"";let serialize=function(obj,prefix){let str=[],p;for(p in obj){if(obj.hasOwnProperty(p)){let k=prefix?prefix+"["+p+"]":p,v=obj[p];if(v===""){continue;} diff --git a/public/dist/scripts/app.js b/public/dist/scripts/app.js index 13eac0b510..f43b3692c6 100644 --- a/public/dist/scripts/app.js +++ b/public/dist/scripts/app.js @@ -358,13 +358,14 @@ function syncB(){picker.value=element.value;} element.parentNode.insertBefore(preview,element);update();syncB();}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-copy",controller:function(element,alerts,document,window){var button=window.document.createElement("i");button.type="button";button.className="icon-docs note copy";button.style.cursor="pointer";element.parentNode.insertBefore(button,element.nextSibling);var copy=function(event){let disabled=element.disabled;element.disabled=false;element.focus();element.select();document.execCommand("Copy");if(document.selection){document.selection.empty();}else if(window.getSelection){window.getSelection().removeAllRanges();} element.disabled=disabled;element.blur();alerts.add({text:"Copied to clipboard",class:""},3000);};button.addEventListener("click",copy);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-custom-id",controller:function(element,sdk,console){let prevData="";let idType=element.dataset["id-type"];const div=window.document.createElement("div");div.className="input-copy";const button=window.document.createElement("i");button.type="button";button.style.cursor="pointer";const writer=document.createElement("input");writer.type="text";writer.className="";writer.setAttribute("maxlength",element.getAttribute("maxlength"));const placeholder=element.getAttribute("placeholder");if(placeholder){writer.setAttribute("placeholder",placeholder);} const info=document.createElement("div");info.className="text-fade text-size-xs margin-top-negative-small margin-bottom";div.appendChild(writer);div.appendChild(button);element.parentNode.insertBefore(div,element);element.parentNode.insertBefore(info,div.nextSibling);const switchType=function(event){if(idType=="custom"){idType="auto";setIdType(idType);}else{idType="custom";setIdType(idType);}} -const validate=function(event){const[service,method]=element.dataset["validator"].split('.');const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{switch(service){case'projects':if(method=='getPlatform'){const projectId=element.form.elements.namedItem("projectId").value;setValidity(console[service][method](projectId,value),event.target);}else{setValidity(console[service][method](value),event.target);} +const validate=function(event){const[service,method]=element.dataset["validator"].split('.');const value=event.target.value;if(value.length<1){event.target.setCustomValidity("ID is required");}else{switch(service){case'projects':if(method=='getPlatform'||method=='getDomain'){const projectId=element.form.elements.namedItem("projectId").value;setValidity(console[service][method](projectId,value),event.target);}else{setValidity(console[service][method](value),event.target);} break;case'teams':if(method=='getMembership'){const teamId=element.form.elements.namedItem("teamId").value;setValidity(sdk[service][method](teamId,value),event.target);}else{setValidity(sdk[service][method](teamId,value),event.target);} break;default:setValidity(sdk[service][method](value),event.target);}}} const setValidity=async function(promise,target){try{await promise;target.setCustomValidity("ID already exists");}catch(e){target.setCustomValidity("");}} -const setIdType=function(idType){element.setAttribute("data-id-type",idType);if(idType=="custom"){info.innerHTML="Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="Appwrite will generate a unique ID";prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';} +const setIdType=function(idType){element.setAttribute("data-id-type",idType);if(idType=="custom"){info.innerHTML="Allowed Characters A-Z, a-z, 0-9, and non-leading underscore";writer.value=prevData;writer.disabled=false;element.value=prevData;writer.focus();writer.addEventListener('blur',validate);}else{info.innerHTML="Appwrite will generate an unique ID";prevData=writer.value;writer.disabled=true;writer.value='auto-generated';element.value='unique()';} button.className=idType=="custom"?"icon-shuffle copy":"icon-edit copy";} -const syncEditorWithID=function(event){if(element.value!=='unique()'){writer.value=element.value;}} +const syncEditorWithID=function(event){if(element.value!=='unique()'||idType!='auto'){writer.value=element.value;} +if(idType=='auto'){element.value='unique()';}} const keypress=function(e){const key=e.which||e.keyCode;const ZERO=48;const NINE=57;const SMALL_A=97;const SMALL_Z=122;const CAPITAL_A=65;const CAPITAL_Z=90;const UNDERSCORE=95;const isNotValidDigit=keyNINE;const isNotValidSmallAlphabet=keySMALL_Z;const isNotValidCapitalAlphabet=keyCAPITAL_Z;if(key==UNDERSCORE&&e.target.value.length==0){e.preventDefault();} if(key!=UNDERSCORE&&isNotValidDigit&&isNotValidSmallAlphabet&&isNotValidCapitalAlphabet){e.preventDefault();}} syncEditorWithID();setIdType(idType);writer.addEventListener("change",function(event){element.value=writer.value;});writer.addEventListener('keypress',keypress);button.addEventListener("click",switchType);}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-document",controller:function(element,container,search){var formsDocument=(element.dataset["formsDocument"]||'');var searchButton=(element.dataset["search"]||0);let path=container.scope(searchButton);element.addEventListener('click',function(){search.selected=element.value;search.path=path;document.dispatchEvent(new CustomEvent(formsDocument,{bubbles:false,cancelable:true}));});}});})(window);(function(window){"use strict";window.ls.container.get("view").add({selector:"data-forms-document-preview",controller:function(element,container,search){element.addEventListener('change',function(){console.log(element.value);});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-forms-filter",controller:function(document,container,expression,element,form,di){let name=element.dataset["formsFilter"]||"";let events=element.dataset["event"]||"";let serialize=function(obj,prefix){let str=[],p;for(p in obj){if(obj.hasOwnProperty(p)){let k=prefix?prefix+"["+p+"]":p,v=obj[p];if(v===""){continue;} diff --git a/public/scripts/views/forms/custom-id.js b/public/scripts/views/forms/custom-id.js index 034a19d252..326e351848 100644 --- a/public/scripts/views/forms/custom-id.js +++ b/public/scripts/views/forms/custom-id.js @@ -48,7 +48,7 @@ } else { switch(service) { case 'projects': - if (method == 'getPlatform') { + if (method == 'getPlatform' || method == 'getDomain') { const projectId = element.form.elements.namedItem("projectId").value; setValidity(console[service][method](projectId, value), event.target); } else { @@ -88,7 +88,7 @@ writer.focus(); writer.addEventListener('blur', validate); } else { - info.innerHTML = "Appwrite will generate a unique ID"; + info.innerHTML = "Appwrite will generate an unique ID"; prevData = writer.value; writer.disabled = true; writer.value = 'auto-generated'; @@ -98,9 +98,12 @@ } const syncEditorWithID = function (event) { - if (element.value !== 'unique()') { + if (element.value !== 'unique()' || idType != 'auto') { writer.value = element.value; } + if(idType == 'auto') { + element.value = 'unique()'; + } } const keypress = function (e) {