initial commit

This commit is contained in:
equippedcoding-master
2025-09-17 09:37:06 -05:00
parent 86108ca47e
commit e2c98790b2
55389 changed files with 6206730 additions and 0 deletions

View File

@@ -0,0 +1,707 @@
function updateMessage(msg){
//document.getElementById("form_submit_status_1").innerHTML = "<span>"+msg+"</span>";
const collection = document.getElementsByClassName("form_submit_status_1");
for (let i = 0; i < collection.length; i++) {
collection[i].innerHTML = "<span>"+msg+"</span>";
}
}
// called in functions.js
function comp_createEmailAddressForm(){
//console.log(app_config);
var form = app.factory.form();
var visualGraph = {
"section_one": { // Category Selection
"section_two": null, // Public Category
"section_three": { // State Selection
"section_four": null, // Public Category
"section_five": { // Type Selection
"section_seven": null, // Admin Defined | Create Email Invitation
"section_eight": null // User Defined
}
}
}
};
app.static.buildFormGraph(visualGraph,form_data,form);
form.onSubmit({
//id: "",
label: "Submit",
style: "width: 100%;",
className: "",// "btn btn-success",
},function(obj){
console.log(obj);
app.overlay(true,9000);
var values = getValues(obj);
console.log(values);
//console.log(form.getSection());
//return; // mmmm
form.disableOnSubmit(true);
setTimeout(function(){ form.disableOnSubmit(false); }, 8000);
if(form.getSection()=="section_two"){
values['state'] = 1;
values['verified'] = 1; // means an actual email account will be created
if(values.username==null){
updateMessage("Username is Required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
if(values.password==null){
updateMessage("Password is Required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
}else if(form.getSection()=="section_seven"){
values['state'] = 0;
values['verified'] = 0; // means an invitation is being sent and the actual email account has NOT been created yet.
if(values.username==null){
updateMessage("Username is Required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
if(values.sender==""){
updateMessage("Sender Required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
if(values.backupEmail==""){
updateMessage("Recipient email is required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
}else if(form.getSection()=="section_eight"){
// ssss
values['state'] = 0;
values['verified'] = 0; // means an invitation is being sent and the actual email account has NOT been created yet.
if(values.backupEmail==""){
updateMessage("Recipient email is required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
if(values.sender==""){
updateMessage("Sender Required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
}else{
values['state'] = 1;
values['verified'] = 1; // means an actual email account will be created
if(values.username==null || values.password==null){
updateMessage("Username and Password Required!");
form.disableOnSubmit(false);
app.overlay(false);
return;
}
}
var checkData = { check_username: true, username: values.username };
$.post("./core/request.php",checkData,function(resp){
//console.log(resp)
resp = JSON.parse(resp);
if(resp['available'] == true){
//document.getElementById("").innerHTML = "";
updateMessage("");
form.disableOnSubmit(false);
// TODO: make sure required format is being followed to create an email
values['token'] = "";
values['userid'] = values['username'];
values['server'] = app_config['server'];
var data = {
"create_email_account": true,
"state": values["state"],
data: JSON.stringify(values)
}
$.post("./core/request.php", data, function(resp1){
console.log(resp1)
//resp1 = JSON.parse(resp1);// "{\"status\":\"success\"}"
app.overlay(false);
window.app_creationData = values;
app_views["dashboard_email"].render("create-success");
});
}else{
app.overlay(false);
//document.getElementById("").innerHTML = "<span>Username already taken!</span>";
updateMessage("Username already taken!");
}
});
});
form.build();
var layout = app.layout.newLayout()
.row()
.col({md:6,offset_md:3},form)
.build();
return layout;
}
function getValues(obj){
// pppp
// # $1 username
// # $2 password
// # $3 domain
// # $4 level
// # $5 type
// # $6 category
// # $7 backupEmail
// # $8 firstname
// # $9 lastname
// # $10 expiry
// # $11 state
// # $12 sender
var username = dosomemore("username",obj);
var password = dosomemore("password",obj);
var domain = dosomemore("domain",obj);
var level = dosomemore("level",obj);
var type = dosomemore("type",obj);
var category = dosomemore("category",obj);
var backupEmail = dosomemore("backupEmail",obj);
var firstname = dosomemore("firstname",obj);
var lastname = dosomemore("lastname",obj);
var expiry = dosomemore("expiry",obj);
var sender = dosomemore("sender",obj);
var state = obj.state;
if(domain==null || domain==undefined){ domain = app_config.domain; }
if(level==null || level==undefined){ level = 0; }
if(type==null || type==undefined){ type = 0; }
if(category==null || category==undefined){ category = 0; }
if(backupEmail==null || backupEmail==undefined){ backupEmail = "_none_"; }
if(firstname==null || firstname==undefined){ firstname = "_none_"; }
if(lastname==null || lastname==undefined){ lastname = "_none_"; }
if(expiry==null || expiry==undefined){ expiry = "72"; }
return {username,password,domain,level,type,category,backupEmail,firstname,lastname,expiry,state,sender};
}
function dosomemore(param,obj){
var n = null;
for(prop in obj.values){
// ssss
if(prop.includes(param) && (obj.values[prop]!="_none_" && obj.values[prop]!=null && obj.values[prop]!="")){
n = obj.values[prop];
break;
}
}
return n;
}
var form_data = {
section_zero: {
addElements: function(form){},
addEndSection: function(formSection,form){}
},
section_one: {
addConnections: {
"back":{
label: "Back"
},
"section_two": {
label: 'Private Category',
className: "section_one_btn btn btn-dark",
// hhhh
listener: function(e){
form.setElementValue("category", 0);
formSection.goTo("section_three");
}
},
"section_three": {
label: 'Public Category ',
className: "section_one_btn btn btn-dark",
listener: function(e){
form.setElementValue("category", 1);
form.setElementValue("state", 1);
formSection.goTo("section_two");
}
}
},
addElements: function(form){
form.addCustom({
tag:"category",
body: "<p>Select an email category</p>"
+ "<ul><li>Public: A general purpose email.</li>"
+ "<li>Private: A user specific email.</li></ul>"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.setButtons([
// nnnn
formSection.button({
label: 'Private Category',
className: "section_one_btn btn btn-dark",
// hhhh
listener: function(e){
form.setElementValue("category", 0);
formSection.goTo("section_three");
}
}),
formSection.button({
label: 'Public Category ',
className: "section_one_btn btn btn-dark",
listener: function(e){
form.setElementValue("category", 1);
form.setElementValue("state", 1);
formSection.goTo("section_two");
}
})
]);
//formSection.backBtn = true;
//formSection.nextBtn = true;
return formSection;
},
},
section_two: { // Public Category
addElements: function(form){
form.addCustom({
//tag:"section_two_234809",
body: "<h3>Create an Administrator email</h3>"
+ "<p>These emails are typically meant for general purpose use by admins.</p>"
});
form.addInput({
label: 'Email Username',
tag: "username_04534546",
type: "text",
span: {label:"@" + app_config.domain}
});
form.addInput({
label: 'Password',
tag: "password_80934563",
type: "text"
});
// form.addInput({
// label: 'First name',
// tag: "firstname_2930842",
// type: "text"
// });
// form.addInput({
// label: 'Last name',
// tag: "lastname_8009244",
// type: "text"
// });
// form.addInput({
// label: 'Backup Email',
// tag: "backupEmail_9080982",
// type: "text"
// });
// form.addInput({
// label: 'Level - To further categorize email accounts, default is 0.',
// tag: "level_908234",
// type: "number"
// });
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.submit = true;
formSection.setButtons([
formSection.button({
label: 'Back To Category Selection',
listener: function(e){
formSection.goTo("section_one");
}
}),
]);
return formSection;
}
},
section_three: { // State Selection
addElements: function(form){
form.addCustom({
tag:"create_type",
body: "<p>How do you want to create email account?</p>"
+ "<ul>"
+ "<li>Self Setup: Create email account yourself.</li>"
+ "<li>Invitation: Send an invite for user to setup email account.</li>"
+ "</ul>"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.setButtons([
formSection.button({
label: 'Self Setup',
className: "section_one_btn btn btn-dark",
listener: function(e){
form.setElementValue("create_type", 0);
form.setElementValue("state", 1);
formSection.goTo("section_four");
}
}),
formSection.button({
label: 'Invitation',
className: "section_one_btn btn btn-dark",
listener: function(e){
form.setElementValue("create_type", 1);
formSection.goTo("section_five");
}
}),
formSection.button({
label: 'Back',
className: "section_one_btn btn btn-dark",
listener: function(e){
formSection.goTo("section_one");
}
})
]);
return formSection;
}
},
section_four: { // Private Category - Self Setup
addElements: function(form){
form.addCustom({
//tag:"admin_create_fields",
body: "<p>Fill out form fields</p>"
+ "<div class=\"form_submit_status_1\"></div>"
});
form.addInput({
label: 'Email Username*',
tag: "username_092423",
type: "text",
span: {label:"@" + app_config.domain}
});
form.addInput({
label: 'Password*',
tag: "password_8092384",
type: "text"
});
form.addInput({
label: 'First name',
tag: "firstname_2930842",
type: "text"
});
form.addInput({
label: 'Last name',
tag: "lastname_8009244",
type: "text"
});
form.addInput({
label: 'Backup Email',
tag: "backupEmail_9080982",
type: "text"
});
form.addInput({
label: 'Level - To further categorize email accounts, default is 0.',
tag: "level_908234",
type: "number"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.submit = {"_id":2,"label":"Create Email Account"};
formSection.setButtons([
formSection.button({
label: 'Back',
listener: function(e){
formSection.goTo("section_three");
}
}),
]);
return formSection;
}
},
section_five: {// Type Selection
addElements: function(form){
form.addCustom({
//tag:"admin_create",
body: "<p>Choose how the email will be created.</p>"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.setButtons([
formSection.button({
label: 'Admin Defined Email',
className: "section_one_btn btn btn-dark",
listener: function(e){
form.setElementValue("type_8409238", 0);
form.setElementValue("state", 0);
formSection.goTo("section_seven");
}
}),
formSection.button({
label: 'User Defined Email',
className: "section_one_btn btn btn-dark",
listener: function(e){
form.setElementValue("type_8409238", 1);
form.setElementValue("state", 0);
formSection.goTo("section_eight");
}
}),
formSection.button({
label: 'Back',
className: "section_one_btn btn btn-dark",
style: "margin-bottom:10px",
listener: function(e){
formSection.goTo("section_three");
}
})
]);
return formSection;
}
},
section_six: {
addElements: function(form){
form.addCustom({
//tag:"creation_type323",
body: "<p>Choose which type of user email</p>"
});
// mmmm
form.addInput({
label: 'Username',
tag: "username_3289892"
});
form.addInput({
label: 'Email',
tag: "email_2834908"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.setButtons([
formSection.button({
label: 'Back',
listener: function(e){
formSection.goTo("section_one");
}
})
]);
return formSection;
}
},
section_seven: { // Admin Defined
addElements: function(form){
var list = [];
list.push("");
for(var i=0; i < app_config.accounts.length; i++){
var category = app_config.accounts[i]['verified']['category'];
if(category==1){
list.push(app_config.accounts[i]['verified']['username']);
}
}
form.addCustom({
//tag:"admin_create_fields",
body: "<h4>Create Email Invitation</h4>"
+ "<div class=\"form_submit_status_1\"></div>"
});
form.addInput({
label: 'Email Username*',
tag: "username_093456",
type: "text",
span: {label:"@" + app_config.domain}
});
form.addInput({
label: 'Recipient Email*',
tag: "backupEmail_019543854",
type: "text"
});
// ssss
form.addSelection({
tag: 'sender_08230948',
label: "Select Sender*",
//id:"",
//classes: "",
defaultSelection: "",
//paramName: "sender_08230948",//String name of the param for value on submit other wise the id of this element
list: list,
// mmmm
// Fire method every time element changes.
changeListener: function(seletedItem, event){
//console.log(seletedItem);
}
});
form.addInput({
label: 'First name',
tag: "firstname_3980934",
type: "text"
});
form.addInput({
label: 'Last name',
tag: "lastname_553453",
type: "text"
});
form.addInput({
label: 'Level - To further categorize email accounts, default is 0.',
tag: "level_4380194423",
type: "number"
});
form.addInput({
label: 'Expiry - When this invite is no longer valid. Default is 72 hours.',
tag: "expiry_03498589",
type: "number"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.submit = {label:"Send Invitation"};
formSection.setButtons([
formSection.button({
label: 'Back',
listener: function(e){
formSection.goTo("section_five");
}
})
]);
return formSection;
}
},
section_eight: {
addElements: function(form){
form.addCustom({
tag:"type_8409238",
body: "<h4>User Defined - Create Email Invitation</h4>"
+ "<div class=\"form_submit_status_1\"></div>"
});
// form.addInput({
// label: 'Email*',
// tag: "username_093456",
// type: "text",
// span: {label:"@" + app_config.domain}
// });
form.addInput({
label: 'Recipient Email*',
tag: "backupEmail_01954345456",
type: "text"
});
var list = [];
list.push("");
for(var i=0; i < app_config.accounts.length; i++){
var category = app_config.accounts[i]['verified']['category'];
if(category==1){
list.push(app_config.accounts[i]['verified']['username']);
}
}
form.addSelection({
tag: 'sender_0833456403845',
label: "Select Sender *",
//id:"",
//classes: "",
defaultSelection: "",
//paramName: "sender_08230948",//String name of the param for value on submit other wise the id of this element
list: list,
// mmmm
// Fire method every time element changes.
changeListener: function(seletedItem, event){
//console.log(seletedItem);
}
});
form.addInput({
label: 'Level - To further categorize email accounts, default is 0.',
tag: "level_4380194234",
type: "number"
});
form.addInput({
label: 'Expiry - When this invite is no longer valid. Default is 72 hours.',
tag: "expiry_0349345",
type: "number"
});
return form;
},
addEndSection: function(formSection,form){
formSection.type = 'page';
formSection.submit = {"label":"Send Invitation"};
formSection.setButtons([
formSection.button({
label: 'Back',
listener: function(e){
formSection.goTo("section_five");
}
})
]);
return formSection;
}
},
};
function comp_CreateNewEmail(){
var form = app.factory.form('form_one');
// Input
form.addInput({
//all: "myinput",
tag: "myinput",
selector: '#myinput',
paramName: 'myinput',
// layout the form elements in bootstrap4
// specifing row starts a new row
layout: {
row: true,
col: {md:12}
},
});
form.onSubmit({
//id: "",
label: "Submit",
style: "width: 100%;",
className: "btn btn-success",
return: 'array'
},function(obj){
console.log(obj);
// type
// backup
// address
// password
// domain
});
form.build();
return form;
}