changed a lot regarding rec state, etc.

This commit is contained in:
Tobias Kurze
2019-12-03 16:05:15 +01:00
parent 39e7bbd098
commit 6b7b9f8f09
13 changed files with 3758 additions and 3757 deletions

7401
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -13,11 +13,11 @@
"@fortawesome/free-solid-svg-icons": "^5.8.1",
"@fortawesome/vue-fontawesome": "^0.1.6",
"@vue/cli": "^3.6.3",
"axios": "^0.18.0",
"axios": "^0.18.1",
"bootstrap": "^4.3.1",
"bootstrap-vue": "^2.0.0-rc.15",
"i": "^0.3.6",
"jquery": "^3.3.1",
"jquery": "^3.4.1",
"js-cookie": "^2.2.0",
"node-sass": "^4.13.0",
"npm": "^6.13.1",

View File

@@ -118,7 +118,7 @@
},
refreshToken() {
this.$store.dispatch('refreshToken');
}
},
},
mounted() {
EventBus.$on('failedLoadingRecorders', (msg) => {
@@ -132,11 +132,11 @@
});
this.$nextTick(() => {
window.setInterval(() => {
//this.$log.debug(getRemainingJwtValiditySeconds(this.$store.state.access_token));
let tokenValidity = getRemainingJwtValiditySeconds(this.$store.state.access_token);
// this.$log.debug(getRemainingJwtValiditySeconds(this.$store.state.access_token));
const tokenValidity = getRemainingJwtValiditySeconds(this.$store.state.access_token);
//this.tokenValidity = this.tokenValidity.format('mm:ss');
let refreshTokenValidity = getRemainingJwtValiditySeconds(this.$store.state.refresh_token);
// this.tokenValidity = this.tokenValidity.format('mm:ss');
const refreshTokenValidity = getRemainingJwtValiditySeconds(this.$store.state.refresh_token);
// this.$log.debug(this.$store.state);
if (tokenValidity < 50 && refreshTokenValidity > 30 && this.autoRenewSession && !this.refreshFailed) {
@@ -170,7 +170,7 @@
profile() {
return this.$store.state.profile;
},
}
},
};
</script>

View File

@@ -120,7 +120,6 @@
this.redirectTarget = this.$route.query.redirectionTarget;
}
this.redirect_interval = window.setInterval(() => {
console.log(this.redirectTime);
this.redirectTime = this.redirectTime - 1;
if (this.redirectTime < 0) {
clearInterval(this.redirect_interval);
@@ -141,8 +140,7 @@
},
authenticated() {
return this.$store.getters.isAuthenticated;
}
},
},
};
</script>

View File

@@ -119,7 +119,7 @@
changeLocale(locale) {
this.$i18n.locale = locale;
// Vue.$moment.locale(locale);
}
},
},
mounted() {
this.$log.debug('Profile: mounting...');

View File

@@ -29,23 +29,24 @@
props: ['recorder'],
data() {
return {
connectedWebsocket: false
}
connectedWebsocket: false,
};
},
mounted() {
this.$socket.client.on('connect', function(msg) {
this.$log.debug("We are connected!");
this.$log.debug('We are connected!');
this.$log.debug(msg);
this.$socket.client.emit('request_recorder_state_' + this.recorder.id, msg);
// this.$socket.client.on('request_recorder_state_' + this.recorder.id, function(msg) { # non arrow function might be necessary!
this.$socket.client.on('request_recorder_state_' + this.recorder.id, (msg) => {
// TODO: refresh state!
this.$log.debug(msg);
this.$socket.client.emit('request_recorder_state_'+ this.recorder.id, msg);
this.$socket.client.on('request_recorder_state_' + this.recorder.id, function(msg) {
//TODO: refresh state!
console.log(msg);
});
});
this.$log.info("mounted called");
this.$log.info('mounted called');
if (!this.$socket.connected) {
this.$log.info("connecting websocket...");
this.$log.info('connecting websocket...');
this.connectWebsocket();
this.connectedWebsocket = true;
}
@@ -53,7 +54,7 @@
},
beforeDestroy() {
this.$log.info("beforeDestroy called");
this.$log.info('beforeDestroy called');
if (this.connectedWebsocket) {
this.disconnectWebsocket();
}
@@ -70,7 +71,7 @@
}
},
},
}
};
</script>
<style scoped>

View File

@@ -240,9 +240,10 @@
description="Set to offline / maintenance mode."
label-for="offline"
:label="$t('offline')">
<b-form-checkbox id="offline"
v-model="form.offline" name="check-button" switch>
<b>({{$t('Offline')}}: {{ form.offline }})</b>
<b-form-checkbox :id="'offline' + recorder.id"
v-model="recorder.offline" name="check-button_offline" switch
@input="()=>{initRecorderUpdate(recorder, 'offline'); updateRecorder(recorder.id, 'offline')}">
<b>({{$t('Offline')}}: {{ recorder.offline }})</b>
</b-form-checkbox>
</b-form-group>
@@ -251,10 +252,10 @@
description="Lock recorder: No changes can be made."
label-for="locked"
:label="$t('locked')">
<b-form-checkbox id="locked"
v-model="recorder.locked" name="check-button" switch
@change="()=>{initRecorderUpdate(recorder, 'locked'); updateRecorder(recorder.id, 'locked')}">
<b>({{$t('Locked')}}: {{ form.locked }})</b>
<b-form-checkbox :id="'locked' + recorder.id"
v-model="recorder.locked" name="check-button_locked" switch
@input="()=>{initRecorderUpdate(recorder, 'locked'); updateRecorder(recorder.id, 'locked')}">
<b>({{$t('Locked')}}: {{ recorder.locked }})</b>
</b-form-checkbox>
</b-form-group>
@@ -662,17 +663,18 @@
},
methods: {
initRecorderUpdate(recorder, fieldName) {
this.$log.debug(recorder);
this.$log.debug(recorder[fieldName]); // THIS SHOULD BE TRUE, NOT FALSE!! grml
this.$set(this.formEditField, recorder.id + '_' + fieldName, true);
this.$set(this.updateValues, recorder.id + '_' + fieldName, recorder[fieldName]);
this.$log.debug(this.updateValues);
},
updateRecorder(id, fieldName) {
this.$log.debug(id);
this.$log.debug(fieldName);
this.$parent.$data.isLoading = true;
const data = {};
this.$log.debug(this.updateValues);
this.$log.debug(this.updateValues[id + '_' + fieldName]);
data[fieldName] = this.updateValues[id + '_' + fieldName];
this.$log.debug(data);
recorderRepository.updateRecorder(id, data)
.then(() => {
this.$store.dispatch('loadRecorders')

View File

@@ -455,13 +455,13 @@
},
rooms() {
if(this.onlyShowRoomsWithRecorder){
return this.$store.state.rooms.filter(item => {
return item.recorder
return this.$store.state.rooms.filter((item) => {
return item.recorder;
});
}
else if(this.onlyShowRoomsWithoutRecorder){
return this.$store.state.rooms.filter(item => {
return !item.recorder
return this.$store.state.rooms.filter((item) => {
return !item.recorder;
});
}
return this.$store.state.rooms;

View File

@@ -2,7 +2,7 @@
<div v-if="authenticated">
<b-form>
<b-input-group>
<select class="form-control" v-model="favorite_recorder_id">
<select class="form-control" v-model="favoriteRecorderId">
<option value="">No recorder selected</option>
<option v-for="recorder in recorders" v-bind:value="recorder.id">
{{ recorder.name }}
@@ -29,7 +29,7 @@
@Component
export default class SelectRecorder extends Vue {
@Prop() private msg!: string;
favorite_recorder_id = '';
private favoriteRecorderId = '';
get authenticated() {
return this.$store.getters.isAuthenticated;
@@ -39,13 +39,13 @@
return this.$store.state.recorders;
}
mounted() {
private mounted() {
this.$store.dispatch('loadProfile');
this.$store.dispatch('loadRecorders');
}
recorderSelected() {
this.$emit('recorderSelected', {'recorder_id': this.favorite_recorder_id});
private recorderSelected() {
this.$emit('recorderSelected', {recorder_id: this.favoriteRecorderId});
}
}
</script>

View File

@@ -44,7 +44,7 @@
// Vue.$moment.locale(locale);
},
sendWsMessage(msg) {
console.log("sending msg: " + msg);
this.$log.debug('sending msg: ' + msg);
this.$socket.client.emit('my_event', msg);
},
connectWebsocket() {
@@ -62,18 +62,18 @@
},
mounted() {
this.$socket.client.on('my_response', function(msg) {
console.log(msg);
this.$log.debug(msg);
});
this.$socket.client.on('server_event', function(msg) {
console.log("get server_event:");
console.log(msg);
this.$log.debug('get server_event:');
this.$log.debug(msg);
});
this.$socket.client.on('connect', function(msg) {
console.log("We are connected!");
console.log(msg);
this.$log.debug('We are connected!');
this.$log.debug(msg);
});
//this.$socket.$unsubscribe('even_name');
// this.$socket.$unsubscribe('even_name');
},
beforeDestroy() {

View File

@@ -76,7 +76,7 @@ Vue.use(VueMoment);
const socket = io('ws://localhost:5443', {
autoConnect: false,
reconnectionAttempts: 3,
query: {jwt: store.state.access_token}
query: {jwt: store.state.access_token},
});
Vue.use(VueSocketIOExt, socket);

View File

@@ -186,14 +186,14 @@ const actions = {
},
logout(context: any, revokeRefreshToken: any) {
context.commit('setTokens', {tokens: {access_token: '', refresh_token: ''}});
if(revokeRefreshToken){
if (revokeRefreshToken) {
return revokeRefreshKey(context.state.access_token)
.catch((error) => {
Vue.$log.warn('Error Authenticating (Could not revoke refresh token): ', error);
EventBus.$emit('failedRevokingRefreshToken', error);
});
}
//this.clearAll();
// this.clearAll();
},
oidc_login(context: any, redirectionUrl: any) {
// context.commit('setUserData', { userData });
@@ -342,9 +342,9 @@ const getters = {
},
// this is probably wrong!!
hasAccessRight(sState: any) {
(requested_permission: string) => {
(requestedPermission: string) => {
return sState.profile.effective_permissions.find((permission: any) => {
permission.name === requested_permission;
permission.name === requestedPermission;
});
};
},

View File

@@ -14,7 +14,7 @@
<hr/>
<p>{{$t('Favorite recorders:')}}</p>
<b-card-group deck>
<RecorderState v-for="recorder in profile.favorite_recorders" :recorder="recorder"/>
<RecorderState v-for="recorder in profile.favorite_recorders" :recorder="recorder" v-bind:key="recorder.id"/>
</b-card-group>
</div>
</div>
@@ -57,8 +57,7 @@
}
addFavoriteRecorderToProfile(recorder) {
console.log(recorder);
userRepository.addFavoriteRecorder(recorder["recorder_id"]).then(() => {
userRepository.addFavoriteRecorder(recorder.recorder_id).then(() => {
this.$store.dispatch('loadProfile');
});
}