From cc88daae344ec54cd9590b1e12e4880757c46e21 Mon Sep 17 00:00:00 2001 From: Mik Date: Fri, 5 Feb 2021 16:34:13 +0100 Subject: [PATCH] permissions editor --- ui/src/views/dashboard/playbooks.vue | 137 +++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/ui/src/views/dashboard/playbooks.vue b/ui/src/views/dashboard/playbooks.vue index f491a154..f513c450 100644 --- a/ui/src/views/dashboard/playbooks.vue +++ b/ui/src/views/dashboard/playbooks.vue @@ -34,6 +34,11 @@ icon="edit" @click="edit(record)" > + + + + + + --- + Owner + Group + Others + + + Use + + + + + + + + + + + + Manage + + + + + + + + + + + + Admin + + + + + + + + + + + + @@ -64,6 +149,9 @@ export default { pool: [], + access_editable: {}, + access_editor_visible: false, + columns: [ { dataIndex: "id", @@ -94,6 +182,12 @@ export default { }; }, computed: { + permissions() { + if (!this.access_editable.permissions) return []; + return this.access_editable.permissions + .split("") + .map((e) => (e == "1" ? true : false)); + }, ...mapGetters(["credentials"]), }, methods: { @@ -134,6 +228,49 @@ export default { this.edit_visible = false; this.editable = {}; }, + + save_access() { + this.$axios({ + method: "post", + url: `/ansible/${this.access_editable.id}/action`, + auth: this.credentials, + data: { + action: { + perform: "update", + params: { + extra_data: { PERMISSIONS: this.access_editable.permissions }, + }, + }, + }, + }).then(() => { + this.$notification.success({ + message: "Success", + description: "Permissions updated successfuly", + }); + this.handleAccessEditorClose(); + this.sync(); + }); + }, + edit_access(record) { + this.access_editable = { + id: record.id, + permissions: record.extra_data.PERMISSIONS, + }; + this.access_editor_visible = true; + }, + updateChecked(e, num) { + let p = this.permissions; + p[num] = e.target.checked; + this.$set( + this.access_editable, + "permissions", + p.map((e) => (e ? "1" : "0")).join("") + ); + }, + handleAccessEditorClose() { + this.access_editor_visible = false; + this.access_editable = {}; + }, }, mounted() { this.$store.dispatch("sync_user_pool");