Upload.vue
4.63 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<template>
<v-sheet>
<v-layout justify-center>
<v-overlay :value="loading">
<v-progress-circular indeterminate size="80"></v-progress-circular>
</v-overlay>
<v-flex xs12 sm8 md6>
<v-row justify="center" class="mx-0 my-12">
<v-icon color="lightblue">mdi-power-on</v-icon>
<div
style="text-align: center; font-size: 22px; font-weight: 400; color: #343a40; "
>Upload Video</div>
<v-icon color="lightblue">mdi-power-on</v-icon>
</v-row>
<v-card elevation="0">
<v-text-field
class="mx-10 mt-12 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 mb-12 mt-6">
<video-upload />
</div>
<v-dialog max-width="400" v-model="successDialog">
<v-card max-width="400" class="pt-3">
<div
style="text-align: center; font-size: 20px;color: #5a5a5a; font-weight: 400"
>Notice</div>
<v-divider class="mt-2 mb-3"></v-divider>
<div
style="margin-left: 10px; margin-right: 10px; text-align: center; font-size: 18px; font-weight: 400"
>Your Video's tags are successfully extracted</div>
<v-btn class="mt-4" elevation="0" block color="primary">Close</v-btn>
</v-card>
</v-dialog>
<v-card outlined class="pa-2 mx-10" elevation="0" min-height="67">
<div
style="margin-left: 5px; margin-top: -18px; background-color: #fff; width: 95px; text-align: center;font-size: 14px; color: #5a5a5a; font-weight: 500"
>Selected Tags</div>
<v-chip-group column>
<v-chip
color="secondary"
v-for="(tag, index) in form.tag"
:key="index"
@click="deleteTags(index)"
>
{{ tag }}
<v-icon small style="margin-left: 3px; margin-top: -2px">mdi-close-circle</v-icon>
</v-chip>
</v-chip-group>
</v-card>
<v-text-field
class="mx-10 my-12"
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-top: 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: "",
tag: [
"Work",
"Home Improvement",
"Vacation",
"Food",
"Drawers",
"Shopping",
"Art",
"Tech",
"Creative Writing"
]
},
successDialog: false,
errorDialog: false,
loading: false
};
},
created() {
this.form.tag = [];
},
methods: {
submit() {
if (!(this.form.tag.length && this.form.title)) {
this.errorDialog = true;
return;
} else {
this.$axios
.post("/home", this.form)
.then(r => {
window.location.reload();
console.log(r);
this.successDialog = true;
})
.catch(e => {
console.log(e);
this.errorDialog = true;
});
}
},
deleteTags(index) {
for (let i = 0; i < this.form.tag.length; i++) {
const element = this.form.tag[i];
if (this.form.tag[index] === element) {
this.form.tag[i] = this.form.tag[this.form.tag.length - 1];
break;
}
}
this.form.tag.pop();
},
addTags(tag) {
let i;
let check = true;
for (i = 0; i < this.form.tag.length; i++) {
const element = this.form.tag[i];
if (tag === element) {
check = false;
}
}
if (tag && check) this.form.tag.push(tag);
this.tag = "";
}
}
};
</script>