Frontend typing fixes, removing dead code.
This commit is contained in:
parent
5bdeb180b5
commit
c2b9ef6c2f
|
@ -1,52 +0,0 @@
|
||||||
<template>
|
|
||||||
<object
|
|
||||||
v-if="props.type === 'pdf'"
|
|
||||||
:data="dataURL"
|
|
||||||
type="application/pdf"
|
|
||||||
width="100%"
|
|
||||||
height="100%"
|
|
||||||
></object>
|
|
||||||
<a-image
|
|
||||||
v-else-if="props.type === 'image'"
|
|
||||||
width="50%"
|
|
||||||
:src="dataURL"
|
|
||||||
@click="() => setVisible(true)"
|
|
||||||
:previewMask="false"
|
|
||||||
:preview="{
|
|
||||||
visibleImg,
|
|
||||||
onVisibleChange: setVisible
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
<!-- Unknown case -->
|
|
||||||
<h1 v-else>Unsupported file type</h1>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { watchEffect, ref } from 'vue'
|
|
||||||
import Router from '@/router/index'
|
|
||||||
import { url_document_get } from '@/repositories/Document'
|
|
||||||
|
|
||||||
const dataURL = ref('')
|
|
||||||
watchEffect(() => {
|
|
||||||
dataURL.value = new URL(
|
|
||||||
url_document_get + Router.currentRoute.value.path,
|
|
||||||
location.origin
|
|
||||||
).toString()
|
|
||||||
})
|
|
||||||
const emit = defineEmits({
|
|
||||||
visibleImg(value: boolean) {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function setVisible(value: boolean) {
|
|
||||||
emit('visibleImg', value)
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
type?: string
|
|
||||||
visibleImg: boolean
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style></style>
|
|
|
@ -9,7 +9,7 @@
|
||||||
<SvgButton
|
<SvgButton
|
||||||
name="create-folder"
|
name="create-folder"
|
||||||
data-tooltip="New folder"
|
data-tooltip="New folder"
|
||||||
@click="() => documentStore.fileExplorer.newFolder()"
|
@click="() => documentStore.fileExplorer!.newFolder()"
|
||||||
/>
|
/>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<div class="spacer smallgap"></div>
|
<div class="spacer smallgap"></div>
|
||||||
|
@ -42,15 +42,15 @@ const showSearchInput = ref<boolean>(false)
|
||||||
const search = ref<HTMLInputElement | null>()
|
const search = ref<HTMLInputElement | null>()
|
||||||
const searchButton = ref<HTMLButtonElement | null>()
|
const searchButton = ref<HTMLButtonElement | null>()
|
||||||
|
|
||||||
const closeSearch = ev => {
|
const closeSearch = (ev: Event) => {
|
||||||
if (!showSearchInput.value) return // Already closing
|
if (!showSearchInput.value) return // Already closing
|
||||||
showSearchInput.value = false
|
showSearchInput.value = false
|
||||||
const breadcrumb = document.querySelector('.breadcrumb') as HTMLElement
|
const breadcrumb = document.querySelector('.breadcrumb') as HTMLElement
|
||||||
breadcrumb.focus()
|
breadcrumb.focus()
|
||||||
updateSearch(ev)
|
updateSearch(ev)
|
||||||
}
|
}
|
||||||
const updateSearch = ev => {
|
const updateSearch = (ev: Event) => {
|
||||||
const q = ev.target.value
|
const q = (ev.target as HTMLInputElement).value
|
||||||
let p = props.path.join('/')
|
let p = props.path.join('/')
|
||||||
p = p ? `/${p}` : ''
|
p = p ? `/${p}` : ''
|
||||||
const url = q ? `${p}//${q}` : (p || '/')
|
const url = q ? `${p}//${q}` : (p || '/')
|
||||||
|
@ -58,9 +58,9 @@ const updateSearch = ev => {
|
||||||
if (!props.query && q) router.push(url)
|
if (!props.query && q) router.push(url)
|
||||||
else router.replace(url)
|
else router.replace(url)
|
||||||
}
|
}
|
||||||
const toggleSearchInput = () => {
|
const toggleSearchInput = (ev: Event) => {
|
||||||
showSearchInput.value = !showSearchInput.value
|
showSearchInput.value = !showSearchInput.value
|
||||||
if (!showSearchInput.value) return closeSearch()
|
if (!showSearchInput.value) return closeSearch(ev)
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const input = search.value
|
const input = search.value
|
||||||
if (input) input.focus()
|
if (input) input.focus()
|
||||||
|
|
|
@ -34,7 +34,7 @@ const op = (op: string, dst?: string) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (dst !== undefined) msg.dst = dst
|
if (dst !== undefined) msg.dst = dst
|
||||||
const control = connect(controlUrl, {
|
const control = connect(controlUrl, {
|
||||||
message(ev: WebSocmetMessageEvent) {
|
message(ev: MessageEvent) {
|
||||||
const res = JSON.parse(ev.data)
|
const res = JSON.parse(ev.data)
|
||||||
if ('error' in res) {
|
if ('error' in res) {
|
||||||
console.error('Control socket error', msg, res.error)
|
console.error('Control socket error', msg, res.error)
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<template>
|
|
||||||
<template v-for="upload in documentStore.uploadingDocuments" :key="upload.key">
|
|
||||||
<span>{{ upload.name }}</span>
|
|
||||||
<div class="progress-container">
|
|
||||||
<a-progress :percent="upload.progress" />
|
|
||||||
<CloseCircleOutlined class="close-button" @click="dismissUpload(upload.key)" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useDocumentStore } from '@/stores/documents'
|
|
||||||
const documentStore = useDocumentStore()
|
|
||||||
|
|
||||||
function dismissUpload(key: number) {
|
|
||||||
documentStore.deleteUploadingDocument(key)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.progress-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.close-button:hover {
|
|
||||||
color: #b81414;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -32,7 +32,7 @@ function uploadHandler(event: Event) {
|
||||||
if (!infiles.length) return
|
if (!infiles.length) return
|
||||||
infiles.sort((a, b) => collator.compare(a.cloudName, b.cloudName))
|
infiles.sort((a, b) => collator.compare(a.cloudName, b.cloudName))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
upqueue = upqueue.concat(infiles)
|
upqueue = [...upqueue, ...infiles]
|
||||||
statsAdd(infiles)
|
statsAdd(infiles)
|
||||||
startWorker()
|
startWorker()
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,14 @@ const uprogress_init = {
|
||||||
tlast: 0,
|
tlast: 0,
|
||||||
statbytes: 0,
|
statbytes: 0,
|
||||||
statdur: 0,
|
statdur: 0,
|
||||||
files: [],
|
files: [] as File[],
|
||||||
filestart: 0,
|
filestart: 0,
|
||||||
fileidx: 0,
|
fileidx: 0,
|
||||||
filecount: 0,
|
filecount: 0,
|
||||||
filename: '',
|
filename: '',
|
||||||
filesize: 0,
|
filesize: 0,
|
||||||
filepos: 0,
|
filepos: 0,
|
||||||
|
status: 'idle',
|
||||||
}
|
}
|
||||||
const uprogress = reactive({...uprogress_init})
|
const uprogress = reactive({...uprogress_init})
|
||||||
const percent = computed(() => uprogress.uploaded / uprogress.total * 100)
|
const percent = computed(() => uprogress.uploaded / uprogress.total * 100)
|
||||||
|
@ -109,7 +110,7 @@ const statsAdd = (f: Array<File>) => {
|
||||||
if (uprogress.files.length === 0) statReset()
|
if (uprogress.files.length === 0) statReset()
|
||||||
uprogress.total += f.reduce((a, b) => a + b.size, 0)
|
uprogress.total += f.reduce((a, b) => a + b.size, 0)
|
||||||
uprogress.filecount += f.length
|
uprogress.filecount += f.length
|
||||||
uprogress.files = uprogress.files.concat(f)
|
uprogress.files = [...uprogress.files, ...f]
|
||||||
statNextFile()
|
statNextFile()
|
||||||
}
|
}
|
||||||
let upqueue = [] as File[]
|
let upqueue = [] as File[]
|
||||||
|
|
|
@ -109,7 +109,7 @@ const handleWatchMessage = (event: MessageEvent) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRootMessage({ root }: { root: DirEntry }) {
|
function handleRootMessage({ root }: { root: FileEntry[] }) {
|
||||||
const store = useDocumentStore()
|
const store = useDocumentStore()
|
||||||
console.log('Watch root', root)
|
console.log('Watch root', root)
|
||||||
store.updateRoot(root)
|
store.updateRoot(root)
|
||||||
|
|
|
@ -21,9 +21,7 @@ export const useDocumentStore = defineStore({
|
||||||
state: () => ({
|
state: () => ({
|
||||||
document: [] as Document[],
|
document: [] as Document[],
|
||||||
selected: new Set<FUID>(),
|
selected: new Set<FUID>(),
|
||||||
uploadingDocuments: [],
|
fileExplorer: null as any,
|
||||||
uploadCount: 0 as number,
|
|
||||||
fileExplorer: null,
|
|
||||||
error: '' as string,
|
error: '' as string,
|
||||||
connected: false,
|
connected: false,
|
||||||
server: {} as Record<string, any>,
|
server: {} as Record<string, any>,
|
||||||
|
@ -53,7 +51,6 @@ export const useDocumentStore = defineStore({
|
||||||
})
|
})
|
||||||
loc.push(name)
|
loc.push(name)
|
||||||
}
|
}
|
||||||
console.log("Documents", docs)
|
|
||||||
this.document = docs as Document[]
|
this.document = docs as Document[]
|
||||||
},
|
},
|
||||||
updateModified() {
|
updateModified() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user