From 03f8a9a30a091d64764a9b823de688f1b427a0ac Mon Sep 17 00:00:00 2001 From: Makaci Michael Gabriel Date: Fri, 24 May 2024 11:55:12 +0200 Subject: [PATCH] update skama_code, profile end (no css) --- css/profile.css | 19 +++++++++++++++++++ html/templates/modal_profile.html | 23 ++++++++++++++++++++--- index.html | 1 + js/controllers/menu_mod.js | 1 - js/controllers/profile.js | 26 +++++++++++++++++++++++--- js/index.js | 19 ++++++++++++++++++- js/skama_code | 2 +- 7 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 css/profile.css diff --git a/css/profile.css b/css/profile.css new file mode 100644 index 0000000..24082be --- /dev/null +++ b/css/profile.css @@ -0,0 +1,19 @@ +#modal_profile +{ + padding: 0; + color: rgb(0, 17, 255); + background-color: rgb(0, 17, 255); +} + +.profile-modal +{ + margin: 20px; + color: white; + display: flex; + flex-direction: column; +} + +.profile-footer button +{ + background-color: red; +} \ No newline at end of file diff --git a/html/templates/modal_profile.html b/html/templates/modal_profile.html index 33dd69c..1a7fba4 100644 --- a/html/templates/modal_profile.html +++ b/html/templates/modal_profile.html @@ -1,3 +1,20 @@ -
-

Profile

-
+
+
+

Profile

+
+ +
+
+

Name:

+

Faction:

+

Credit:

+

Headquarters:

+

Ship count:

+

Token:

+
+
+ + +
\ No newline at end of file diff --git a/index.html b/index.html index 5ec4a93..11100ae 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,7 @@ + diff --git a/js/controllers/menu_mod.js b/js/controllers/menu_mod.js index 4e2e771..d22848c 100644 --- a/js/controllers/menu_mod.js +++ b/js/controllers/menu_mod.js @@ -1,5 +1,4 @@ import { My } from "../skama_code/commun/my.js"; -import login from "./login.js"; import profile from "./profile.js"; function loged_links(temp_engine) { diff --git a/js/controllers/profile.js b/js/controllers/profile.js index c090d2b..c50b1a9 100644 --- a/js/controllers/profile.js +++ b/js/controllers/profile.js @@ -1,9 +1,29 @@ import { Modal } from "../skama_code/ui/modal.js" +import { Auth } from "../skama_code/auth/auth.js" +import { My } from "../skama_code/commun/my.js" +import login from "./login.js"; export default function profile(temp_engine) { - let modal = new Modal("profile-modal", temp_engine); - modal.load("templates/modal_profile.html"); - modal.after_load((temp_engine) => { + let modal = new Modal("modal_profile", temp_engine); + modal.after_load(() => { modal.show(); + $('#name').append(My.agent.name); + $('#faction').append(My.agent.faction); + $('#credit').append(My.agent.credit); + $('#hq').append(My.agent.hq); + $('#shipcount').append(My.agent.ships_cpt); + + $('#btn-token').on('click', () => { + navigator.clipboard.writeText(My.agent.token); + alert('Token copied !'); + }) + + $('#btn-logout').on('click', () => { + const auth = new Auth(); + auth.unload_token(); + login(temp_engine); + }) }); + + modal.load("templates/modal_profile.html"); } \ No newline at end of file diff --git a/js/index.js b/js/index.js index 85f6808..2ae0a27 100644 --- a/js/index.js +++ b/js/index.js @@ -2,6 +2,23 @@ "use strict"; import { TemplateEngine } from "./skama_code/ui/templeting_engine.js"; import login from "./controllers/login.js"; +import { Auth } from "./skama_code/auth/auth.js"; +import { AgentBuilder } from "./skama_code/api/agent.js"; +import { My } from "./skama_code/commun/my.js"; +import home from "./controllers/home.js"; let temp_engine = new TemplateEngine("html"); -login(temp_engine); + +//Auth +const auth = new Auth; +if(auth.relog()) +{ + AgentBuilder.get(localStorage.getItem('token'), (agent) => { + My.agent = agent; + home(temp_engine); + }) +} +else +{ + login(temp_engine); +} diff --git a/js/skama_code b/js/skama_code index f6268ed..df0d1be 160000 --- a/js/skama_code +++ b/js/skama_code @@ -1 +1 @@ -Subproject commit f6268ed6d83e077ddf4ff362530e9469f8f8a738 +Subproject commit df0d1be1df444b48cd1b6c09e5188af501bc9793