Adding functions to the login

skamkraft_proto
anulax1225 ago%!(EXTRA string=1 year)
parent 066d70ff8b
commit 477009cbbb
  1. 8
      css/style.css
  2. 1
      html/template.html
  3. 44
      js/index.js
  4. 54
      js/scripts/main.js
  5. 14
      js/skama_code/commun/initialzer.js
  6. 2
      js/skama_code/ui/modal.js
  7. 5
      js/skama_code/ui/templeting_engine.js
  8. 2
      js/test/tests.js

@ -104,10 +104,16 @@ footer {
box-shadow: 3px 2px white;
}
.pseudo {
color: white;
}
/* General */
.smooth {
padding: 5px;
border-radius: 10px;
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
}
.in-big {

@ -3,6 +3,7 @@
<div class="nav-brand">
<img src="assets/logo/logoblancnotext.png" />
</div>
<p class="pseudo"></p>
<ul class="nav-links">
<li class="nav-link smooth" id="contracts-link">Contracts</li>
<li class="nav-link smooth" id="systems-link">System</li>

@ -1,47 +1,11 @@
// Copyright © 2023 Entreprise SkamKraft
'use strict';
import { Modal } from "./skama_code/ui/modal.js";
import { TemplateEngine } from "./skama_code/ui/templeting_engine.js";
import { AgentBuilder } from "./skama_code/api/agent.js";
import { Auth } from "./skama_code/auth/auth.js";
import { init_login } from "./scripts/main.js";
let temp_engine = new TemplateEngine("html");
let auth = new Auth(true);
let modal = new Modal("login-modal", temp_engine);
init_login(temp_engine);
temp_engine.add_event("#ok", "click", () => {
temp_engine.render("templates/home.html");
temp_engine.add_event("#signin-link", "click", () => {
init_login(temp_engine);
});
temp_engine.add_event("#forget", "click", () => {
auth.unload_token();
modal.close();
});
temp_engine.add_event("#val", "click", () => {
let token = $("#in-token").val();
auth.login(token);
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-token").val("");
});
temp_engine.render("templates/login.html");
modal.add_class("ext-modal");
modal.render("templates/login_modal.html");
auth.done((agent) => {
modal.show();
}).fail((errs) => {
$(".errors").html("");
errs.forEach(err => {
$(".errors").append(`
<p>${err}</p>
`);
});
});
auth.relog();

@ -0,0 +1,54 @@
import { Modal } from "../skama_code/ui/modal.js";
import { Auth } from "../skama_code/auth/auth.js";
let my_agent = null;
function menu_mod() {
if(my_agent && my_agent.name) $(".pseudo").text(`Agent name : ${my_agent.name}`);
}
export function init_login(temp_engine) {
let auth = new Auth(true);
let modal = new Modal("login-modal", temp_engine);
temp_engine.render("templates/login.html");
menu_mod();
temp_engine.add_event("#ok", "click", () => {
temp_engine.render("templates/home.html");
menu_mod();
});
temp_engine.add_event("#forget", "click", () => {
my_agent = null;
auth.unload_token();
modal.close();
temp_engine.render("templates/login.html");
});
temp_engine.add_event("#val", "click", () => {
let token = $("#in-token").val();
auth.login(token);
});
temp_engine.add_event("#cancel", "click", () => {
$("#in-token").val("");
});
modal.add_class("ext-modal");
modal.load("templates/login_modal.html");
auth.done((agent) => {
modal.show();
my_agent = agent;
}).fail((errs) => {
$(".errors").html("");
errs.forEach(err => {
$(".errors").append(`
<p>${err}</p>
`);
});
});
auth.relog();
}

@ -1,14 +0,0 @@
// Copyright © 2023 Entreprise SkamKraft
'use strict';
export class Initialzer {
constructor(UI) {
this.UI = UI;
}
init_menu_link(tag, template) {
this.UI.add_event(tag, "click", () => {
this.UI.render(`templates/${template}`);
})
}
}

@ -9,7 +9,7 @@ export class Modal {
this.modal_class = "";
}
render(template) {
load(template) {
this.template_engine.get_template((reponse) => {
$(this.tag).prepend(`
<dialog id="${this.name}" class="${this.modal_class} modal-disable">

@ -31,7 +31,12 @@ export class TemplateEngine {
}
});
}
add_event(tag, action, callback) {
$("body").on(action, tag, callback);
}
after_temp_load() {
}
}

@ -71,7 +71,7 @@ let tests = {
let modal = new Modal("test-modal", template_engine);
modal.add_class("ext-modal")
modal.render("templates/test_modal.html");
modal.load("templates/test_modal.html");
template_engine.add_event("#valid", "click", () => {
modal.show();

Loading…
Cancel
Save