Add user login to admin interface
This commit is contained in:
parent
dbe494751a
commit
82bfc15057
15 changed files with 256 additions and 79 deletions
|
|
@ -16,13 +16,13 @@ var AssetsComponentsIndex = Assets{
|
|||
|
||||
// AssetsControlIndex contains assets for the 'ControlIndex' entrypoint.
|
||||
var AssetsControlIndex = Assets{
|
||||
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ControlIndex.6d1d8ee0.js"></script><script src="/static/ControlIndex.03d7b00f.js" nomodule="" defer></script>`,
|
||||
Scripts: `<script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ControlIndex.a72fc239.js"></script><script src="/static/ControlIndex.75d2a312.js" nomodule="" defer></script>`,
|
||||
Styles: `<link rel="stylesheet" href="/static/HomeHome.a75f04fa.css"><link rel="stylesheet" href="/static/ControlIndex.6d59e220.css"><link rel="stylesheet" href="/static/ControlIndex.6d2ae968.css">`,
|
||||
}
|
||||
|
||||
// AssetsControlInstance contains assets for the 'ControlInstance' entrypoint.
|
||||
var AssetsControlInstance = Assets{
|
||||
Scripts: `<script nomodule="" defer src="/static/ControlIndex.03d7b00f.js"></script><script type="module" src="/static/ControlIndex.6d1d8ee0.js"></script><script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ControlInstance.66b95713.js"></script><script src="/static/ControlInstance.9cc7166d.js" nomodule="" defer></script>`,
|
||||
Scripts: `<script nomodule="" defer src="/static/ControlIndex.75d2a312.js"></script><script type="module" src="/static/ControlIndex.a72fc239.js"></script><script type="module" src="/static/HomeHome.38d394c2.js"></script><script src="/static/HomeHome.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/ControlInstance.66b95713.js"></script><script src="/static/ControlInstance.9cc7166d.js" nomodule="" defer></script>`,
|
||||
Styles: `<link rel="stylesheet" href="/static/HomeHome.a75f04fa.css"><link rel="stylesheet" href="/static/ControlIndex.6d59e220.css"><link rel="stylesheet" href="/static/ControlIndex.6d2ae968.css"><link rel="stylesheet" href="/static/ControlInstance.38d394c2.css">`,
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
internal/dis/component/control/static/dist/ControlIndex.75d2a312.js
vendored
Normal file
1
internal/dis/component/control/static/dist/ControlIndex.75d2a312.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
internal/dis/component/control/static/dist/ControlIndex.a72fc239.js
vendored
Normal file
1
internal/dis/component/control/static/dist/ControlIndex.a72fc239.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -46,8 +46,8 @@ function makeTextBuffer(target: HTMLElement, scrollContainer: HTMLElement, size:
|
|||
return println;
|
||||
}
|
||||
|
||||
const elements = document.getElementsByClassName('remote-action')
|
||||
Array.from(elements).forEach((element) => {
|
||||
const remote_action = document.getElementsByClassName('remote-action')
|
||||
Array.from(remote_action).forEach((element) => {
|
||||
const action = element.getAttribute('data-action') as string;
|
||||
const reload = element.hasAttribute('data-force-reload');
|
||||
const param = element.getAttribute('data-param') as string | undefined;
|
||||
|
|
@ -122,4 +122,59 @@ Array.from(elements).forEach((element) => {
|
|||
close();
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
const remote_link = document.getElementsByClassName('remote-link')
|
||||
Array.from(remote_link).forEach((element) => {
|
||||
const action = element.getAttribute('data-action') as string;
|
||||
const param = element.getAttribute('data-params') as string | undefined;
|
||||
const params = param?.split(" ");
|
||||
|
||||
element.addEventListener('click', function (ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
getValue(action, params).then(v => {
|
||||
window.open(v);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
})
|
||||
});
|
||||
})
|
||||
|
||||
async function getValue(action: string, params?: Array<string>): Promise<any> {
|
||||
return new Promise((rs, rj) => {
|
||||
let buffer = "";
|
||||
var resolve = function() {
|
||||
const index = buffer.indexOf('\n')
|
||||
if (index < 0) {
|
||||
rj("invalid buffer");
|
||||
return
|
||||
}
|
||||
|
||||
// check that the server sent back true
|
||||
const ok = buffer.substring(0, index) === 'true';
|
||||
if(!ok) {
|
||||
rj(buffer);
|
||||
return
|
||||
}
|
||||
|
||||
// parse the rest as json
|
||||
const value = JSON.parse(buffer.substring(index+1))
|
||||
rs(value);
|
||||
}
|
||||
|
||||
connectSocket((socket) => {
|
||||
socket.send(action);
|
||||
if (params) {
|
||||
params.forEach(p => socket.send(p))
|
||||
}
|
||||
}, (data) => {
|
||||
buffer += data + "\n";
|
||||
}).then(() => {
|
||||
resolve();
|
||||
}).catch(() => {
|
||||
buffer = "false\n";
|
||||
resolve();
|
||||
});
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue