|
71 | 71 | </v-flex>
|
72 | 72 | <v-flex xs12 sm12>
|
73 | 73 | <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"> |
75 | 75 | Scatta foto
|
76 | 76 | <v-icon dark>camera_alt</v-icon>
|
77 | 77 | </v-btn>
|
78 | 78 | </v-btn-toggle>
|
79 | 79 | </v-flex>
|
80 | 80 | <v-flex xs12 sm12>
|
81 | 81 | <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> |
85 | 85 | </v-btn>
|
86 | 86 | </v-btn-toggle>
|
87 | 87 | </v-flex>
|
@@ -120,9 +120,58 @@ export default {
|
120 | 120 | components: { sidebar },
|
121 | 121 | name: 'HelloWorld',
|
122 | 122 | 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 | + }, |
126 | 175 | showGallery() {},
|
127 | 176 | pollStatus() {
|
128 | 177 | let axios = this.$axios
|
@@ -156,7 +205,6 @@ export default {
|
156 | 205 | },
|
157 | 206 | move: function(direction) {
|
158 | 207 | this.$data.pressDuration = performance.now()
|
159 |
| - console.log("move") |
160 | 208 | let axios = this.$axios
|
161 | 209 | let CB = this.$data.CB
|
162 | 210 | if (direction == 0) {
|
@@ -234,8 +282,17 @@ export default {
|
234 | 282 | snackbar: false,
|
235 | 283 | webcamStream: process.env.CB_ENDPOINT + process.env.APIv1 + '/video/stream',
|
236 | 284 | CB: process.env.CB_ENDPOINT + process.env.APIv2,
|
| 285 | + CBv1: process.env.CB_ENDPOINT + process.env.APIv1, |
237 | 286 | status: null,
|
238 | 287 | pressDuration: null,
|
| 288 | + photoBtnEnabled: true, |
| 289 | + videoBtn: { |
| 290 | + 'text': 'Registra Video', |
| 291 | + 'icon': 'videocam', |
| 292 | + 'enabled': 'true', |
| 293 | + 'action': 'record' |
| 294 | +
|
| 295 | + } |
239 | 296 | };
|
240 | 297 | },
|
241 | 298 | mounted() {
|
|
0 commit comments