2023-05-15 03:32:16 +03:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { getElementInfo } from "moveable";
|
|
|
|
import { VueSelecto } from "vue3-selecto";
|
2023-05-19 00:07:04 +03:00
|
|
|
import { useDisplay } from 'vuetify/lib/framework.mjs';
|
2023-06-03 05:27:08 +03:00
|
|
|
import { HistoryManager } from './composables/history-manager';
|
|
|
|
import { FilesManager } from './composables/files-manager';
|
2023-05-15 03:32:16 +03:00
|
|
|
|
2023-05-19 00:07:04 +03:00
|
|
|
let display = useDisplay();
|
2023-05-29 21:23:40 +03:00
|
|
|
let drawer = ref(!display.mdAndDown.value);
|
2023-05-19 18:09:48 +03:00
|
|
|
let loadingModel = ref(false);
|
2023-05-15 03:32:16 +03:00
|
|
|
let files = ref([]);
|
|
|
|
|
|
|
|
let filesList = ref<any>([]);
|
2023-06-03 06:53:03 +03:00
|
|
|
let selectedPath = useSelectedPath();
|
2023-05-19 18:09:48 +03:00
|
|
|
let filesGridList = ref<any>([])
|
2023-05-29 19:51:08 +03:00
|
|
|
let selectedList = ref<any>([]);
|
2023-06-03 06:53:03 +03:00
|
|
|
let filesManager = new FilesManager(filesList);
|
|
|
|
let history = new HistoryManager(filesManager);
|
2023-05-15 03:32:16 +03:00
|
|
|
|
|
|
|
watchEffect(async () => {
|
|
|
|
if (files.value?.[0]) {
|
2023-05-19 18:09:48 +03:00
|
|
|
loadingModel.value = true;
|
2023-05-15 03:32:16 +03:00
|
|
|
filesList.value = [];
|
|
|
|
|
2023-06-03 06:53:03 +03:00
|
|
|
filesManager.loadArchive(files.value?.[0]);
|
2023-05-15 03:32:16 +03:00
|
|
|
|
2023-05-19 18:09:48 +03:00
|
|
|
loadingModel.value = false;
|
2023-05-15 03:32:16 +03:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function onDrop(e: any) {
|
2023-05-29 19:51:08 +03:00
|
|
|
if (!e.dataTransfer.files.length) return;
|
2023-05-15 03:32:16 +03:00
|
|
|
files.value = e.dataTransfer.files;
|
2023-06-03 06:53:03 +03:00
|
|
|
selectedPath.value = '/';
|
2023-05-15 03:32:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function preventDefaults(e: any) {
|
|
|
|
e.preventDefault()
|
|
|
|
}
|
|
|
|
|
|
|
|
const events = ['dragenter', 'dragover', 'dragleave', 'drop']
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
events.forEach((eventName) => {
|
|
|
|
document.body.addEventListener(eventName, preventDefaults)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
events.forEach((eventName) => {
|
|
|
|
document.body.removeEventListener(eventName, preventDefaults)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
watchEffect(() => {
|
2023-06-03 06:53:03 +03:00
|
|
|
const file = filesManager.getFile(selectedPath.value);
|
2023-06-03 06:59:17 +03:00
|
|
|
filesGridList.value = file?.content;
|
2023-06-03 06:53:03 +03:00
|
|
|
|
2023-05-18 23:54:37 +03:00
|
|
|
selectedList.value = [];
|
|
|
|
for (const selectedElement of document.querySelectorAll(".selectable.selected")) {
|
|
|
|
selectedElement.classList.remove("selected");
|
|
|
|
}
|
2023-05-15 03:32:16 +03:00
|
|
|
})
|
|
|
|
|
2023-06-03 06:53:03 +03:00
|
|
|
const dragContainer = document.querySelector(".select-area");
|
2023-05-15 03:32:16 +03:00
|
|
|
|
|
|
|
function onSelectStart(e: any) {
|
|
|
|
e.added.forEach((el: any) => {
|
|
|
|
el.classList.add("selected");
|
2023-05-18 23:54:37 +03:00
|
|
|
selectedList.value = [...selectedList.value, el?.__vnode?.ctx?.props?.value];
|
2023-05-15 03:32:16 +03:00
|
|
|
});
|
|
|
|
e.removed.forEach((el: any) => {
|
|
|
|
el.classList.remove("selected");
|
2023-05-18 23:54:37 +03:00
|
|
|
selectedList.value = selectedList.value.filter((value: string) => value != el?.__vnode?.ctx?.props?.value)
|
2023-05-15 03:32:16 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSelectEnd(e: any) {
|
|
|
|
e.afterAdded.forEach((el: any) => {
|
|
|
|
el.classList.add("selected");
|
2023-05-18 23:54:37 +03:00
|
|
|
selectedList.value = [...selectedList.value, el?.__vnode?.ctx?.props?.value];
|
2023-05-15 03:32:16 +03:00
|
|
|
});
|
|
|
|
e.afterRemoved.forEach((el: any) => {
|
|
|
|
el.classList.remove("selected");
|
2023-05-18 23:54:37 +03:00
|
|
|
selectedList.value = selectedList.value.filter((value: string) => value != el?.__vnode?.ctx?.props?.value)
|
2023-05-15 03:32:16 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-29 19:51:08 +03:00
|
|
|
// step up from current path
|
|
|
|
function stepUp(path: string) {
|
2023-06-03 06:53:03 +03:00
|
|
|
const pathArray = path.split("/");
|
2023-05-29 19:51:08 +03:00
|
|
|
pathArray.pop();
|
2023-06-03 06:40:47 +03:00
|
|
|
return (pathArray.join("/") || "/");
|
2023-05-29 19:51:08 +03:00
|
|
|
}
|
|
|
|
|
2023-05-15 03:32:16 +03:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<v-layout @drop.prevent="onDrop">
|
|
|
|
<v-app-bar color="light-blue-darken-1">
|
|
|
|
<v-btn variant="text" icon="mdi-menu" v-slot:prepend @click="drawer = !drawer"></v-btn>
|
2023-05-19 00:12:11 +03:00
|
|
|
<v-toolbar-title>Extractify.zip</v-toolbar-title>
|
2023-05-15 03:32:16 +03:00
|
|
|
</v-app-bar>
|
2023-05-19 00:07:04 +03:00
|
|
|
<v-navigation-drawer v-model="drawer" :permanent="!display.xs">
|
2023-05-15 03:32:16 +03:00
|
|
|
<v-toolbar density="comfortable" title="Files">
|
|
|
|
<template v-slot:prepend>
|
2023-06-03 06:53:03 +03:00
|
|
|
<v-btn icon="mdi-home" @click="selectedPath = '/'"></v-btn>
|
2023-05-15 03:32:16 +03:00
|
|
|
</template>
|
|
|
|
</v-toolbar>
|
|
|
|
<TreeView :filesList="filesList" :nav=true></TreeView>
|
|
|
|
</v-navigation-drawer>
|
2023-05-31 01:02:18 +03:00
|
|
|
<v-main class="select-area" style="height: 100dvh;">
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-toolbar class="px-5" height="auto">
|
|
|
|
|
|
|
|
<v-row align="center" justify="center">
|
2023-05-30 04:01:16 +03:00
|
|
|
<v-col cols="12" lg="2" md="12" style="display: inline-flex;">
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-btn title="Back" aria-label="Back" icon="mdi-arrow-left" :disabled="!history.hasUndo.value"
|
2023-05-30 04:01:16 +03:00
|
|
|
@click="history.undo();"></v-btn>
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-btn title="Forward" aria-label="Forward" icon="mdi-arrow-right" :disabled="!history.hasRedo.value"
|
2023-05-30 04:01:16 +03:00
|
|
|
@click="history.redo();"></v-btn>
|
|
|
|
<v-btn title="Refresh" aria-label="Refresh" icon="mdi-refresh" :disabled="!files.length"
|
|
|
|
@click="history.refresh();"></v-btn>
|
2023-06-03 06:53:03 +03:00
|
|
|
<v-btn title="Parent Folder" aria-label="Parent Folder" icon="mdi-arrow-up" :disabled="selectedPath == '/'"
|
|
|
|
@click="selectedPath = stepUp(selectedPath);"></v-btn>
|
2023-05-29 19:51:08 +03:00
|
|
|
</v-col>
|
2023-06-03 05:53:52 +03:00
|
|
|
<v-col cols="10" lg="8" md="10">
|
2023-05-30 04:01:16 +03:00
|
|
|
<v-text-field :disabled="!files.length" hide-details title="Location" single-line placeholder="location"
|
2023-06-03 06:53:03 +03:00
|
|
|
v-model="selectedPath"></v-text-field>
|
2023-05-30 04:01:16 +03:00
|
|
|
</v-col>
|
2023-06-03 05:53:52 +03:00
|
|
|
<v-col cols="2">
|
2023-05-30 04:01:16 +03:00
|
|
|
<v-menu>
|
|
|
|
<template v-slot:activator="{ props }">
|
|
|
|
<v-btn :disabled="!files.length" title="Menu" aria-label="Menu" icon="mdi-dots-vertical"
|
|
|
|
v-bind="props"></v-btn>
|
|
|
|
</template>
|
|
|
|
<v-list>
|
|
|
|
<v-list-item title="Close" aria-label="Close" icon="mdi-close"
|
2023-06-03 06:53:03 +03:00
|
|
|
@click="files = []; selectedPath = '/'; selectedList = []; filesGridList = []; filesList = []; history.reset()">
|
2023-05-30 04:01:16 +03:00
|
|
|
<template v-slot:prepend>
|
|
|
|
<v-icon icon="mdi-close"></v-icon>
|
|
|
|
</template>
|
|
|
|
</v-list-item>
|
|
|
|
</v-list>
|
|
|
|
</v-menu>
|
2023-05-29 19:51:08 +03:00
|
|
|
</v-col>
|
|
|
|
</v-row>
|
2023-05-15 03:32:16 +03:00
|
|
|
</v-toolbar>
|
2023-06-03 06:53:03 +03:00
|
|
|
<template v-if="filesManager.getFile(selectedPath)?.isFolder || false">
|
2023-05-15 03:32:16 +03:00
|
|
|
<v-container>
|
2023-06-03 06:53:03 +03:00
|
|
|
<v-list :selected="[selectedPath]">
|
2023-05-15 03:32:16 +03:00
|
|
|
<v-row no-gutters>
|
2023-05-18 23:54:37 +03:00
|
|
|
<v-col cols="6" lg="2" md="3" sm="6" v-for="file of filesGridList" style="text-align: center;">
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-list-item class="ma-2 pa-5 selectable" active-color="light-blue-darken-4" :value="file.path" rounded
|
2023-06-03 06:53:03 +03:00
|
|
|
@click="selectedPath = file.path">
|
2023-05-15 03:32:16 +03:00
|
|
|
<v-avatar class="mb-2" :color="file.isFolder ? 'light-blue-accent-4' : 'blue-grey-darken-1'">
|
|
|
|
<v-icon color="white">{{ file.isFolder ? 'mdi-folder' : 'mdi-file' }}</v-icon>
|
|
|
|
</v-avatar>
|
|
|
|
<p>{{ file.name }}</p>
|
|
|
|
</v-list-item>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-list>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
2023-05-29 19:51:08 +03:00
|
|
|
|
2023-05-15 03:32:16 +03:00
|
|
|
<VueSelecto :selectableTargets="['.selectable']" :dragContainer="dragContainer" :hitRate="20"
|
2023-05-29 17:40:58 +03:00
|
|
|
:selectFromInside="false" :toggleContinueSelect="'ctrl'" @select="onSelectStart" @selectStart="onSelectStart"
|
2023-05-30 12:47:52 +03:00
|
|
|
:get-element-rect="getElementInfo" @selectEnd="onSelectEnd" :select-by-click="false" />
|
2023-05-29 19:51:08 +03:00
|
|
|
|
2023-05-18 23:02:50 +03:00
|
|
|
<template v-if="!files.length">
|
|
|
|
<!-- tutorial drag and drop zipped file here and review it securely -->
|
|
|
|
<v-container fill-height fluid>
|
|
|
|
<v-row align="center" justify="center">
|
2023-05-19 00:07:04 +03:00
|
|
|
<v-col cols="12">
|
|
|
|
<v-card variant="flat" class="mx-auto" max-width="768">
|
2023-05-18 23:02:50 +03:00
|
|
|
<!-- v-icon for file -->
|
|
|
|
<v-icon class="mx-auto" size="100">mdi-file</v-icon>
|
2023-05-19 00:07:04 +03:00
|
|
|
<v-card-title>Drag and Drop Compressed Files</v-card-title>
|
2023-05-30 03:27:34 +03:00
|
|
|
<v-card-text class="font-weight-bold">
|
|
|
|
Extract and Explore compressed files online and securely.
|
|
|
|
<p class="text-subtitle-2 font-weight-regular text-medium-emphasis">
|
2023-05-30 04:01:16 +03:00
|
|
|
<v-icon class="mx-auto" size="1em" color="#007B4F">mdi-shield</v-icon> <strong>nothing</strong> leave
|
|
|
|
your browser
|
2023-05-30 03:27:34 +03:00
|
|
|
</p>
|
2023-05-18 23:02:50 +03:00
|
|
|
</v-card-text>
|
2023-05-19 00:07:04 +03:00
|
|
|
|
|
|
|
<!-- file input -->
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-file-input class="mx-5" v-model="files" accept=".zip,.7z,.rar,.tar.bz2,.tar.gz,.tar.xz"
|
|
|
|
label="or select a file..." variant="outlined"></v-file-input>
|
2023-05-18 23:02:50 +03:00
|
|
|
</v-card>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
2023-05-29 19:51:08 +03:00
|
|
|
</v-container>
|
2023-05-18 23:02:50 +03:00
|
|
|
</template>
|
2023-05-15 03:32:16 +03:00
|
|
|
</v-main>
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-dialog v-model="loadingModel" persistent width="auto">
|
2023-05-19 18:09:48 +03:00
|
|
|
<v-card>
|
|
|
|
<v-card-text>
|
|
|
|
Please stand by
|
2023-05-29 19:51:08 +03:00
|
|
|
<v-progress-linear indeterminate color="light-blue-darken-1" class="mb-0"></v-progress-linear>
|
2023-05-19 18:09:48 +03:00
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
2023-05-15 03:32:16 +03:00
|
|
|
</v-layout>
|
|
|
|
</template>
|
|
|
|
<style>
|
|
|
|
.v-list-item {
|
|
|
|
border: 2px solid transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selected {
|
2023-05-18 23:02:50 +03:00
|
|
|
background: rgba(48, 150, 243, 0.1);
|
2023-05-15 03:32:16 +03:00
|
|
|
}
|
|
|
|
</style>
|