@live-change/upload-frontend 0.0.3
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/LICENSE +21 -0
- package/front/index.html +11 -0
- package/front/public/favicon.ico +0 -0
- package/front/public/images/empty-photo.svg +38 -0
- package/front/public/images/empty-user-photo.svg +33 -0
- package/front/public/images/logo.svg +34 -0
- package/front/public/images/logo128.png +0 -0
- package/front/src/App.vue +32 -0
- package/front/src/DropZone.vue +101 -0
- package/front/src/FileInput.vue +69 -0
- package/front/src/NavBar.vue +105 -0
- package/front/src/Upload.js +85 -0
- package/front/src/UploadTest.vue +40 -0
- package/front/src/UploadView.vue +45 -0
- package/front/src/entry-client.js +6 -0
- package/front/src/entry-server.js +6 -0
- package/front/src/router.js +35 -0
- package/front/vite.config.js +18 -0
- package/index.js +6 -0
- package/package.json +79 -0
- package/server/init.js +5 -0
- package/server/services.config.js +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Michał Łaszczewski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/front/index.html
ADDED
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
version="1.1"
|
|
6
|
+
id="Layer_1"
|
|
7
|
+
x="0px"
|
|
8
|
+
y="0px"
|
|
9
|
+
width="512px"
|
|
10
|
+
height="512px"
|
|
11
|
+
viewBox="0 0 512 512"
|
|
12
|
+
enable-background="new 0 0 512 512"
|
|
13
|
+
xml:space="preserve"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
16
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
17
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
18
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
|
|
19
|
+
id="metadata9"><rdf:RDF><cc:Work
|
|
20
|
+
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
|
21
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
|
22
|
+
id="defs7" />
|
|
23
|
+
<rect
|
|
24
|
+
style="fill:#dbdbdb;fill-opacity:1;stroke:none;stroke-width:1.88976383;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
25
|
+
id="rect821"
|
|
26
|
+
width="512.54236"
|
|
27
|
+
height="512.54236"
|
|
28
|
+
x="0.54237288"
|
|
29
|
+
y="0.54237235" />
|
|
30
|
+
<path
|
|
31
|
+
style="fill:#f6f6f6;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
32
|
+
d="M 0.54237288,470.23729 125.83051,306.44068 l 60.20339,70.50847 130.71186,-174.10169 195.79661,261.42373 0.54235,48.81353 H 0.54237288 Z"
|
|
33
|
+
id="path816" /><circle
|
|
34
|
+
style="fill:#f6f6f6;fill-opacity:1;stroke:none;stroke-width:4.80000019;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
35
|
+
id="path818"
|
|
36
|
+
cx="118.50848"
|
|
37
|
+
cy="106.57627"
|
|
38
|
+
r="57.762711" /></svg>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
version="1.1"
|
|
6
|
+
id="Layer_1"
|
|
7
|
+
x="0px"
|
|
8
|
+
y="0px"
|
|
9
|
+
width="512px"
|
|
10
|
+
height="512px"
|
|
11
|
+
viewBox="0 0 512 512"
|
|
12
|
+
enable-background="new 0 0 512 512"
|
|
13
|
+
xml:space="preserve"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
16
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
17
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
18
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
|
|
19
|
+
id="metadata9"><rdf:RDF><cc:Work
|
|
20
|
+
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
|
21
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
|
22
|
+
id="defs7" />
|
|
23
|
+
<rect
|
|
24
|
+
style="fill:#dbdbdb;fill-opacity:1;stroke:none;stroke-width:1.88976383;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
25
|
+
id="rect821"
|
|
26
|
+
width="512.54236"
|
|
27
|
+
height="512.54236"
|
|
28
|
+
x="0.54237288"
|
|
29
|
+
y="0.54237235" /><path
|
|
30
|
+
d="m 313.14122,310.64877 c 9.02181,-8.85097 12.15686,-31.23733 20.41627,-39.3056 11.69771,-11.43183 24.39381,-25.50218 27.98588,-43.06851 4.82003,-23.34203 -4.96846,-26.30516 -4.96846,-34.3713 0,-16.90002 -0.15376,-44.65739 -5.43081,-62.68607 -0.30326,-23.7809 -4.20499,-34.123578 -12.38858,-43.031138 -7.72017,-8.33522 -26.68637,-6.366203 -36.59125,-11.85361 C 286.83605,67.825407 274.23818,64.594254 258.15823,64.17461 v -0.09503 c -0.47624,0 -0.93539,0.05659 -1.41162,0.05659 -0.78484,0 -1.53123,-0.05659 -2.35343,-0.05659 l 0.0395,0.151627 c -39.17105,1.472492 -80.84608,26.170627 -95.16524,65.895863 -5.31335,14.71958 -3.28881,46.87521 -3.28881,63.77522 0,8.06721 -9.78742,11.02927 -4.96846,34.37131 3.61129,17.56632 16.28817,31.63668 27.98588,43.06851 8.26048,8.06827 11.39446,30.45462 20.39705,39.30559 1.96902,13.0378 2.1986,9.31012 2.12278,21.23954 -0.0203,4.03307 0.11426,10.28502 -6.32669,16.4398 -12.17822,11.6614 -40.14595,36.95324 -63.08756,46.79832 -30.24,12.98014 -79.41203,33.74237 -90.746691,39.59069 -11.334661,5.84833 -41.2532541,21.69763 -41.2532541,31.79045 0,10.11417 0,47.33542 0,47.33542 h 253.3742451 5.79494 253.37318 c 0,0 0,-37.22125 0,-47.33542 0,-10.09282 -29.89723,-25.94212 -41.25645,-31.79045 -11.35389,-5.84938 -60.48321,-26.61055 -90.72641,-39.59069 -22.32976,-9.57707 -49.43685,-33.81712 -62.09344,-45.84158 -4.2808,-4.05228 -7.3016,-8.29784 -7.3411,-18.62023 -0.0737,-12.00417 0.23278,-7.41692 2.14306,-20.01478"
|
|
31
|
+
id="path2"
|
|
32
|
+
style="clip-rule:evenodd;fill-rule:evenodd;stroke-width:1.06779659;fill:#f6f6f6;fill-opacity:1" />
|
|
33
|
+
</svg>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
width="512"
|
|
4
|
+
height="512"
|
|
5
|
+
viewBox="0 0 135.46667 135.46667"
|
|
6
|
+
version="1.1"
|
|
7
|
+
id="svg977"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
10
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
11
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
12
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
|
13
|
+
<defs
|
|
14
|
+
id="defs971" />
|
|
15
|
+
<metadata
|
|
16
|
+
id="metadata974">
|
|
17
|
+
<rdf:RDF>
|
|
18
|
+
<cc:Work
|
|
19
|
+
rdf:about="">
|
|
20
|
+
<dc:format>image/svg+xml</dc:format>
|
|
21
|
+
<dc:type
|
|
22
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
23
|
+
</cc:Work>
|
|
24
|
+
</rdf:RDF>
|
|
25
|
+
</metadata>
|
|
26
|
+
<g
|
|
27
|
+
id="layer1"
|
|
28
|
+
style="fill:#666666">
|
|
29
|
+
<path
|
|
30
|
+
style="fill:#666666;fill-opacity:1;stroke:none;stroke-width:2.70907px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
31
|
+
d="M 54.181439,13.558436 67.726801,0.01304296 135.45359,67.739804 67.726801,135.46667 29.799793,97.539626 V 65.030766 L 13.545362,81.285197 0,67.739804 40.636077,27.103727 81.272154,67.739804 67.726801,81.285197 51.472371,65.030766 V 92.12155 l 16.25443,16.25433 40.636069,-40.636076 z"
|
|
32
|
+
id="path892" />
|
|
33
|
+
</g>
|
|
34
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view-root>
|
|
3
|
+
<template #navbar>
|
|
4
|
+
<NavBar />
|
|
5
|
+
</template>
|
|
6
|
+
</view-root>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import 'primevue/resources/themes/saga-green/theme.css'
|
|
11
|
+
import "@fortawesome/fontawesome-free/css/all.min.css"
|
|
12
|
+
|
|
13
|
+
import ViewRoot from "@live-change/frontend-base/ViewRoot.vue"
|
|
14
|
+
import NavBar from "./NavBar.vue"
|
|
15
|
+
|
|
16
|
+
import { useMeta } from 'vue-meta'
|
|
17
|
+
const { meta } = useMeta({
|
|
18
|
+
title: 'Title',
|
|
19
|
+
htmlAttrs: {
|
|
20
|
+
lang: 'en',
|
|
21
|
+
amp: true
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
import { watch } from 'vue'
|
|
26
|
+
import { client as useClient } from '@live-change/vue3-ssr'
|
|
27
|
+
const client = useClient()
|
|
28
|
+
watch(client, (newClient, oldClient) => {
|
|
29
|
+
console.log("WATCH CLIENT", oldClient, '=>', newClient)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div @dragenter="handleDrag"
|
|
3
|
+
@dragover="handleDrag"
|
|
4
|
+
@dragleave="handleDragLeave"
|
|
5
|
+
@drop="handleDrop"
|
|
6
|
+
:class="[{
|
|
7
|
+
[props.acceptedClass]: dragging && accepted,
|
|
8
|
+
[props.wrongClass]: dragging && !accepted
|
|
9
|
+
}, props.class]">
|
|
10
|
+
<FileInput v-if="clickable" @input="input => emit('input', input)">
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</FileInput>
|
|
13
|
+
<slot v-else></slot>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import FileInput from "./FileInput.vue";
|
|
19
|
+
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
accept: {
|
|
22
|
+
type: String
|
|
23
|
+
},
|
|
24
|
+
multiple: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false
|
|
27
|
+
},
|
|
28
|
+
acceptedClass: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'surface-500'
|
|
31
|
+
},
|
|
32
|
+
wrongClass: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'bg-orange-300'
|
|
35
|
+
},
|
|
36
|
+
class: {
|
|
37
|
+
type: String
|
|
38
|
+
},
|
|
39
|
+
clickable: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const emit = defineEmits(['input'])
|
|
46
|
+
|
|
47
|
+
import { ref } from 'vue'
|
|
48
|
+
|
|
49
|
+
const dragging = ref(false)
|
|
50
|
+
const accepted = ref(false)
|
|
51
|
+
|
|
52
|
+
function isAccepted(dataTransfer) {
|
|
53
|
+
if(!props.accept) return true // accept everything
|
|
54
|
+
const accepted = props.accept.split(',').map(x=>x.trim())
|
|
55
|
+
for (let i = 0; i < dataTransfer.items.length; i++) {
|
|
56
|
+
const item = dataTransfer.items[i]
|
|
57
|
+
if(!accepted.includes(item.type)) return false
|
|
58
|
+
}
|
|
59
|
+
return true
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function handleDrag(e) {
|
|
63
|
+
dragging.value = true
|
|
64
|
+
accepted.value = isAccepted(e.dataTransfer)
|
|
65
|
+
e.dataTransfer.dropEffect = accepted.value ? 'copy' : 'none'
|
|
66
|
+
e.preventDefault()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function handleDragLeave(ev) {
|
|
70
|
+
dragging.value = false
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function handleDrop(ev) {
|
|
74
|
+
dragging.value = false
|
|
75
|
+
ev.preventDefault()
|
|
76
|
+
console.log("DROPPED", ev)
|
|
77
|
+
let files = []
|
|
78
|
+
if(ev.dataTransfer.items) {
|
|
79
|
+
for(let i = 0; i < ev.dataTransfer.items.length; i++) {
|
|
80
|
+
if(ev.dataTransfer.items[i].kind === 'file') {
|
|
81
|
+
let file = ev.dataTransfer.items[i].getAsFile();
|
|
82
|
+
files.push(file)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
for (let i = 0; i < ev.dataTransfer.files.length; i++) {
|
|
87
|
+
files.push(ev.dataTransfer.files[i])
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if(this.multiple) {
|
|
91
|
+
emit('input', files)
|
|
92
|
+
} else {
|
|
93
|
+
emit('input', files[0])
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style scoped>
|
|
100
|
+
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="relative">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
<input class="hidden-file" :name="name" type="file" :multiple="multiple" :accept="accept"
|
|
5
|
+
@change="handleInputChange" ref="fileInput">
|
|
6
|
+
</span>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { ref } from "vue"
|
|
11
|
+
import { toRefs } from "@vueuse/core"
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
accept: {
|
|
15
|
+
type: String
|
|
16
|
+
},
|
|
17
|
+
multiple: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
name: {
|
|
22
|
+
type: String
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const { multiple } = toRefs(props)
|
|
27
|
+
|
|
28
|
+
const fileInput = ref()
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits(['input'])
|
|
31
|
+
|
|
32
|
+
function handleFileSelected(file) {
|
|
33
|
+
emit('input', file)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function handleInputChange(e) {
|
|
37
|
+
let files = e.target.files || e.dataTransfer.files
|
|
38
|
+
if (!files.length) return
|
|
39
|
+
if(multiple.value) {
|
|
40
|
+
handleFileSelected(files)
|
|
41
|
+
} else {
|
|
42
|
+
handleFileSelected(files[0])
|
|
43
|
+
}
|
|
44
|
+
fileInput.value = null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style scoped>
|
|
50
|
+
span.file-input {
|
|
51
|
+
position: relative;
|
|
52
|
+
display: flex;
|
|
53
|
+
height: auto;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
input.hidden-file {
|
|
57
|
+
border: none;
|
|
58
|
+
position: absolute;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
top: 0;
|
|
62
|
+
bottom: 0;
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
pointer-events: all;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
opacity: 0;
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="surface-overlay py-3 px-6 shadow-2 flex align-items-center justify-content-between
|
|
3
|
+
relative md:sticky top-0 z-5"
|
|
4
|
+
style="min-height: 80px" key="navbar">
|
|
5
|
+
<img src="/images/logo.svg" alt="Image" height="40" class="mr-0 lg:mr-6">
|
|
6
|
+
<a v-ripple class="cursor-pointer block lg:hidden text-700 p-ripple"
|
|
7
|
+
v-styleclass="{ selector: '@next', enterClass: 'hidden', leaveToClass: 'hidden', hideOnOutsideClick: true }">
|
|
8
|
+
<i class="pi pi-bars text-4xl"></i>
|
|
9
|
+
</a>
|
|
10
|
+
<div class="align-items-center flex-grow-1 justify-content-between hidden lg:flex absolute lg:static w-full surface-overlay left-0 top-100 z-1 shadow-2 lg:shadow-none">
|
|
11
|
+
<ul class="list-none p-0 m-0 flex lg:align-items-center select-none flex-column lg:flex-row">
|
|
12
|
+
<li>
|
|
13
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
14
|
+
<i class="pi pi-home mr-2"></i>
|
|
15
|
+
<span>Home</span>
|
|
16
|
+
</a>
|
|
17
|
+
</li>
|
|
18
|
+
<li class="lg:relative">
|
|
19
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple"
|
|
20
|
+
v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'scalein', leaveToClass: 'hidden', leaveActiveClass: 'fadeout', hideOnOutsideClick: true }">
|
|
21
|
+
<i class="pi pi-users mr-2"></i>
|
|
22
|
+
<span>Customers</span>
|
|
23
|
+
<i class="pi pi-angle-down ml-auto lg:ml-3"></i>
|
|
24
|
+
</a>
|
|
25
|
+
<ul class="list-none py-3 px-6 m-0 lg:px-0 lg:py-0 border-round shadow-0 lg:shadow-2 lg:border-1 border-50 lg:absolute surface-overlay hidden origin-top w-full lg:w-15rem cursor-pointer">
|
|
26
|
+
<li>
|
|
27
|
+
<a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple">
|
|
28
|
+
<i class="pi pi-user-plus mr-2"></i>
|
|
29
|
+
<span class="font-medium">Add New</span>
|
|
30
|
+
</a>
|
|
31
|
+
</li>
|
|
32
|
+
<li class="relative">
|
|
33
|
+
<a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple"
|
|
34
|
+
v-styleclass="{ selector: '@next', enterClass: 'hidden', enterActiveClass: 'scalein', leaveToClass: 'hidden', leaveActiveClass: 'fadeout', hideOnOutsideClick: true }">
|
|
35
|
+
<i class="pi pi-search mr-2"></i>
|
|
36
|
+
<span class="font-medium">Search</span>
|
|
37
|
+
<i class="pi pi-angle-down ml-auto lg:-rotate-90"></i>
|
|
38
|
+
</a>
|
|
39
|
+
<ul class="list-none py-3 pl-3 m-0 lg:px-0 lg:py-0 border-round shadow-0 lg:shadow-2 lg:border-1 border-50 lg:absolute surface-overlay hidden origin-top w-full lg:w-15rem cursor-pointer left-100 top-0">
|
|
40
|
+
<li>
|
|
41
|
+
<a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple">
|
|
42
|
+
<i class="pi pi-shopping-cart mr-2"></i>
|
|
43
|
+
<span class="font-medium">Purchases</span>
|
|
44
|
+
</a>
|
|
45
|
+
</li>
|
|
46
|
+
<li class="relative">
|
|
47
|
+
<a v-ripple class="flex p-3 align-items-center text-600 hover:text-900 hover:surface-100 transition-colors transition-duration-150 p-ripple">
|
|
48
|
+
<i class="pi pi-comments mr-2"></i>
|
|
49
|
+
<span class="font-medium">Messages</span>
|
|
50
|
+
</a>
|
|
51
|
+
</li>
|
|
52
|
+
</ul>
|
|
53
|
+
</li>
|
|
54
|
+
</ul>
|
|
55
|
+
</li>
|
|
56
|
+
<li>
|
|
57
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
58
|
+
<i class="pi pi-calendar mr-2"></i>
|
|
59
|
+
<span>Calendar</span>
|
|
60
|
+
</a>
|
|
61
|
+
</li>
|
|
62
|
+
<li>
|
|
63
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
64
|
+
<i class="pi pi-chart-line mr-2"></i>
|
|
65
|
+
<span>Stats</span>
|
|
66
|
+
</a>
|
|
67
|
+
</li>
|
|
68
|
+
</ul>
|
|
69
|
+
<ul class="list-none p-0 m-0 flex lg:align-items-center select-none flex-column lg:flex-row border-top-1 surface-border lg:border-top-none">
|
|
70
|
+
<li>
|
|
71
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center text-600 hover:text-900 hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
72
|
+
<i class="pi pi-inbox text-base lg:text-2xl mr-2 lg:mr-0"></i>
|
|
73
|
+
<span class="block lg:hidden font-medium">Inbox</span>
|
|
74
|
+
</a>
|
|
75
|
+
</li>
|
|
76
|
+
<li>
|
|
77
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-3 align-items-center text-600 hover:text-900 hover:surface-100
|
|
78
|
+
font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
79
|
+
<i class="pi pi-bell text-base lg:text-2xl mr-2 lg:mr-0 p-overlay-badge">
|
|
80
|
+
<Badge value="2"></Badge>
|
|
81
|
+
</i>
|
|
82
|
+
<span class="block lg:hidden font-medium">Notifications</span>
|
|
83
|
+
</a>
|
|
84
|
+
</li>
|
|
85
|
+
<li class="border-top-1 surface-border lg:border-top-none">
|
|
86
|
+
<a v-ripple class="flex px-6 p-3 lg:px-3 lg:py-2 align-items-center hover:surface-100 font-medium border-round cursor-pointer transition-colors transition-duration-150 p-ripple">
|
|
87
|
+
<img src="/images/empty-user-photo.svg" class="mr-3 lg:mr-0 border-circle" style="width: 28px; height: 28px"/>
|
|
88
|
+
<div class="block lg:hidden">
|
|
89
|
+
<div class="text-900 font-medium">Josephine Lillard</div>
|
|
90
|
+
<span class="text-600 font-medium text-sm">Marketing Specialist</span>
|
|
91
|
+
</div>
|
|
92
|
+
</a>
|
|
93
|
+
</li>
|
|
94
|
+
</ul>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<script setup>
|
|
100
|
+
import Badge from "primevue/badge"
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<style scoped>
|
|
104
|
+
|
|
105
|
+
</style>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ref, onUnmounted, watch } from 'vue'
|
|
2
|
+
import { api as useApi } from '@live-change/vue3-ssr'
|
|
3
|
+
|
|
4
|
+
class Upload {
|
|
5
|
+
constructor(purpose, blob, options = {}) {
|
|
6
|
+
const {
|
|
7
|
+
size = blob.size,
|
|
8
|
+
fileName = blob.name || 'unknown',
|
|
9
|
+
api = useApi(options.appContext),
|
|
10
|
+
service = 'upload',
|
|
11
|
+
endpoint = 'upload',
|
|
12
|
+
view = 'upload'
|
|
13
|
+
} = options
|
|
14
|
+
|
|
15
|
+
this.purpose = purpose
|
|
16
|
+
this.blob = blob
|
|
17
|
+
|
|
18
|
+
this.api = api
|
|
19
|
+
|
|
20
|
+
this.id = api.uid()
|
|
21
|
+
|
|
22
|
+
this.url =`${document.location.protocol}//${document.location.host}/api/upload/upload/${purpose}/${fileName}/${this.id}`
|
|
23
|
+
|
|
24
|
+
this.state = ref('starting')
|
|
25
|
+
this.error = ref(null)
|
|
26
|
+
|
|
27
|
+
let promiseCb
|
|
28
|
+
this.promise = new Promise((resolve, reject) => promiseCb = { resolve, reject })
|
|
29
|
+
|
|
30
|
+
this.clientTransferred = ref(0)
|
|
31
|
+
this.serverUpload = ref(null)
|
|
32
|
+
this.serverObservable = api.observable([service, view, { upload: this.id }])
|
|
33
|
+
this.serverObservable.bindProperty(this.serverUpload, 'value')
|
|
34
|
+
onUnmounted(() => {
|
|
35
|
+
if(this.serverObservable) {
|
|
36
|
+
this.serverObservable.unbindProperty(this.serverUpload, 'value')
|
|
37
|
+
this.serverObservable = null
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
watch(() => this.serverUpload.value, value => {
|
|
41
|
+
if(value?.state === 'done' && this.serverObservable) {
|
|
42
|
+
this.serverObservable.unbindProperty(this.serverUpload, 'value')
|
|
43
|
+
this.serverObservable = null
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
this.xhr = new XMLHttpRequest()
|
|
48
|
+
|
|
49
|
+
this.xhr.upload.addEventListener('progress', (evt) => {
|
|
50
|
+
this.clientTransferred.value = evt.loaded
|
|
51
|
+
}, false)
|
|
52
|
+
this.xhr.addEventListener("readystatechange", evt => {
|
|
53
|
+
if(this.xhr.readyState == 4) {
|
|
54
|
+
if(this.xhr.status == 200) {
|
|
55
|
+
this.state.value = 'done'
|
|
56
|
+
promiseCb.resolve(this.id)
|
|
57
|
+
} else {
|
|
58
|
+
this.state.value = 'failed'
|
|
59
|
+
this.error.value = this.xhr.status + " " + this.xhr.responseText
|
|
60
|
+
promiseCb.reject(this.error.value)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
this.xhr.addEventListener( "error", () => {
|
|
65
|
+
this.state.value = 'failed'
|
|
66
|
+
this.state.error = 'XHR error'
|
|
67
|
+
promiseCb.reject(this.error.value)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
this.xhr.open('POST', this.url, true)
|
|
71
|
+
this.xhr.send(blob)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
cancel() {
|
|
75
|
+
if(this.xhr.readyState != 4) {
|
|
76
|
+
this.xhr.abort()
|
|
77
|
+
}
|
|
78
|
+
if(this.serverObservable) {
|
|
79
|
+
this.serverObservable.unbindProperty(this.serverUpload, 'value')
|
|
80
|
+
this.serverObservable = null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default Upload
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-full sm:w-9 md:w-8 lg:w-6 surface-card p-4 shadow-2 border-round">
|
|
3
|
+
<div class="text-center mb-5">
|
|
4
|
+
<div class="text-900 text-3xl font-medium mb-3">
|
|
5
|
+
Upload Test
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<FileInput @input="handleUpload" class="inline-block">
|
|
10
|
+
<Button label="Upload File" icon="pi pi-upload"></Button>
|
|
11
|
+
</FileInput>
|
|
12
|
+
|
|
13
|
+
<UploadView v-if="upload" :upload="upload" cancelable class="surface-card shadow-2 border-round p-4 mt-3" />
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import Button from "primevue/button"
|
|
19
|
+
import FileInput from "./FileInput.vue"
|
|
20
|
+
import Upload from "./Upload.js"
|
|
21
|
+
import { ref, getCurrentInstance } from 'vue'
|
|
22
|
+
import UploadView from "./UploadView.vue"
|
|
23
|
+
|
|
24
|
+
const upload = ref()
|
|
25
|
+
const appContext = getCurrentInstance().appContext
|
|
26
|
+
|
|
27
|
+
async function handleUpload(file) {
|
|
28
|
+
console.log("FILE", file)
|
|
29
|
+
upload.value = new Upload('test', file, { appContext })
|
|
30
|
+
|
|
31
|
+
await upload.value.promise
|
|
32
|
+
upload.value = null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- <pre>{{ JSON.stringify(upload.serverUpload, null, ' ') }}</pre>-->
|
|
3
|
+
<div class="surface-card" v-if="upload.serverUpload">
|
|
4
|
+
<ProgressBar :value="upload.serverUpload.progress.percentage.toFixed()" />
|
|
5
|
+
<div v-if="upload.serverUpload.state != 'done'" class="flex mt-2">
|
|
6
|
+
<div class="flex-grow-1">
|
|
7
|
+
{{ prettyBytes(upload.serverUpload.progress.transferred) }}
|
|
8
|
+
/
|
|
9
|
+
{{ prettyBytes(upload.serverUpload.progress.length) }}
|
|
10
|
+
</div>
|
|
11
|
+
<div class="text-right ml-2" v-if="upload.serverUpload.progress.eta">
|
|
12
|
+
eta: {{ Duration.fromMillis(upload.serverUpload.progress.eta).toHuman({ unitDisplay: "short" }) }}
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div v-else class="text-center">
|
|
16
|
+
Uploaded {{ prettyBytes(upload.serverUpload.progress.length) }}
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
|
|
23
|
+
import ProgressBar from "primevue/progressbar"
|
|
24
|
+
import { toRefs } from "@vueuse/core"
|
|
25
|
+
import prettyBytes from 'pretty-bytes';
|
|
26
|
+
import { Duration } from 'luxon'
|
|
27
|
+
|
|
28
|
+
const props = defineProps({
|
|
29
|
+
upload: {
|
|
30
|
+
type: Object,
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
cancelable: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const { upload, cancelable } = toRefs(props)
|
|
40
|
+
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<style scoped>
|
|
44
|
+
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMemoryHistory,
|
|
3
|
+
createRouter as _createRouter,
|
|
4
|
+
createWebHistory
|
|
5
|
+
} from 'vue-router'
|
|
6
|
+
|
|
7
|
+
import { dbAdminRoutes } from "@live-change/db-admin"
|
|
8
|
+
|
|
9
|
+
export function wysiwygRoutes(config = {}) {
|
|
10
|
+
const { prefix = '/', route = (r) => r } = config
|
|
11
|
+
return [
|
|
12
|
+
route({
|
|
13
|
+
name: 'upload:test', path: prefix + '', meta: { },
|
|
14
|
+
component: () => import("./UploadTest.vue"),
|
|
15
|
+
props: {
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
|
|
19
|
+
...dbAdminRoutes({ prefix: '/_db', route: r => ({ ...r, meta: { ...r.meta, raw: true }}) })
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function sitemap(route, api) {
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export function createRouter(app, config) {
|
|
29
|
+
const router = _createRouter({
|
|
30
|
+
history: import.meta.env.SSR ? createMemoryHistory() : createWebHistory(),
|
|
31
|
+
routes: wysiwygRoutes(config)
|
|
32
|
+
})
|
|
33
|
+
return router
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
|
|
3
|
+
import baseViteConfig from '@live-change/frontend-base/vite-config.js'
|
|
4
|
+
|
|
5
|
+
export default defineConfig(async ({ command, mode }) => {
|
|
6
|
+
const baseConfig = (await baseViteConfig({ command, mode }))
|
|
7
|
+
return {
|
|
8
|
+
...baseConfig,
|
|
9
|
+
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: [
|
|
12
|
+
...baseConfig.resolve.alias,
|
|
13
|
+
/* { find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' },
|
|
14
|
+
{ find: 'vue/server-renderer', replacement: 'vue/server-renderer' },*/
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@live-change/upload-frontend",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"memDev": "lcli memDev --enableSessions --initScript ./init.js --dbAccess",
|
|
6
|
+
"localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
|
|
7
|
+
"localDev": "lcli localDev --enableSessions",
|
|
8
|
+
"dev": "lcli dev --enableSessions",
|
|
9
|
+
"ssrDev": "lcli ssrDev --enableSessions",
|
|
10
|
+
"serveAllMem": "cross-env NODE_ENV=production lcli ssrServer --withApi --withServices --updateServices --enableSessions --withDb --dbBackend mem --createDb",
|
|
11
|
+
"serveAll": "cross-env NODE_ENV=production lcli ssrServer --withApi --withServices --updateServices --enableSessions",
|
|
12
|
+
"serve": "cross-env NODE_ENV=production lcli ssrServer --enableSessions",
|
|
13
|
+
"apiServer": "lcli apiServer --enableSessions",
|
|
14
|
+
"devApiServer": "lcli devApiServer --enableSessions",
|
|
15
|
+
"memApiServer": "lcli memApiServer --enableSessions",
|
|
16
|
+
"build": "cd front; yarn build:client && yarn build:server",
|
|
17
|
+
"build:client": "cd front; vite build --ssrManifest --outDir dist/client",
|
|
18
|
+
"build:server": "cd front; vite build --ssr src/entry-server.js --outDir dist/server",
|
|
19
|
+
"generate": "vite build --ssrManifest --outDir dist/static && yarn build:server && node prerender",
|
|
20
|
+
"debug": "node --inspect-brk server"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@live-change/framework": "0.6.5",
|
|
24
|
+
"@live-change/cli": "0.6.5",
|
|
25
|
+
"@live-change/dao": "0.4.13",
|
|
26
|
+
"@live-change/dao-vue3": "0.4.13",
|
|
27
|
+
"@live-change/dao-websocket": "0.4.13",
|
|
28
|
+
"@live-change/vue3-ssr": "0.2.14",
|
|
29
|
+
"@live-change/vue3-components": "0.2.12",
|
|
30
|
+
"@live-change/session-service": "0.2.39",
|
|
31
|
+
"@live-change/user-service": "0.2.37",
|
|
32
|
+
"@live-change/password-authentication-service": "0.2.39",
|
|
33
|
+
"@live-change/secret-link-service": "0.2.39",
|
|
34
|
+
"@live-change/secret-code-service": "0.2.39",
|
|
35
|
+
"@live-change/security-frontend": "0.0.3",
|
|
36
|
+
"@vitejs/plugin-vue": "^2.3.1",
|
|
37
|
+
"@vitejs/plugin-vue-jsx": "^1.3.10",
|
|
38
|
+
"@vue/compiler-sfc": "^3.2.33",
|
|
39
|
+
"@vueuse/core": "^8.3.1",
|
|
40
|
+
"v-shared-element": "3.1.0",
|
|
41
|
+
"vue3-scroll-border": "0.1.2",
|
|
42
|
+
"codeceptjs-assert": "^0.0.5",
|
|
43
|
+
"compression": "^1.7.4",
|
|
44
|
+
"cross-env": "^7.0.3",
|
|
45
|
+
"get-port-sync": "1.0.1",
|
|
46
|
+
"primeicons": "^5.0.0",
|
|
47
|
+
"primevue": "^3.15.0",
|
|
48
|
+
"primeflex": "^3.2.1",
|
|
49
|
+
"rollup-plugin-node-builtins": "^2.1.2",
|
|
50
|
+
"serialize-javascript": "^6.0.0",
|
|
51
|
+
"serve-static": "^1.15.0",
|
|
52
|
+
"vite": "^2.9.6",
|
|
53
|
+
"vue": "^3.2.33",
|
|
54
|
+
"vue-meta": "^3.0.0-alpha.9",
|
|
55
|
+
"vue-router": "^4.0.14",
|
|
56
|
+
"vite-plugin-compression": "0.5.1",
|
|
57
|
+
"vite-plugin-vue-images": "^0.6.1",
|
|
58
|
+
"rollup-plugin-visualizer": "5.6.0",
|
|
59
|
+
"@tiptap/vue-3": "2.0.0-beta.91",
|
|
60
|
+
"@tiptap/starter-kit": "^2.0.0-beta.185",
|
|
61
|
+
"@tiptap/extension-underline": "2.0.0-beta.23",
|
|
62
|
+
"@tiptap/extension-highlight": "^2.0.0-beta.33",
|
|
63
|
+
"@fortawesome/fontawesome-free": "^6.1.1",
|
|
64
|
+
"pretty-bytes": "^6.0.0"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@live-change/codeceptjs-helper": "0.6.5",
|
|
68
|
+
"@wdio/selenium-standalone-service": "^7.19.5",
|
|
69
|
+
"codeceptjs": "^3.3.1",
|
|
70
|
+
"playwright": "^1.21.1",
|
|
71
|
+
"random-profile-generator": "^2.3.0",
|
|
72
|
+
"txtgen": "^3.0.1",
|
|
73
|
+
"generate-password": "1.7.0",
|
|
74
|
+
"webdriverio": "^7.19.5"
|
|
75
|
+
},
|
|
76
|
+
"author": "",
|
|
77
|
+
"license": "ISC",
|
|
78
|
+
"description": ""
|
|
79
|
+
}
|
package/server/init.js
ADDED