webapp folder migration
@ -4,6 +4,7 @@ const winston = require('winston');
|
||||
const express = require('express');
|
||||
const mstream = express();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const jukebox = require('./modules/jukebox.js');
|
||||
@ -54,6 +55,7 @@ exports.serveIt = async configFile => {
|
||||
|
||||
// Give access to public folder
|
||||
mstream.use('/public', express.static( config.program.webAppDirectory ));
|
||||
mstream.use('/', express.static(path.join(__dirname, 'webapp')));
|
||||
// Serve the webapp
|
||||
mstream.get('/', (req, res) => {
|
||||
res.sendFile('mstream.html', { root: config.program.webAppDirectory });
|
||||
|
||||
@ -6,14 +6,14 @@
|
||||
<title>mStream Admin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="public/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="public/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="public/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="public/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="public/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="public/assets/fav/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="/assets/fav/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-config" content="public/assets/fav/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="/assets/fav/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<!-- Font -->
|
||||
@ -23,7 +23,6 @@
|
||||
<script src="/public/js/lib/axios.js"></script>
|
||||
<script defer src="/public/js/lib/materialize.js"></script>
|
||||
<script defer src="/public/js/spa.js"></script>
|
||||
<script defer src="/public/js/api.js"></script>
|
||||
<script defer src="/public/js/admin.js"></script>
|
||||
|
||||
<!-- iziToast -->
|
||||
@ -35,6 +34,9 @@
|
||||
<link rel="stylesheet" href="/public/css/spa.css">
|
||||
<link rel="stylesheet" href="/public/css/spinner.css">
|
||||
<link rel="stylesheet" href="/public/css/admin.css">
|
||||
|
||||
<script src="/assets/js/api.js"></script>
|
||||
<script>API.checkAuthAndKickToLogin();</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@ -292,7 +292,6 @@ const usersView = Vue.component('users-view', {
|
||||
guest: this.userClass === 'guest' ? true : false
|
||||
};
|
||||
|
||||
console.log(data)
|
||||
await API.axios({
|
||||
method: 'PUT',
|
||||
url: `${API.url()}/api/v1/admin/user`,
|
||||
@ -303,6 +302,23 @@ const usersView = Vue.component('users-view', {
|
||||
this.newUsername = '';
|
||||
this.newPassword = '';
|
||||
|
||||
// if this is the first user, prompt user and take them to login page
|
||||
if (Object.keys(ADMINDATA.users).length === 1) {
|
||||
iziToast.question({
|
||||
timeout: false,
|
||||
close: false,
|
||||
overlay: true,
|
||||
displayMode: 'once',
|
||||
id: 'question',
|
||||
zindex: 99999,
|
||||
title: 'You will be taken the login page',
|
||||
position: 'center',
|
||||
buttons: [['<button>Go!</button>', (instance, toast) => {
|
||||
API.checkAuthAndKickToLogin();
|
||||
}, true]],
|
||||
});
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
M.updateTextFields();
|
||||
});
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
const API = (() => {
|
||||
const module = {};
|
||||
|
||||
// initialize with a default server
|
||||
module.servers = [{
|
||||
name: "default",
|
||||
url: window.location.origin,
|
||||
token: localStorage.getItem('token')
|
||||
}];
|
||||
|
||||
module.selectedServer = 0;
|
||||
|
||||
module.addServer = (name, url, username, password) => {
|
||||
module.servers.push({
|
||||
name: name,
|
||||
url: url,
|
||||
token: null
|
||||
})
|
||||
}
|
||||
|
||||
module.name = () => {
|
||||
return module.servers[module.selectedServer].name;
|
||||
}
|
||||
|
||||
module.token = () => {
|
||||
return module.servers[module.selectedServer].token;
|
||||
}
|
||||
|
||||
module.url = () => {
|
||||
return module.servers[module.selectedServer].url;
|
||||
}
|
||||
|
||||
module.checkAuthAndKickToLogin = async () => {
|
||||
if (module.servers[0].token === null) {
|
||||
window.location.replace(`/login?redirect=${encodeURIComponent(window.location.pathname)}`);
|
||||
}
|
||||
|
||||
// Send request to server
|
||||
try {
|
||||
await axios({
|
||||
method: 'GET',
|
||||
url: `${module.url()}/api/`,
|
||||
headers: { 'x-access-token': module.token() }
|
||||
});
|
||||
} catch (err) {
|
||||
window.location.replace(`/login?redirect=${encodeURIComponent(window.location.pathname)}`);
|
||||
}
|
||||
}
|
||||
|
||||
module.logout = () => {
|
||||
localStorage.removeItem('authToken');
|
||||
window.location.replace(`/login`);
|
||||
}
|
||||
|
||||
module.axios = axios.create({
|
||||
baseURL: module.url(),
|
||||
headers: { 'x-access-token': module.token() }
|
||||
});
|
||||
|
||||
return module;
|
||||
})();
|
||||
@ -10,14 +10,14 @@
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="public/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="public/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="public/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="public/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="public/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="public/assets/fav/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="/assets/fav/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-config" content="public/assets/fav/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="/assets/fav/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<link rel="stylesheet" href="/public/css/foundation.css" />
|
||||
|
||||
@ -7,14 +7,14 @@
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="public/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="public/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="public/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="public/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="public/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="public/assets/fav/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="/assets/fav/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-config" content="public/assets/fav/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="/assets/fav/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<script src="/public/js/lib/jquery-2.2.4.min.js"></script>
|
||||
|
||||
@ -6,14 +6,14 @@
|
||||
<title>mStream Remote</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="public/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="public/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="public/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="public/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="public/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="public/assets/fav/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="/assets/fav/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-config" content="public/assets/fav/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="/assets/fav/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<!-- mStream CSS -->
|
||||
|
||||
@ -6,14 +6,14 @@
|
||||
<title>mStream Music</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="public/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="public/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="public/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="public/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="public/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="public/assets/fav/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="/assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="/assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="/assets/fav/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-config" content="public/assets/fav/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="/assets/fav/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<!-- mStream CSS -->
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 414 B |
|
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 492 B |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -5,7 +5,7 @@ const API = (() => {
|
||||
module.servers = [{
|
||||
name: "default",
|
||||
url: window.location.origin,
|
||||
token: localStorage.getItem('authToken')
|
||||
token: localStorage.getItem('token')
|
||||
}];
|
||||
|
||||
module.selectedServer = 0;
|
||||
@ -48,7 +48,7 @@ const API = (() => {
|
||||
}
|
||||
|
||||
module.logout = () => {
|
||||
localStorage.removeItem('authToken');
|
||||
localStorage.removeItem('token');
|
||||
window.location.replace(`/login`);
|
||||
}
|
||||
|
||||
@ -6,25 +6,25 @@
|
||||
<title>Login</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="/fav/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="../assets/fav/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="../assets/fav/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../assets/fav/favicon-16x16.png">
|
||||
<link rel="manifest" href="../assets/fav/site.webmanifest">
|
||||
<link rel="mask-icon" href="../assets/fav/safari-pinned-tab.svg" color="#5bbad5">
|
||||
<link rel="shortcut icon" href="../assets/fav/favicon.ico">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-config" content="/fav/browserconfig.xml">
|
||||
<meta name="msapplication-config" content="../assets/fav/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<script defer src="/js/lib/axios.js"></script>
|
||||
<script defer src="/js/lib/izi-toast.js"></script>
|
||||
<script defer src="/js/api.js"></script>
|
||||
<script defer src="../assets/js/lib/axios.js"></script>
|
||||
<script defer src="../assets/js/lib/izi-toast.js"></script>
|
||||
<script defer src="../assets/js/api.js"></script>
|
||||
<script defer src="index.js"></script>
|
||||
<script defer src="/js/waves.js"></script>
|
||||
<script defer src="../assets/js/waves.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/css/izi-toast.css">
|
||||
<link rel="stylesheet" href="/css/material-input.css">
|
||||
<link rel="stylesheet" href="/css/waves.css">
|
||||
<link rel="stylesheet" href="../assets/css/izi-toast.css">
|
||||
<link rel="stylesheet" href="../assets/css/material-input.css">
|
||||
<link rel="stylesheet" href="../assets/css/waves.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
@ -1,6 +1,6 @@
|
||||
// Check Token
|
||||
async function checkToken() {
|
||||
if (!localStorage.getItem('authToken')) {
|
||||
if (!localStorage.getItem('token')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -8,12 +8,12 @@ async function checkToken() {
|
||||
await axios({
|
||||
method: 'GET',
|
||||
url: `${API.url()}/api/`,
|
||||
headers: { 'x-access-token': localStorage.getItem('authToken') }
|
||||
headers: { 'x-access-token': localStorage.getItem('token') }
|
||||
});
|
||||
|
||||
window.location.replace(`/`);
|
||||
} catch (err) {
|
||||
// localStorage.removeItem('authToken');
|
||||
// localStorage.removeItem('token');
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ document.getElementById("login").addEventListener("submit", async e =>{
|
||||
}
|
||||
});
|
||||
|
||||
localStorage.setItem("authToken", res.data.token);
|
||||
localStorage.setItem("token", res.data.token);
|
||||
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||