-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#8 add route to receive PatchSets via link
- Loading branch information
Max.-F.Helm
committed
Apr 9, 2024
1 parent
63b2b57
commit 61423d2
Showing
4 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
|
||
</template> | ||
|
||
<script setup lang="ts"> | ||
import {onBeforeMount} from "vue"; | ||
import {useToast} from "primevue/usetoast"; | ||
import libsodium from "libsodium-wrappers-sumo"; | ||
import {Buffer} from "buffer"; | ||
import FileProcessorWrapper from "@/FileProcessorWrapper"; | ||
import {useRouter} from "vue-router"; | ||
const toast = useToast(); | ||
const router = useRouter(); | ||
onBeforeMount(() => { | ||
let dataStr = location.hash; | ||
if(dataStr === "" || dataStr === "#") { | ||
toast.add({ | ||
severity: "error", | ||
summary: "No data was given to be imported as a Patchset", | ||
life: 5000 | ||
}); | ||
navigateToDocumentView(); | ||
return; | ||
} | ||
try { | ||
dataStr = dataStr.substring(1);// remove '#' | ||
const data = new Buffer(libsodium.from_base64(dataStr, libsodium.base64_variants.URLSAFE)); | ||
FileProcessorWrapper.INSTANCE.addToBeLoadedPatch(data); | ||
toast.add({ | ||
severity: "success", | ||
summary: "The Patchset will be imported as soon as you opened the document", | ||
life: 3000 | ||
}); | ||
navigateToDocumentView(); | ||
} catch(e) { | ||
console.error("error while reading PatchSet", e); | ||
toast.add({ | ||
severity: "error", | ||
summary: "Unable to import Patchset", | ||
life: 5000 | ||
}); | ||
navigateToDocumentView(); | ||
} | ||
}); | ||
function navigateToDocumentView() { | ||
router.push({ name: "document" }); | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function basePath(): string { | ||
const baseUrlStr = import.meta.env.BASE_URL; | ||
const baseUrl = new URL(baseUrlStr, location.href); | ||
const path = baseUrl.pathname; | ||
|
||
if(path.endsWith("/")) | ||
return path.substring(0, path.length - 1); | ||
return path; | ||
} |