Skip to content

Commit 0768a7d

Browse files
alexey-yarmoshMartinKolarik
authored andcommitted
feat: add token support to demo page (#645)
1 parent 08f8b92 commit 0768a7d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

public/demo/measurements.vue.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const app = () => ({
33
data () {
44
return {
5+
token: new URLSearchParams(window.location.search).get('token') || '',
56
query: {
67
type: 'ping',
78
locations: [],
@@ -37,6 +38,11 @@ const app = () => ({
3738
clearInterval(this.resultInterval);
3839
}
3940
},
41+
token (newToken) {
42+
const url = new URL(window.location);
43+
newToken ? url.searchParams.set('token', newToken) : url.searchParams.delete('token');
44+
window.history.replaceState({}, '', url);
45+
},
4046
},
4147
computed: {
4248
responseParams () {
@@ -273,6 +279,7 @@ const app = () => ({
273279
body: JSON.stringify(body),
274280
headers: {
275281
'content-type': 'application/json',
282+
...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
276283
},
277284
});
278285

@@ -315,6 +322,12 @@ const app = () => ({
315322
</div>
316323
<div class="row border border-primary">
317324
<form @submit="submitPostMeasurement" class="col">
325+
<div class="form-group row">
326+
<label for="token" class="col-sm-2 col-form-label">token</label>
327+
<div class="col-sm-10">
328+
<input v-model="token" name="token" id="token" placeholder="GP API token" />
329+
</div>
330+
</div>
318331
<div class="form-group row">
319332
<label for="query_type" class="col-sm-2 col-form-label">type</label>
320333
<div class="col-sm-10">

0 commit comments

Comments
 (0)