Skip to content

Commit

Permalink
#27 - Added the abillity to download blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikpyt committed Oct 17, 2023
1 parent 2f312cd commit 2e60944
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
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

0 comments on commit 2e60944

Please sign in to comment.