Skip to content

Commit 4bd2403

Browse files
committed
Dynamic event binding on the video recording button, take photo API call, dynamic binding things
1 parent 6654c1c commit 4bd2403

File tree

1 file changed

+65
-8
lines changed

1 file changed

+65
-8
lines changed

src/components/Control.vue

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@
7171
</v-flex>
7272
<v-flex xs12 sm12>
7373
<v-btn-toggle>
74-
<v-btn large color="blue-grey darken-4" class="white--text" v-on:click="takePhoto()">
74+
<v-btn large color="blue-grey darken-4" class="white--text" v-on:click="takePhoto()" :disabled="!photoBtnEnabled">
7575
Scatta foto
7676
<v-icon dark>camera_alt</v-icon>
7777
</v-btn>
7878
</v-btn-toggle>
7979
</v-flex>
8080
<v-flex xs12 sm12>
8181
<v-btn-toggle>
82-
<v-btn large color="blue-grey darken-4" class="white--text" v-on:click="recordVideo()">
83-
Registra video
84-
<v-icon dark>videocam</v-icon>
82+
<v-btn large color="blue-grey darken-4" class="white--text" v-on:click="videoHandler()" :disabled="!videoBtn.enabled">
83+
{{ videoBtn.text }}
84+
<v-icon dark>{{ videoBtn.icon }} </v-icon>
8585
</v-btn>
8686
</v-btn-toggle>
8787
</v-flex>
@@ -120,9 +120,58 @@ export default {
120120
components: { sidebar },
121121
name: 'HelloWorld',
122122
methods: {
123-
say() {},
124-
takePhoto() {},
125-
recordVideo() {},
123+
say() {
124+
125+
},
126+
takePhoto() {
127+
let CBv1 = this.$data.CBv1
128+
let axios = this.$axios;
129+
axios.get(CBv1, { params: { 'cmd': 'take_photo' } })
130+
.then(function(response) {
131+
this.$data.snackText = 'Foto scattata'
132+
this.$data.snackbar = true
133+
this.$data.photoBtnEnabled = false
134+
setTimeout(function() {
135+
this.$data.photoBtnEnabled = true
136+
}.bind(this), 1000)
137+
138+
}.bind(this))
139+
},
140+
videoHandler() {
141+
if (this.$data.videoBtn.action == 'record')
142+
this.recordVideo()
143+
else
144+
this.stopVideoRecording()
145+
},
146+
recordVideo() {
147+
let CBv1 = this.$data.CBv1
148+
let axios = this.$axios;
149+
axios.get(CBv1, { params: { 'cmd': 'video_rec' } })
150+
.then(function(response) {
151+
this.$data.snackText = 'Registrazione Avviata'
152+
this.$data.snackbar = true
153+
this.$data.videoBtn.text = 'Ferma registrazione video'
154+
this.$data.videoBtn.icon = 'stop'
155+
this.videoBtn.action = 'stop'
156+
157+
}.bind(this))
158+
},
159+
stopVideoRecording() {
160+
let CBv1 = this.$data.CBv1
161+
let axios = this.$axios;
162+
axios.get(CBv1, { params: { 'cmd': 'video_rec' } })
163+
.then(function(response) {
164+
this.$data.snackText = 'Registrazione terminata'
165+
this.$data.snackbar = true
166+
this.$data.videoBtn.enabled = false
167+
this.videoBtn.action = 'record'
168+
setTimeout(function() {
169+
this.$data.videoBtn.enabled = true
170+
this.$data.videoBtn.text = 'Registra Video'
171+
this.$data.videoBtn.icon = 'videocam'
172+
}.bind(this), 1000)
173+
}.bind(this))
174+
},
126175
showGallery() {},
127176
pollStatus() {
128177
let axios = this.$axios
@@ -156,7 +205,6 @@ export default {
156205
},
157206
move: function(direction) {
158207
this.$data.pressDuration = performance.now()
159-
console.log("move")
160208
let axios = this.$axios
161209
let CB = this.$data.CB
162210
if (direction == 0) {
@@ -234,8 +282,17 @@ export default {
234282
snackbar: false,
235283
webcamStream: process.env.CB_ENDPOINT + process.env.APIv1 + '/video/stream',
236284
CB: process.env.CB_ENDPOINT + process.env.APIv2,
285+
CBv1: process.env.CB_ENDPOINT + process.env.APIv1,
237286
status: null,
238287
pressDuration: null,
288+
photoBtnEnabled: true,
289+
videoBtn: {
290+
'text': 'Registra Video',
291+
'icon': 'videocam',
292+
'enabled': 'true',
293+
'action': 'record'
294+
295+
}
239296
};
240297
},
241298
mounted() {

0 commit comments

Comments
 (0)