Customlogin

From Catglobe Wiki
Revision as of 08:20, 12 January 2023 by Administrator (talk | contribs)
Jump to: navigation, search

Create catglobe custom login layout
1. Create files:
        1.1. Stylesheet:

        - Create stylesheet file: default.css

  1. loginBackground::before {
     background: #595959;
    }
    #loginBackground form {
     max-width: 400px;
     margin: 0 auto;
     box-sizing: border-box;
    }
  2. loginBackground .wrapper-logo {
     width: 100%;
    }
  3. loginBackground #loginLogo {
     height: 50px;
     width: auto;
     margin: 0;
    }
  4. loginBackground .version {
     margin-top: 0;
     margin-bottom: 10px;
     color: #fff !important;
    }
  5. loginBackground input {
     box-sizing: border-box;
     width: 100%;
     min-width: 300px;
     background: #fff;
     border-color: rgb(var(--cg));
     border-radius: 10px;
     padding: 10px 15px;
     height: unset;
     margin-bottom: 10px;
     color: #000;
    }
  6. loginBackground .login-submit {
     width: 100% !important;
     justify-content: space-between !important;
    }
 #loginBackground .login-submit a {
  color: #fff !important;
 }
 #loginBackground .login-submit button {
  border-radius: 5px;
  height: unset;
  padding: 10px 30px;
  font-size: 14px;
 }
  1. loginBackground .bottom-logo {
     margin-top: 50px;
    }
  2. loginBackground .vox-logo {
     background: url('./Voxmeter-logo.png') no-repeat;
     height: 28px;
     width: 100px;
     background-size: 100px 28px;
     margin: auto;
    }
  3. loginBackground .cem-logo {
     background: url('./CEM-intelligence-logo.png') no-repeat;
     height: 26px;
     width: 150px;
     background-size: 150px 28px;
     margin: auto;
    }

        1.2. Javascript:
        - Create javascript file: default.js

document.addEventListener('DOMContentLoaded', function () {
 let userLang = navigator.language || navigator.userLanguage; 
 let form = document.getElementById('loginBackground').getElementsByTagName('form')[0];
 let submit = document.querySelector('[type="submit"]');
 submit.parentElement.className += 'login-submit';
 let logo = document.querySelector('#loginLogo');
 let wrapperLogo = document.createElement('div');
 wrapperLogo.classList.add('wrapper-logo');
 logo.parentNode.insertBefore(wrapperLogo, logo);
 wrapperLogo.appendChild(logo);
 let version = document.createElement('p');
 let versionText;
 if(userLang === 'da-DK'){
    versionText = document.createTextNode('Velcome to version 10.0');
 } else {
    versionText = document.createTextNode('Welcome to version 10.0');
 }
 version.classList.add('version');
 version.appendChild(versionText);
 wrapperLogo.appendChild(version);
 let vox = document.createElement('div');
 vox.classList.add('bottom-logo');
 vox.innerHTML = `<div class="vox-logo"></div><div class="cem-logo"></div>`;
 form.appendChild(vox);
}, false);

       1.3. Upload: stylesheet and javascript files to location where You can get public link.

2. Config:
- Add config to catglobe.json on server.

     "loginPageCustomization": [
          {
             "name": "",
             "urlToExtraCss": "https://voxmeter.dk/custom-login/default.css",
             "urlToExtraJs": "https://voxmeter.dk/custom-login/default.js"
         },
         {
             "name": "/cembank",
             "urlToExtraCss": "https://localhost/test/cembank.css",
             "urlToExtraJs": "https://localhost/test/cembank.js"
         }
    ]