if(!$_$.autoFill && $_$.appId!="") { $_$.appId = _$$appId.substr(1, _$$appId.length) } var _$$imageUrl = (function() { // if(_$$product=="analytics_aimagin_com") return "https://iot.aimagin.com/files/images/png/aimagin-analytics-logo-login.png"; // else if(_$$product=="emacs_aimagin_com" || _$$product=="iot_aimagin_com") // return "https://iot.aimagin.com/files/images/png/aimagin_big_logo_transparent.png"; })(); function log_in_page() { let div = d3.select("body").attr("class", "be-splash-screen") .append("div").attr("class", "be-wrapper be-login").append("div").attr("class", "be-content") .append("div").attr("class", "main-content container-fluid").append("div").attr("class", "splash-container"); div = div.append("div").attr("class", "card card-border-color card-border-color-primary"); let card = div.append("div").attr("class", "card-header"); card.append("img").attr("src", _$$imageUrl).attr("class", "logo-img").attr("alt", "logo").style("width", "90%"); //condisder height control let form = div.append("div").attr("class", "card-body").style("padding-top", "0px").append("form"); form.append("div").attr("class", "form-group").append("input").attr("class", "form-control").attr("id", "appId").attr("type","text") .attr("onkeyup", "this.value = this.value.toLowerCase();").attr("onchange", "this.value = this.value.toLowerCase();") .property("placeholder", "Organization ID").attr("autocomplete", "on").property("value", $_$.appId).style("display", $_$.autoFill?"none":""); form.append("div").attr("class", "form-group").append("input").attr("class", "form-control").attr("id", "username").attr("type","text") .property("placeholder", "Username").attr("autocomplete", "on") .attr("onchange", "if(this.value.indexOf('@')>=0) {this.value = this.value.toLowerCase();}").attr("onkeyup", "this.value = this.value.toLowerCase();"); let input_group = form.append("div").attr("class", "form-group").append("div").attr("class", "input-group mb-3"); input_group.append("input").attr("class", "form-control").attr("id", "pwd").attr("type","password") .property("placeholder", "Password"); input_group.append("div").attr("class", "input-group-append") .append("a").attr("class", "btn btn-secondary btn-xl").attr("href", "#") .html("") .on("click", function(e) { if(d3.select("#pwd").attr("type")=="password") { d3.select("#pwd").attr("type", "text"); d3.select("#eye").attr("class", "fa fa-eye-slash"); } else { d3.select("#pwd").attr("type", "password"); d3.select("#eye").attr("class", "fa fa-eye"); } }); let login_tools = form.append("div").attr("class", "form-group row login-tools").style("padding-top", "0px").style("margin-bottom", "0px"); login_tools.append("div").attr("class", "col-6 login-remember"); login_tools.append("div").attr("class", "col-6 login-forgot-password") .append("a").html("Forgot Password?").attr("href", "#").on("click", forgot_password_page); form.append("div").attr("class", "form-group login-submit") .append("button").attr("class", "btn btn-primary btn-xl").attr("data-dismiss", "modal").html("Log in").attr("id", "submit") .attr("href", "#").on("click", function(e) { d3.event.preventDefault(); if (d3.select(".be-login").select("#appId").property("value")=="") { alert("Please check your Organization ID!"); return; } d3.select(".be-login").select("#submit").property("disabled", true); let req = new XMLHttpRequest(); req.open("POST", window.origin+"/login", true); req.responseType = "json"; req.onload = function(e) { //console.log(req.response); if (req.response.res) { log_in_page = null; forgot_password_page = null; d3.select('body').attr("class", ""); d3.select(".be-login").remove(); eval(req.response.app); no_role_page = null; } else { alert(req.response.text); d3.select(".be-login").select("#submit").property("disabled", false); } }; let log = {event:"Log in", page:"", description:"Manual login"}; $_$.genLogDatetime(log); req.send(JSON.stringify({ '_': '1', '0': d3.select(".be-login").select("#username").property("value"), '1': d3.select(".be-login").select("#pwd").property("value"), '2':localStorage.ip, appId:d3.select(".be-login").select("#appId").property("value"), log:log })); }); } function forgot_password_page() { d3.select(".be-login").select(".splash-container").attr("class", "splash-container forgot-password"); d3.select(".be-login").select(".splash-container").append("div").attr("class", "splash-footer").html("© 2018 Aimagin Co., Ltd.") d3.select(".be-login").select(".splash-description").html("Forgot your password?"); let div = d3.select(".be-login").select(".card-body"); div.select("form").remove(); let form = div.append("form"); form.append("div").attr("class", "form-group pt-4").append("input").attr("class", "form-control") .attr("type", "text").attr("name", "email").attr("required","").property("placeholder", "Organization ID").attr("id", "appId") .attr("autocomplete", "on").property("value", $_$.appId).style("display", $_$.autoFill?"none":"") .attr("onchange", "this.value = this.value.toLowerCase();").attr("onkeyup", "this.value = this.value.toLowerCase();"); form.append("div").attr("class", "form-group").append("input").attr("class", "form-control") .attr("type", "email").attr("name", "email").attr("required","").property("placeholder", "Your Email").attr("id", "email") .attr("autocomplete", "on").attr("onchange", "if(this.value.indexOf('@')>=0) {this.value = this.value.toLowerCase();}")//.attr("onkeyup", "this.value = this.value.toLowerCase();"); form.append("div").attr("class", "form-group pt-1").append("button").attr("class", "btn btn-block btn-primary btn-xl").attr("href", "#").html("Reset password") .on("click", function(e) { d3.event.preventDefault(); if (d3.select(".forgot-password").select("#email").property("value") == "") { alert("Please enter your email"); return; } if (d3.select(".forgot-password").select("#email").property("value").indexOf("@") < 0) { alert("Please check your email!"); return; } if (d3.select(".forgot-password").select("#appId").property("value")=="") { alert("Please check your Organization ID!"); return; } let email = d3.select(".forgot-password").select("#email").property("value"); let appId = d3.select(".be-login").select("#appId").property("value"); let req = new XMLHttpRequest(); req.open("POST", window.origin + "/reset", true); req.responseType = "json"; req.onload = function(e) { d3.select(".be-login").remove(); let jumbotron = d3.select('body').append("div").attr("class", "container-fluid").append("div").attr("class", "jumbotron"); jumbotron.append("h2").attr("class", "text-center") .html("
If there is an account associated with "+email +($_$.autoFill?"":(" and Organization ID: " + appId)) +" you will receive an email with a link to reset your password."); setTimeout(function() { location.reload(); }, 10000); }; let log = {event:"Reset", page:"", description:"Reset password"}; $_$.genLogDatetime(log); req.send(JSON.stringify({ 'email': email, 'appId':appId, log:log})); }); } function no_role_page() { let jumbotron = d3.select("body").append("div").attr("class", "container-fluid").append("div").attr("class", "jumbotron"); jumbotron.append("h1").html("Warning!"); jumbotron.append("h2") .html("
The screen may appear blank because no role has been assigned to your account.

Please contact system administrator to resolve the issue."); d3.selectAll(".my-modal").remove(); } (function() { let MONTHS = {"1":"Jan", "2":"Feb", "3":"Mar", "4":"Apr", "5":"May", "6":"Jun", "7":"Jul", "8":"Aug", "9":"Sep", "10":"Oct", "11":"Nov", "12":"Dec"}; function zeroPadding(d) { return (d<10?"0":"")+d; } $_$.genLogDatetime = function(log) { let dt = new Date(); log.datetime = dt.toISOString(); log.date = dt.getDate() + " " + MONTHS[dt.getMonth()+1] + " " + dt.getFullYear(); log.time = zeroPadding(dt.getHours())+":"+zeroPadding(dt.getMinutes())+":"+zeroPadding(dt.getSeconds()); } })(); (function getIP() { let req = new XMLHttpRequest(); req.open("GET", "https://api.ipify.org"); req.onload = function(e) { // req = {responseText:'Not available'}; localStorage.ip = req.responseText; (localStorage.amgSysSiD != undefined && localStorage.amgSysSiD.indexOf(localStorage.ip)>=0 && localStorage.appId!=undefined ? function() { let req = new XMLHttpRequest(); req.open("POST", window.origin + "/login", true); req.responseType = 'json'; req.onload = function(e) { if (req.response.res) { verify = null; log_in_page = null; forgot_password_page = null; eval(req.response.app); no_role_page = null; } else { delete localStorage.amgSysSiD; delete localStorage.appId; log_in_page(); } }; let log = {event:"Log in", page:"", description:"Auto login"}; $_$.genLogDatetime(log); req.send(JSON.stringify({ '_': '0', '0': localStorage.email, '1': localStorage.amgSysSiD, '2':localStorage.ip, appId:localStorage.appId, log:log})); } : log_in_page)(); }; req.send(null); })();