| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- var Unibase;
- (function (Unibase) {
- let Themes;
- (function (Themes) {
- let Compact;
- (function (Compact) {
- let Components;
- (function (Components) {
- class Login extends Unibase.Platform.Core.BaseComponent {
- jsFiles() {
- var jsfiles = ["platform/bundle/default.login.min.js"];
- return jsfiles;
- }
- cssFiles() {
- return [];
- }
- load(id, containerid, callback) {
- this._accountManager = Unibase.Platform.Membership.Managers.AccountManager.Instance();
- Unibase.Platform.Membership.Infos.Identity.setCurrentUser(null);
- var instance = this;
- jQuery(".preloader-it").delay(500).fadeOut("slow");
- jQuery("#external-container").delay(500).fadeIn("slow");
- jQuery("#bizgaze_body").css("background-color", "#f4f6f7");
- $("#InputEmail,#InputPassword").keypress(function (e) {
- if (e.which == 13)
- document.getElementById("BtnLogin").click();
- });
- $('#PasswordHide').click(function () {
- var input = $('#InputPassword');
- input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password');
- $('#PasswordHide').toggleClass('fa-eye-slash fa-eye');
- });
- $("#btnClearcache").click(function () {
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().openSettings();
- }
- });
- jQuery("#InputEmail,#InputPassword").on("input", function () {
- let username = $("#InputEmail").val().toString().trim();
- let password = $("#InputPassword").val();
- let validData = true;
- if (username == '' || username == undefined || password == '' || password == undefined)
- validData = false;
- if (validData) {
- jQuery("#BtnLogin").removeClass("disabled");
- }
- else {
- jQuery("#BtnLogin").addClass("disabled");
- }
- });
- jQuery("#BtnLogin").click(function () {
- instance.validate();
- });
- if (callback != null) {
- callback();
- }
- jQuery("#btn_loginhelp").click(function () {
- var instance = this;
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(["apps/support/components/loginhelp.component.js"], function () {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popin(0, "external-form", Bizgaze.Apps.Support.Components.LoginHelp.Instance(), null);
- });
- });
- }
- loadDomainLogo(imagerurl) {
- if (imagerurl != null && imagerurl != undefined && imagerurl != "") {
- this.imageurl = imagerurl;
- }
- else {
- this.imageurl = "tenants/themes/compact/imgs/bg_1.png";
- }
- }
- validate(username, password, remember) {
- MessageHelper.Instance().hideMessage();
- if (!isMobileApp() || (username == undefined && password == undefined)) {
- username = $("#InputEmail").val().toString().trim();
- password = $("#InputPassword").val().toString();
- remember = $("#InputRemember").prop("checked");
- }
- else {
- remember = true;
- }
- let validData = true;
- if (username == '' || username == undefined || password == '' || password == undefined)
- validData = false;
- if (validData) {
- jQuery("#BtnLogin").addClass("disabled");
- jQuery("#BtnLogin").text("Validating");
- var request = new Unibase.Platform.Membership.Requests.Login(username, password, "", remember);
- if (this._accountManager == undefined) {
- this._accountManager = Unibase.Platform.Membership.Managers.AccountManager.Instance();
- }
- this._accountManager.validateLogin(request).then(function (response) {
- var identity = response.result;
- if (identity === null) {
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().cacheUserCredantials('', '');
- }
- MessageHelper.Instance().showError(response.message, 'validation-summary');
- jQuery("#BtnLogin").removeClass("disabled");
- jQuery("#BtnLogin").text("Login");
- }
- else {
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().cacheUserCredantials(username, password);
- Unibase.Platform.Helpers.MobileHelper.Instance().saveUserDevice(identity.sessionId);
- }
- Unibase.Platform.Membership.Infos.Identity.setCurrentUser(identity);
- window.location.href = '#/welcome';
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().SendUserDetails(JSON.stringify(identity));
- }
- }
- });
- }
- else {
- if (isMobileApp()) {
- Unibase.Platform.Helpers.MobileHelper.Instance().cacheUserCredantials('', '');
- Unibase.Platform.Helpers.MobileHelper.Instance().redirectToLogin();
- }
- MessageHelper.Instance().showError("Mandatory fields are missing", 'validation-summary');
- }
- }
- html(id, containerid) {
- if (jQuery("#external-form").length === 0) {
- var index = new Compact.Components.Index_Anonymous();
- index.init(null, this.imageurl);
- }
- const html = `<form id="Frm_Login" default="" data-validate="parsley" data-isdynamic="false"><h1 class="display-4 mb-10">Login</h1><p class="mb-30">Sign in to your account and enjoy unlimited perks.</p><div id="validation-summary"></div><div class="form-group"><input class="form-control" id="InputEmail" placeholder="Phone or Email" type="text"></div><div class="form-group mb-20"><input class="form-control" id="InputPassword" placeholder="Password" type="password" autocomplete="new-password"><span toggle="#InputPassword" id="PasswordHide" class="fa fa-eye-slash font-15 mr-10 field-icon"></span></div><div class="input-group mb-20"><div class="custom-control custom-checkbox col-xs"><input class="custom-control-input" id="InputRemember" type="checkbox"><label class="custom-control-label font-14" for="InputRemember">Keep me logged in</label></div><div class="col-xs ml-auto"><p class="text-right"><a href="index.html#/forgotpassword">Forgot Password?</a></p></div></div><a class="btn btn-primary btn-block text-white disabled" id="BtnLogin">Login</a><div class="col-2 mt-5" id="btn_loginhelp"><a href="#" style="text-decoration:underline">Help</a></div></form><div class="option-sep">or</div><div class="row"><div class="text-center col-sm-6 pa-5">Already an existing user? <a href="index.html#/registeruser">Register</a></div><div class="text-center col-sm-6 pa-5">Don’t have an account yet? <a href="index.html#/createcustomer">Create a Contact</a></div><div class="text-center col-sm p-2"></div></div>`;
- return html;
- }
- static Instance() {
- return new Login();
- }
- }
- Components.Login = Login;
- })(Components = Compact.Components || (Compact.Components = {}));
- })(Compact = Themes.Compact || (Themes.Compact = {}));
- })(Themes = Unibase.Themes || (Unibase.Themes = {}));
- })(Unibase || (Unibase = {}));
|