mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2026-10-19 16:14:39 +00:00
chore (refactoring): cleanup
This commit is contained in:
+4
-1
@@ -23,7 +23,8 @@
|
||||
"crw": "image/x-canon-crw",
|
||||
"css": "text/css",
|
||||
"csv": "text/csv",
|
||||
"dcm": "image/dicom",
|
||||
"dbf": "application/dbf",
|
||||
"dcm": "image/dicom",
|
||||
"dcr": "image/x-kodak-dcr",
|
||||
"deb": "application/octet-stream",
|
||||
"der": "application/x-x509-ca-cert",
|
||||
@@ -128,6 +129,7 @@
|
||||
"pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
|
||||
"pptx": "application/powerpoint",
|
||||
"prc": "application/x-pilot",
|
||||
"prj": "application/text",
|
||||
"properties": "text/x-ini",
|
||||
"ps": "application/postscript",
|
||||
"psd": "image/vnd.adobe.photoshop",
|
||||
@@ -145,6 +147,7 @@
|
||||
"sea": "application/x-sea",
|
||||
"shtml": "text/html",
|
||||
"shp": "application/vnd.shp",
|
||||
"shx": "application/vnd.shx",
|
||||
"sit": "application/x-stuffit",
|
||||
"so": "application/octet-stream",
|
||||
"sr2": "image/x-sony-sr2",
|
||||
|
||||
@@ -47,7 +47,7 @@ function execute(module, $app, opts) {
|
||||
|
||||
function poweredBy($app) {
|
||||
return createElement(`
|
||||
<div style="position: absolute; bottom: 0; left: 0; font-size: 0.9rem; display: inline-block;">
|
||||
<div style="position: absolute; bottom: 0; left: 0; font-size: 0.9rem; display: inline-block; z-index: 2">
|
||||
Powered By <a href="https://www.filestash.app" style="text-decoration:underline;">Filestash</a>
|
||||
</div>
|
||||
`);
|
||||
|
||||
+10
-17
@@ -39,29 +39,22 @@ function processError(xhr, err) {
|
||||
let responseText = "";
|
||||
try {
|
||||
responseText = xhr?.responseText;
|
||||
} catch (err) {
|
||||
if (err.name === "InvalidStateError") {} // InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').
|
||||
else throw err;
|
||||
}
|
||||
// InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').
|
||||
} catch (err) {}
|
||||
|
||||
const response = (function(content) {
|
||||
let message = content;
|
||||
const message = (function(content) {
|
||||
try {
|
||||
message = JSON.parse(content);
|
||||
return JSON.parse(content).message;
|
||||
} catch (err) {
|
||||
return {
|
||||
message: Array.from(new Set(
|
||||
content.replace(/<[^>]*>/g, "")
|
||||
.replace(/\n{2,}/, "\n")
|
||||
.trim()
|
||||
.split("\n")
|
||||
)).join(" ")
|
||||
};
|
||||
return Array.from(new Set(
|
||||
content.replace(/<[^>]*>/g, "")
|
||||
.replace(/\n{2,}/, "\n")
|
||||
.trim()
|
||||
.split("\n")
|
||||
)).join(" ");
|
||||
}
|
||||
return message || { message: "empty response" };
|
||||
})(responseText);
|
||||
|
||||
const message = response.message || null;
|
||||
if (window.navigator.onLine === false) {
|
||||
return new AjaxError("Connection Lost", err, "NO_INTERNET");
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
function createCommonjsModule(fn) {
|
||||
var module = { exports: {} };
|
||||
return fn(module, module.exports), module.exports;
|
||||
@@ -2740,3 +2741,4 @@ class BrowserShp extends Shp {
|
||||
|
||||
export { BrowserShp as default };
|
||||
export const Buffer = buffer.Buffer;
|
||||
export const DBase = Properties;
|
||||
|
||||
@@ -99,7 +99,6 @@ function formatTrace(str) {
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
|
||||
const css = `
|
||||
.error-page {
|
||||
width: 80%;
|
||||
|
||||
@@ -41,6 +41,8 @@ function loadModule(appName) {
|
||||
return import("./viewerpage/application_map.js");
|
||||
case "url":
|
||||
return import("./viewerpage/application_url.js");
|
||||
case "table":
|
||||
return import("./viewerpage/application_table.js");
|
||||
default:
|
||||
throw new ApplicationError("Internal Error", `Unknown opener app "${appName}" at "${getCurrentPath()}"`);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createElement, nop } from "../../lib/skeleton/index.js";
|
||||
import rxjs, { effect } from "../../lib/rx.js";
|
||||
import { qs } from "../../lib/dom.js";
|
||||
import { extname } from "../../lib/path.js";
|
||||
import ajax from "../../lib/ajax.js";
|
||||
import { loadCSS, loadJS } from "../../helpers/loader.js";
|
||||
import { createLoader } from "../../components/loader.js";
|
||||
@@ -33,12 +32,14 @@ export default async function(render, { mime, getDownloadUrl = nop, getFilename
|
||||
const removeLoader = createLoader(qs($page, "#map"));
|
||||
await effect(ajax({ url: getDownloadUrl(), responseType: "arraybuffer" }).pipe(
|
||||
rxjs.map(({ response }) => response),
|
||||
rxjs.mergeMap(async(data) => { switch(mime) {
|
||||
rxjs.mergeMap(async(data) => {
|
||||
switch (mime) {
|
||||
case "application/geo+json": return loadGeoJSON(map, JSON.parse(new TextDecoder().decode(data)));
|
||||
case "application/vnd.ogc.wms_xml": return loadWMS(map, new TextDecoder().decode(data));
|
||||
case "application/vnd.shp": return await loadSHP(map, data);
|
||||
default: throw new Error(`Insupported mime type: '${mime}'`);
|
||||
}}),
|
||||
}
|
||||
}),
|
||||
removeLoader,
|
||||
rxjs.catchError(ctrlError()),
|
||||
));
|
||||
|
||||
@@ -34,7 +34,9 @@ export function opener(file = "", mimes) {
|
||||
return ["3d", { mime }];
|
||||
} else if (mime === "application/x-url") {
|
||||
return ["url", { mime }];
|
||||
} else if (type === "application") {
|
||||
} else if (["application/dbf"].indexOf(mime) !== -1) {
|
||||
return ["table", { mime }];
|
||||
} else if (type === "application" && mime !== "application/text") {
|
||||
return ["download", { mime }];
|
||||
}
|
||||
return ["editor", { mime }];
|
||||
|
||||
@@ -127,6 +127,9 @@
|
||||
],
|
||||
"no-template-curly-in-string": [
|
||||
"off"
|
||||
],
|
||||
"new-cap": [
|
||||
"off"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user