Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added the abillity to download blobs #36

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions src/components/item/file/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<div class="relative">
<!-- File -->
<a
href="#"
href="javascript:void(0)"
class="block max-w-sm rounded-lg border border-gray-200 bg-white p-6 shadow hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:hover:bg-gray-700"
v-on:contextmenu.prevent="fileContextMenu?.openMenu"
@click.prevent="downloadFile"
>
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">
{{ modelValue.name }}
Expand All @@ -30,6 +31,14 @@
>{{ t('fileBrowser.file.action.share') }}</a
>
</li>
<li>
<a
href="javascript:void(0)"
@click="downloadFile"
class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>{{ t('fileBrowser.file.action.download') }}</a
>
</li>
</ul>
<div class="py-2">
<a
Expand All @@ -51,15 +60,21 @@
</template>

<script setup lang="ts">
// Lib
import { ref, type PropType } from 'vue';
import { FileClass } from '@lib/items/files';
import ContextMenu from '@components/base/contextMenu.vue';
import BaseConfirmModal, { ConfirmModalType } from '@components/base/confirmModal.vue';
import EditFileModal from './EditModal.vue';
import ShareItemModal from '../ShareItemModal.vue';

// Helpers
import { t } from '@lib/i18n';

// Components
import ContextMenu from '@components/base/contextMenu.vue';

// Stores
import { removeItem } from '@stores/items';

// File
import { FileClass } from '@lib/items/files';

const fileContextMenu = ref<InstanceType<typeof ContextMenu>>();

defineEmits(['update:modelValue']);
Expand All @@ -70,6 +85,19 @@ const props = defineProps({
},
});

function downloadFile() {
window.open(props.modelValue.blobUrl, '_blank');

fileContextMenu.value?.closeMenu();
}

/*
* Modals
*/
import BaseConfirmModal, { ConfirmModalType } from '@components/base/confirmModal.vue';
import EditFileModal from './EditModal.vue';
import ShareItemModal from '../ShareItemModal.vue';

const deleteFileModal = ref<InstanceType<typeof BaseConfirmModal>>();
async function deleteFile() {
try {
Expand Down
1 change: 1 addition & 0 deletions src/lang/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
edit: 'Omdøb fil',
share: 'Del',
delete: 'Slet',
download: 'Download',
confirmDelete: 'Er du sikker på, at du vil slette denne fil?',
},
},
Expand Down
1 change: 1 addition & 0 deletions src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
edit: 'Rename file',
share: 'Share',
delete: 'Delete',
download: 'Download',
confirmDelete: 'Are you sure you want to delete this file?',
},
},
Expand Down