Skip to content

Commit

Permalink
feat: Add placeholder icons for file upload preview
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwong89 committed Jan 24, 2024
1 parent bbb49c2 commit bde0128
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/src/assets/images/compressed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/doc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/email.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/pdf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/shape.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/src/assets/images/spreadsheet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 55 additions & 1 deletion frontend/src/components/file/DocumentCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import { filesize } from 'filesize';
import { Button, Card, useConfirm, useToast } from '@/lib/primevue';
import { documentService } from '@/services';
import { formatDateLong } from '@/utils/formatters';
import { getFilenameAndExtension } from '@/utils/utils';
import bcboxy from '@/assets/images/bcboxy.png';

Check warning on line 9 in frontend/src/components/file/DocumentCard.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'bcboxy' is defined but never used

Check warning on line 9 in frontend/src/components/file/DocumentCard.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'bcboxy' is defined but never used

Check warning on line 9 in frontend/src/components/file/DocumentCard.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'bcboxy' is defined but never used

Check warning on line 9 in frontend/src/components/file/DocumentCard.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (16.x)

'bcboxy' is defined but never used

Check warning on line 9 in frontend/src/components/file/DocumentCard.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

'bcboxy' is defined but never used

Check warning on line 9 in frontend/src/components/file/DocumentCard.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

'bcboxy' is defined but never used
import compressed from '@/assets/images/image.svg';
import doc from '@/assets/images/doc.svg';
import email from '@/assets/images/shape.svg';
import file from '@/assets/images/file.svg';
import image from '@/assets/images/image.svg';
import pdf from '@/assets/images/doc.svg';
import shape from '@/assets/images/shape.svg';
import spreadsheet from '@/assets/images/image.svg';
import type { Document } from '@/types';
Expand Down Expand Up @@ -43,14 +54,57 @@ const confirmDelete = (documentId: string, filename: string) => {
});
}
};
const displayExtensionIcon = (fileString: string) => {
const fileAndExtension = getFilenameAndExtension(fileString);
const extension = fileAndExtension?.extension?.toLowerCase() ?? '';
switch (extension) {
case 'shp':
case 'dbs':
case 'cpg':
case 'prj':
case 'shx':
return shape;
case 'docx':
case 'doc':
return doc;
case 'pdf':
return pdf;
case 'xls':
case 'xlsx':
case 'csv':
return spreadsheet;
case 'jpg':
case 'jpeg':
case 'png':
case 'bmp':
case 'gif':
case 'svg':
case 'webp':
case 'tiff':
return image;
case 'eml':
case 'pst':
case 'msg':
return email;
case 'zip':
case 'rar':
case 'gz':
case '7z':
return compressed;
default:
return file;
}
};
</script>

<template>
<Card class="pt-2 pb-1 text-center">
<template #header>
<img
alt="document header"
src="@/assets/images/bcboxy.png"
:src="displayExtensionIcon(props.document.filename)"
class="document-image"
/>
</template>
Expand Down

0 comments on commit bde0128

Please sign in to comment.