diff --git a/package.json b/package.json index 91774fd..35c1c00 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "license": "MIT", "config": { "forge": { - "packagerConfig": {}, + "packagerConfig": { + "icon": "./src/assets/icon.ico" + }, "makers": [ { "name": "@electron-forge/maker-squirrel", diff --git a/src/assets/icon.ico b/src/assets/icon.ico new file mode 100644 index 0000000..5115a5d Binary files /dev/null and b/src/assets/icon.ico differ diff --git a/src/assets/icon.png b/src/assets/icon.png index ea18d25..cbbaaaa 100644 Binary files a/src/assets/icon.png and b/src/assets/icon.png differ diff --git a/src/common/apiclient.js b/src/common/apiclient.js new file mode 100644 index 0000000..6a28f1a --- /dev/null +++ b/src/common/apiclient.js @@ -0,0 +1,16 @@ +const { Jellyfin } = require('@thornbill/jellyfin-sdk'); +const config = require('../config'); + +var apiclient = new Jellyfin({ + clientInfo: { + name: 'Mordern Jellyfin client in Electron', + version: "0.0.1" + }, + deviceInfo: { + name: "JellyPlayer", + id: "JellyPlayerClient" + } +}); +var api = apiclient.createApi(config.get('serverUrl')); + +module.exports = api; \ No newline at end of file diff --git a/src/index.js b/src/index.js index e6248b0..3069696 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ const { app, BrowserWindow } = require('electron'); const config = require("./config"); const emitter = require("./common/emitter"); const LoginPage = require("./pages/login"); -const HomePage = require("./pages/home"); +const MainPage = require("./pages/main"); async function createWindow() { var splash = new BrowserWindow({ @@ -16,24 +16,19 @@ async function createWindow() { } }); splash.loadFile('./src/render/html/splash.html'); - var homePage = new HomePage(); + var mainPage = new MainPage(); var loginPage = new LoginPage(); loginPage.window.on('ready-to-show', () => { splash.destroy(); - if (!config.get('serverUrl')) { - loginPage.showLogin(); - } else if (config.get('openHome') == false) { + if (config.get('openHome') == false) { loginPage.showLogin(); + } else if (config.get('openHome') == true) { + loginPage.hideLogin(); + mainPage.showMain(); } emitter.on('logged-in', () => { loginPage.hideLogin(); - homePage.showHome(); - }); - emitter.on('closeHome', () => { - homePage.hideHome(); - config.set('openHome', false); - app.relaunch(); - app.exit(0); + mainPage.showMain(); }); }); } @@ -42,8 +37,6 @@ app.whenReady().then(() => { createWindow(); }); -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.exit(0); - } -}); +emitter.on('close-app', () => { + app.quit(); +}); \ No newline at end of file diff --git a/src/pages/login.js b/src/pages/login.js index f5dc17d..566955d 100644 --- a/src/pages/login.js +++ b/src/pages/login.js @@ -1,20 +1,16 @@ -const { app, BrowserWindow, ipcMain, nativeImage } = require('electron'); +const { app, BrowserWindow, ipcMain } = require('electron'); const got = require('got'); const emitter = require('../common/emitter'); const config = require('../config'); -const { Jellyfin } = require('@thornbill/jellyfin-sdk'); - -var icon = nativeImage.createFromPath('../assets/icon.png'); - +const api = require('../common/apiclient'); class LoginPage { constructor() { this.createWindow(); this.setConfig(); this.onstartUp(); this.authUser(); - this.logoutUser(); - this.getUserlist(); this.clearData(); + this.apiclient = api; } createWindow() { this.window = new BrowserWindow({ @@ -28,12 +24,15 @@ class LoginPage { contextIsolation: false }, show: false, - icon: icon + icon: "../assets/icon.ico" }); this.window.loadFile("./src/render/html/login.html"); - this.window.webContents.openDevTools(); this.window.setMenu(null); this.window.maximize(); + this.window.webContents.openDevTools(); + this.window.on('closed', () => { + emitter.emit('close-app'); + }); } onstartUp() { ipcMain.on('check-server-status', (event) => { @@ -41,6 +40,7 @@ class LoginPage { if (response.body == '"Jellyfin Server"') { event.sender.send('server-online'); this.serverOnline = true; + this.getUserlist(); } else { event.sender.send('server-offline'); @@ -50,14 +50,16 @@ class LoginPage { let error; event.sender.send('server-offline'); if (typeof er == 'string') { - error = e; + error = er; } else { error = "Can't connect to Jellyfin server"; } + console.log(error); }); }); ipcMain.on('reload-page', () => { - this.window.reload(); + app.relaunch(); + app.quit(); }); } setConfig() { @@ -68,9 +70,8 @@ class LoginPage { event.sender.send('is-jf-server'); config.set('serverUrl', serverUrl); config.set('serverGo', true); - this.window.reload(); - } - else { + this.getUserlist(); + } else { event.sender.send('not-jf-server'); } }).catch((er) => { @@ -85,25 +86,19 @@ class LoginPage { }); } getUserlist() { - this.apiclient = new Jellyfin({ - clientInfo: { - name: 'Mordern Jellyfin client in Electron', - version: "0.0.1" - }, - deviceInfo: { - name: "JellyPlayer", - id: "JellyPlayerClient" + this.window.once('ready-to-show', async () => { + if (this.getUsers != false) { + ipcMain.on('waiting-for-userlist', async (event) => { + this.users = await this.apiclient.userApi.getPublicUsers(); + if (await this.users.length == 0) { + event.sender.send('no-public-users'); + } else { + event.sender.send('userlist', this.users.data); + } + }); } - }); - this.api = this.apiclient.createApi(config.get('serverUrl')); - this.window.once('ready-to-show', () => { - ipcMain.on('waiting-for-userlist', async (event) => { - let users = await this.api.userApi.getPublicUsers(); - if (users.data.length == 0) { - event.sender.send('no-public-users'); - } else { - event.sender.send('userlist', users.data); - } + ipcMain.on('userlist-recieved', () => { + this.getUsers = false; }); }); } @@ -112,7 +107,7 @@ class LoginPage { if (config.get('openHome') == true) { if (this.serverOnline == true) { try { - auth = await this.api.authenticateUserByName(config.get('user.name'), config.get('user.pass')); + auth = await this.apiclient.authenticateUserByName(config.get('user.name'), config.get('user.pass')); emitter.emit('logged-in'); } catch (err) { console.log(err); @@ -122,7 +117,7 @@ class LoginPage { this.window.once('ready-to-show', () => { ipcMain.on('user-auth-details', async (event, user) => { try { - auth = await this.api.authenticateUserByName(user[0], user[1]); + auth = await this.apiclient.authenticateUserByName(user[0], user[1]); if (user[2] == true) { config.set('user.name', user[0]); config.set('user.pass', user[1]); @@ -130,7 +125,7 @@ class LoginPage { } emitter.emit('logged-in'); } catch (err) { - console.log("err"); + console.log(err); event.sender.send('user-auth-failed'); } @@ -138,16 +133,11 @@ class LoginPage { }); } } - logoutUser() { - emitter.on('logout-user', async () => { - await this.api.logout(); - emitter.emit('closeHome'); - }); - } clearData() { ipcMain.on('clear-user-data', async () => { config.clear(); - this.window.reload(); + app.relaunch(); + app.quit(); }); } showLogin() { diff --git a/src/pages/home.js b/src/pages/main.js similarity index 72% rename from src/pages/home.js rename to src/pages/main.js index 81955b0..257552b 100644 --- a/src/pages/home.js +++ b/src/pages/main.js @@ -4,7 +4,7 @@ const emitter = require('../common/emitter'); const config = require('../config'); const { Jellyfin } = require('@thornbill/jellyfin-sdk'); -class HomePage { +class MainPage { constructor() { this.createWindow(); this.logoutRequest(); @@ -21,23 +21,25 @@ class HomePage { nodeIntegration: true } }); - this.window.loadFile("./src/render/html/home.html"); + this.window.loadFile("./src/render/html/main.html"); this.window.webContents.openDevTools(); + this.window.setMenu(null); + this.window.maximize(); + this.window.on('closed', () => { + emitter.emit('close-app'); + }); } logoutRequest() { ipcMain.on('logout-user', () => { emitter.emit('logout-user'); }); } - showHome() { + showMain() { this.window.show(); } - hideHome() { + hideMain() { this.window.hide(); } - closeHome() { - this.window.close(); - } } -module.exports = HomePage; \ No newline at end of file +module.exports = MainPage; \ No newline at end of file diff --git a/src/render/css/global.css b/src/render/css/global.css index 6b84018..ee7511a 100644 --- a/src/render/css/global.css +++ b/src/render/css/global.css @@ -1,15 +1,18 @@ /** @format */ -@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"); -@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap"); :root { --main-bg: #0d0326; - --warning-yellow: #e5df30; - --error-red: #b33a3a; + --warning-yellow: #f18e06; + --warning-bg: rgba(220, 128, 1, 0.16); + --error-red: #a94442; --error-red-darker-1: #8b2e2e; + --error-red-bg: #240e0ea0; + --yes-green: #18be12; + --yes-green-darker-1: #15a010; --rounding: 10px; --rounding-1: 5px; - --transition-time-fast-1: 100ms; + --transition-time-fast-2: 100ms; + --transition-time-fast-1: 150ms; --transition-time-default: 250ms; --transition-time-slow-1: 350ms; } diff --git a/src/render/css/login.css b/src/render/css/login.css index 8b1502b..c0bdfa1 100644 --- a/src/render/css/login.css +++ b/src/render/css/login.css @@ -27,7 +27,7 @@ main { height: 100vh; z-index: 1; display: flex; - justify-content: flex-start; + /* justify-content: flex-start; */ align-items: center; overflow: hidden; } @@ -61,16 +61,31 @@ main { .page > button { width: 60vw; + max-width: 32em; +} + +.page.manual__login { + position: relative; } .server__cont, .user__cont, .manual__input { position: static; - width: 60vw; + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; max-width: 30em; } +.manual__input { + width: 60vw; + display: flex; + flex-flow: column; + align-items: stretch; + justify-content: center; +} + .server__cont { display: flex; flex-flow: column; @@ -84,7 +99,7 @@ button.clicky { button.clicky::after { content: ""; - box-shadow: 0 0 15px 40px white; + box-shadow: 0 0 15px 40px var(--clr); position: absolute; width: 100%; height: 100%; @@ -111,6 +126,7 @@ input[type="password"] { } button { + --clr: currentColor; overflow: hidden; background: #ffffff4b; border: 2px solid white; @@ -161,10 +177,12 @@ input:focus + .input__label, font-size: calc(60vw / 20); } -.info svg { +.info i { color: var(--warning-yellow); - height: 100%; - width: min(1.5em, 30px); + font-size: min(1.5em, 30px); + height: -webkit-fit-content; + height: -moz-fit-content; + height: fit-content; } .info div { @@ -175,76 +193,138 @@ input:focus + .input__label, width: fit-content; } -.popup { - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - width: 40vw; - height: 30vh; - min-height: 15em; - min-width: 25em; -} - -.icon { - height: 40%; +.alert { + position: absolute; + box-sizing: content-box; + width: 50vw; + max-width: 20em; display: flex; - align-items: flex-start; - justify-content: flex-start; -} - -.icon svg { - width: auto; - height: 100%; -} - -.error .icon svg { - color: var(--error-red); -} - -.waring .icon svg { - color: var(--warning-yellow); -} - -.popup .text { - font-family: "IBM Plex Mono"; - font-weight: 300; -} - -.popup__exit__btn { - border-radius: 100px; - border: none; - background: var(--error-red); + left: 20px; + background: var(--background); color: white; - transition: background var(--transition-time-default); + border-radius: var(--rounding); + font-weight: 600; + justify-content: center; + align-items: center; + box-shadow: 0 0 30px rgb(0 0 0 / 0.5); + overflow: hidden; + -webkit-animation: comeIn var(--transition-time-default) forwards; + animation: comeIn var(--transition-time-default) forwards; } -.popup__exit__btn:hover { - background: var(--error-red-darker-1); +.alert .icon { + font-size: 2.5em; + background: var(--color); + height: 100%; + flex-shrink: 0; + flex-grow: 1; + padding: 15px; +} + +.alert .msg { + padding: 0 15px; +} + +.warning { + --background: var(--warning-bg); + --color: var(--warning-yellow); +} + +.alert.error { + --background: var(--main-bg); + --color: var(--error-red); +} + +.dialog { + position: fixed; + background: var(--main-bg); + z-index: 1; + height: -webkit-fit-content; + height: -moz-fit-content; + height: fit-content; + inset: 50% 0 0 50%; + transform: translate(-50%, -50%); + box-sizing: content-box; + padding: 20px; + color: black; + border-radius: var(--rounding); + box-shadow: 0 10px 35px rgba(5, 5, 5, 0.7); + max-width: 20em; +} + +.dialog .icon { + color: var(--color); + border-left: 5px solid; + padding: 0 0 0 15px; + font-size: 3em; + margin-left: -20px; +} + +.dialog.error { + --color: var(--error-red); +} + +.dialog.warning { + --color: var(--warning-yellow); +} + +.dialog .title { + font-size: 2em; + font-weight: 600; + color: rgb(255 255 255 / 90%); +} + +.dialog .msg { + font-size: 1.25em; + font-weight: 400; + color: rgb(255 255 255 / 65%); + margin: 0.5em 0; +} + +.buttons { + display: flex; + gap: 10px; +} + +.dialog__close { + position: fixed; + width: 100vw; + height: 100vh; + background: rgba(5, 5, 5, 0.5); + z-index: 0; } .error.active, -.popup__exit.active { - -webkit-animation: fadeIn var(--transition-time-slow-1); - animation: fadeIn var(--transition-time-slow-1); +.dialog.active, +.warning.active, +.dialog__close.active { + -webkit-animation: fadeIn var(--transition-time-fast-1); + animation: fadeIn var(--transition-time-fast-1); display: block; visibility: visible; } -.popup__exit { - position: fixed; - width: 100vw; - height: 100vh; - background: rgba(0, 0, 0, 0.3); - opacity: 1; - -webkit-backdrop-filter: blur(10px); - backdrop-filter: blur(10px); +.dialog.fadeOut, +.dialog__close.fadeOut { + -webkit-animation: fadeOut var(--transition-time-fast-1) forwards; + animation: fadeOut var(--transition-time-fast-1) forwards; } -.popup__exit.fadeOut, -.popup.error.fadeOut { - -webkit-animation: fadeOut var(--transition-time-slow-1) forwards; - animation: fadeOut var(--transition-time-slow-1) forwards; +.alert.goOut { + -webkit-animation: goOut var(--transition-time-default) forwards; + animation: goOut var(--transition-time-default) forwards; +} + +.alert .load { + position: absolute; + bottom: 0; + height: 5px; + background: white; + width: 100%; + transform: scaleX(0); + -webkit-animation: load 3s forwards; + animation: load 3s forwards linear; + transform-origin: left; } .loader { @@ -279,10 +359,13 @@ section.user__cont { display: flex; justify-content: space-between; overflow: auto hidden; + gap: 1em; } .user__card { - width: 50%; + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; overflow: hidden; flex-shrink: 0; } @@ -328,14 +411,41 @@ section.user__cont { grid-gap: 10px; } -.user__info .name { - text-shadow: 0 0 8px #00000057; +.title__name { + -webkit-filter: drop-shadow(0 0 8px #00000057); + filter: drop-shadow(0 0 8px #00000057); text-align: center; - width: 100%; - font-weight: 300; + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; + font-weight: 500; padding: 0; margin: 0; - font-size: min(2em, calc(100vw / 25)); + font-size: calc(100vw / 15); + position: relative; + margin-bottom: 0.5em; + align-self: center; +} + +.title__name::after { + content: ""; + width: 70%; + height: 2px; + position: absolute; + bottom: -2px; + left: 50%; + transform: translateX(-50%); + background: white; +} + +.user__info .title__name::after, +.manual__login .title__name::after { + all: unset; +} + +.user__info .title__name { + font-size: calc(100vw / 20); + margin-bottom: 0; } .user__info .user__img { @@ -364,8 +474,8 @@ section.user__cont { .tick path { stroke: white; stroke-dasharray: 100%; - stroke-dashoffset: 100%; - transition: stroke-dashoffset var(--transition-time-fast-1); + stroke-dashoffset: -100%; + transition: stroke-dashoffset var(--transition-time-fast-2); } input[type="checkbox"]:checked + .tick > path { @@ -381,6 +491,34 @@ input[type="checkbox"]:checked + .tick > path { margin: 0; } +.manual__form { + display: flex; + flex-flow: column; + gap: 20px; + row-gap: 20px; + -moz-column-gap: 20px; + column-gap: 20px; +} + +.back { + position: absolute; + top: 0; + left: 0; + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; + z-index: 1; + padding: 0.3em 0.5em; + font-size: 1.5em; + background: rgb(20 20 20 / 0.5); + border-radius: 0 0 5px 0; + transition: background var(--transition-time-fast-1); +} + +.back:hover { + background: rgb(20 20 20 / 0.7); +} + /*Animations*/ @-webkit-keyframes fadeInBg { 0% { @@ -447,3 +585,65 @@ input[type="checkbox"]:checked + .tick > path { opacity: 0; } } + +@-webkit-keyframes comeIn { + 0% { + bottom: -100%; + } + 100% { + bottom: 20px; + } +} + +@keyframes comeIn { + 0% { + bottom: -100%; + } + 100% { + bottom: 20px; + } +} + +@-webkit-keyframes goOut { + 0% { + bottom: 20px; + } + 100% { + bottom: -100%; + } +} + +@keyframes goOut { + 0% { + bottom: 20px; + } + 100% { + bottom: -100%; + } +} + +@-webkit-keyframes load { + 0% { + transform: scaleX(0); + } + 100% { + transform: scaleX(1); + } +} + +@keyframes load { + 0% { + transform: scaleX(0); + } + 100% { + transform: scaleX(1); + } +} + +/*Scaling for other display*/ + +@media (min-width: 800px) { + .title__name { + font-size: 2.7em; + } +} diff --git a/src/render/css/home.css b/src/render/css/main.css similarity index 100% rename from src/render/css/home.css rename to src/render/css/main.css diff --git a/src/render/html/login.html b/src/render/html/login.html index 8b80f7e..f080947 100644 --- a/src/render/html/login.html +++ b/src/render/html/login.html @@ -6,6 +6,10 @@ + + + + Jellyfin @@ -47,10 +51,7 @@ Save
- - - - +
Enter your Jellyfin server address above
Example: https://jellyfin.mydomain.com or http://192.168.25.35:8096 @@ -60,57 +61,51 @@
+

Users

+
- - `; } else if (!user.PrimaryImageTag) { html = `
-
- -

${user.Name}

-
-
`; +
+ +

${user.Name}

+
+
`; } document.querySelector('.user__cont').insertAdjacentHTML('beforeend', html); }); document.querySelector('.users').classList.remove('hide'); document.querySelector('.users').scrollIntoView({ behavior: "smooth" }); document.querySelector('.loader').classList.add('hide'); - setInterval(() => { + setTimeout(() => { document.querySelector('.server').classList.add('hide'); }, 1000); // $('main').scrollTo('.users', '2s'); @@ -44,91 +44,119 @@ const createUserList = () => { ipcRenderer.on('no-public-users', () => { document.querySelector('.loader').classList.add('hide'); createManualLogin(); - document.querySelector('.manual__login').classList.remove('hide'); - document.querySelector('.manual__login').scrollIntoView({ behavior: "smooth" }); + setTimeout(() => { + document.querySelector('.server').classList.add('hide'); + }, 1000); }); }; -const closePopup = () => { - document.querySelector('.popup__exit').addEventListener('click', () => { - document.querySelector('.error').classList.remove('active'); - document.querySelector('.error').classList.add('fadeOut'); - document.querySelector('.popup__exit').classList.remove('active'); - document.querySelector('.popup__exit').classList.add('fadeOut'); - setTimeout(() => { - document.querySelector('.error').classList.remove('fadeOut'); - document.querySelector('.popup__exit').classList.remove('fadeOut'); - document.querySelector('.error').classList.add('hide'); - document.querySelector('.popup__exit').classList.add('hide'); - }, 305); - }); - - document.querySelector('.popup__exit__btn').addEventListener('click', () => { - document.querySelector('.error').classList.remove('active'); - document.querySelector('.error').classList.add('fadeOut'); - document.querySelector('.popup__exit').classList.remove('active'); - document.querySelector('.popup__exit').classList.add('fadeOut'); - setTimeout(() => { - document.querySelector('.error').classList.remove('fadeOut'); - document.querySelector('.popup__exit').classList.remove('fadeOut'); - document.querySelector('.error').classList.add('hide'); - document.querySelector('.popup__exit').classList.add('hide'); - }, 300); - }); +const closeDialog = () => { + document.querySelector('.dialog').classList.remove('active'); + document.querySelector('.dialog__close').classList.remove('active'); + document.querySelector('.dialog').classList.add('fadeOut'); + document.querySelector('.dialog__close').classList.add('fadeOut'); + setTimeout(() => { + document.querySelector('.dialog').classList.remove('fadeOut'); + document.querySelector('.dialog__close').classList.remove('fadeOut'); + document.querySelector('.dialog').remove(); + document.querySelector('.dialog__close').remove(); + }, 305); }; -const createServerErr = () => { - document.querySelector('.error').classList.remove('hide'); - document.querySelector('.error').classList.add('active'); - document.querySelector('.popup__exit').classList.remove('hide'); - document.querySelector('.popup__exit').classList.add('active'); - closePopup(); +const createAlert = (type, msg, page) => { + html = `
+
+ +
+
+ ${msg} +
+
+
`; + document.querySelector(page).insertAdjacentHTML('beforeend', html); + setTimeout(() => { + document.querySelector('.alert').classList.add('goOut'); + setTimeout(() => { + document.querySelector('.alert').remove(); + }, 1000); + }, 3000); +}; + +const createDialog = (title, msg, btn, type) => { + html = `
+
+ +
+
+ ${title} +
+
+ ${msg} +
+
+
`; + document.querySelector('main').insertAdjacentHTML('beforeend', html); + if (btn == "yes__no") { + html = `
+ + +
`; + document.querySelector('.dialog').insertAdjacentHTML('beforeend', html); + } else if (btn == "remove__server") { + html = `
+ + +
`; + document.querySelector('.dialog').insertAdjacentHTML('beforeend', html); + } + document.querySelector('.dialog').classList.add('active'); + document.querySelector('.dialog__close').classList.add('active'); + document.querySelector('.dialog__close').addEventListener('click', () => { + closeDialog(); + }); + document.querySelector('.loader').classList.add('hide'); }; const sendClearDataRequest = () => { ipcRenderer.send('clear-user-data'); - console.log('cleardata'); }; - -if (config.get('serverGo') == true) { - document.querySelector('.loader').classList.remove('hide'); - ipcRenderer.send('check-server-status'); - ipcRenderer.on('server-online', () => { - document.querySelector('.loader').classList.add('hide'); - createUserList(); - }); - ipcRenderer.on('server-offline', () => { - html = ``; - document.querySelector('.loader').classList.add('hide'); - document.querySelector('.popup__exit__btn').addEventListener('click', () => { - ipcRenderer.send('reload-page'); - }); - document.querySelector('.error').insertAdjacentHTML('beforeend', html); - createServerErr(); - }); -} else if (config.get('serverGo') == false) { - saveBtn.onclick = () => { - ipcRenderer.send('setServer', serverUrl.value); - document.querySelector('.loader').classList.remove('hide'); - ipcRenderer.on('not-jf-server', () => { - document.querySelector('.loader').classList.add('hide'); - createServerErr(); - }); - }; -} - - const createManualLogin = () => { - html = `
- - - - -
`; + html = `

Login

+
+
+ + +
+
+ + +
+
+ + + + + +
+ + +
`; document.querySelector('.manual__input').insertAdjacentHTML('beforeend', html); + document.querySelector('.manual__login').classList.remove('hide'); + document.querySelector('.manual__login').scrollIntoView({ behavior: "smooth" }); }; const setLabelPos = (element) => { @@ -140,119 +168,84 @@ const setLabelPos = (element) => { }; const createEnterPassword = (userName, userImg, userId) => { - if (userImg == true) { - html = `
-
- -

Hello, ${userName}

-
-
- - -
-
- - - - - -
- -
`; - } else if (userImg == false) { - html = `
-
- -

Hello, ${userName}

-
-
- - -
-
- - - - - -
- -
`; - } + html = `
+
+

Hello, ${userName}

+
+
+ + +
+
+ + + + + +
+ +
`; document.querySelector('.manual__input').insertAdjacentHTML('beforeend', html); + if (userImg == true) { + html = ``; + document.querySelector('.manual__input').querySelector('.user__info').insertAdjacentHTML('afterbegin', html); + } else if (userImg == false) { + html = ``; + document.querySelector('.manual__input').querySelector('.user__info').insertAdjacentHTML('afterbegin', html); + } document.querySelector('.manual__login').classList.remove('hide'); document.querySelector('.manual__login').scrollIntoView({ behavior: "smooth" }); - setInterval(() => { - document.querySelector('.users').classList.add('hide'); - }, 1000); }; -const sendAuthInfo = (userName, password, checkbox) =>{ +const sendAuthInfo = (userName, password, checkbox) => { if (checkbox.checked == true) { ipcRenderer.send('user-auth-details', [userName, password, true]); } else { ipcRenderer.send('user-auth-details', [userName, password, false]); } - ipcRenderer.on('user-auth-failed', () => { - console.log('heloo'); - document.querySelector('.error').querySelector('.text').innerHTML = "Unable to login Please check your password"; - createServerErr(); - }); }; - const changeServer = () => { - html = ``; - document.querySelector('main').insertAdjacentHTML('beforeend', html); - - document.querySelector('.warning').classList.remove('hide'); - document.querySelector('.warning').classList.add('active'); - document.querySelector('.popup__exit').classList.remove('hide'); - document.querySelector('.popup__exit').classList.add('active'); + createDialog('Are you sure?', "You want to remove this server", "yes__no", "warning"); +}; - document.querySelector('.popup__exit').addEventListener('click', () => { - document.querySelector('.warning').classList.remove('active'); - document.querySelector('.warning').classList.add('fadeOut'); - document.querySelector('.popup__exit').classList.remove('active'); - document.querySelector('.popup__exit').classList.add('fadeOut'); - setTimeout(() => { - document.querySelector('.warning').classList.remove('fadeOut'); - document.querySelector('.popup__exit').classList.remove('fadeOut'); - document.querySelector('.warning').classList.add('hide'); - document.querySelector('.popup__exit').classList.add('hide'); - document.querySelector('.warning').remove(); - }, 305); +const goBack = (from, to, loginForm, button) => { + to.scrollIntoView({ behavior: "smooth" }); + setTimeout(() => { + from.classList.add('hide'); + from.querySelector(`.${loginForm}`).remove(); + html = `
`; + from.insertAdjacentHTML('beforeend', html); + }, 1000); +}; + +if (config.get('serverGo') == true) { + document.querySelector('.loader').classList.remove('hide'); + ipcRenderer.send('check-server-status'); + ipcRenderer.on('server-online', () => { + document.querySelector('.loader').classList.add('hide'); + createUserList(); }); - - document.querySelector('.popup__exit__btn').addEventListener('click', () => { - document.querySelector('.warning').classList.remove('active'); - document.querySelector('.warning').classList.add('fadeOut'); - document.querySelector('.popup__exit').classList.remove('active'); - document.querySelector('.popup__exit').classList.add('fadeOut'); - setTimeout(() => { - document.querySelector('.warning').classList.remove('fadeOut'); - document.querySelector('.popup__exit').classList.remove('fadeOut'); - document.querySelector('.warning').classList.add('hide'); - document.querySelector('.popup__exit').classList.add('hide'); - document.querySelector('.warning').remove(); - }, 305); + ipcRenderer.on('server-offline', () => { + createDialog('Error', "Cant connect to the jellyfin server", "remove__server", "error"); }); -}; \ No newline at end of file +} else if (config.get('serverGo') == false) { + saveBtn.addEventListener('click', () => { + ipcRenderer.send('setServer', serverUrl.value); + document.querySelector('.loader').classList.remove('hide'); + }, true); + ipcRenderer.on('not-jf-server', () => { + document.querySelector('.loader').classList.add('hide'); + createAlert('error', "Can't detrmine if the give server address is a valid Jellyfin server", ".server"); + }); + ipcRenderer.on('is-jf-server', () => { + createUserList(); + }); +} + +ipcRenderer.on('user-auth-failed', () => { + console.log(1); + createAlert('error', "Unable to login. Please check your password", ".manual__login"); +}); \ No newline at end of file diff --git a/src/render/js/home.js b/src/render/js/main.js similarity index 100% rename from src/render/js/home.js rename to src/render/js/main.js