added permission repo and changes to recorder state, etc
This commit is contained in:
7599
package-lock.json
generated
7599
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@
|
|||||||
"jquery": "^3.3.1",
|
"jquery": "^3.3.1",
|
||||||
"js-cookie": "^2.2.0",
|
"js-cookie": "^2.2.0",
|
||||||
"node-sass": "^4.13.0",
|
"node-sass": "^4.13.0",
|
||||||
"npm": "^6.9.0",
|
"npm": "^6.13.1",
|
||||||
"npm-sass": "^2.3.0",
|
"npm-sass": "^2.3.0",
|
||||||
"popper.js": "^1.15.0",
|
"popper.js": "^1.15.0",
|
||||||
"socket.io-client": "^2.3.0",
|
"socket.io-client": "^2.3.0",
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import GroupRepository from './groupRepository';
|
import GroupRepository from './groupRepository';
|
||||||
import UserRepository from './userRepository';
|
import UserRepository from './userRepository';
|
||||||
|
import PermissionRepository from './permissionsRepository';
|
||||||
|
|
||||||
import RoomRepository from './roomRepository';
|
import RoomRepository from './roomRepository';
|
||||||
import RecorderRepository from './recorderRepository';
|
import RecorderRepository from './recorderRepository';
|
||||||
import CommandRepository from './commandRepository';
|
import CommandRepository from './commandRepository';
|
||||||
@@ -21,6 +23,9 @@ export default function get(name: string) {
|
|||||||
case 'user': {
|
case 'user': {
|
||||||
return UserRepository;
|
return UserRepository;
|
||||||
}
|
}
|
||||||
|
case 'permission': {
|
||||||
|
return PermissionRepository;
|
||||||
|
}
|
||||||
case 'command': {
|
case 'command': {
|
||||||
return CommandRepository;
|
return CommandRepository;
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/api/permissionsRepository.ts
Normal file
20
src/api/permissionsRepository.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// groupRepository.js
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
import Repository from './Repository';
|
||||||
|
|
||||||
|
const resource = '/permissions';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getPermissions() {
|
||||||
|
return Repository.get(`${resource}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
getGroup(permissionId: number) {
|
||||||
|
return Repository.get(`${resource}/${permissionId}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
createGroup(permissionData: any) {
|
||||||
|
return Repository.post(`${resource}`, permissionData);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -9,19 +9,29 @@ import {dictEmptyValToNull} from '@/utils';
|
|||||||
const resource = '/user';
|
const resource = '/user';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getUsers() {
|
getUsers() {
|
||||||
return Repository.get(`${resource}`);
|
return Repository.get(`${resource}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
getUser(userId: number) {
|
getUser(userId: number) {
|
||||||
return Repository.get(`${resource}/${userId}`);
|
return Repository.get(`${resource}/${userId}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
createUser(userData: any) {
|
createUser(userData: any) {
|
||||||
return Repository.post(`${resource}`, userData);
|
return Repository.post(`${resource}`, userData);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateProfile(userData: any) {
|
getProfile() {
|
||||||
return Repository.put(`${resource}/profile`, dictEmptyValToNull(userData));
|
return Repository.get(`${resource}/profile`);
|
||||||
},
|
},
|
||||||
|
updateProfile(userData: any) {
|
||||||
|
return Repository.put(`${resource}/profile`, dictEmptyValToNull(userData));
|
||||||
|
},
|
||||||
|
getFavoriteRecorders() {
|
||||||
|
return Repository.get(`${resource}/profile/favorite_recorders`);
|
||||||
|
},
|
||||||
|
|
||||||
|
addFavoriteRecorder(recorderId: any) {
|
||||||
|
return Repository.put(`${resource}/profile/favorite_recorders`, {id: recorderId});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
<router-link :to="{ name: 'admin.group'}">{{ $t('group') }}</router-link>
|
<router-link :to="{ name: 'admin.group'}">{{ $t('group') }}</router-link>
|
||||||
<br>
|
<br>
|
||||||
<router-link :to="{ name: 'admin.user'}">{{ $t('user') }}</router-link>
|
<router-link :to="{ name: 'admin.user'}">{{ $t('user') }}</router-link>
|
||||||
|
<br>
|
||||||
|
<router-link :to="{ name: 'admin.permission'}">{{ $t('permission') }}</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
redirectTarget: 'profile',
|
redirectTarget: 'profile',
|
||||||
redirectTime: 5,
|
redirectTime: 5,
|
||||||
loginProviders: [],
|
loginProviders: [],
|
||||||
|
redirect_interval: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -118,11 +119,11 @@
|
|||||||
if (this.$route.query.redirectionTarget) {
|
if (this.$route.query.redirectionTarget) {
|
||||||
this.redirectTarget = this.$route.query.redirectionTarget;
|
this.redirectTarget = this.$route.query.redirectionTarget;
|
||||||
}
|
}
|
||||||
let interval = window.setInterval(() => {
|
this.redirect_interval = window.setInterval(() => {
|
||||||
console.log(this.redirectTime);
|
console.log(this.redirectTime);
|
||||||
this.redirectTime = this.redirectTime - 1;
|
this.redirectTime = this.redirectTime - 1;
|
||||||
if (this.redirectTime < 0) {
|
if (this.redirectTime < 0) {
|
||||||
clearInterval(interval);
|
clearInterval(this.redirect_interval);
|
||||||
this.$router.push({name: this.redirectTarget});
|
this.$router.push({name: this.redirectTarget});
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -130,6 +131,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
clearInterval(this.redirect_interval);
|
||||||
EventBus.$off('failedRegistering');
|
EventBus.$off('failedRegistering');
|
||||||
EventBus.$off('failedAuthentication');
|
EventBus.$off('failedAuthentication');
|
||||||
},
|
},
|
||||||
|
|||||||
250
src/components/Permission.vue
Normal file
250
src/components/Permission.vue
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
<!-- components/Permission.vue -->
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<section class="hero is-primary">
|
||||||
|
<div class="hero-body">
|
||||||
|
<div class="container has-text-centered">
|
||||||
|
<h2 class="title">Permissions</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="permissionTable">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th v-for="col in permission_columns" v-on:click="sortTable(col)">{{col}}
|
||||||
|
<div class="arrow" v-if="col == sortColumn"
|
||||||
|
v-bind:class="[ascending ? 'arrow_up' : 'arrow_down']"></div>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="row in get_permission_rows()">
|
||||||
|
<td v-for="col in permission_columns">{{row[col]}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="pagination">
|
||||||
|
<div class="number"
|
||||||
|
v-for="i in num_permission_pages()"
|
||||||
|
v-bind:class="[i == currentPage ? 'active' : '']"
|
||||||
|
v-on:click="change_page(i)">{{i}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="subtitle error-msg">{{ errorMsg }}</p>
|
||||||
|
<h3 class="title">Add Permission</h3>
|
||||||
|
<label>
|
||||||
|
<input v-model="permission.name" placeholder="Permission name">
|
||||||
|
</label>
|
||||||
|
<p>Name is: {{ permission.name }}</p>
|
||||||
|
<span>Multiline message is:</span>
|
||||||
|
<p style="white-space: pre-line;">{{ permission.description }}</p>
|
||||||
|
<br>
|
||||||
|
<textarea v-model="permission.description" placeholder="Description for permission"></textarea>
|
||||||
|
<button v-on:click="createPermission">{{$t('create_permission')}}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {EventBus} from '@/utils';
|
||||||
|
import getRepository from '@/api/RepositoryFactory';
|
||||||
|
|
||||||
|
const PermissionRepository = getRepository('permission');
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isLoading: false,
|
||||||
|
permissions: [],
|
||||||
|
errorMsg: '',
|
||||||
|
permission: {name: '', description: ''},
|
||||||
|
sortColumn: '',
|
||||||
|
currentPage: 1,
|
||||||
|
elementsPerPage: 5,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetch() {
|
||||||
|
this.isLoading = true;
|
||||||
|
// const { data } = await PermissionRepository.get();
|
||||||
|
PermissionRepository.getPermissions()
|
||||||
|
.then((response) => {
|
||||||
|
this.permissions = response.data;
|
||||||
|
this.isLoading = false;
|
||||||
|
this.$log.debug(response);
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
get_permission_rows() {
|
||||||
|
const start = (this.currentPage - 1) * this.elementsPerPage;
|
||||||
|
const end = start + this.elementsPerPage;
|
||||||
|
return this.permissions.slice(start, end);
|
||||||
|
},
|
||||||
|
num_permission_pages() {
|
||||||
|
return Math.ceil(this.permissions.length / this.elementsPerPage);
|
||||||
|
},
|
||||||
|
change_page(page) {
|
||||||
|
this.currentPage = page;
|
||||||
|
},
|
||||||
|
sortTable(col) {
|
||||||
|
if (this.sortColumn === col) {
|
||||||
|
this.ascending = !this.ascending;
|
||||||
|
} else {
|
||||||
|
this.ascending = true;
|
||||||
|
this.sortColumn = col;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ascending = this.ascending;
|
||||||
|
|
||||||
|
this.permissions.sort((a, b) => {
|
||||||
|
if (a[col] > b[col]) {
|
||||||
|
return ascending ? 1 : -1;
|
||||||
|
} else if (a[col] < b[col]) {
|
||||||
|
return ascending ? -1 : 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
createPermission() {
|
||||||
|
this.$log.info('Creating new permission...');
|
||||||
|
PermissionRepository.createPermission(this.permission);
|
||||||
|
this.fetch();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetch();
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
// todo....or not
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
permission_columns() {
|
||||||
|
if (this.permissions.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return Object.keys(this.permissions[0]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.error-msg {
|
||||||
|
color: red;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
width: 750px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 3px solid #44475C;
|
||||||
|
margin: 10px 10px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th {
|
||||||
|
text-transform: uppercase;
|
||||||
|
text-align: left;
|
||||||
|
background: #44475C;
|
||||||
|
color: #FFF;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px;
|
||||||
|
min-width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th:hover {
|
||||||
|
background: #717699;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
border-right: 2px solid #7D82A8;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td:last-child {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tbody tr:nth-child(2n) td {
|
||||||
|
background: #D4D8F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
width: 750px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 3px solid #44475C;
|
||||||
|
margin: 10px 10px 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th {
|
||||||
|
text-transform: uppercase;
|
||||||
|
text-align: left;
|
||||||
|
background: #44475C;
|
||||||
|
color: #FFF;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px;
|
||||||
|
min-width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table th:hover {
|
||||||
|
background: #717699;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px;
|
||||||
|
border-right: 2px solid #7D82A8;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td:last-child {
|
||||||
|
border-right: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tbody tr:nth-child(2n) td {
|
||||||
|
background: #D4D8F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
text-align: right;
|
||||||
|
width: 750px;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow_down {
|
||||||
|
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB8AAAAaCAYAAABPY4eKAAAAAXNSR0IArs4c6QAAAvlJREFUSA29Vk1PGlEUHQaiiewslpUJiyYs2yb9AyRuJGm7c0VJoFXSX9A0sSZN04ULF12YEBQDhMCuSZOm1FhTiLY2Rky0QPlQBLRUsICoIN/0PCsGyox26NC3eTNn3r3n3TvnvvsE1PkwGo3yUqkkEQqFgw2Mz7lWqwng7ztN06mxsTEv8U0Aam5u7r5EInkplUol/f391wAJCc7nEAgE9Uwmkzo4OPiJMa1Wq6cFs7Ozt0H6RqlUDmJXfPIx+qrX69Ti4mIyHA5r6Wq1egND+j+IyW6QAUoul18XiUTDNHaSyGazKcZtdgk8wqhUKh9o/OMvsVgsfHJy0iWqVrcQNRUMBnd6enqc9MjISAmRP3e73T9al3XnbWNjIw2+KY1Gc3imsNHR0YV4PP5+d3e32h3K316TySQFoX2WyWR2glzIO5fLTSD6IElLNwbqnFpbWyO/96lCoai0cZjN5kfYQAYi5H34fL6cxWIZbya9iJyAhULBHAqFVlMpfsV/fHxMeb3er+Vy+VUzeduzwWC45XA4dlD/vEXvdDrj8DvURsYEWK3WF4FA4JQP9mg0WrHZbEYmnpa0NxYgPVObm5teiLABdTQT8a6vrwdRWhOcHMzMzCiXlpb2/yV6qDttMpkeshEzRk4Wo/bfoe4X9vb2amzGl+HoXNT29vZqsVi0sK1jJScG+Xx+HGkL4Tew2TPi5zUdQQt9otPpuBk3e0TaHmMDh1zS7/f780S0zX6Yni+NnBj09fUZUfvudDrNZN+GkQbl8Xi8RLRtHzsB9Hr9nfn5+SjSeWUCXC7XPq5kw53wsNogjZNohYXL2EljstvtrAL70/mVaW8Y4OidRO1/gwgbUMvcqGmcDc9aPvD1gnTeQ+0nmaInokRj0nHh+uvIiVOtVvt2a2vLv7Ky0tL3cRTXIcpPAwMDpq6R4/JXE4vFQ5FI5CN+QTaRSFCYc8vLy1l0rge4ARe5kJ/d27kYkLXoy2Jo4C7K8CZOsEBvb+9rlUp1xNXPL7v3IDwxvPD6AAAAAElFTkSuQmCC')
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow_up {
|
||||||
|
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAaCAYAAACgoey0AAAAAXNSR0IArs4c6QAAAwpJREFUSA21Vt1PUmEYP4dvkQ8JFMwtBRocWAkDbiqXrUWXzU1rrTt0bdVqXbb1tbW16C9IBUSmm27cODdneoXjputa6069qwuW6IIBIdLvdaF4OAcOiGeDc87zPs/vd57P96WpFq7p6enbGo1mjKZpeTabjU1MTCRagGnOZHFxcXxtbe1XKpUq7+zslJeXl//Mz8+Hy+Uy3RxSE9qTk5M3otFooVQqgef4Wl9f343FYoEmoISrxuNxFX5f9vb2jhn/PxUKhfLS0tIPfFifUESRUMV8Pv/M6XReRm5rTGQyGeXxeGxYe1ezeBpBOBx2rKysbO7v79d4Wy3Y2Nj4GQqFbgnhaugxwiuGJx99Pp9FLBbXxYTXvTqd7v3MzIy6riIWGxJnMpl7AwMD14xGYyMsSq1WUyQdUqn0eSPlusQIsbGrq+vl4OCgvhFQZd1utyv1en0gEolcqsi47nWJlUrlG5fLZVcoFFy2nDKSDpIWlUoVTCQSEk4lCHmJMZ2GTCbTiMVikfIZ88l7enoos9l8dXt7+z6fDicxSJUokqDX6xXcl2wCROoc0vQCWL3sNfLOSdzR0fHY4XC4tVotl40gmVwup9xuN4OQv+UyqCFGH9rg7SOGYVRcBs3IEG4J0nVnamrqOtvuBDGGgQg9+wHFcVEi4a0LNkbdd6TrPKo8ODc311mteIIYjT/a398/jK+s1jnVM0kXoufCFvq0GuiIGEVgQIhfoygM1QrteEa9dAL7ITiYCt4RMabOK5AyKKzKWtvupLcRciu8D5J0EuDDPyT/Snd39yh6VtY2NhYQSR9G79Ds7OxdskRjEyAufvb7/cPoO5Z6e1+xtVKrq6vfcFzyi/A3ZrPZ3GdNSlwgo5ekE4X2RIQGf2C1WlufFE0GBeGWYQ8YERWLxQtnUVB830MKLZfL9RHir8lkssCn2G751tZWEWe03zTKm15YWPiEiXXTYDB0Ig/t7yd8PRws4EicwWHxO4jHD8/C5HiTTqd1BwcHFozKU89origB+y/kmzgYpgOBQP4fGmUiZmJ+WNgAAAAASUVORK5CYII=')
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow {
|
||||||
|
float: right;
|
||||||
|
width: 12px;
|
||||||
|
height: 15px;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: contain;
|
||||||
|
background-position-y: bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px 10px;
|
||||||
|
color: #FFF;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #44475C;
|
||||||
|
margin: 0px 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number:hover, .number.active {
|
||||||
|
background: #717699;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
{{profile}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
<b-card-text>
|
<b-card-text>
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
<strong>{{ $t('name') }}: {{recorder.name}}</strong> 
|
<strong>{{ $t('name') }}: {{recorder.name}}</strong> 
|
||||||
<router-link :to="{ name: 'recorders'}"> ({{$t('recorders')}} 
|
|
||||||
|
<!--<router-link :to="{ name: 'recorders'}"> ({{$t('recorders')}} 
|
||||||
<font-awesome-icon icon="external-link-alt"/>
|
<font-awesome-icon icon="external-link-alt"/>
|
||||||
)
|
)
|
||||||
</router-link>
|
</router-link>-->
|
||||||
</h5>
|
</h5>
|
||||||
|
<p v-if="recorder.offline">{{$t('recorder is in offline mode')}}!</p>
|
||||||
|
|
||||||
</b-card-text>
|
</b-card-text>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
@@ -33,8 +35,8 @@
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$socket.client.on('connect', function(msg) {
|
this.$socket.client.on('connect', function(msg) {
|
||||||
console.log("We are connected!");
|
this.$log.debug("We are connected!");
|
||||||
console.log(msg);
|
this.$log.debug(msg);
|
||||||
this.$socket.client.emit('request_recorder_state_'+ this.recorder.id, msg);
|
this.$socket.client.emit('request_recorder_state_'+ this.recorder.id, msg);
|
||||||
this.$socket.client.on('request_recorder_state_' + this.recorder.id, function(msg) {
|
this.$socket.client.on('request_recorder_state_' + this.recorder.id, function(msg) {
|
||||||
//TODO: refresh state!
|
//TODO: refresh state!
|
||||||
@@ -43,9 +45,10 @@
|
|||||||
});
|
});
|
||||||
this.$log.info("mounted called");
|
this.$log.info("mounted called");
|
||||||
if (!this.$socket.connected) {
|
if (!this.$socket.connected) {
|
||||||
|
this.$log.info("connecting websocket...");
|
||||||
this.connectWebsocket();
|
this.connectWebsocket();
|
||||||
this.connectedWebsocket = true;
|
this.connectedWebsocket = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@
|
|||||||
if (this.$socket.connected) {
|
if (this.$socket.connected) {
|
||||||
this.$socket.client.disconnect();
|
this.$socket.client.disconnect();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="authenticated">
|
<div v-if="authenticated">
|
||||||
<div v-if="profile.favorite_recorders.length <=0">
|
|
||||||
<p>You haven't configured favorite recorders yet – click below to do so!</p>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<p>Yeah, you already configured a favorite recorder :)</p>
|
|
||||||
<ul>
|
|
||||||
<li v-for="recorder in profile.favorite_recorders">{{recorder.name}}</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<b-form>
|
<b-form>
|
||||||
<b-input-group>
|
<b-input-group>
|
||||||
<select class="form-control" v-model="favorite_recorder_id">
|
<select class="form-control" v-model="favorite_recorder_id">
|
||||||
@@ -19,8 +9,9 @@
|
|||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<b-input-group-append>
|
<b-input-group-append>
|
||||||
<b-button variant="outline-success">
|
<b-button variant="outline-success"
|
||||||
<font-awesome-icon icon="check"></font-awesome-icon>
|
@click="recorderSelected()">
|
||||||
|
<font-awesome-icon icon="check"/>
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-input-group-append>
|
</b-input-group-append>
|
||||||
</b-input-group>
|
</b-input-group>
|
||||||
@@ -38,22 +29,23 @@
|
|||||||
@Component
|
@Component
|
||||||
export default class SelectRecorder extends Vue {
|
export default class SelectRecorder extends Vue {
|
||||||
@Prop() private msg!: string;
|
@Prop() private msg!: string;
|
||||||
@Prop() private favorite_recorder_id!: string;
|
favorite_recorder_id = '';
|
||||||
|
|
||||||
get authenticated() {
|
get authenticated() {
|
||||||
return this.$store.getters.isAuthenticated;
|
return this.$store.getters.isAuthenticated;
|
||||||
}
|
}
|
||||||
|
|
||||||
get profile() {
|
|
||||||
return this.$store.state.profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
get recorders() {
|
get recorders() {
|
||||||
return this.$store.state.recorders;
|
return this.$store.state.recorders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private mounted() {
|
mounted() {
|
||||||
this.$store.dispatch('loadProfile');
|
this.$store.dispatch('loadProfile');
|
||||||
|
this.$store.dispatch('loadRecorders');
|
||||||
|
}
|
||||||
|
|
||||||
|
recorderSelected() {
|
||||||
|
this.$emit('recorderSelected', {'recorder_id': this.favorite_recorder_id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
62
src/main.ts
62
src/main.ts
@@ -21,20 +21,20 @@ import VueMoment from 'vue-moment';
|
|||||||
|
|
||||||
import {library} from '@fortawesome/fontawesome-svg-core';
|
import {library} from '@fortawesome/fontawesome-svg-core';
|
||||||
import {
|
import {
|
||||||
faCoffee,
|
faCoffee,
|
||||||
faDoorOpen,
|
faDoorOpen,
|
||||||
faCheck,
|
faCheck,
|
||||||
faPlus,
|
faPlus,
|
||||||
faScroll,
|
faScroll,
|
||||||
faCircle,
|
faCircle,
|
||||||
faList,
|
faList,
|
||||||
faTrash,
|
faTrash,
|
||||||
faPencilAlt,
|
faPencilAlt,
|
||||||
faCogs,
|
faCogs,
|
||||||
faAt,
|
faAt,
|
||||||
faUser,
|
faUser,
|
||||||
faEnvelope,
|
faEnvelope,
|
||||||
faUserTag, faExternalLinkAlt,
|
faUserTag, faExternalLinkAlt,
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome';
|
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome';
|
||||||
|
|
||||||
@@ -48,19 +48,19 @@ import 'bootstrap-vue/dist/bootstrap-vue.css';
|
|||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
|
||||||
library.add(faCoffee, faTrash, faPencilAlt, faScroll, faCheck, faCircle, faList, faPlus, faDoorOpen, faCogs, faAt,
|
library.add(faCoffee, faTrash, faPencilAlt, faScroll, faCheck, faCircle, faList, faPlus, faDoorOpen, faCogs, faAt,
|
||||||
faUser, faEnvelope, faUserTag, faExternalLinkAlt);
|
faUser, faEnvelope, faUserTag, faExternalLinkAlt);
|
||||||
|
|
||||||
Vue.component('font-awesome-icon', FontAwesomeIcon);
|
Vue.component('font-awesome-icon', FontAwesomeIcon);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
// logLevel : isProduction ? 'error' : 'debug',
|
// logLevel : isProduction ? 'error' : 'debug',
|
||||||
logLevel: 'debug',
|
logLevel: 'debug',
|
||||||
stringifyArguments: false,
|
stringifyArguments: false,
|
||||||
showLogLevel: true,
|
showLogLevel: true,
|
||||||
showMethodName: true,
|
showMethodName: true,
|
||||||
separator: '|',
|
separator: '|',
|
||||||
showConsoleColors: true,
|
showConsoleColors: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
Vue.use(VueLogger, options);
|
Vue.use(VueLogger, options);
|
||||||
@@ -73,7 +73,11 @@ Vue.use(VeeValidate);
|
|||||||
Vue.use(VueMoment);
|
Vue.use(VueMoment);
|
||||||
|
|
||||||
// const socket = io('ws://localhost:5000',{autoConnect: false, reconnectionAttempts: 3});
|
// const socket = io('ws://localhost:5000',{autoConnect: false, reconnectionAttempts: 3});
|
||||||
const socket = io('ws://localhost:5443',{autoConnect: false, reconnectionAttempts: 3});
|
const socket = io('ws://localhost:5443', {
|
||||||
|
autoConnect: false,
|
||||||
|
reconnectionAttempts: 3,
|
||||||
|
query: {jwt: store.state.access_token}
|
||||||
|
});
|
||||||
Vue.use(VueSocketIOExt, socket);
|
Vue.use(VueSocketIOExt, socket);
|
||||||
|
|
||||||
|
|
||||||
@@ -87,12 +91,12 @@ Vue.config.productionTip = false;
|
|||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
String.prototype.isEmpty = function() {
|
String.prototype.isEmpty = function() {
|
||||||
return (this.length === 0 || !this.trim());
|
return (this.length === 0 || !this.trim());
|
||||||
};
|
};
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
i18n,
|
i18n,
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
render: (h) => h(App),
|
render: (h) => h(App),
|
||||||
}).$mount('#app');
|
}).$mount('#app');
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import Profile from '@/components/Profile.vue';
|
|||||||
import User from '@/components/User.vue';
|
import User from '@/components/User.vue';
|
||||||
import Test from '@/components/Test.vue';
|
import Test from '@/components/Test.vue';
|
||||||
import Group from '@/components/Group.vue';
|
import Group from '@/components/Group.vue';
|
||||||
|
import Permission from '@/components/Permission.vue';
|
||||||
import Rooms from '@/components/Rooms.vue';
|
import Rooms from '@/components/Rooms.vue';
|
||||||
import Recorders from '@/components/Recorders.vue';
|
import Recorders from '@/components/Recorders.vue';
|
||||||
import Commands from '@/components/Commands.vue';
|
import Commands from '@/components/Commands.vue';
|
||||||
@@ -48,6 +49,11 @@ export const router = new Router({
|
|||||||
path: 'group',
|
path: 'group',
|
||||||
component: Group,
|
component: Group,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'admin.permission',
|
||||||
|
path: 'permission',
|
||||||
|
component: Permission,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,62 +2,76 @@
|
|||||||
<div class="home">
|
<div class="home">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<section class="section">
|
<section class="section">
|
||||||
|
|
||||||
<HelloWorld v-if="!authenticated" msg="you are not authenticated!"/>
|
<HelloWorld v-if="!authenticated" msg="you are not authenticated!"/>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<h1>Welcome <span v-if="profile.last_seen!=null">back</span> {{$store.getters.getUserName}}! <span
|
<h1>Welcome <span v-if="profile.last_seen!=null">back</span> {{$store.getters.getUserName}}! <span
|
||||||
v-if="profile.last_seen!=null">(Last seen: {{profile.last_seen | moment("dddd, MMMM Do YYYY")}})</span>
|
v-if="profile.last_seen!=null">(Last seen: {{profile.last_seen | moment("dddd, MMMM Do YYYY")}})</span>
|
||||||
</h1>
|
</h1>
|
||||||
<SelectRecorder/>
|
<p>{{$t('Add favorite recorder:')}}</p>
|
||||||
|
<SelectRecorder @recorderSelected="addFavoriteRecorderToProfile"/>
|
||||||
|
|
||||||
<div v-if="profile.favorite_recorders.length >0">
|
<div v-if="profile.favorite_recorders.length >0">
|
||||||
<ul>
|
<hr/>
|
||||||
<li v-for="recorder in profile.favorite_recorders">{{recorder.name}}</li>
|
<p>{{$t('Favorite recorders:')}}</p>
|
||||||
</ul>
|
<b-card-group deck>
|
||||||
<RecorderState v-for="recorder in profile.favorite_recorders" :recorder="recorder"/>
|
<RecorderState v-for="recorder in profile.favorite_recorders" :recorder="recorder"/>
|
||||||
|
</b-card-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script>
|
||||||
import {Component, Vue} from 'vue-property-decorator';
|
import {Component, Vue} from 'vue-property-decorator';
|
||||||
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
|
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
|
||||||
import i18n from '@/plugins/i18n';
|
import i18n from '@/plugins/i18n';
|
||||||
import SelectRecorder from '@/components/SelectRecorder.vue';
|
import SelectRecorder from '@/components/SelectRecorder.vue';
|
||||||
import RecorderState from '@/components/RecorderState.vue';
|
import RecorderState from '@/components/RecorderState.vue';
|
||||||
|
import getRepository from '@/api/RepositoryFactory';
|
||||||
|
|
||||||
|
const userRepository = getRepository('user');
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
components: {
|
||||||
|
RecorderState,
|
||||||
|
SelectRecorder,
|
||||||
|
HelloWorld,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
export default class Home extends Vue {
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
if (this.authenticated) {
|
||||||
|
if (this.profile == null || Object.keys(this.profile).length === 0) {
|
||||||
|
this.$parent.$data.isLoading = true;
|
||||||
|
this.$store.dispatch('loadProfile').then(() => {
|
||||||
|
this.$parent.$data.isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addFavoriteRecorderToProfile(recorder) {
|
||||||
|
console.log(recorder);
|
||||||
|
userRepository.addFavoriteRecorder(recorder["recorder_id"]).then(() => {
|
||||||
|
this.$store.dispatch('loadProfile');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get authenticated() {
|
||||||
|
return this.$store.getters.isAuthenticated;
|
||||||
|
}
|
||||||
|
|
||||||
|
get profile() {
|
||||||
|
return this.$store.state.profile;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
|
||||||
components: {
|
|
||||||
RecorderState,
|
|
||||||
SelectRecorder,
|
|
||||||
HelloWorld,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
export default class Home extends Vue {
|
|
||||||
public data() {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
|
||||||
if (this.profile == null || Object.keys(this.profile).length === 0) {
|
|
||||||
this.$store.dispatch('loadProfile');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get authenticated() {
|
|
||||||
return this.$store.getters.isAuthenticated;
|
|
||||||
}
|
|
||||||
|
|
||||||
get profile() {
|
|
||||||
return this.$store.state.profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Reference in New Issue
Block a user