summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/api/clients.js7
-rw-r--r--server/api/groups.js7
-rw-r--r--webapp/src/components/GroupModuleHomeView.vue16
-rw-r--r--webapp/src/store/groups.js4
4 files changed, 30 insertions, 4 deletions
diff --git a/server/api/clients.js b/server/api/clients.js
index 1f28c0b..2780bd6 100644
--- a/server/api/clients.js
+++ b/server/api/clients.js
@@ -10,6 +10,13 @@ module.exports.get = {
})
},
+ // get all groups
+ getAll: function (req, res) {
+ db.client.findAll().then(list => {
+ res.send(list)
+ })
+ },
+
// get all clients that have no groups
getTopLevel: function (req, res) {
db.client.findAll({ where: { '$groups.id$': null }, include: ['groups'] }).then(clients => {
diff --git a/server/api/groups.js b/server/api/groups.js
index af63d98..43abe4e 100644
--- a/server/api/groups.js
+++ b/server/api/groups.js
@@ -11,6 +11,13 @@ module.exports.get = {
})
},
+ // get all groups
+ getAll: function (req, res) {
+ db.group.findAll().then(list => {
+ res.send(list)
+ })
+ },
+
// get all groups that have no parents
getTopLevel: function (req, res) {
db.group.findAll({ where: { '$parents.id$': null }, include: ['parents'] }).then(groups => {
diff --git a/webapp/src/components/GroupModuleHomeView.vue b/webapp/src/components/GroupModuleHomeView.vue
index 3fd127b..0ec8893 100644
--- a/webapp/src/components/GroupModuleHomeView.vue
+++ b/webapp/src/components/GroupModuleHomeView.vue
@@ -9,6 +9,10 @@
<template>
<div>
+ <v-layout>
+ <v-spacer></v-spacer>
+ <div><v-switch class="show-toggle" label="Show All" hide-details color="primary" :input-value="showAll" @change="setShowAll"></v-switch></div>
+ </v-layout>
<v-subheader>Groups</v-subheader>
<group-module-group-list :tabIndex="0" :groups="home.groups" />
<div class="text-xs-right">
@@ -43,8 +47,13 @@ export default {
computed: {
...mapState('groups', ['showAll'])
},
+ watch: {
+ showAll () {
+ this.$store.dispatch('groups/loadHome')
+ }
+ },
methods: {
- ...mapMutations('groups', ['setActiveTab', 'setTab']),
+ ...mapMutations('groups', ['setActiveTab', 'setTab', 'setShowAll']),
newGroup () {
this.setTab({ index: 1, item: { tabType: 'group' } })
this.setActiveTab(1)
@@ -59,7 +68,8 @@ export default {
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
-.info-input {
- margin: 10px;
+.show-toggle {
+ margin-top: 20px;
+ margin-right: 20px;
}
</style>
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index aad77f4..137ae6a 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -13,6 +13,7 @@ export default {
setGroupList: (state, list) => { state.groupList = list },
setClientList: (state, list) => { state.clientList = list },
setActiveTab: (state, index) => { state.activeTab = index },
+ setShowAll: (state, value) => { state.showAll = value },
deleteFromTabChain: (state, { index, count }) => { state.tabChain.splice(index, count) },
setTab: (state, { index, item }) => {
if (state.tabChain.length > index + 1 && (state.tabChain[index].tabType !== item.tabType || state.tabChain[index].id !== item.id)) {
@@ -29,7 +30,8 @@ export default {
})
},
loadHome (context) {
- Promise.all([axios.get('/api/groups/getTopLevel'), axios.get('/api/clients/getTopLevel')]).then(res => {
+ var apiFunction = context.state.showAll ? 'getAll' : 'getTopLevel'
+ Promise.all([axios.get('/api/groups/' + apiFunction), axios.get('/api/clients/' + apiFunction)]).then(res => {
context.commit('setTab', { index: 0, item: { tabType: 'home', groups: res[0].data, clients: res[1].data } })
})
},