Added persistence for revoked accounts filter
This commit is contained in:
parent
a65bda0f19
commit
f3a7f1f869
5 changed files with 35 additions and 14 deletions
5
frontend/package-lock.json
generated
5
frontend/package-lock.json
generated
|
@ -7800,6 +7800,11 @@
|
|||
"clipboard": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"vue-cookies": {
|
||||
"version": "1.7.4",
|
||||
"resolved": "https://registry.npmjs.org/vue-cookies/-/vue-cookies-1.7.4.tgz",
|
||||
"integrity": "sha512-mOS5Btr8V9zvAtkmQ7/TfqJIropOx7etDAgBywPCmHjvfJl2gFbH2XgoMghleLoyyMTi5eaJss0mPN7arMoslA=="
|
||||
},
|
||||
"vue-good-table": {
|
||||
"version": "2.21.1",
|
||||
"resolved": "https://registry.npmjs.org/vue-good-table/-/vue-good-table-2.21.1.tgz",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"axios": "^0.19.2",
|
||||
"vue": "^2.6.12",
|
||||
"vue-clipboard2": "^0.2.1",
|
||||
"vue-cookies": "^1.7.4",
|
||||
"vue-good-table": "^2.21.1"
|
||||
},
|
||||
"browserslist": [
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Vue from 'vue';
|
||||
import axios from 'axios';
|
||||
import VueCookies from 'vue-cookies'
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
import VueGoodTablePlugin from 'vue-good-table'
|
||||
|
||||
|
@ -7,6 +8,7 @@ import 'vue-good-table/dist/vue-good-table.css'
|
|||
|
||||
Vue.use(VueClipboard)
|
||||
Vue.use(VueGoodTablePlugin)
|
||||
Vue.use(VueCookies)
|
||||
|
||||
var axios_cfg = function(url, data='', type='form') {
|
||||
if (data == '') {
|
||||
|
@ -109,7 +111,7 @@ new Vue({
|
|||
}
|
||||
],
|
||||
filters: {
|
||||
hide_revoked: true
|
||||
hideRevoked: true,
|
||||
},
|
||||
u: {
|
||||
newUserName: '',
|
||||
|
@ -132,10 +134,16 @@ new Vue({
|
|||
watch: {
|
||||
},
|
||||
mounted: function () {
|
||||
this.u_get_data()
|
||||
this.u_get_data();
|
||||
this.filters.hideRevoked = this.$cookies.isKey('hideRevoked') ? (this.$cookies.get('hideRevoked') == "true") : false
|
||||
},
|
||||
created() {
|
||||
var _this = this
|
||||
var _this = this;
|
||||
|
||||
// if (!_this.$cookies.isKey('hideRevoked')) {
|
||||
// _this.$cookies.set('hideRevoked', true, -1);
|
||||
// }
|
||||
|
||||
_this.$root.$on('u-revoke', function (msg) {
|
||||
var data = new URLSearchParams();
|
||||
data.append('username', _this.username);
|
||||
|
@ -209,15 +217,16 @@ new Vue({
|
|||
modalShowCcdDisplay: function () {
|
||||
return this.u.modalShowCcdVisible ? {display: 'flex'} : {}
|
||||
},
|
||||
revokeFilterText: function() {
|
||||
return this.filters.hideRevoked ? "Show revoked" : "Hide revoked"
|
||||
},
|
||||
filteredRows: function() {
|
||||
var _this = this;
|
||||
|
||||
if(_this.filters.hide_revoked) {
|
||||
return _this.rows.filter(function(account) {
|
||||
if (this.filters.hideRevoked) {
|
||||
return this.rows.filter(function(account) {
|
||||
return account.AccountStatus === "Active";
|
||||
});
|
||||
} else {
|
||||
return _this.rows;
|
||||
return this.rows;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
:search-options="{ enabled: true}" >
|
||||
<div slot="table-actions">
|
||||
<button type="button" class="btn btn-sm btn-success el-square" v-on:click.stop="u.modalNewUserVisible=true">Add user</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary el-square" v-on:click.stop="filters.hide_revoked=!filters.hide_revoked" v-show="filters.hide_revoked">Show revoked</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary el-square" v-on:click.stop="filters.hide_revoked=!filters.hide_revoked" v-show="!filters.hide_revoked">Hide revoked</button>
|
||||
<button type="button" class="btn btn-sm btn-secondary el-square" v-on:click.stop="filters.hideRevoked=!filters.hideRevoked;this.$cookies.set('hideRevoked',!(this.$cookies.get('hideRevoked') == 'true'), -1);">{{ revokeFilterText }}</button>
|
||||
</div>
|
||||
<div slot="emptystate" class="d-flex justify-content-center">
|
||||
<h4>No users have been created yet.</h4>
|
||||
|
|
15
main.go
15
main.go
|
@ -397,14 +397,21 @@ func usersList() []openvpnClient {
|
|||
}
|
||||
|
||||
func userCreate(username string) (bool, string) {
|
||||
ucErr := ""
|
||||
// TODO: add password for user cert . priority=low
|
||||
if validateUsername(username) == false {
|
||||
fmt.Printf("Username \"%s\" incorrect, you can use only %s\n", username, usernameRegexp)
|
||||
return false, fmt.Sprintf("Username \"%s\" incorrect, you can use only %s", username, usernameRegexp)
|
||||
ucErr = fmt.Sprintf("Username \"%s\" incorrect, you can use only %s\n", username, usernameRegexp)
|
||||
if *debug {
|
||||
log.Printf("ERROR: userCreate: %s", ucErr)
|
||||
}
|
||||
return false, ucErr
|
||||
}
|
||||
if checkUserExist(username) {
|
||||
fmt.Printf("User \"%s\" already exists\n", username)
|
||||
return false, fmt.Sprintf("User \"%s\" already exists", username)
|
||||
ucErr = fmt.Sprintf("User \"%s\" already exists\n", username)
|
||||
if *debug {
|
||||
log.Printf("ERROR: userCreate: %s", ucErr)
|
||||
}
|
||||
return false, ucErr
|
||||
}
|
||||
o := runBash(fmt.Sprintf("date +%%Y-%%m-%%d\\ %%H:%%M:%%S && cd %s && easyrsa build-client-full %s nopass", *easyrsaDirPath, username))
|
||||
fmt.Println(o)
|
||||
|
|
Loading…
Reference in a new issue