Fix popout alignment, gzip local storage cache array, add file watcher
Signed-off-by: 0xf8 <0xf8.dev@proton.me>
This commit is contained in:
parent
0039bacd24
commit
0e30201502
@ -4,7 +4,6 @@
|
|||||||
"main": "dist/server.js",
|
"main": "dist/server.js",
|
||||||
"types": "dist/types.d.ts",
|
"types": "dist/types.d.ts",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "GLP-3.0-only",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npx parcel watch & npx nodemon dist/server.js",
|
"dev": "npx parcel watch & npx nodemon dist/server.js",
|
||||||
"build": "npx parcel build"
|
"build": "npx parcel build"
|
||||||
|
@ -10,7 +10,7 @@ You should have received a copy of the GNU General Public License along with Gal
|
|||||||
|
|
||||||
import { createHash } from "crypto";
|
import { createHash } from "crypto";
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { readdirSync, existsSync, mkdirSync, statSync, readFileSync } from "fs";
|
import { readdirSync, existsSync, mkdirSync, statSync, readFileSync, watch } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
class Sync {
|
class Sync {
|
||||||
@ -35,7 +35,7 @@ class Sync {
|
|||||||
await this.update();
|
await this.update();
|
||||||
res();
|
res();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
let c = createHash("sha1");
|
let c = createHash("sha1");
|
||||||
|
|
||||||
@ -61,25 +61,36 @@ class Sync {
|
|||||||
pastchecksum: string[];
|
pastchecksum: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const state: Sync = new Sync();
|
const state: Sync = new Sync();
|
||||||
|
|
||||||
|
let lastUpdate = Date.now();
|
||||||
|
watch(state.root, {}, (e, f) => {
|
||||||
|
let now = Date.now();
|
||||||
|
|
||||||
|
// If lastUpdate occured within 1 second
|
||||||
|
if (now - lastUpdate < 1000) {
|
||||||
|
lastUpdate = now;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastUpdate = now;
|
||||||
|
state.update();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
let sync = async (req: Request, res: Response) => {
|
let sync = async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
case "GET": { // "Update me"
|
case "GET": { // "Update me"
|
||||||
res.status(405);
|
res.status(405);
|
||||||
|
|
||||||
// await state.update();
|
|
||||||
// res.write(JSON.stringify({
|
|
||||||
// checksum: state.checksum,
|
|
||||||
// files: state.files
|
|
||||||
// }));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "POST": {
|
case "POST": {
|
||||||
await state.update();
|
await state.update();
|
||||||
let reqd;
|
let reqd: { action: string; checksum: string; };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
reqd = JSON.parse(req.body);
|
reqd = JSON.parse(req.body);
|
||||||
|
@ -6,15 +6,21 @@
|
|||||||
"www/settings.html"
|
"www/settings.html"
|
||||||
],
|
],
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "GLP-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npx parcel serve",
|
"dev": "npx parcel serve",
|
||||||
"build": "npx parcel build"
|
"build": "npx parcel build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@parcel/transformer-sass": "2.8.0",
|
"@parcel/transformer-sass": "2.8.0",
|
||||||
|
"assert": "^2.0.0",
|
||||||
|
"browserify-zlib": "^0.2.0",
|
||||||
|
"buffer": "^5.5.0",
|
||||||
|
"events": "^3.1.0",
|
||||||
"parcel": "latest",
|
"parcel": "latest",
|
||||||
"process": "^0.11.10"
|
"process": "^0.11.10",
|
||||||
|
"stream-browserify": "^3.0.0",
|
||||||
|
"util": "^0.12.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.2.0",
|
"@fortawesome/fontawesome-svg-core": "^6.2.0",
|
||||||
@ -31,6 +37,5 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0"
|
"react-dom": "^18.2.0"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only",
|
|
||||||
"sourceMap": false
|
"sourceMap": false
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,6 @@ span#title {
|
|||||||
width: 100vw;
|
width: 100vw;
|
||||||
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-content: center;
|
|
||||||
|
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
|
|
||||||
@ -99,59 +98,7 @@ span#title {
|
|||||||
display: block;
|
display: block;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
|
||||||
border-radius: 8px;
|
border-radius: 12px;
|
||||||
}
|
align-self: center;
|
||||||
|
|
||||||
.contextmenu {
|
|
||||||
position: fixed;
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
flex-direction: column;
|
|
||||||
padding: .4em 1em;
|
|
||||||
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
|
||||||
|
|
||||||
border: 2px rgba(0, 0, 0, 0.9) solid;
|
|
||||||
border-radius: 8px;
|
|
||||||
|
|
||||||
max-width: 18vw;
|
|
||||||
|
|
||||||
height: max-content;
|
|
||||||
width: max-content;
|
|
||||||
|
|
||||||
hr {
|
|
||||||
width: 5em;
|
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
:first-child {
|
|
||||||
font-weight: 600;
|
|
||||||
margin-bottom: .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
:last-child {
|
|
||||||
margin-top: .4em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.option {
|
|
||||||
font-size: .9em;
|
|
||||||
|
|
||||||
width: fit-content;
|
|
||||||
height: auto;
|
|
||||||
|
|
||||||
border: 3px transparent solid;
|
|
||||||
background: transparent;
|
|
||||||
color: white;
|
|
||||||
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.option:hover {
|
|
||||||
color: black;
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,9 @@ You should have received a copy of the GNU General Public License along with Gal
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<root></root>
|
<root>
|
||||||
|
|
||||||
|
</root>
|
||||||
<script type="module" src="index.html.tsx"></script>
|
<script type="module" src="index.html.tsx"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@ Galerie is distributed in the hope that it will be useful, but WITHOUT ANY WARRA
|
|||||||
You should have received a copy of the GNU General Public License along with Galerie. If not, see <https://www.gnu.org/licenses/>.
|
You should have received a copy of the GNU General Public License along with Galerie. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let apiUrl: string = `${ location.protocol }//${location.hostname}:8856/`;
|
import { gzipSync, gunzipSync } from "zlib";
|
||||||
|
|
||||||
|
let apiUrl: string = `${location.protocol}//${location.hostname}:8856/`;
|
||||||
|
|
||||||
class Favorites {
|
class Favorites {
|
||||||
private data: string[] = [];
|
private data: string[] = [];
|
||||||
@ -115,7 +117,10 @@ class Cache {
|
|||||||
async load(): Promise<void> {
|
async load(): Promise<void> {
|
||||||
console.log("Loading cache");
|
console.log("Loading cache");
|
||||||
|
|
||||||
this.cache = JSON.parse(localStorage.getItem("cache")) || [];
|
if (localStorage.getItem("cache"))
|
||||||
|
this.cache = JSON.parse(gunzipSync(Buffer.from(localStorage.getItem("cache"), "base64")).toString());
|
||||||
|
else
|
||||||
|
this.cache = [];
|
||||||
this.checksum = localStorage.getItem("cache.checksum");
|
this.checksum = localStorage.getItem("cache.checksum");
|
||||||
|
|
||||||
if (!this.cache || !this.checksum) {
|
if (!this.cache || !this.checksum) {
|
||||||
@ -152,7 +157,7 @@ class Cache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async update(): Promise<void> {
|
private async update(): Promise<void> {
|
||||||
localStorage.setItem("cache", JSON.stringify(this.cache));
|
localStorage.setItem("cache", gzipSync(JSON.stringify(this.cache)).toString("base64"));
|
||||||
localStorage.setItem("cache.checksum", this.checksum);
|
localStorage.setItem("cache.checksum", this.checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +215,7 @@ class Config {
|
|||||||
|
|
||||||
if (!localStorage.getItem("config"))
|
if (!localStorage.getItem("config"))
|
||||||
localStorage.setItem("config", JSON.stringify(this.defaultConfig));
|
localStorage.setItem("config", JSON.stringify(this.defaultConfig));
|
||||||
|
|
||||||
this.data = JSON.parse(localStorage.getItem("config"));
|
this.data = JSON.parse(localStorage.getItem("config"));
|
||||||
|
|
||||||
this.verify();
|
this.verify();
|
||||||
|
Loading…
Reference in New Issue
Block a user