From 4580972a4914519d6fb468c03d7dcfab92b46b59 Mon Sep 17 00:00:00 2001 From: Paul Sori Date: Sat, 9 Mar 2019 22:26:12 -0800 Subject: [PATCH] users panel --- electron/css/index3.css | 6 +- electron/index3.html | 156 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 156 insertions(+), 6 deletions(-) diff --git a/electron/css/index3.css b/electron/css/index3.css index 2df30e2..0912183 100644 --- a/electron/css/index3.css +++ b/electron/css/index3.css @@ -151,4 +151,8 @@ ul.left-nav-menu li.left-nav-selected { .folder-button-group { float: right; -} \ No newline at end of file +} + +.row-mod { + margin-bottom: 10px !important; +} diff --git a/electron/index3.html b/electron/index3.html index 9b93739..b5bf98c 100644 --- a/electron/index3.html +++ b/electron/index3.html @@ -62,7 +62,7 @@
- Boot Server + Boot Server
@@ -77,11 +77,12 @@ const app = remote.app; const dialog = remote.require('electron').dialog; const audioDirs = { }; + const serverUsers = { }; var vm; var foldersView; window.onload = function () { - const folderSelector = Vue.component('folder-accordion', { + Vue.component('folder-accordion', { data: function() { return { instances: null, @@ -89,7 +90,6 @@ resetFlag: false, closeOverride: () => { if (this.resetFlag) { - console.log('AERGEAR') this.$parent.componentKey = !this.$parent.componentKey; } } @@ -183,7 +183,7 @@ \ No special characters\ \ - \ \ @@ -217,11 +217,157 @@ ', }); + Vue.component('user-accordion', { + data: function() { + return { + instances: null, + users: serverUsers, + resetFlag: false, + closeOverride: () => { + if (this.resetFlag) { + this.$parent.componentKey = !this.$parent.componentKey; + } + } + }; + }, + template: '\ + ', + mounted: function () { + this.instances = M.Collapsible.init(document.querySelectorAll('.collapsible-folders'), { onCloseEnd: this.closeOverride }); + }, + beforeDestroy: function() { + this.instances[0].destroy(); + }, + methods: { + changeDirectory: function(value, key, index) { + + }, + deleteFolder: function(value, key, index) { + iziToast.question({ + timeout: 20000, + close: false, + overlayClose: true, + overlay: true, + displayMode: 'once', + id: 'question', + zindex: 99999, + title: "Delete '" + value + "'?", + position: 'center', + buttons: [ + ['', (instance, toast) => { + delete serverUsers[key]; + this.resetFlag = true; + this.instances[0].close(index); + instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); + }, true], + ['', (instance, toast) => { + instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); + }], + ] + }); + }, + toggleOptions: function(index, el) { + if(el.target.classList.contains('btn')){ + return; + } + + if(el.currentTarget.classList.contains('active')){ + this.instances[0].close(index); + return; + } + + this.instances[0].open(index); + } + } + }); + const usersView = Vue.component('users-view', { + data() { + return { + directories: audioDirs, + componentKey: false, // Flip this value to force re-render the folder accordion thing + newUsername: '', // for the input field + selectInstance: null, + newPassword: '' + }; + }, template: '\
\ - Users\ +
\ +
New User
\ +
\ +
\ +
\ + \ + \ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
Users:
\ + \ +
\
', + mounted: function () { + this.selectInstance = M.FormSelect.init(document.querySelectorAll("#new-user-dirs")); + }, + beforeDestroy: function() { + this.selectInstance[0].destroy(); + }, + methods: { + addUser: function (event) { + if (this.selectInstance[0].getSelectedValues().length === 0) { + iziToast.warning({ + title: 'Cannot add user without a directory', + position: 'topCenter', + timeout: 3500 + }); + return; + } + console.log(this.selectInstance[0].getSelectedValues()); + + // serverUsers[this.newUsername] = 'password'; + // this.componentKey = !this.componentKey; + // this.newUsername = ''; + // this.newPassword = ''; + }, + } }); const networkView = Vue.component('network-view', {