Update skama_code and add auto login

fusion
ZimPoPo ago%!(EXTRA string=1 year)
parent 45ff06af84
commit 068153abb8
No known key found for this signature in database
GPG Key ID: C0FB08DFF342B693
  1. 6
      html/template.html
  2. 9
      html/templates/auth/login_modal.html
  3. 10
      html/templates/auth/reg_modal.html
  4. 18
      js/controllers/home.js
  5. 58
      js/controllers/menu_mod.js
  6. 2
      js/skama_code

@ -4,11 +4,7 @@
<img src="assets/logo/elephant.png" />
</div>
<div class="stats"></div>
<ul class="nav-links">
<li class="nav-link smooth" id="systems-link">Systems</li>
<li class="nav-link smooth" id="login-link">Log in</li>
<li class="nav-link smooth" id="reg-link">New Agent</li>
</ul>
<ul class="nav-links"></ul>
</nav>
<main id="block-content"></main>
<footer>

@ -1,9 +0,0 @@
<!-- Copyright © 2023 Entreprise SkamKraft -->
<div class="my-modal">
<p class="modal-title">Login success</p>
<div>
<button id="ok" class="btn btn-val">Continue</button>
<button id="forget_login" class="btn btn-cancel">Forget agent</button>
</div>
</div>

@ -1,10 +0,0 @@
<!-- Copyright © 2023 Entreprise SkamKraft -->
<div class="my-modal">
<p class="modal-title">Login success</p>
<p class="show-token"></p>
<div>
<button id="ok" class="btn btn-val">Continue</button>
<button id="forget_reg" class="btn btn-cancel">Forget agent</button>
</div>
</div>

@ -1,10 +1,18 @@
import { AgentBuilder, My } from "../skama_code/api/agent.js";
import { Auth } from "../skama_code/auth/auth.js";
import menu_mod from "./menu_mod.js";
export default function home(temp_engine) {
console.log("test");
temp_engine.after_render(menu_mod);
temp_engine.render("templates/home.html");
}
//Auto login
const auth = new Auth();
if (auth.relog()) {
AgentBuilder.get(localStorage.getItem("token"), (agent) => {
My.agent = agent;
menu_mod(temp_engine);
});
}
temp_engine.after_render(menu_mod);
temp_engine.render("templates/home.html");
}

@ -1,31 +1,31 @@
import { My } from "../skama_code/api/agent.js";
import home from "./home.js";
import login from "./login.js";
import reg from "./reg.js";
import home from "./home.js";
import { systems } from "./systems.js";
function init_menu(temp_engine) {
temp_engine.add_event("#reg-link", "click", () => {
reg(temp_engine);
});
temp_engine.add_event("#login-link", "click", () => {
login(temp_engine);
});
temp_engine.add_event("#systems-link", "click", () => {
systems(temp_engine);
});
temp_engine.add_event(".nav-brand", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#logout-link", "click", () => {
My.agent = null;
localStorage.removeItem("token");
home(temp_engine);
});
temp_engine.add_event("#reg-link", "click", () => {
reg(temp_engine);
});
temp_engine.add_event("#login-link", "click", () => {
login(temp_engine);
});
temp_engine.add_event("#systems-link", "click", () => {
systems(temp_engine);
});
temp_engine.add_event(".nav-brand", "click", () => {
home(temp_engine);
});
temp_engine.add_event("#logout-link", "click", () => {
My.agent = null;
localStorage.removeItem("token");
home(temp_engine);
});
}
function loged_links() {
$(".nav-links").prepend(`
$(".nav-links").html(`
<li class="nav-link smooth" id="systems-link">Systems</li>
<li class="nav-link smooth" id="contracts-link">Contracts</li>
<li class="nav-link smooth" id="ships-link">Ships</li>
@ -34,14 +34,14 @@ function loged_links() {
}
function unloged_links() {
$(".nav-links").prepend(`
$(".nav-links").html(`
<li class="nav-link smooth" id="login-link">Log in</li>
<li class="nav-link smooth" id="reg-link">New Agent</li>
`);
}
function show_stats() {
$(".stats").html(`
$(".stats").html(`
<p>Agent name : ${My.agent.name}</p>
<p>Credits : ${My.agent.credits}</p>
<p>Ships : ${My.agent.ships_cpt}</p>
@ -51,11 +51,11 @@ function show_stats() {
}
export default function menu_mod(temp_engine) {
init_menu(temp_engine);
if (My.agent) {
show_stats();
loged_links();
} else {
unloged_links();
}
}
init_menu(temp_engine);
if (My.agent) {
show_stats();
loged_links();
} else {
unloged_links();
}
}

@ -1 +1 @@
Subproject commit 77c805654739b07aeecccb90ee53c9126ff158a0
Subproject commit f6c0518ebb6f53be77117d72ac3d4fa56307a37c
Loading…
Cancel
Save