parent
d7edb7cf28
commit
a99ffd4544
5 changed files with 92 additions and 20 deletions
@ -0,0 +1,9 @@ |
|||||||
|
<!-- Copyright © 2023 Entreprise SkamKraft --> |
||||||
|
|
||||||
|
<div class="my-modal"> |
||||||
|
<p class="modal-title">Login success</p> |
||||||
|
<div> |
||||||
|
<button id="ok" class="btn btn-val">Ok</button> |
||||||
|
<button id="forget" class="btn btn-cancel">Forget agent</button> |
||||||
|
</div> |
||||||
|
</div> |
@ -1,7 +0,0 @@ |
|||||||
<!-- Copyright © 2023 Entreprise SkamKraft --> |
|
||||||
|
|
||||||
<div class="my-modal"> |
|
||||||
<p class="modal-title">Bienvenue dans cet modal</p> |
|
||||||
<div id="timer"></div> |
|
||||||
<button id="ok">OK</button> |
|
||||||
</div> |
|
@ -1,6 +1,47 @@ |
|||||||
// Copyright © 2023 Entreprise SkamKraft
|
// Copyright © 2023 Entreprise SkamKraft
|
||||||
'use strict'; |
'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 tests from "./test/tests.js"; |
let temp_engine = new TemplateEngine("html"); |
||||||
|
let auth = new Auth(true); |
||||||
|
let modal = new Modal("login-modal", temp_engine); |
||||||
|
|
||||||
|
temp_engine.add_event("#ok", "click", () => { |
||||||
|
temp_engine.render("templates/home.html"); |
||||||
|
}); |
||||||
|
|
||||||
|
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(); |
||||||
|
|
||||||
tests.modal(); |
|
Loading…
Reference in New Issue