1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00

update domain id

This commit is contained in:
Damodar Lohani 2021-08-05 11:09:41 +05:45
parent f173218104
commit ef6831d651
4 changed files with 24 additions and 9 deletions

View file

@ -427,6 +427,16 @@ $smtpEnabled = $this->getParam('smtpEnabled', false);
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<label for="keyId">Domain ID</label>
<input
type="hidden"
data-custom-id
data-id-type="auto"
data-validator="projects.getDomain"
required
maxlength="36"
name="domainId" />
<label for="name">Domain Name</label>
<input type="text" class="full-width" id="domain" name="domain" placeholder="appwrite.example.com" required autocomplete="off" title="Enter a valid domain name" pattern="^([a-zA-Z0-9][a-zA-Z0-9-_]*\.)*[a-zA-Z0-9]*[a-zA-Z0-9-_]*[[a-zA-Z0-9]+$" />

View file

@ -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=key<ZERO||key>NINE;const isNotValidSmallAlphabet=key<SMALL_A||key>SMALL_Z;const isNotValidCapitalAlphabet=key<CAPITAL_A||key>CAPITAL_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;}

View file

@ -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=key<ZERO||key>NINE;const isNotValidSmallAlphabet=key<SMALL_A||key>SMALL_Z;const isNotValidCapitalAlphabet=key<CAPITAL_A||key>CAPITAL_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;}

View file

@ -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) {