Upload.vue
3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
<v-sheet>
<v-layout justify-center>
<v-flex xs12 sm8 md6>
<v-row justify="center" class="mx-0 mt-10">
<v-icon color="grey500">mdi-power-on</v-icon>
<div
style="text-align: center; font-size: 22px; font-weight: 400; color: #343a40; "
>
Upload Video
</div>
<v-icon color="grey500">mdi-power-on</v-icon>
</v-row>
<v-card elevation="0">
<v-text-field
class="mx-10 mt-8 mb-6"
prepend-inner-icon="mdi-pen"
v-model="form.title"
:counter="40"
label="Title"
placeholder="Please input Title"
type="text"
>
</v-text-field>
<!-- file upload -->
<div class="mx-10">
<video-upload />
</div>
<v-card outlined class="pa-2 mx-10" elevation="0" min-height="67">
<v-chip-group column>
<v-chip
color="secondary"
v-for="(tag, index) in form.tags"
:key="index"
@click="deleteTags(index)"
>
{{ tag }}
</v-chip>
</v-chip-group>
</v-card>
<v-text-field
class="mx-10 mt-3 mb-5"
prepend-inner-icon="mdi-shape"
v-model="tag"
:counter="20"
label="Tag"
placeholder="Type to add Tag"
append-icon="mdi-arrow-up-bold"
@click:append="addTags(tag)"
@keydown.enter="addTags(tag)"
type="text"
>
</v-text-field>
</v-card>
<v-row justify="center" style="margin-bottom: 30px">
<v-btn elevation="0" large color="primary" @click="submit()">
<span style="font-size: 24px; font-weight: 300; letter-spacing: 2px"
>Upload</span
>
</v-btn>
</v-row>
</v-flex>
</v-layout>
</v-sheet>
</template>
<script>
import videoUpload from "../components/uploadFile";
export default {
name: "Upload",
components: {
videoUpload
},
data() {
return {
myFiles: [],
tag: "",
form: {
title: "",
videoUrl: "",
tags: [
"Work",
"Home Improvement",
"Vacation",
"Food",
"Drawers",
"Shopping",
"Art",
"Tech",
"Creative Writing"
]
},
successDialog: false,
errorDialog: false
};
},
mounted() {
this.form.tags = this.$store.getters.getTags;
},
methods: {
submit() {
if (this.form.tags.length || this.form.title) {
this.errorDialog = true;
} else {
this.$axios
.post("/upload/post", this.form)
.then(r => {
console.log(r);
this.successDialog = true;
})
.catch(e => {
console.log(e);
this.errorDialog = true;
});
}
},
deleteTags(index) {
for (let i = 0; i < this.form.tags.length; i++) {
const element = this.form.tags[i];
if (this.form.tags[index] === element) {
this.form.tags[i] = this.form.tags[this.form.tags.length - 1];
break;
}
}
this.form.tags.pop();
},
addTags(tag) {
let i;
let check = true;
for (i = 0; i < this.form.tags.length; i++) {
const element = this.form.tags[i];
if (tag === element) {
check = false;
}
}
if (tag && check) this.form.tags.push(tag);
this.tag = "";
}
}
};
</script>