Comments (3)
Hi @sudo-self - I'm confused 😃 - what is the motivation of this issue?
from sharry.
certainly. Using MacBook with silicon hardware (fixed storage docker not really option)
Better example:
Sharry.js ----> Sharry.ts
/* Sharry TS */
function forEachIn(obj: object, fn: (value: any, key: string, index: number) => void): void {
let index = 0;
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
fn(obj[key], key, index++);
}
}
}
function extend(...args: object[]): object {
let result = {};
for (let i = 0; i < args.length; i++) {
forEachIn(args[i], (obj, key) => {
result[key] = obj;
});
}
return result;
}
function applyUiTheme(themeName: string): void {
let body = document.getElementsByTagName("body");
if (themeName && body && body.length > 0) {
let bodyClasses = body[0].classList;
// seems that body attributes cannot be set from inside Elm.
if (themeName.toLowerCase() === 'dark') {
bodyClasses.add("bg-stone-800");
bodyClasses.add("dark");
} else {
bodyClasses.remove("bg-stone-800");
bodyClasses.remove("dark");
}
}
}
let elmApp = Elm.Main.init({
node: document.getElementById("sharry-app"),
flags: elmFlags
});
elmApp.ports.setLanguage.subscribe(function(lang: string) {
localStorage.setItem("language", lang);
elmApp.ports.receiveLanguage.send(lang);
});
elmApp.ports.setAccount.subscribe(function(authResult: any) {
localStorage.setItem("account", JSON.stringify(authResult));
});
elmApp.ports.removeAccount.subscribe(function() {
localStorage.removeItem("account");
});
elmApp.ports.scrollTop.subscribe(function(data: any) {
window.scrollTo(0, 0);
});
elmApp.ports.scrollToElem.subscribe(function(id: string) {
if (id && id != "") {
window.setTimeout(function() {
let el = document.getElementById(id);
if (el) {
if (el["scrollIntoViewIfNeeded"]) {
el.scrollIntoViewIfNeeded();
} else {
el.scrollIntoView();
}
}
}, 0);
}
});
let sharry_uploads: { [id: string]: any } = {};
elmApp.ports.submitFiles.subscribe(function(data: any) {
let url = data.url;
let files = data.files;
let myHeaders: { [key: string]: string } = {};
if (data.aliasId) {
myHeaders["Sharry-Alias"] = data.aliasId;
}
let doUpload = function (index: number, file: any) {
let upload = new tus.Upload(
file,
{ endpoint: url,
chunkSize: sharryFlags.chunkSize,
retryDelays: sharryFlags.retryDelays,
removeFingerprintOnSuccess: true,
headers: extend(myHeaders, {
"Sharry-File-Name": encodeURIComponent(file.name),
"Sharry-File-Length": file.size,
"Sharry-File-Type": file.type
}),
onError: function(error: any) {
console.log("XX: " + error);
elmApp.ports.uploadState.send({
id: data.id,
file: index,
progress: {
state: "failed",
error: (error || "").toString()
}
});
},
onProgress: function(bytesUploaded: number, bytesTotal: number) {
elmApp.ports.uploadState.send({
id: data.id,
file: index,
progress: {
state: "progress",
uploaded: bytesUploaded,
total: bytesTotal
}
});
},
onChunkComplete: function(chunkSize: number, bytesUploaded: number, bytesTotal: number) {
elmApp.ports.uploadState.send({
id: data.id,
file: index,
progress: {
state: "progress",
uploaded: bytesUploaded,
total: bytesTotal
}
});
},
onSuccess: function() {
elmApp.ports.uploadState.send({
id: data.id,
file: index,
progress: {
state: "complete"
}
});
let next = index + 1;
if (next < files.length) {
doUpload(next, files[next]);
} else {
delete sharry_uploads[data.id];
}
}
});
sharry_uploads[data.id] = upload;
upload.start();
};
if (url && files && files.length > 0) {
doUpload(0, files[0]);
} else {
console.log("No files to upload");
}
});
elmApp.ports.stopUpload.subscribe(function(id: string) {
let upload = sharry_uploads[id];
if (upload) {
upload.abort(false, function(error: any) {
elmApp.ports.uploadStopped.send(error);
});
// The callback is not called by tus-js-client …
elmApp.ports.uploadStopped.send(null);
}
});
elmApp.ports.startUpload.subscribe(function(id: string) {
let upload = sharry_uploads[id];
if (upload) {
upload.start();
}
});
let sharry_clipboards: { [page: string]: any } = {};
elmApp.ports.initClipboard.subscribe(function(args: any[]) {
let page = args[0];
if (!sharry_clipboards[page]) {
let sel = args[1];
sharry_clipboards[page] = new ClipboardJS(sel);
}
});
elmApp.ports.internalSetUiTheme.subscribe(function(themeName: string) {
if (themeName) {
localStorage.setItem("uiTheme", themeName);
applyUiTheme(themeName);
}
});
applyUiTheme(theme);
from sharry.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. This only applies to 'question' issues. Always feel free to reopen or create new issues. Thank you!
from sharry.
Related Issues (20)
- s3 auth does not seem to support node / service account roles - access key and secret required HOT 3
- Problems with using Keycloak as OAuth provider HOT 6
- Azure AD Authentication doesn't work with java.net.ConnectException: Connection timed out HOT 6
- CORS blocked when uploading a file using Caddy reverse proxy. HOT 5
- nix: build sharry from source
- Error message : 106% percent over 100 HOT 6
- mp4 files are not playing in browser HOT 10
- Add ability to create admin accounts with all auth modules HOT 2
- Broken Nix installation guide HOT 1
- Sign-in with oauth (via Google) creates accounts even if signup is set to "invite" or "closed" HOT 4
- Site breaks in Chrome/Edge when `require-trusted-types-for` is enabled in CSP header HOT 3
- Shares disappearing after reboot HOT 2
- mp4 files are not playing in browser - maybe related to #1328 HOT 1
- Disable new user signup HOT 2
- Unraid support HOT 1
- Possible to set longer expirations HOT 1
- Nginx HOT 2
- Run Sharry as a service HOT 4
- [Feature request] Publish container to Github container registry HOT 3
- [feature request] Add user email to TemplateData HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharry.