1
1
/**
2
2
* The MIT License (MIT)
3
3
*
4
- * Igor Zinken 2023 - https://www.igorski.nl
4
+ * Igor Zinken 2023-2025 - https://www.igorski.nl
5
5
*
6
6
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7
7
* this software and associated documentation files (the "Software"), to deal in
20
20
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
21
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
*/
23
+ <template src="../cloud-file-selector.html "></template >
24
+
23
25
<script lang="ts">
24
26
import type { Component } from " vue" ;
25
- import { mapMutations } from " vuex" ;
26
- import CloudFileSelector from " ../cloud-file-selector.vue" ;
27
- import type { FileNode } from " ../cloud-file-selector.vue" ;
27
+ import CloudFileSelector from " ../cloud-file-selector" ;
28
28
import S3ImagePreview from " ./aws-s3-image-preview.vue" ;
29
29
import { PROJECT_FILE_EXTENSION } from " @/definitions/file-types" ;
30
- import { STORAGE_TYPES } from " @/definitions/storage-types" ;
30
+ import { type FileNode , STORAGE_TYPES } from " @/definitions/storage-types" ;
31
31
import { getS3Service } from " @/utils/cloud-service-loader" ;
32
32
33
33
let listFolder, createFolder, downloadFileAsBlob, deleteEntry;
34
34
35
- export default {
36
- extends: CloudFileSelector ,
37
- data : () => ({
38
- LAST_FOLDER_STORAGE_KEY: " bpy_s3Db" ,
39
- STORAGE_PROVIDER: STORAGE_TYPES .S3 ,
40
- }),
41
- computed: {
42
- imagePreviewComponent(): Component {
43
- return S3ImagePreview ;
44
- },
45
- },
46
- async created(): Promise <void > {
47
- ({ listFolder , createFolder , downloadFileAsBlob , deleteEntry } = await getS3Service () );
48
- this .tree .path = " " ;
35
+ export default {
36
+ mixins: [ CloudFileSelector ] ,
37
+ data : () => ({
38
+ LAST_FOLDER_STORAGE_KEY: " bpy_s3Db" ,
39
+ STORAGE_PROVIDER: STORAGE_TYPES .S3 ,
40
+ }),
41
+ computed: {
42
+ imagePreviewComponent(): Component {
43
+ return S3ImagePreview ;
44
+ },
45
+ },
46
+ async created(): Promise <void > {
47
+ ({ listFolder , createFolder , downloadFileAsBlob , deleteEntry } = await getS3Service () );
48
+ this .tree .path = " " ;
49
49
50
- let pathToRetrieve = this .tree .path ;
51
- try {
52
- const { tree, path } = JSON .parse ( sessionStorage .getItem ( this .LAST_FOLDER_STORAGE_KEY ));
53
- this .tree = { ... this .tree , ... tree };
54
- pathToRetrieve = path ;
55
- } catch {
56
- // no tree stored in SessionStorage, continue.
57
- }
58
- this .retrieveFiles ( pathToRetrieve );
59
- },
60
- methods: {
61
- /* base component overrides */
62
- _getServicePathForNode( node : FileNode ): string {
63
- return node .key ?? node .path ;
64
- },
65
- async _listFolder( path : string ): Promise <FileNode []> {
66
- const entries = await listFolder ( path );
67
- return entries ;
68
- },
69
- async _createFolder( parent : string , name : string ): Promise <Boolean > {
70
- return createFolder ( parent , name );
71
- },
72
- async _downloadFile( node : FileNode , returnAsURL = false ): Promise <Blob | string | null > {
50
+ let pathToRetrieve = this .tree .path ;
51
+ try {
52
+ const { tree, path } = JSON .parse ( sessionStorage .getItem ( this .LAST_FOLDER_STORAGE_KEY ));
53
+ this .tree = { ... this .tree , ... tree };
54
+ pathToRetrieve = path ;
55
+ } catch {
56
+ // no tree stored in SessionStorage, continue.
57
+ }
58
+ this .retrieveFiles ( pathToRetrieve );
59
+ },
60
+ methods: {
61
+ /* base component overrides */
62
+ _getServicePathForNode( node : FileNode ): string {
63
+ return node .key ?? node .path ;
64
+ },
65
+ async _listFolder( path : string ): Promise <FileNode []> {
66
+ const entries = await listFolder ( path );
67
+ return entries ;
68
+ },
69
+ async _createFolder( parent : string , name : string ): Promise <boolean > {
70
+ return createFolder ( parent , name );
71
+ },
72
+ async _downloadFile( node : FileNode , returnAsURL = false ): Promise <Blob | string | null > {
73
73
return downloadFileAsBlob ( node .key , returnAsURL );
74
- },
75
- async _deleteEntry( node : FileNode ): Promise <boolean > {
76
- return deleteEntry ( node .key );
77
- },
78
- _mapEntry( entry : FileNode , children = [], parent = null ): FileNode {
79
- if ( entry .name .endsWith ( PROJECT_FILE_EXTENSION )) {
80
- entry .type = PROJECT_FILE_EXTENSION ;
81
- }
82
- return {
83
- ... entry ,
84
- path : entry .name ,
85
- children ,
86
- parent ,
87
- };
88
- },
89
- }
90
- };
91
- </script >
74
+ },
75
+ async _deleteEntry( node : FileNode ): Promise <boolean > {
76
+ return deleteEntry ( node .key );
77
+ },
78
+ _mapEntry( entry : FileNode , children = [], parent = null ): FileNode {
79
+ if ( entry .name .endsWith ( PROJECT_FILE_EXTENSION )) {
80
+ entry .type = PROJECT_FILE_EXTENSION ;
81
+ }
82
+ return {
83
+ ... entry ,
84
+ path : entry .name ,
85
+ children ,
86
+ parent ,
87
+ };
88
+ },
89
+ }
90
+ };
91
+ </script >
92
+
93
+ <style lang="scss" src="../cloud-file-selector.scss " scoped />
0 commit comments