1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
<template>
<div id="app">
<app-navigation :menu="menu">
<template slot="settings-content">
<div>
<input type="checkbox" id="showLastLogin" class="checkbox"
:checked="showLastLogin" v-model="showLastLogin">
<label for="showLastLogin">{{t('settings', 'Show last login')}}</label>
</div>
<div>
<input type="checkbox" id="showUserBackend" class="checkbox"
:checked="showUserBackend" v-model="showUserBackend">
<label for="showUserBackend">{{t('settings', 'Show user backend')}}</label>
</div>
<div>
<input type="checkbox" id="showStoragePath" class="checkbox"
:checked="showStoragePath" v-model="showStoragePath">
<label for="showStoragePath">{{t('settings', 'Show storage path')}}</label>
</div>
</template>
</app-navigation>
<user-list :users="users" :showConfig="showConfig" />
</div>
</template>
<script>
import appNavigation from '../components/appNavigation';
import userList from '../components/userList';
import Vue from 'vue';
import VueLocalStorage from 'vue-localstorage'
Vue.use(VueLocalStorage)
export default {
name: 'Users',
components: {
appNavigation,
userList
},
beforeMount() {
this.$store.commit('initGroups', {
groups: this.$store.getters.getServerData.groups,
orderBy: this.$store.getters.getServerData.sortGroups,
userCount: this.$store.getters.getServerData.userCount
});
this.$store.dispatch('getPasswordPolicyMinLength');
},
data() {
return {
showConfig: {
showStoragePath: false,
showUserBackend: false,
showLastLogin: false,
showNewUserForm: false
}
}
},
methods: {
getLocalstorage(key) {
// force initialization
this.showConfig[key] = this.$localStorage.get(key) === 'true';
return this.showConfig[key];
},
setLocalStorage(key, status) {
this.showConfig[key] = status;
this.$localStorage.set(key, status);
return status;
}
},
computed: {
route() {
return this.$store.getters.getRoute;
},
users() {
return this.$store.getters.getUsers;
},
loading() {
return Object.keys(this.users).length === 0;
},
usersOffset() {
return this.$store.getters.getUsersOffset;
},
usersLimit() {
return this.$store.getters.getUsersLimit;
},
showLastLogin: {
get: function() {return this.getLocalstorage('showLastLogin')},
set: function(status) {
this.setLocalStorage('showLastLogin', status);
}
},
showUserBackend: {
get: function() {return this.getLocalstorage('showUserBackend')},
set: function(status) {
this.setLocalStorage('showUserBackend', status);
}
},
showStoragePath: {
get: function() {return this.getLocalstorage('showStoragePath')},
set: function(status) {
this.setLocalStorage('showStoragePath', status);
}
},
userCount() {
return this.$store.getters.getUserCount;
},
menu() {
let self = this;
// Data provided php side
let groups = this.$store.getters.getGroups;
groups = Array.isArray(groups) ? groups : [];
// Map groups
groups = groups.map(group => {
let item = {};
item.id = group.id.replace(' ', '_');
item.classes = [];
item.href = '#group'+group.id.replace(' ', '_');
item.text = group.name;
item.utils = {counter: group.usercount};
return item;
});
// Adjust data
let adminGroup = groups.find(group => group.id == 'admin');
let disabledGroup = groups.find(group => group.id == '_disabled');
if (adminGroup.text) {
adminGroup.text = t('settings', 'Admins');} // rename admin group
if (disabledGroup.text) {
disabledGroup.text = t('settings', 'Disabled users'); // rename disabled group
if (disabledGroup.utils.counter === 0) {
groups.splice(groups.findIndex(group => group.id == '_disabled'), 1); // remove disabled if empty
}
}
// Add everyone group
groups.unshift({
id: '_everyone',
classes: [],
href:'#group_everyone',
text: t('settings', 'Everyone'),
utils: {counter: this.userCount}
});
// Set current group as active
let activeGroup = groups.findIndex(group => group.href === this.route.hash);
if (activeGroup >= 0) {
groups[activeGroup].classes.push('active');
} else {
groups[0].classes.push('active');
}
// Return
return {
id: 'usergrouplist',
new: {
id:'new-user-button',
text: t('settings','New user'),
icon: 'icon-add',
action: function(){self.showConfig.showNewUserForm=!self.showConfig.showNewUserForm}
},
items: groups
}
}
}
}
</script>
<style lang="scss">
</style>
|