added more fields (read only atm) for recorders
This commit is contained in:
7002
package-lock.json
generated
7002
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
src/App.vue
11
src/App.vue
@@ -87,6 +87,7 @@
|
||||
return {
|
||||
isLoading: false,
|
||||
tokenValidity: -1,
|
||||
refreshFailed: false,
|
||||
refreshTokenValidity: -1,
|
||||
showAlert: true,
|
||||
alertMessage: 'NO MESSAGE PROVIDED',
|
||||
@@ -112,15 +113,23 @@
|
||||
EventBus.$on('failedLoadingRooms', (msg) => {
|
||||
this.showErrorMessage(msg);
|
||||
});
|
||||
EventBus.$on('failedRefreshingToken', (msg)=>{
|
||||
this.refreshFailed = true;
|
||||
});
|
||||
this.$nextTick(() => {
|
||||
window.setInterval(() => {
|
||||
// this.$log.debug(getRemainingJwtValiditySeconds(this.$store.state.access_token));
|
||||
this.tokenValidity = getRemainingJwtValiditySeconds(this.$store.state.access_token);
|
||||
this.refreshTokenValidity = getRemainingJwtValiditySeconds(this.$store.state.refresh_token);
|
||||
// this.$log.debug(this.$store.state);
|
||||
if (this.tokenValidity < 50 && this.refreshTokenValidity > 30) {
|
||||
if (this.tokenValidity < 50 && this.refreshTokenValidity > 30 && !this.refreshFailed) {
|
||||
this.$store.dispatch('refreshToken'); // renew access token
|
||||
}
|
||||
if(this.refreshFailed){
|
||||
this.$store.dispatch('resetToken'); // delete all token info if refresh fails
|
||||
this.$router.push({ name: 'login'});
|
||||
this.refreshFailed = false;
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!-- components/Login.vue -->
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!authenticated">
|
||||
<section class="hero is-primary">
|
||||
<div class="hero-body">
|
||||
<div class="container has-text-centered">
|
||||
@@ -45,7 +46,11 @@
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div v-else>
|
||||
<h1>{{ $t('You are already logged in!') }}</h1>
|
||||
<p><a href="some_logout_url">{{$t('logout')}}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -108,6 +113,10 @@
|
||||
users() {
|
||||
return this.$store.state.users;
|
||||
},
|
||||
authenticated() {
|
||||
return this.$store.getters.isAuthenticated;
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -52,11 +52,19 @@
|
||||
</b-input-group>
|
||||
</h5>
|
||||
<hr/>
|
||||
<p class="card-text"><strong>{{ $t('Model') }}:</strong>
|
||||
{{recorder.model_name}}
|
||||
</p>
|
||||
<p class="card-text"><strong>{{ $t('firmware_version') }}:</strong>
|
||||
{{recorder.firmware_version}}
|
||||
</p>
|
||||
<p class="card-text"><strong>{{ $t('serial_number') }}:</strong>
|
||||
{{recorder.serial_number}}
|
||||
</p>
|
||||
<p class="card-text"><strong>{{ $t('network_name') }}:</strong>
|
||||
<span v-if="!formEditField[recorder.id+'_network_name']">{{recorder.network_name}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initRecorderUpdate(recorder, 'network_name')">
|
||||
<font-awesome-icon
|
||||
@click="initRecorderUpdate(recorder, 'network_name')"
|
||||
icon="pencil-alt"/>
|
||||
</a>
|
||||
</span>
|
||||
@@ -82,9 +90,8 @@
|
||||
|
||||
<p class="card-text"><strong>{{ $t('ip') }}:</strong>
|
||||
<span v-if="!formEditField[recorder.id+'_ip']">{{recorder.ip}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initRecorderUpdate(recorder, 'ip')">
|
||||
<font-awesome-icon
|
||||
@click="initRecorderUpdate(recorder, 'ip')"
|
||||
icon="pencil-alt"/>
|
||||
</a>
|
||||
</span>
|
||||
@@ -110,9 +117,8 @@
|
||||
|
||||
<p class="card-text"><strong>{{ $t('ip v6') }}:</strong>
|
||||
<span v-if="!formEditField[recorder.id+'_ip6']">{{recorder.ip6}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initRecorderUpdate(recorder, 'ip6')">
|
||||
<font-awesome-icon
|
||||
@click="initRecorderUpdate(recorder, 'ip6')"
|
||||
icon="pencil-alt"/>
|
||||
</a>
|
||||
</span>
|
||||
@@ -138,9 +144,8 @@
|
||||
|
||||
<p class="card-text"><strong>{{ $t('ssh_port') }}:</strong>
|
||||
<span v-if="!formEditField[recorder.id+'_ssh_port']">{{recorder.ssh_port}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initRecorderUpdate(recorder, 'ssh_port')">
|
||||
<font-awesome-icon
|
||||
@click="initRecorderUpdate(recorder, 'ssh_port')"
|
||||
icon="pencil-alt"/>
|
||||
</a>
|
||||
</span>
|
||||
@@ -197,9 +202,8 @@
|
||||
<hr/>
|
||||
<div v-if="recorder.room && !formEditField[recorder.id+'_room_id']">
|
||||
<p class="card-text"><strong>{{ $t('Room') }}:</strong> {{recorder.room.name}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initRecorderUpdate(recorder, 'room_id')">
|
||||
<font-awesome-icon
|
||||
@click="initRecorderUpdate(recorder, 'room_id')"
|
||||
icon="pencil-alt"/>
|
||||
</a></p>
|
||||
</div>
|
||||
@@ -269,18 +273,18 @@
|
||||
|
||||
<hr/>
|
||||
<div v-if="recorder.recorder_model">
|
||||
<p class="card-text"><strong>{{ $t('Model') }}:</strong> {{recorder.recorder_model.name}}
|
||||
<p class="card-text"><strong>{{ $t('Model Adadpter') }}:</strong> {{recorder.recorder_model.name}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<font-awesome-icon icon="pencil-alt"/>
|
||||
</a></p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<p class="card-text"><strong>{{ $t('Model') }}:</strong> {{
|
||||
<p class="card-text"><strong>{{ $t('Model Adadpter') }}:</strong> {{
|
||||
$t('no_model_defined')}}</p>
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" v-model="form.recorder_model">
|
||||
<option value="">{{$t('No model selected')}}</option>
|
||||
<option value="">{{$t('No Model Adadpter selected')}}</option>
|
||||
<option v-for="recorderModel in recorderModels"
|
||||
v-bind:value="recorderModel.id">
|
||||
{{ recorderModel.name }}
|
||||
@@ -294,9 +298,8 @@
|
||||
|
||||
<strong>{{ $t('description') }}:</strong>
|
||||
<span v-if="!formEditField[recorder.id+'_description']">{{recorder.description}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initRecorderUpdate(recorder, 'description')">
|
||||
<font-awesome-icon
|
||||
@click="initRecorderUpdate(recorder, 'description')"
|
||||
icon="pencil-alt"/>
|
||||
</a>
|
||||
</span>
|
||||
@@ -392,6 +395,20 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="label col-sm-2 col-form-label">{{ $t('mac') }}</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="mac"
|
||||
v-validate="'mac'"
|
||||
v-model="form.mac"
|
||||
v-bind:class="{'is-danger': errors.has('mac'), 'is-invalid': errors.has('mac')}"
|
||||
class="form-control" type="text" :placeholder="$t('Recorder') + ' ' + $t('mac')">
|
||||
</div>
|
||||
<p class="col-sm-4" v-show="errors.has('mac')">
|
||||
{{ errors.first('mac') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="label col-sm-2 col-form-label">{{ $t('ip') }}</label>
|
||||
<div class="col-sm-6">
|
||||
@@ -534,9 +551,8 @@
|
||||
<p class="card-text">
|
||||
<strong>{{ $t('notes') }}:</strong>
|
||||
<span v-if="!formEditField['model_'+recorderModel.id+'notes']">{{recorderModel.notes}}
|
||||
<a class="float-right badge badge-pill badge-info">
|
||||
<a class="float-right badge badge-pill badge-info" @click="initrecorderModelUpdate(recorderModel, 'notes')">
|
||||
<font-awesome-icon
|
||||
@click="initrecorderModelUpdate(recorderModel, 'notes')"
|
||||
icon="pencil-alt"/>
|
||||
</a>
|
||||
</span>
|
||||
|
||||
11
src/store.ts
11
src/store.ts
@@ -206,6 +206,13 @@ const actions = {
|
||||
EventBus.$emit('failedRefreshingToken', error);
|
||||
});
|
||||
},
|
||||
resetToken(context: any) {
|
||||
EventBus.$emit('resettingTokens');
|
||||
Vue.$log.debug('Resetting tokens!');
|
||||
context.commit('setTokens', {tokens: {access_token: '', refresh_token: ''}});
|
||||
EventBus.$emit('tokensReset');
|
||||
Vue.$log.debug('Tokens reset!');
|
||||
},
|
||||
storeTokens(context: any, tokens: any) {
|
||||
context.commit('setTokens', {tokens});
|
||||
EventBus.$emit('storedTokens');
|
||||
@@ -285,10 +292,10 @@ const mutations = {
|
||||
},
|
||||
setTokens(sState: any, payload: any) {
|
||||
Vue.$log.debug('setTokens payload = ', payload);
|
||||
if (payload.tokens.access_token) {
|
||||
if ('access_token' in payload.tokens) {
|
||||
sState.access_token = payload.tokens.access_token;
|
||||
}
|
||||
if (payload.tokens.refresh_token) {
|
||||
if ('refresh_token' in payload.tokens) {
|
||||
sState.refresh_token = payload.tokens.refresh_token;
|
||||
}
|
||||
Vue.$log.debug('access_token: ' + sState.access_token);
|
||||
|
||||
Reference in New Issue
Block a user