diff --git a/package-lock.json b/package-lock.json index a03a407..b21e6a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "electron-squirrel-startup": "^1.0.0", "extract-zip": "^2.0.1", "hasha": "^5.2.2", + "izitoast": "^1.4.0", "minecraft-launcher-core": "^3.16.9", "msmc": "^3.0.1", "vue": "^2.6.14" @@ -3912,6 +3913,11 @@ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, + "node_modules/izitoast": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/izitoast/-/izitoast-1.4.0.tgz", + "integrity": "sha512-Oc1X2wiQtPp39i5VpIjf3GJf5sfCtHKXZ5szx7RareyEeFLUlcEW0FSfBni28+Ul6KNKZRKzhVuWzSP4Xngh0w==" + }, "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -9761,6 +9767,11 @@ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, + "izitoast": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/izitoast/-/izitoast-1.4.0.tgz", + "integrity": "sha512-Oc1X2wiQtPp39i5VpIjf3GJf5sfCtHKXZ5szx7RareyEeFLUlcEW0FSfBni28+Ul6KNKZRKzhVuWzSP4Xngh0w==" + }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", diff --git a/package.json b/package.json index f16a202..33728b2 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "electron-squirrel-startup": "^1.0.0", "extract-zip": "^2.0.1", "hasha": "^5.2.2", + "izitoast": "^1.4.0", "minecraft-launcher-core": "^3.16.9", "msmc": "^3.0.1", "vue": "^2.6.14" diff --git a/src/client/assets/css/menubar.css b/src/client/assets/css/menubar.css index 92422f4..6e81cc8 100644 --- a/src/client/assets/css/menubar.css +++ b/src/client/assets/css/menubar.css @@ -69,4 +69,8 @@ #vue { width: 100vw; height: 100vh; +} + +.iziToast-wrapper-topRight { + top: 25px; } \ No newline at end of file diff --git a/src/client/assets/js/index.js b/src/client/assets/js/index.js index d1d1f2a..4fd6d4d 100644 --- a/src/client/assets/js/index.js +++ b/src/client/assets/js/index.js @@ -19,15 +19,27 @@ let app = new vue({ loadingMessageText: "Téléchargement de Minecraft en cours...", fullprogressbarHidden: true, progressbarWidth: 0, - sidebarContent: "
Chargement en cours
" + sidebarContent: "Chargement en cours
", + notificationTitle: "", + notificationMessage: "" }, mounted: function () { this.demandModsInformations() + iziToast.settings({ + close: false, + closeOnClick: true, + timeout: 5000, + position: 'topRight', + resetOnHover: true, + }) }, methods: { invalidateData: function () { this.invalidateButtonDisabled = true this.invalidateButtonText = "Opération en cours" + this.notificationTitle = "Opération en cours" + this.notificationMessage = "Suppression des données du jeu en cours" + this.showInfo() ipcRenderer.send('invalidateData') }, launchBtnClick: function () { @@ -45,10 +57,9 @@ let app = new vue({ localStorage.setItem("maxMem", this.maxMemValue) gameLaunching = true } else{ - ipcRenderer.send('notification', { - title: "Erreur de lancement", - body: "La mémoire minimale doit être inférieure ou égale à la mémoire maximale" - }) + app.notificationTitle = "Erreur de lancement" + app.notificationMessage = "La mémoire minimale doit être inférieure ou égale à la mémoire maximale." + this.showError() } }, disconnectBtn: function () { @@ -65,6 +76,32 @@ let app = new vue({ }, demandModsInformations: function () { ipcRenderer.send('demandModsInformations') + }, + showInfo: function () { + iziToast.info({ + title: this.notificationTitle, + message: this.notificationMessage, + }) + }, + showError: function() { + iziToast.show({ + title: this.notificationTitle, + message: this.notificationMessage, + color: 'red' + + }) + }, + showWarning: function() { + iziToast.warning({ + title: this.notificationTitle, + message: this.notificationMessage, + }) + }, + showSuccess: function () { + iziToast.success({ + title: this.notificationTitle, + message: this.notificationMessage, + }) } } }) @@ -77,6 +114,9 @@ ipcRenderer.on("nick", (_, args) => app.nick = args.name) ipcRenderer.on("invalidated", () => { app.invalidateButtonDisabled = false app.invalidateButtonText = "Supprimer et retélécharger les bibliothèques" + app.notificationTitle = "Opération terminée" + app.notificationMessage = "Les données du jeu ont été supprimé avec succès" + app.showSuccess() }) ipcRenderer.on("progress", (e, args) => { diff --git a/src/client/assets/js/login.js b/src/client/assets/js/login.js index 8bd73e1..cce4bb5 100644 --- a/src/client/assets/js/login.js +++ b/src/client/assets/js/login.js @@ -1,5 +1,4 @@ - - +// const {default: iziToast } = require('izitoast') let app = new vue({ el: "#vue", data: { @@ -7,10 +6,21 @@ let app = new vue({ email: "Email", password: "Mot de passe", send_credentials: "Se connecter", - microsoft_button: "Connexion avec un compte Microsoft" + microsoft_button: "Connexion avec un compte Microsoft", + notificationTitle: "", + notificationMessage: "" + }, + mounted: function () { + iziToast.settings({ + close: false, + closeOnClick: true, + timeout: 5000, + position: 'topRight', + resetOnHover: true, + }) }, methods: { - formSubmit: (e) => { + formSubmit: function (e) { e.preventDefault() if(!microsoftButton.disabled) { form.disabled = true @@ -20,20 +30,48 @@ let app = new vue({ pass: password.value }) }else{ - ipcRenderer.send("notification", { - title: "error", - body: "Veuillez entrer des identifiants" - }) + this.notificationTitle = "Erreur de connexion" + this.notificationMessage = "Veuillez entrer des identifiants" + this.showWarning() } } }, - microsoftButton: (e) => { + microsoftButton: function (e) { e.preventDefault() if(!form.disabled) { microsoftButton.disabled = true form.disabled = true ipcRenderer.send("microsoft-login") } + }, + showInfo: function () { + iziToast.info({ + title: this.notificationTitle, + message: this.notificationMessage, + color: 'blue' + }) + }, + showError: function() { + iziToast.show({ + title: this.notificationTitle, + message: this.notificationMessage, + color: 'red' + + }) + }, + showWarning: function() { + iziToast.warning({ + title: this.notificationTitle, + message: this.notificationMessage, + color: 'yellow' + }) + }, + showSuccess: function () { + iziToast.success({ + title: this.notificationTitle, + message: this.notificationMessage, + color: 'green' + }) } } }); @@ -47,4 +85,4 @@ const microsoftButton = document.querySelector("#microsoft-button") ipcRenderer.on("loginError", () => { form.disabled = false microsoftButton.disabled = false -}) \ No newline at end of file +}) diff --git a/src/client/assets/js/script.js b/src/client/assets/js/preload.js similarity index 52% rename from src/client/assets/js/script.js rename to src/client/assets/js/preload.js index 5b4cc20..822e5aa 100644 --- a/src/client/assets/js/script.js +++ b/src/client/assets/js/preload.js @@ -10,3 +10,21 @@ window.addEventListener("DOMContentLoaded", () => { closeButton.addEventListener("click", () => ipcRenderer.send('closeWindow')) }) + +ipcRenderer.on('notification', (_e, args) => { + app.notificationTitle = args.title + app.notificationMessage = args.body + switch(args.class) { + case "success": + app.showSuccess() + break; + case "warning": + app.showWarning() + break; + case "error": + app.showError() + break; + case "info":default: + app.showInfo() + } +}) diff --git a/src/client/index.html b/src/client/index.html index 50784ee..28469d2 100644 --- a/src/client/index.html +++ b/src/client/index.html @@ -4,6 +4,7 @@