fix container sizes

This commit is contained in:
Salem Yaslem 2024-11-04 09:44:01 +03:00
parent 816f50a452
commit 21dc8009ba
4 changed files with 48 additions and 7 deletions

39
app.vue
View File

@ -3,7 +3,7 @@ import { getElementInfo } from "moveable";
import { VueSelecto } from "vue3-selecto"; import { VueSelecto } from "vue3-selecto";
import { useDisplay } from 'vuetify/lib/framework.mjs'; import { useDisplay } from 'vuetify/lib/framework.mjs';
import { HistoryManager } from './composables/history-manager'; import { HistoryManager } from './composables/history-manager';
import { FilesManager } from './composables/files-manager'; import { FilesManager, supportedExtensions } from './composables/files-manager';
import type { iFile } from "composables/worker/7zip-manager" import type { iFile } from "composables/worker/7zip-manager"
import { videoExtensions, binaryExtensions } from '#imports'; import { videoExtensions, binaryExtensions } from '#imports';
@ -19,13 +19,21 @@ let selectedList = ref<any>([]);
let filesManager = new FilesManager(filesList); let filesManager = new FilesManager(filesList);
let history = new HistoryManager(filesManager); let history = new HistoryManager(filesManager);
let mediaBlobUrl = ref(''); let mediaBlobUrl = ref('');
let errorDialog = ref(false);
let errorMessage = ref('');
watchEffect(async () => { watchEffect(async () => {
if (files.value?.[0]) { if (files.value?.[0]) {
loadingModel.value = true; loadingModel.value = true;
filesList.value = []; filesList.value = [];
await filesManager.loadArchive(files.value?.[0]); try {
await filesManager.loadArchive(files.value?.[0]);
} catch (error: any) {
errorMessage.value = error.message;
errorDialog.value = true;
files.value = [];
}
loadingModel.value = false; loadingModel.value = false;
} }
}) })
@ -164,7 +172,7 @@ function stepUp(path: string) {
</v-toolbar> </v-toolbar>
<v-container> <v-container>
<template v-if="filesManager.getFile(selectedPath)?.isFolder"> <template v-if="filesManager.getFile(selectedPath)?.isFolder">
<v-list :selected="[selectedPath]"> <v-list :selected="[selectedPath]" style="height: calc(100vh - 120px);">
<v-row no-gutters> <v-row no-gutters>
<v-col cols="6" lg="2" md="3" sm="6" v-for="file of filesGridList" style="text-align: center;"> <v-col cols="6" lg="2" md="3" sm="6" v-for="file of filesGridList" style="text-align: center;">
<v-list-item class="position-relative ma-2 pa-5 selectable" active-color="light-blue-darken-4" <v-list-item class="position-relative ma-2 pa-5 selectable" active-color="light-blue-darken-4"
@ -205,7 +213,7 @@ function stepUp(path: string) {
</template> </template>
<template v-if="!files.length"> <template v-if="!files.length">
<!-- tutorial drag and drop zipped file here and review it securely --> <!-- tutorial drag and drop zipped file here and review it securely -->
<v-row align="center" justify="center"> <v-row align="center" justify="center" style="height: calc(100vh - 120px)">
<v-col cols="12"> <v-col cols="12">
<v-card variant="flat" class="mx-auto" max-width="768"> <v-card variant="flat" class="mx-auto" max-width="768">
<!-- v-icon for file --> <!-- v-icon for file -->
@ -221,7 +229,7 @@ function stepUp(path: string) {
</v-card-text> </v-card-text>
<!-- file input --> <!-- file input -->
<v-file-input class="mx-5" v-model="files" accept=".zip,.7z,.rar,.tar.bz2,.tar.gz,.tar.xz" <v-file-input class="mx-5" v-model="files" :accept="supportedExtensions.map(extension => `.${extension}`).join(',')"
label="or select a file..." variant="outlined"></v-file-input> label="or select a file..." variant="outlined"></v-file-input>
</v-card> </v-card>
</v-col> </v-col>
@ -241,6 +249,22 @@ function stepUp(path: string) {
</v-card-text> </v-card-text>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-dialog v-model="errorDialog" width="auto">
<v-card>
<v-card-title class="text-error">
Error
</v-card-title>
<v-card-text>
{{ errorMessage }}
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" variant="text" @click="errorDialog = false">
Close
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout> </v-layout>
</template> </template>
<style> <style>
@ -251,4 +275,9 @@ function stepUp(path: string) {
.selected { .selected {
background: rgba(48, 150, 243, 0.1); background: rgba(48, 150, 243, 0.1);
} }
.v-container {
height: calc(100vh - 120px);
padding: 0;
}
</style> </style>

View File

@ -103,7 +103,7 @@ onMounted(async () => {
white-space: pre; white-space: pre;
padding: 1rem; padding: 1rem;
background-color: var(--v-theme-surface); background-color: var(--v-theme-surface);
height: calc(100vh - 150px); height: calc(100vh - 120px);
} }
.hex-container { .hex-container {

View File

@ -35,6 +35,6 @@ onMounted(async () => {
<style scoped> <style scoped>
#editor { #editor {
width: 100vw; width: 100vw;
height: 100vh; height: calc(100vh - 120px);
} }
</style> </style>

View File

@ -12,6 +12,12 @@ export const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
export const audioExtensions = ['mp3', 'wav', 'ogg', 'flac']; export const audioExtensions = ['mp3', 'wav', 'ogg', 'flac'];
export const textExtensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'md', 'js', 'ts', 'php', 'c', 'cpp', 'py', 'html', 'css', 'scss', 'sass', 'less', 'json', 'xml', 'sql', 'java', 'go', 'rb', 'sh', 'bat', 'ps1', 'cmd', 'yml', 'yaml', 'ini', 'toml', 'csv', 'tsv', 'gitignore', 'lock', 'htaccess', 'htpasswd', 'env', 'dockerfile', 'gitattributes', 'gitmodules', 'editorconfig', 'babelrc', 'eslintrc', 'eslintignore', 'prettierrc', 'prettierignore', 'stylelintrc', 'stylelintignore', 'postcssrc', 'postcss.config', 'jsx', 'tsx', 'license']; export const textExtensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'md', 'js', 'ts', 'php', 'c', 'cpp', 'py', 'html', 'css', 'scss', 'sass', 'less', 'json', 'xml', 'sql', 'java', 'go', 'rb', 'sh', 'bat', 'ps1', 'cmd', 'yml', 'yaml', 'ini', 'toml', 'csv', 'tsv', 'gitignore', 'lock', 'htaccess', 'htpasswd', 'env', 'dockerfile', 'gitattributes', 'gitmodules', 'editorconfig', 'babelrc', 'eslintrc', 'eslintignore', 'prettierrc', 'prettierignore', 'stylelintrc', 'stylelintignore', 'postcssrc', 'postcss.config', 'jsx', 'tsx', 'license'];
export const binaryExtensions = ['exe', 'dll', 'so', 'dylib', 'bin', 'dat', 'db', 'sqlite', 'o', 'class', 'pyc']; export const binaryExtensions = ['exe', 'dll', 'so', 'dylib', 'bin', 'dat', 'db', 'sqlite', 'o', 'class', 'pyc'];
export const supportedExtensions = [
'7z', 'xz', 'bz2', 'gz', 'tar', 'zip', 'wim',
'apfs', 'ar', 'arj', 'cab', 'chm', 'cpio', 'dmg', 'ext', 'fat', 'gpt', 'hfs',
'ihex', 'iso', 'lzh', 'lzma', 'mbr', 'msi', 'nsis', 'ntfs', 'qcow2', 'rar',
'rpm', 'squashfs', 'udf', 'uefi', 'vdi', 'vhd', 'vhdx', 'vmdk', 'xar', 'z'
];
export class FilesManager { export class FilesManager {
consoleOutputBuffer: string[] = []; consoleOutputBuffer: string[] = [];
@ -28,6 +34,12 @@ export class FilesManager {
async loadArchive(file: File) { async loadArchive(file: File) {
if (!this.remoteSevenZipManager) return; if (!this.remoteSevenZipManager) return;
const extension = file.name.split('.').pop()?.toLowerCase();
if (!extension || !supportedExtensions.includes(extension)) {
throw new Error('Unsupported file format. Please use a supported archive format.');
}
this.filesList.value = await this.remoteSevenZipManager.loadArchive(file) || []; this.filesList.value = await this.remoteSevenZipManager.loadArchive(file) || [];
} }