mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-04 05:27:04 +08:00
chore (cleanup): refactoring syntax issue
This commit is contained in:
@ -51,7 +51,7 @@ export default async function(render) {
|
|||||||
effect(init$.pipe(
|
effect(init$.pipe(
|
||||||
rxjs.concatMap(() => getMiddlewareEnabled()),
|
rxjs.concatMap(() => getMiddlewareEnabled()),
|
||||||
rxjs.filter((backend) => !!backend),
|
rxjs.filter((backend) => !!backend),
|
||||||
rxjs.tap((backend) => qsa($page, "[is=\"box-item\"]").forEach(($button) => {
|
rxjs.tap((backend) => qsa($page, `[is="box-item"]`).forEach(($button) => {
|
||||||
$button.getAttribute("data-label") === backend
|
$button.getAttribute("data-label") === backend
|
||||||
? $button.classList.add("active")
|
? $button.classList.add("active")
|
||||||
: $button.classList.remove("active");
|
: $button.classList.remove("active");
|
||||||
@ -98,7 +98,7 @@ export default async function(render) {
|
|||||||
}
|
}
|
||||||
return idps;
|
return idps;
|
||||||
}),
|
}),
|
||||||
applyMutations(qs($page, "[data-bind=\"idp\"]"), "appendChild"),
|
applyMutations(qs($page, `[data-bind="idp"]`), "appendChild"),
|
||||||
rxjs.share(),
|
rxjs.share(),
|
||||||
);
|
);
|
||||||
effect(setupIDPForm$);
|
effect(setupIDPForm$);
|
||||||
@ -107,12 +107,12 @@ export default async function(render) {
|
|||||||
effect(setupIDPForm$.pipe(
|
effect(setupIDPForm$.pipe(
|
||||||
rxjs.concatMap(() => getMiddlewareEnabled()),
|
rxjs.concatMap(() => getMiddlewareEnabled()),
|
||||||
rxjs.tap((currentMiddleware) => {
|
rxjs.tap((currentMiddleware) => {
|
||||||
qsa($page, "[data-bind=\"idp\"] .formbuilder").forEach(($node) => {
|
qsa($page, `[data-bind="idp"] .formbuilder`).forEach(($node) => {
|
||||||
$node.getAttribute("id") === currentMiddleware
|
$node.getAttribute("id") === currentMiddleware
|
||||||
? $node.classList.remove("hidden")
|
? $node.classList.remove("hidden")
|
||||||
: $node.classList.add("hidden");
|
: $node.classList.add("hidden");
|
||||||
});
|
});
|
||||||
const $attrMap = qs($page, "[data-bind=\"attribute-mapping\"]");
|
const $attrMap = qs($page, `[data-bind="attribute-mapping"]`);
|
||||||
currentMiddleware
|
currentMiddleware
|
||||||
? $attrMap.classList.remove("hidden")
|
? $attrMap.classList.remove("hidden")
|
||||||
: $attrMap.classList.add("hidden");
|
: $attrMap.classList.add("hidden");
|
||||||
@ -154,7 +154,7 @@ export default async function(render) {
|
|||||||
}),
|
}),
|
||||||
)),
|
)),
|
||||||
rxjs.concatMap(async(specs) => await createForm(specs, formTmpl({}))),
|
rxjs.concatMap(async(specs) => await createForm(specs, formTmpl({}))),
|
||||||
applyMutation(qs($page, "[data-bind=\"attribute-mapping\"]"), "replaceChildren"),
|
applyMutation(qs($page, `[data-bind="attribute-mapping"]`), "replaceChildren"),
|
||||||
rxjs.share(),
|
rxjs.share(),
|
||||||
);
|
);
|
||||||
effect(setupAMForm$);
|
effect(setupAMForm$);
|
||||||
@ -163,14 +163,14 @@ export default async function(render) {
|
|||||||
effect(setupAMForm$.pipe(
|
effect(setupAMForm$.pipe(
|
||||||
rxjs.switchMap(() => rxjs.merge(
|
rxjs.switchMap(() => rxjs.merge(
|
||||||
getBackendEnabled(),
|
getBackendEnabled(),
|
||||||
rxjs.fromEvent(qs(document.body, "[data-bind=\"backend-enabled\"]"), "input").pipe(
|
rxjs.fromEvent(qs(document.body, `[data-bind="backend-enabled"]`), "input").pipe(
|
||||||
rxjs.debounceTime(500),
|
rxjs.debounceTime(500),
|
||||||
rxjs.mergeMap(() => getState().pipe(rxjs.map(({ connections }) => connections))),
|
rxjs.mergeMap(() => getState().pipe(rxjs.map(({ connections }) => connections))),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
rxjs.map((connections) => connections.map(({ label }) => label)),
|
rxjs.map((connections) => connections.map(({ label }) => label)),
|
||||||
rxjs.tap((datalist) => {
|
rxjs.tap((datalist) => {
|
||||||
const $input = $page.querySelector("[name=\"attribute_mapping.related_backend\"]");
|
const $input = $page.querySelector(`[name="attribute_mapping.related_backend"]`);
|
||||||
if (!$input) throw new ApplicationError("INTERNAL_ERROR", "assumption failed: missing related backend");
|
if (!$input) throw new ApplicationError("INTERNAL_ERROR", "assumption failed: missing related backend");
|
||||||
$input.setAttribute("datalist", datalist.join(","));
|
$input.setAttribute("datalist", datalist.join(","));
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -182,16 +182,16 @@ export default async function(render) {
|
|||||||
effect(setupAMForm$.pipe(
|
effect(setupAMForm$.pipe(
|
||||||
rxjs.switchMap(() => rxjs.merge(
|
rxjs.switchMap(() => rxjs.merge(
|
||||||
// case 1: user is typing in the related backend field
|
// case 1: user is typing in the related backend field
|
||||||
rxjs.fromEvent(qs($page, "[name=\"attribute_mapping.related_backend\"]"), "input").pipe(
|
rxjs.fromEvent(qs($page, `[name="attribute_mapping.related_backend"]`), "input").pipe(
|
||||||
rxjs.map((e) => e.target.value),
|
rxjs.map((e) => e.target.value),
|
||||||
),
|
),
|
||||||
// case 2: user is adding / removing a storage backend
|
// case 2: user is adding / removing a storage backend
|
||||||
getBackendEnabled().pipe(
|
getBackendEnabled().pipe(
|
||||||
rxjs.map(() => qs($page, "[name=\"attribute_mapping.related_backend\"]").value)
|
rxjs.map(() => qs($page, `[name=\"attribute_mapping.related_backend"]`).value)
|
||||||
),
|
),
|
||||||
// case 3: user is changing the storage backend label
|
// case 3: user is changing the storage backend label
|
||||||
rxjs.fromEvent(qs(document.body, "[data-bind=\"backend-enabled\"]"), "input").pipe(
|
rxjs.fromEvent(qs(document.body, `[data-bind="backend-enabled"]`), "input").pipe(
|
||||||
rxjs.map(() => qs($page, "[name=\"attribute_mapping.related_backend\"]").value),
|
rxjs.map(() => qs($page, `[name="attribute_mapping.related_backend"]`).value),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
rxjs.map((value) => value.split(",").map((val) => (val || "").trim()).filter((t) => !!t)),
|
rxjs.map((value) => value.split(",").map((val) => (val || "").trim()).filter((t) => !!t)),
|
||||||
@ -247,7 +247,7 @@ export default async function(render) {
|
|||||||
rxjs.tap(($node) => {
|
rxjs.tap(($node) => {
|
||||||
/** @type { Element | undefined} */
|
/** @type { Element | undefined} */
|
||||||
let $relatedBackendField;
|
let $relatedBackendField;
|
||||||
$page.querySelectorAll("[data-bind=\"attribute-mapping\"] fieldset").forEach(($el, i) => {
|
$page.querySelectorAll(`[data-bind="attribute-mapping"] fieldset`).forEach(($el, i) => {
|
||||||
if (i === 0) $relatedBackendField = $el;
|
if (i === 0) $relatedBackendField = $el;
|
||||||
else $el.remove();
|
else $el.remove();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -83,7 +83,7 @@ export function getState() {
|
|||||||
formObjToJSON$(),
|
formObjToJSON$(),
|
||||||
rxjs.map((config) => { // connections
|
rxjs.map((config) => { // connections
|
||||||
const connections = [];
|
const connections = [];
|
||||||
const formData = new FormData(qs(document.body, "[data-bind=\"backend-enabled\"]"));
|
const formData = new FormData(qs(document.body, `[data-bind="backend-enabled"]`));
|
||||||
for (const [type, label] of formData.entries()) {
|
for (const [type, label] of formData.entries()) {
|
||||||
connections.push({ type, label });
|
connections.push({ type, label });
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ export function getState() {
|
|||||||
}),
|
}),
|
||||||
rxjs.map((config) => { // middleware
|
rxjs.map((config) => { // middleware
|
||||||
const authType = document
|
const authType = document
|
||||||
.querySelector("[data-bind=\"authentication_middleware\"] [is=\"box-item\"].active")
|
.querySelector(`[data-bind="authentication_middleware"] [is="box-item"].active`)
|
||||||
?.getAttribute("data-label");
|
?.getAttribute("data-label");
|
||||||
|
|
||||||
config.middleware = {
|
config.middleware = {
|
||||||
@ -101,7 +101,7 @@ export function getState() {
|
|||||||
};
|
};
|
||||||
if (!authType) return config;
|
if (!authType) return config;
|
||||||
|
|
||||||
const $formIDP = document.querySelector("[data-bind=\"idp\"]");
|
const $formIDP = document.querySelector(`[data-bind="idp"]`);
|
||||||
if (!($formIDP instanceof window.HTMLFormElement)) throw new ApplicationError("INTERNAL_ERROR", "assumption failed: idp isn't a form");
|
if (!($formIDP instanceof window.HTMLFormElement)) throw new ApplicationError("INTERNAL_ERROR", "assumption failed: idp isn't a form");
|
||||||
let formValues = [...new FormData($formIDP)];
|
let formValues = [...new FormData($formIDP)];
|
||||||
config.middleware.identity_provider = {
|
config.middleware.identity_provider = {
|
||||||
@ -121,7 +121,7 @@ export function getState() {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
const $formAM = document.querySelector("[data-bind=\"attribute-mapping\"]");
|
const $formAM = document.querySelector(`[data-bind="attribute-mapping"]`);
|
||||||
if (!($formAM instanceof window.HTMLFormElement)) throw new ApplicationError("INTERNAL_ERROR", "assumption failed: attribute mapping isn't a form");
|
if (!($formAM instanceof window.HTMLFormElement)) throw new ApplicationError("INTERNAL_ERROR", "assumption failed: attribute mapping isn't a form");
|
||||||
formValues = [...new FormData($formAM)];
|
formValues = [...new FormData($formAM)];
|
||||||
config.middleware.attribute_mapping = {
|
config.middleware.attribute_mapping = {
|
||||||
|
|||||||
Reference in New Issue
Block a user