mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
html files for pages
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -32,3 +32,5 @@ app/src/nativeModulesContent.js
|
|||||||
packages/api/src/nativeModulesContent.js
|
packages/api/src/nativeModulesContent.js
|
||||||
packages/api/src/packagedPluginsContent.js
|
packages/api/src/packagedPluginsContent.js
|
||||||
.VSCodeCounter
|
.VSCodeCounter
|
||||||
|
|
||||||
|
pacgaes/web/public/*.html
|
||||||
8
packages/web/build-index.js
Normal file
8
packages/web/build-index.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const template = fs.readFileSync('./index.html.tpl', 'utf-8');
|
||||||
|
|
||||||
|
for (const page of ['', 'not-logged', 'error', 'admin-login', 'login', 'admin', 'license']) {
|
||||||
|
const text = template.replace(/{{page}}/g, page);
|
||||||
|
fs.writeFileSync(`public/${page || 'index'}.html`, text);
|
||||||
|
}
|
||||||
@@ -22,6 +22,11 @@
|
|||||||
<link rel="stylesheet" href="build/fonts/materialdesignicons.css" />
|
<link rel="stylesheet" href="build/fonts/materialdesignicons.css" />
|
||||||
<link rel="stylesheet" href="build/diff2html.min.css" />
|
<link rel="stylesheet" href="build/diff2html.min.css" />
|
||||||
|
|
||||||
|
<script lang="javascript">
|
||||||
|
window.dbgate_page = '{{page}}';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script defer src="build/bundle.js"></script>
|
<script defer src="build/bundle.js"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -2,10 +2,11 @@
|
|||||||
"name": "dbgate-web",
|
"name": "dbgate-web",
|
||||||
"version": "5.0.0-alpha.1",
|
"version": "5.0.0-alpha.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"build": "yarn build:index && rollup -c",
|
||||||
"dev": "cross-env API_URL=http://localhost:3000 rollup -c -w",
|
"dev": "yarn build:index && cross-env API_URL=http://localhost:3000 rollup -c -w",
|
||||||
"start": "sirv public --port 5001",
|
"start": "sirv public --port 5001",
|
||||||
"validate": "svelte-check",
|
"validate": "svelte-check",
|
||||||
|
"build:index": "node build-index.js",
|
||||||
"prepublishOnly": "yarn build"
|
"prepublishOnly": "yarn build"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
});
|
});
|
||||||
if (resp.error) {
|
if (resp.error) {
|
||||||
internalRedirectTo(
|
internalRedirectTo(
|
||||||
`/?page=not-logged&error=${encodeURIComponent(resp.error)}&is-admin=${isAdminPage ? 'true' : ''}`
|
`/not-logged.html?error=${encodeURIComponent(resp.error)}&is-admin=${isAdminPage ? 'true' : ''}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -111,13 +111,13 @@
|
|||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
localStorage.setItem(isAdminPage ? 'adminAccessToken' : 'accessToken', accessToken);
|
localStorage.setItem(isAdminPage ? 'adminAccessToken' : 'accessToken', accessToken);
|
||||||
if (isAdminPage) {
|
if (isAdminPage) {
|
||||||
internalRedirectTo('/?page=admin');
|
internalRedirectTo('/admin.html');
|
||||||
} else {
|
} else {
|
||||||
internalRedirectTo('/');
|
internalRedirectTo('/');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
internalRedirectTo(`/?page=not-logged`);
|
internalRedirectTo(`/not-logged.html`);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function handleOauthCallback() {
|
|||||||
internalRedirectTo('/');
|
internalRedirectTo('/');
|
||||||
} else {
|
} else {
|
||||||
console.log('Error when processing OAUTH callback', error || errorMessage);
|
console.log('Error when processing OAUTH callback', error || errorMessage);
|
||||||
internalRedirectTo(`/?page=not-logged&error=${error || errorMessage}`);
|
internalRedirectTo(`/not-logged.html?error=${error || errorMessage}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,9 +81,9 @@ export function handleOauthCallback() {
|
|||||||
if (authResp.success) {
|
if (authResp.success) {
|
||||||
window.close();
|
window.close();
|
||||||
} else if (authResp.error) {
|
} else if (authResp.error) {
|
||||||
internalRedirectTo(`/?page=error&error=${encodeURIComponent(authResp.error)}`);
|
internalRedirectTo(`/error.html?error=${encodeURIComponent(authResp.error)}`);
|
||||||
} else {
|
} else {
|
||||||
internalRedirectTo(`/?page=error`);
|
internalRedirectTo(`/error.html`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,9 +105,9 @@ export function handleOauthCallback() {
|
|||||||
localStorage.setItem('accessToken', authResp.accessToken);
|
localStorage.setItem('accessToken', authResp.accessToken);
|
||||||
internalRedirectTo('/');
|
internalRedirectTo('/');
|
||||||
} else if (authResp.error) {
|
} else if (authResp.error) {
|
||||||
internalRedirectTo(`/?page=error&error=${encodeURIComponent(authResp.error)}`);
|
internalRedirectTo(`/error.html?error=${encodeURIComponent(authResp.error)}`);
|
||||||
} else {
|
} else {
|
||||||
internalRedirectTo(`/?page=error`);
|
internalRedirectTo(`/error.html`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -119,15 +119,15 @@ export function handleOauthCallback() {
|
|||||||
|
|
||||||
export async function handleAuthOnStartup(config, isAdminPage = false) {
|
export async function handleAuthOnStartup(config, isAdminPage = false) {
|
||||||
if (config.configurationError) {
|
if (config.configurationError) {
|
||||||
internalRedirectTo(`/?page=error`);
|
internalRedirectTo(`/error.html`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.isLicenseValid) {
|
if (!config.isLicenseValid) {
|
||||||
if (config.storageDatabase || getElectron()) {
|
if (config.storageDatabase || getElectron()) {
|
||||||
internalRedirectTo(`/?page=license`);
|
internalRedirectTo(`/license.html`);
|
||||||
} else {
|
} else {
|
||||||
internalRedirectTo(`/?page=error`);
|
internalRedirectTo(`/error.html`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ export async function handleAuthOnStartup(config, isAdminPage = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function redirectToAdminLogin() {
|
export async function redirectToAdminLogin() {
|
||||||
internalRedirectTo('/?page=admin-login');
|
internalRedirectTo('/admin-login.html');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,12 +165,12 @@ export async function redirectToLogin(config = null, force = false) {
|
|||||||
|
|
||||||
if (getAuthCategory(config) == 'token') {
|
if (getAuthCategory(config) == 'token') {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
const params = new URLSearchParams(location.search);
|
const page = window['dbgate_page']
|
||||||
if (params.get('page') == 'login' || params.get('page') == 'admin-login' || params.get('page') == 'not-logged') {
|
if (page == 'login' || page == 'admin-login' || page == 'not-logged') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internalRedirectTo('/?page=login');
|
internalRedirectTo('/login.html');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,13 +201,13 @@ export async function doLogout() {
|
|||||||
|
|
||||||
if (category == 'admin') {
|
if (category == 'admin') {
|
||||||
localStorage.removeItem('adminAccessToken');
|
localStorage.removeItem('adminAccessToken');
|
||||||
internalRedirectTo('/?page=admin-login&is-admin=true');
|
internalRedirectTo('/admin-login.html?is-admin=true');
|
||||||
} else if (category == 'token') {
|
} else if (category == 'token') {
|
||||||
localStorage.removeItem('accessToken');
|
localStorage.removeItem('accessToken');
|
||||||
if (config.logoutUrl) {
|
if (config.logoutUrl) {
|
||||||
window.location.href = config.logoutUrl;
|
window.location.href = config.logoutUrl;
|
||||||
} else {
|
} else {
|
||||||
internalRedirectTo('/?page=not-logged');
|
internalRedirectTo('/not-logged.html');
|
||||||
}
|
}
|
||||||
} else if (category == 'basic') {
|
} else if (category == 'basic') {
|
||||||
window.location.href = 'config/logout';
|
window.location.href = 'config/logout';
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ import NotLoggedPage from './NotLoggedPage.svelte';
|
|||||||
import ErrorPage from './ErrorPage.svelte';
|
import ErrorPage from './ErrorPage.svelte';
|
||||||
import EnterLicensePage from './EnterLicensePage.svelte';
|
import EnterLicensePage from './EnterLicensePage.svelte';
|
||||||
|
|
||||||
const params = new URLSearchParams(location.search);
|
|
||||||
const page = params.get('page');
|
|
||||||
|
|
||||||
const isOauthCallback = handleOauthCallback();
|
const isOauthCallback = handleOauthCallback();
|
||||||
|
|
||||||
localStorageGarbageCollector();
|
localStorageGarbageCollector();
|
||||||
@@ -21,7 +18,7 @@ function createApp() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (page) {
|
switch (window['dbgate_page']) {
|
||||||
case 'login':
|
case 'login':
|
||||||
return new LoginPage({
|
return new LoginPage({
|
||||||
target: document.body,
|
target: document.body,
|
||||||
|
|||||||
@@ -175,13 +175,13 @@ export async function apiCall(route: string, args: {} = undefined) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (resp.status == 401 && !apiDisabled) {
|
if (resp.status == 401 && !apiDisabled) {
|
||||||
const params = new URLSearchParams(location.search);
|
const page = window['dbgate_page'];
|
||||||
|
|
||||||
disableApi();
|
disableApi();
|
||||||
console.log('Disabling API', route);
|
console.log('Disabling API', route);
|
||||||
if (params.get('page') != 'login' && params.get('page') != 'admin-login' && params.get('page') != 'not-logged') {
|
if (page != 'login' && page != 'admin-login' && page != 'not-logged') {
|
||||||
// unauthorized
|
// unauthorized
|
||||||
if (params.get('page') == 'admin') {
|
if (page == 'admin') {
|
||||||
redirectToAdminLogin();
|
redirectToAdminLogin();
|
||||||
} else {
|
} else {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
let isAdminPageCache;
|
|
||||||
|
|
||||||
export function isAdminPage() {
|
export function isAdminPage() {
|
||||||
if (isAdminPageCache == null) {
|
return window['dbgate_page'] == 'admin';
|
||||||
const params = new URLSearchParams(location.search);
|
|
||||||
const urlPage = params.get('page');
|
|
||||||
|
|
||||||
isAdminPageCache = urlPage == 'admin';
|
|
||||||
}
|
|
||||||
return isAdminPageCache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOpenedTabsStorageName() {
|
export function getOpenedTabsStorageName() {
|
||||||
|
|||||||
Reference in New Issue
Block a user