Works under a nested path
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
324be24430
commit
d562beef8e
@ -1,8 +1,8 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link rel="icon" href="../frontend/icons-192.png" sizes="192x192">
|
<link rel="icon" href="./frontend/icons-192.png" sizes="192x192">
|
||||||
<base href="/photos/">
|
<base href="/chalk/">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background-image: linear-gradient(#090B1A, #131524);
|
background-image: linear-gradient(#090B1A, #131524);
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
"googleapis": "^40.0.0",
|
"googleapis": "^40.0.0",
|
||||||
"handlebars": "^4.7.2",
|
"handlebars": "^4.7.2",
|
||||||
"jira-connector": "^2.10.0",
|
"jira-connector": "^2.10.0",
|
||||||
"ldapauth-fork": "^4.3.0",
|
"ldapauth-fork": "=4.2.0",
|
||||||
"ldapjs": "^1.0.2",
|
"ldapjs": "^1.0.2",
|
||||||
"mariasql": "^0.2.6",
|
"mariasql": "^0.2.6",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
|
@ -35,6 +35,7 @@ function ldapPromise(username, password) {
|
|||||||
if (!ldap) {
|
if (!ldap) {
|
||||||
return Promise.reject("LDAP not being used");
|
return Promise.reject("LDAP not being used");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
ldap.authenticate(username.replace(/@.*$/, ""), password, function(error, user) {
|
ldap.authenticate(username.replace(/@.*$/, ""), password, function(error, user) {
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -48,7 +49,6 @@ function ldapPromise(username, password) {
|
|||||||
const ldapJS = require("ldapjs"),
|
const ldapJS = require("ldapjs"),
|
||||||
ldapConfig = config.get("ldap");
|
ldapConfig = config.get("ldap");
|
||||||
|
|
||||||
|
|
||||||
const ldapSetPassword = function(username, password) {
|
const ldapSetPassword = function(username, password) {
|
||||||
const client = ldapJS.createClient({
|
const client = ldapJS.createClient({
|
||||||
url: ldapConfig.url
|
url: ldapConfig.url
|
||||||
@ -325,7 +325,8 @@ router.post("/login", function(req, res) {
|
|||||||
req.session.userId = "LDAP";
|
req.session.userId = "LDAP";
|
||||||
req.session.ldapUser = user;
|
req.session.ldapUser = user;
|
||||||
return user;
|
return user;
|
||||||
}).catch(function() {
|
}).catch(function(error) {
|
||||||
|
console.warn(error);
|
||||||
console.log("User not found in LDAP. Looking up in DB.");
|
console.log("User not found in LDAP. Looking up in DB.");
|
||||||
let query = "SELECT " +
|
let query = "SELECT " +
|
||||||
"id,mailVerified,authenticated,uid AS username,displayName AS name,mail " +
|
"id,mailVerified,authenticated,uid AS username,displayName AS name,mail " +
|
||||||
|
24
src/App.js
24
src/App.js
@ -108,14 +108,22 @@ class App extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log("App");
|
const tmp = document.querySelector("base");
|
||||||
|
let base;
|
||||||
|
if (tmp) {
|
||||||
|
base = new URL(tmp.href).pathname.replace(/\/$/, "") + "/"; /* Make sure there is a trailing slash */
|
||||||
|
} else {
|
||||||
|
base = "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("App: " + base);
|
||||||
return (
|
return (
|
||||||
<div className="App" ref={ ref => (this.app = ref) }>
|
<div className="App" ref={ ref => (this.app = ref) }>
|
||||||
<Header/>
|
<Header/>
|
||||||
<div className="Body">
|
<div className="Body">
|
||||||
<div className="Main">
|
<div className="Main">
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/identities" render={ (props) => <Identities {...props}/> }/>
|
<Route path={ base + "identities" } render={ (props) => <Identities {...props}/> }/>
|
||||||
<Route path="/faces" render={ props => <div {...props}/> }/>
|
<Route path="/faces" render={ props => <div {...props}/> }/>
|
||||||
<Route path="/photos" render={ props => <div {...props}/> }/>
|
<Route path="/photos" render={ props => <div {...props}/> }/>
|
||||||
</Switch>
|
</Switch>
|
||||||
@ -258,6 +266,8 @@ function makeFaceBoxes(photo, photoExplorer) {
|
|||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
window.open("identities?face=" + face.id, "faceId-" + face.id);
|
window.open("identities?face=" + face.id, "faceId-" + face.id);
|
||||||
} else {
|
} else {
|
||||||
|
const identitiesBlock = document.getElementById("identities");
|
||||||
|
identitiesBlock.innerHTML = "";
|
||||||
loadFace(face.id);
|
loadFace(face.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -425,6 +435,8 @@ function createUseThisIdentityButton(identityId) {
|
|||||||
const button = document.createElement("button");
|
const button = document.createElement("button");
|
||||||
button.textContent = "Use this identity";
|
button.textContent = "Use this identity";
|
||||||
button.addEventListener("click", (event) => {
|
button.addEventListener("click", (event) => {
|
||||||
|
const identitiesBlock = document.getElementById("identities");
|
||||||
|
identitiesBlock.innerHTML = "";
|
||||||
const object = {
|
const object = {
|
||||||
faces: []
|
faces: []
|
||||||
};
|
};
|
||||||
@ -457,6 +469,8 @@ function createActionButtons() {
|
|||||||
button = document.createElement("button");
|
button = document.createElement("button");
|
||||||
button.textContent = "Load random face";
|
button.textContent = "Load random face";
|
||||||
button.addEventListener("click", (event) => {
|
button.addEventListener("click", (event) => {
|
||||||
|
const identitiesBlock = document.getElementById("identities");
|
||||||
|
identitiesBlock.innerHTML = "";
|
||||||
loadFace();
|
loadFace();
|
||||||
});
|
});
|
||||||
buttonBlock.appendChild(button);
|
buttonBlock.appendChild(button);
|
||||||
@ -472,6 +486,8 @@ function createActionButtons() {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({ faceId: faceId })
|
body: JSON.stringify({ faceId: faceId })
|
||||||
}).then(res => res.json()).then(() => {
|
}).then(res => res.json()).then(() => {
|
||||||
|
const identitiesBlock = document.getElementById("identities");
|
||||||
|
identitiesBlock.innerHTML = "";
|
||||||
loadFace();
|
loadFace();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -562,6 +578,8 @@ function createNewIdentityEditor() {
|
|||||||
object.faces.push(face.getAttribute("face-id"));
|
object.faces.push(face.getAttribute("face-id"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const identitiesBlock = document.getElementById("identities");
|
||||||
|
identitiesBlock.innerHTML = "";
|
||||||
window.fetch("api/v1/identities", {
|
window.fetch("api/v1/identities", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@ -579,6 +597,8 @@ function createNewIdentityEditor() {
|
|||||||
});
|
});
|
||||||
const face = document.body.querySelector("#face-editor .face"),
|
const face = document.body.querySelector("#face-editor .face"),
|
||||||
faceId = parseInt(face.getAttribute("face-id"));
|
faceId = parseInt(face.getAttribute("face-id"));
|
||||||
|
const identitiesBlock = document.getElementById("identities");
|
||||||
|
identitiesBlock.innerHTML = "";
|
||||||
loadFace(faceId);
|
loadFace(faceId);
|
||||||
getIdentities(faceId);
|
getIdentities(faceId);
|
||||||
});
|
});
|
||||||
|
@ -2,30 +2,36 @@ const path = require("path");
|
|||||||
const merge = require('webpack-merge')
|
const merge = require('webpack-merge')
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
|
const config = require('config');
|
||||||
|
|
||||||
|
const base = config.get("basePath");
|
||||||
|
|
||||||
|
const proxy = {
|
||||||
|
// "/photos/api/*": "http://localhost:8123/",
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy[`${base}/`] = {
|
||||||
|
target: "http://localhost:8766",
|
||||||
|
bypass: function(req, res, proxyOptions) {
|
||||||
|
console.log(req.url);
|
||||||
|
if (req.url.match(new RegExp(base.replace(/\//g, "\\/") + "\/identities[/?]?"))) {
|
||||||
|
return 'index.html';
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = merge(common, {
|
module.exports = merge(common, {
|
||||||
mode: "development",
|
mode: "development",
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: path.join(__dirname, "/"),
|
contentBase: path.join(__dirname, "/"),
|
||||||
port: 8765,
|
port: 8765,
|
||||||
publicPath: "http://localhost:8765/photos/dist/",
|
publicPath: `http://localhost:8765${base}/dist/`,
|
||||||
hotOnly: true,
|
hotOnly: true,
|
||||||
disableHostCheck: true,
|
disableHostCheck: true,
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
proxy: {
|
proxy: proxy
|
||||||
// "/photos/api/*": "http://localhost:8123/",
|
|
||||||
"/photos/": {
|
|
||||||
target: "http://localhost:8123",
|
|
||||||
bypass: function(req, res, proxyOptions) {
|
|
||||||
console.log(req.url);
|
|
||||||
if (req.url.match(/^\/photos\/identities[/?]?/)) {
|
|
||||||
return 'index.html';
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
plugins: [new webpack.HotModuleReplacementPlugin()]
|
plugins: [new webpack.HotModuleReplacementPlugin()]
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user