diff --git a/assets/js/charts/dashboard.js b/assets/js/charts/dashboard.js index 0134d97..f63bbab 100644 --- a/assets/js/charts/dashboard.js +++ b/assets/js/charts/dashboard.js @@ -4,6 +4,12 @@ var cpu = [] var ram = [] + function getCookie(name) { + const value = `; ${document.cookie}`; + const parts = value.split(`; ${name}=`); + if (parts.length === 2) return parts.pop().split(';').shift(); + } + async function postData(url = '', data = {}) { const response = await fetch(url, { method: 'POST', @@ -48,17 +54,15 @@ 'oom_disabled': true } console.log(data); - - postData('http://localhost:400/api/create_ptero_services', data) - .then(data => { - }); - } - - fetch('http://localhost:400/?token=0123456789') + postData('http://localhost:400/api/create_ptero_services', data) + .then(data => {}); +} + fetch(`http://127.0.0.1:400/?uuid=${getCookie("uuid")}&token=${getCookie("token")}`) .then(function (response) { return response.json(); }) .then(function (myJson) { + console.log(myJson) if (myJson.error === false) { document.getElementById("hello").innerHTML = "Bonjour " + myJson.username + " !" @@ -70,11 +74,11 @@ document.getElementById("services_suspended").innerHTML = myJson.counters[4] document.getElementById("alerts").innerHTML = myJson.counters[5] var invoiced_table = "" - var color = "green" + var color = "#39EE30" for (let i = 0; i < myJson.invoices_table.length; i++) { - if (myJson.invoices_table[i].status == "Terminé") {color = "green"} - if (myJson.invoices_table[i].status == "En Attente") {color = "orange"} - if (myJson.invoices_table[i].status == "Remboursé") {color = "blue"} + if (myJson.invoices_table[i].status == "Terminé") {color = "#28B463"} + if (myJson.invoices_table[i].status == "En Attente") {color = "#E67E22"} + if (myJson.invoices_table[i].status == "Remboursé") {color = "#2874A6"} invoiced_table = invoiced_table + ` @@ -369,7 +373,7 @@ }) } } else { - window.location.replace("file:///C:/Users/Savalet/Documents/DEV/sites/Arkia%20Cloud%20Dashboard/dashboard/auth/sign-in.html"); + // window.location.replace("file:///C:/Users/Savalet/Documents/DEV/sites/MercuryCloud_Dashboard/dashboard/auth/sign-in.html"); } }) })(jQuery) diff --git a/assets/js/pages/sign-in.js b/assets/js/pages/sign-in.js new file mode 100644 index 0000000..3e62e72 --- /dev/null +++ b/assets/js/pages/sign-in.js @@ -0,0 +1,29 @@ +async function postData(url = '', data = {}) { + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(data) + }); + return response.json() +} + +function connect() { + let data = { + 'mail': document.getElementById("email").value, + 'password': document.getElementById("password").value + } + postData('http://127.0.0.1:400/api/login-user', data).then(data => { + console.log(data) + if (data.error == false) { + document.cookie = `uuid=${data.uuid}` + document.cookie = `token=${data.token}` + window.location.replace("file:///C:/Users/Savalet/Documents/DEV/sites/MercuryCloud_Dashboard/dashboard/index.html") + } else { + document.getElementById("email").value = "" + document.getElementById("password").value = "" + document.getElementById("message").innerHTML = "Mot de passe ou email invalide !" + } + }); +} \ No newline at end of file diff --git a/dashboard/auth/sign-in.html b/dashboard/auth/sign-in.html index 600d6aa..3ae7de0 100644 --- a/dashboard/auth/sign-in.html +++ b/dashboard/auth/sign-in.html @@ -6,7 +6,7 @@ - Hope UI | Responsive Bootstrap 5 Admin Dashboard Template + Mercury Cloud | Connexion @@ -15,7 +15,7 @@ - + @@ -55,56 +55,38 @@ -

Hope UI

+

Mercury Cloud

-

Sign In

-

Login to stay connected.

-
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
- Forgot Password? +

Connexion

+

Connectez vous à votre tableau de bord.

+

+
+
+
+ +
-
- +
+
+ + +
-

or sign in with other accounts?

-
-
    -
  • - fb -
  • -
  • - gm -
  • -
  • - im -
  • -
  • - li -
  • -
+
+
+ + +
+ Mot de passe oublié ?
-

- Don’t have an account? Click here to sign up. -

- +
+
+ +
+

+ Vous n'avez pas de compte ? Cliquez ici pour vous inscrire. +

@@ -148,9 +130,9 @@ - - - + + + diff --git a/dashboard/index.html b/dashboard/index.html index 4acbdda..02dbbb6 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -4,7 +4,7 @@ - Arkia Cloud | Tableau de bord + Mercury Cloud | Tableau de bord @@ -41,7 +41,7 @@ -

Arkia Cloud

+

Mercury Cloud