glib-web 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nav/drawer.vue +38 -8
- package/package.json +1 -1
- package/utils/mime_type.js +78 -0
- package/utils/uploader.js +9 -18
package/nav/drawer.vue
CHANGED
|
@@ -7,26 +7,41 @@
|
|
|
7
7
|
app
|
|
8
8
|
:class="cssClasses"
|
|
9
9
|
:dark="cssClasses.includes('dark')"
|
|
10
|
-
:expand-on-hover="expandOnHover()"
|
|
11
10
|
:permanent="cssClasses.includes('permanent')"
|
|
12
11
|
:style="style"
|
|
12
|
+
:expand-on-hover="expandOnHover()"
|
|
13
|
+
:mini-variant.sync="mini"
|
|
13
14
|
@input="updateState"
|
|
14
15
|
>
|
|
16
|
+
<template v-slot:prepend>
|
|
17
|
+
<v-list-item>
|
|
18
|
+
<v-list-item-icon>
|
|
19
|
+
<v-icon v-if="!mini">mdi-chevron-left</v-icon>
|
|
20
|
+
<v-icon v-if="mini">mdi-chevron-right</v-icon>
|
|
21
|
+
</v-list-item-icon>
|
|
22
|
+
</v-list-item>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
15
25
|
<template v-if="spec.header">
|
|
16
|
-
<!-- <v-toolbar flat> -->
|
|
17
26
|
<panels-responsive :spec="spec.header" />
|
|
18
|
-
<!-- </v-toolbar> -->
|
|
19
|
-
<v-divider></v-divider>
|
|
20
27
|
</template>
|
|
21
28
|
|
|
22
29
|
<v-list dense class="pt-0">
|
|
23
|
-
<div v-for="(item, index) in spec.rows" :key="index">
|
|
30
|
+
<div v-for="(item, index) in spec.rows" :key="index" class="nav-item">
|
|
31
|
+
<div v-if="item.type == 'button'" class="indicator"></div>
|
|
24
32
|
<v-divider v-if="item.type == 'divider'" />
|
|
25
33
|
<nav-drawerLabel v-else-if="item.type == 'label'" :spec="item" />
|
|
26
34
|
<nav-drawerButton v-else :spec="item" />
|
|
27
|
-
<!-- <nav-drawerButton :spec="item" :state="state" v-else /> -->
|
|
28
35
|
</div>
|
|
29
36
|
</v-list>
|
|
37
|
+
|
|
38
|
+
<template v-if="spec.footer" v-slot:append>
|
|
39
|
+
<v-list-item>
|
|
40
|
+
<!-- Display the first line when the drawer is shrunk. Display the second line when the drawer is expanded -->
|
|
41
|
+
<div style="display: none">Show if expand</div>
|
|
42
|
+
<panels-responsive :spec="spec.footer" />
|
|
43
|
+
</v-list-item>
|
|
44
|
+
</template>
|
|
30
45
|
</v-navigation-drawer>
|
|
31
46
|
</template>
|
|
32
47
|
|
|
@@ -50,7 +65,8 @@ export default {
|
|
|
50
65
|
return {
|
|
51
66
|
// Using null as the starting value for its v-model will initialize the drawer as closed on mobile and as open on desktop.
|
|
52
67
|
// See https://vuetifyjs.com/en/components/navigation-drawers
|
|
53
|
-
state: null
|
|
68
|
+
state: null,
|
|
69
|
+
mini: true
|
|
54
70
|
};
|
|
55
71
|
},
|
|
56
72
|
computed: {
|
|
@@ -102,4 +118,18 @@ export default {
|
|
|
102
118
|
};
|
|
103
119
|
</script>
|
|
104
120
|
|
|
105
|
-
<style scoped
|
|
121
|
+
<style scoped>
|
|
122
|
+
.nav-item {
|
|
123
|
+
position: relative;
|
|
124
|
+
}
|
|
125
|
+
.nav-item:hover .indicator {
|
|
126
|
+
display: flex;
|
|
127
|
+
position: absolute;
|
|
128
|
+
width: 3px;
|
|
129
|
+
height: 65%;
|
|
130
|
+
margin: 10px 0;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
align-items: center;
|
|
133
|
+
background-color: white;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
package/package.json
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
aac: "audio/aac",
|
|
3
|
+
abw: "application/x-abiword",
|
|
4
|
+
ai: "application/postscript",
|
|
5
|
+
arc: "application/octet-stream",
|
|
6
|
+
avi: "video/x-msvideo",
|
|
7
|
+
azw: "application/vnd.amazon.ebook",
|
|
8
|
+
bin: "application/octet-stream",
|
|
9
|
+
bz: "application/x-bzip",
|
|
10
|
+
bz2: "application/x-bzip2",
|
|
11
|
+
csh: "application/x-csh",
|
|
12
|
+
css: "text/css",
|
|
13
|
+
csv: "text/csv",
|
|
14
|
+
doc: "application/msword",
|
|
15
|
+
dll: "application/octet-stream",
|
|
16
|
+
eot: "application/vnd.ms-fontobject",
|
|
17
|
+
epub: "application/epub+zip",
|
|
18
|
+
gif: "image/gif",
|
|
19
|
+
htm: "text/html",
|
|
20
|
+
html: "text/html",
|
|
21
|
+
ico: "image/x-icon",
|
|
22
|
+
ics: "text/calendar",
|
|
23
|
+
jar: "application/java-archive",
|
|
24
|
+
jpeg: "image/jpeg",
|
|
25
|
+
jpg: "image/jpeg",
|
|
26
|
+
js: "application/javascript",
|
|
27
|
+
json: "application/json",
|
|
28
|
+
mid: "audio/midi",
|
|
29
|
+
midi: "audio/midi",
|
|
30
|
+
mp2: "audio/mpeg",
|
|
31
|
+
mp3: "audio/mpeg",
|
|
32
|
+
mp4: "video/mp4",
|
|
33
|
+
mpa: "video/mpeg",
|
|
34
|
+
mpe: "video/mpeg",
|
|
35
|
+
mpeg: "video/mpeg",
|
|
36
|
+
mpkg: "application/vnd.apple.installer+xml",
|
|
37
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
38
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
39
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
40
|
+
oga: "audio/ogg",
|
|
41
|
+
ogv: "video/ogg",
|
|
42
|
+
ogx: "application/ogg",
|
|
43
|
+
otf: "font/otf",
|
|
44
|
+
png: "image/png",
|
|
45
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
46
|
+
rar: "application/x-rar-compressed",
|
|
47
|
+
rtf: "application/rtf",
|
|
48
|
+
sh: "application/x-sh",
|
|
49
|
+
svg: "image/svg+xml",
|
|
50
|
+
swf: "application/x-shockwave-flash",
|
|
51
|
+
tar: "application/x-tar",
|
|
52
|
+
tif: "image/tiff",
|
|
53
|
+
tiff: "image/tiff",
|
|
54
|
+
ts: "application/typescript",
|
|
55
|
+
ttf: "font/ttf",
|
|
56
|
+
txt: "text/plain",
|
|
57
|
+
vsd: "application/vnd.visio",
|
|
58
|
+
wav: "audio/x-wav",
|
|
59
|
+
weba: "audio/webm",
|
|
60
|
+
webm: "video/webm",
|
|
61
|
+
webp: "image/webp",
|
|
62
|
+
woff: "font/woff",
|
|
63
|
+
woff2: "font/woff2",
|
|
64
|
+
xhtml: "application/xhtml+xml",
|
|
65
|
+
xls: "application/vnd.ms-excel",
|
|
66
|
+
xlsx: "application/vnd.ms-excel",
|
|
67
|
+
xlsx_OLD: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
68
|
+
xml: "application/xml",
|
|
69
|
+
xul: "application/vnd.mozilla.xul+xml",
|
|
70
|
+
"3gp": "video/3gpp",
|
|
71
|
+
"3gp_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp",
|
|
72
|
+
"3gp2": "video/3gpp2",
|
|
73
|
+
"3gp2_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp2",
|
|
74
|
+
"7z": "application/x-7z-compressed",
|
|
75
|
+
image: "image/*",
|
|
76
|
+
pdf: "application/pdf",
|
|
77
|
+
zip: "application/(zip|x-zip-compressed|octet-stream)"
|
|
78
|
+
};
|
package/utils/uploader.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DirectUpload } from "@rails/activestorage";
|
|
2
2
|
import Type from "../utils/type";
|
|
3
|
+
import mimeType from "../utils/mime_type";
|
|
3
4
|
|
|
4
5
|
const MB_SIZE = 1000;
|
|
5
6
|
|
|
@@ -67,25 +68,15 @@ export default class Uploader {
|
|
|
67
68
|
|
|
68
69
|
validateFileAccordingToRules(spec) {
|
|
69
70
|
if (Type.isObject(spec)) {
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
mimeType = "application/pdf";
|
|
78
|
-
break;
|
|
79
|
-
case "zip":
|
|
80
|
-
// See https://stackoverflow.com/questions/856013/mime-type-for-zip-file-in-google-chrome
|
|
81
|
-
mimeType = "application/(zip|x-zip-compressed|octet-stream)";
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
71
|
+
let validFileType = false;
|
|
72
|
+
[spec.fileType].flat().forEach(key => {
|
|
73
|
+
const acceptsRegex = new RegExp(mimeType[key]);
|
|
74
|
+
if (acceptsRegex.test(this.file.type)) {
|
|
75
|
+
validFileType = true;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
86
78
|
|
|
87
|
-
|
|
88
|
-
if (!acceptsRegex.test(this.file.type)) {
|
|
79
|
+
if (!validFileType) {
|
|
89
80
|
alert(spec.fileTypeErrorText || "Invalid file type");
|
|
90
81
|
return false;
|
|
91
82
|
}
|