mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
chore (refactoring): 3d app revamp
This commit is contained in:
parent
fd839808b7
commit
0d4709595c
7 changed files with 32 additions and 24 deletions
|
|
@ -9,11 +9,12 @@ const config$ = ajax({
|
||||||
rxjs.map(({ responseJSON }) => responseJSON.result),
|
rxjs.map(({ responseJSON }) => responseJSON.result),
|
||||||
);
|
);
|
||||||
|
|
||||||
export function get() {
|
|
||||||
return config$;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function init() {
|
export async function init() {
|
||||||
const config = await config$.toPromise();
|
const config = await config$.toPromise();
|
||||||
window.CONFIG = config;
|
window.CONFIG = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function get(key) {
|
||||||
|
if (key) return window.CONFIG[key];
|
||||||
|
return window.CONFIG;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ export default function(render) {
|
||||||
function processError(err) {
|
function processError(err) {
|
||||||
let msg, trace;
|
let msg, trace;
|
||||||
if (err instanceof AjaxError) {
|
if (err instanceof AjaxError) {
|
||||||
msg = t(err.message);
|
msg = t(err.code());
|
||||||
trace = `
|
trace = `
|
||||||
type: ${err.type()}
|
type: ${err.type()}
|
||||||
code: ${err.code()}
|
code: ${err.code()}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import { createElement, createRender, nop } from "../../lib/skeleton/index.js";
|
import { createElement, createRender, nop } from "../../lib/skeleton/index.js";
|
||||||
import rxjs, { effect } from "../../lib/rx.js";
|
import rxjs, { effect } from "../../lib/rx.js";
|
||||||
import { qs } from "../../lib/dom.js";
|
import { qs } from "../../lib/dom.js";
|
||||||
|
import { AjaxError } from "../../lib/error.js";
|
||||||
import { load as loadPlugin } from "../../model/plugin.js";
|
import { load as loadPlugin } from "../../model/plugin.js";
|
||||||
import { loadCSS } from "../../helpers/loader.js";
|
import { loadCSS } from "../../helpers/loader.js";
|
||||||
import { createLoader } from "../../components/loader.js";
|
import { createLoader } from "../../components/loader.js";
|
||||||
|
import t from "../../locales/index.js";
|
||||||
import ctrlError from "../ctrl_error.js";
|
import ctrlError from "../ctrl_error.js";
|
||||||
|
|
||||||
import componentDownloader, { init as initDownloader } from "./application_downloader.js";
|
import componentDownloader, { init as initDownloader } from "./application_downloader.js";
|
||||||
|
|
@ -63,7 +65,15 @@ export default async function(render, { mime, acl$, getDownloadUrl = nop, getFil
|
||||||
hasCube, mime, is2D: loader.is2D,
|
hasCube, mime, is2D: loader.is2D,
|
||||||
})),
|
})),
|
||||||
)),
|
)),
|
||||||
rxjs.catchError(ctrlError()),
|
rxjs.catchError((err) => {
|
||||||
|
let _err = err;
|
||||||
|
if (err.response.status === 401) {
|
||||||
|
_err = new Error(err.message);
|
||||||
|
_err.status = err.response.status;
|
||||||
|
_err = new AjaxError(err.message, _err, "Not Authorised");
|
||||||
|
}
|
||||||
|
return ctrlError()(_err);
|
||||||
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ export default function({ THREE, $page, $menubar, mesh, refresh, is2D }) {
|
||||||
maxDim * 1000,
|
maxDim * 1000,
|
||||||
);
|
);
|
||||||
const controls = new OrbitControls(camera, renderer.domElement);
|
const controls = new OrbitControls(camera, renderer.domElement);
|
||||||
controls.zoomToCursor = true;
|
|
||||||
if (is2D()) {
|
if (is2D()) {
|
||||||
|
controls.zoomToCursor = true;
|
||||||
controls.enableRotate = false;
|
controls.enableRotate = false;
|
||||||
controls.mouseButtons = {
|
controls.mouseButtons = {
|
||||||
LEFT: THREE.MOUSE.PAN,
|
LEFT: THREE.MOUSE.PAN,
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,7 @@ func (this *Configuration) Export() interface{} {
|
||||||
Thumbnailer []string `json:"thumbnailer"`
|
Thumbnailer []string `json:"thumbnailer"`
|
||||||
EnableChromecast bool `json:"enable_chromecast"`
|
EnableChromecast bool `json:"enable_chromecast"`
|
||||||
Origin string `json:"origin"`
|
Origin string `json:"origin"`
|
||||||
|
Version string `json:"version"`
|
||||||
}{
|
}{
|
||||||
Editor: this.Get("general.editor").String(),
|
Editor: this.Get("general.editor").String(),
|
||||||
ForkButton: this.Get("general.fork_button").Bool(),
|
ForkButton: this.Get("general.fork_button").Bool(),
|
||||||
|
|
@ -415,6 +416,7 @@ func (this *Configuration) Export() interface{} {
|
||||||
}
|
}
|
||||||
return scheme + host
|
return scheme + host
|
||||||
}(),
|
}(),
|
||||||
|
Version: BUILD_REF[:7],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ func ServeBackofficeHandler(ctx *App, res http.ResponseWriter, req *http.Request
|
||||||
head.Add(
|
head.Add(
|
||||||
"Link",
|
"Link",
|
||||||
fmt.Sprintf(`<%s>; rel="preload"; as="script"; crossorigin="anonymous";`, WithBase(
|
fmt.Sprintf(`<%s>; rel="preload"; as="script"; crossorigin="anonymous";`, WithBase(
|
||||||
strings.Replace(href, "/assets/", "/assets/"+version()+"/", 1),
|
strings.Replace(href, "/assets/", "/assets/"+BUILD_REF+"/", 1),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ func ServeFrontofficeHandler(ctx *App, res http.ResponseWriter, req *http.Reques
|
||||||
head.Add(
|
head.Add(
|
||||||
"Link",
|
"Link",
|
||||||
fmt.Sprintf(`<%s>; rel="preload"; as="script"; crossorigin="anonymous";`, WithBase(
|
fmt.Sprintf(`<%s>; rel="preload"; as="script"; crossorigin="anonymous";`, WithBase(
|
||||||
strings.Replace(href, "/assets/", "/assets/"+version()+"/", 1),
|
strings.Replace(href, "/assets/", "/assets/"+BUILD_REF+"/", 1),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -431,7 +431,7 @@ func ServeFile(chroot string) func(*App, http.ResponseWriter, *http.Request) {
|
||||||
chroot,
|
chroot,
|
||||||
strings.Replace(
|
strings.Replace(
|
||||||
TrimBase(req.URL.Path),
|
TrimBase(req.URL.Path),
|
||||||
"assets/"+version()+"/",
|
"assets/"+BUILD_REF+"/",
|
||||||
"assets/",
|
"assets/",
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
|
|
@ -546,7 +546,7 @@ func ServeIndex(indexPath string) func(*App, http.ResponseWriter, *http.Request)
|
||||||
res.WriteHeader(http.StatusOK)
|
res.WriteHeader(http.StatusOK)
|
||||||
template.Must(template.New(indexPath).Parse(string(b))).Execute(res, map[string]any{
|
template.Must(template.New(indexPath).Parse(string(b))).Execute(res, map[string]any{
|
||||||
"base": WithBase("/"),
|
"base": WithBase("/"),
|
||||||
"version": version(),
|
"version": BUILD_REF,
|
||||||
"license": LICENSE,
|
"license": LICENSE,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -572,7 +572,3 @@ func InitPluginList(code []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func version() string {
|
|
||||||
return BUILD_REF[:7]
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,19 @@ func main() {
|
||||||
cmd.Stdout = b
|
cmd.Stdout = b
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
|
|
||||||
content := fmt.Sprintf(`package common
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
BUILD_REF = "%s"
|
|
||||||
BUILD_DATE = "%s"
|
|
||||||
}
|
|
||||||
`, strings.TrimSpace(b.String()), time.Now().Format("20060102"))
|
|
||||||
|
|
||||||
f, err := os.OpenFile("../common/constants_generated.go", os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
f, err := os.OpenFile("../common/constants_generated.go", os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.Write([]byte(content))
|
f.Write([]byte(fmt.Sprintf(`
|
||||||
|
package common
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
BUILD_REF = "%s"
|
||||||
|
BUILD_DATE = "%s"
|
||||||
|
}
|
||||||
|
`, b.String()[0:7], time.Now().Format("20060102"))))
|
||||||
f.Close()
|
f.Close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue