Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
ec6f32d2
Commit
ec6f32d2
authored
Jan 05, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edit User client logic + Delete User UI
parent
08099469
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
25 deletions
+126
-25
app.css
assets/css/app.css
+0
-0
app.js
assets/js/app.js
+0
-0
admin-users-create.js
client/js/modals/admin-users-create.js
+4
-4
admin-users-delete.js
client/js/modals/admin-users-delete.js
+23
-0
admin.js
client/js/pages/admin.js
+47
-2
admin.js
controllers/admin.js
+11
-2
admin-createuser.pug
views/modals/admin-createuser.pug
+1
-1
admin-deleteuser.pug
views/modals/admin-deleteuser.pug
+11
-0
users-edit.pug
views/pages/admin/users-edit.pug
+28
-15
users.pug
views/pages/admin/users.pug
+1
-1
No files found.
assets/css/app.css
View file @
ec6f32d2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
assets/js/app.js
View file @
ec6f32d2
This diff is collapsed.
Click to expand it.
client/js/modals/admin-
createuser
.js
→
client/js/modals/admin-
users-create
.js
View file @
ec6f32d2
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Vue Create User instance
// Vue Create User instance
let
vueCreateUser
=
new
Vue
({
let
vueCreateUser
=
new
Vue
({
el
:
'#modal-admin-
createuser
'
,
el
:
'#modal-admin-
users-create
'
,
data
:
{
data
:
{
email
:
''
,
email
:
''
,
provider
:
'local'
,
provider
:
'local'
,
...
@@ -11,11 +11,11 @@ let vueCreateUser = new Vue({
...
@@ -11,11 +11,11 @@ let vueCreateUser = new Vue({
},
},
methods
:
{
methods
:
{
open
:
(
ev
)
=>
{
open
:
(
ev
)
=>
{
$
(
'#modal-admin-
createuser
'
).
addClass
(
'is-active'
);
$
(
'#modal-admin-
users-create
'
).
addClass
(
'is-active'
);
$
(
'#modal-admin-
createuser
input'
).
first
().
focus
();
$
(
'#modal-admin-
users-create
input'
).
first
().
focus
();
},
},
cancel
:
(
ev
)
=>
{
cancel
:
(
ev
)
=>
{
$
(
'#modal-admin-
createuser
'
).
removeClass
(
'is-active'
);
$
(
'#modal-admin-
users-create
'
).
removeClass
(
'is-active'
);
vueCreateUser
.
email
=
''
;
vueCreateUser
.
email
=
''
;
vueCreateUser
.
provider
=
'local'
;
vueCreateUser
.
provider
=
'local'
;
},
},
...
...
client/js/modals/admin-users-delete.js
0 → 100644
View file @
ec6f32d2
// Vue Delete User instance
let
vueDeleteUser
=
new
Vue
({
el
:
'#modal-admin-users-delete'
,
data
:
{
},
methods
:
{
open
:
(
ev
)
=>
{
$
(
'#modal-admin-users-delete'
).
addClass
(
'is-active'
);
},
cancel
:
(
ev
)
=>
{
$
(
'#modal-admin-users-delete'
).
removeClass
(
'is-active'
);
},
deleteUser
:
(
ev
)
=>
{
vueDeleteUser
.
cancel
();
}
}
});
$
(
'.btn-deluser-prompt'
).
on
(
'click'
,
vueDeleteUser
.
open
);
\ No newline at end of file
client/js/pages/admin.js
View file @
ec6f32d2
if
(
$
(
'#page-type-admin'
).
length
)
{
if
(
$
(
'#page-type-admin
-users
'
).
length
)
{
//=include ../modals/admin-createuser.js
//=include ../modals/admin-users-create.js
}
else
if
(
$
(
'#page-type-admin-users-edit'
).
length
)
{
let
vueEditUser
=
new
Vue
({
el
:
'#page-type-admin-users-edit'
,
data
:
{
id
:
''
,
email
:
''
,
password
:
'********'
,
name
:
''
,
rights
:
[],
roleoverride
:
'none'
},
methods
:
{
addRightsRow
:
(
ev
)
=>
{
vueEditUser
.
rights
.
push
({});
},
removeRightsRow
:
(
ev
)
=>
{
},
saveUser
:
(
ev
)
=>
{
}
},
created
:
function
()
{
this
.
id
=
usrData
.
_id
;
this
.
email
=
usrData
.
email
;
this
.
name
=
usrData
.
name
;
console
.
log
(
_
.
find
(
usrData
.
rights
,
{
role
:
'admin'
}));
if
(
_
.
find
(
usrData
.
rights
,
{
role
:
'admin'
}))
{
this
.
rights
=
_
.
reject
(
usrData
.
rights
,
[
'role'
,
'admin'
]);
this
.
roleoverride
=
'admin'
;
}
else
{
this
.
rights
=
usrData
.
rights
;
}
}
});
//=include ../modals/admin-users-delete.js
}
}
\ No newline at end of file
controllers/admin.js
View file @
ec6f32d2
...
@@ -69,9 +69,18 @@ router.get('/users/:id', (req, res) => {
...
@@ -69,9 +69,18 @@ router.get('/users/:id', (req, res) => {
}
}
db
.
User
.
findById
(
req
.
params
.
id
)
db
.
User
.
findById
(
req
.
params
.
id
)
.
select
(
'-password'
)
.
select
(
'-password
-providerId
'
)
.
exec
().
then
((
usr
)
=>
{
.
exec
().
then
((
usr
)
=>
{
res
.
render
(
'pages/admin/users-edit'
,
{
adminTab
:
'users'
,
usr
});
let
usrOpts
=
{
canChangeEmail
:
(
usr
.
email
!==
'guest'
&&
usr
.
provider
===
'local'
&&
usr
.
email
!==
req
.
app
.
locals
.
appconfig
.
admin
),
canChangeName
:
(
usr
.
email
!==
'guest'
),
canChangePassword
:
(
usr
.
email
!==
'guest'
&&
usr
.
provider
===
'local'
),
canChangeRole
:
(
usr
.
email
!==
'guest'
&&
!
(
usr
.
provider
===
'local'
&&
usr
.
email
===
req
.
app
.
locals
.
appconfig
.
admin
)),
canBeDeleted
:
(
usr
.
email
!==
'guest'
&&
!
(
usr
.
provider
===
'local'
&&
usr
.
email
===
req
.
app
.
locals
.
appconfig
.
admin
))
};
res
.
render
(
'pages/admin/users-edit'
,
{
adminTab
:
'users'
,
usr
,
usrOpts
});
});
});
});
});
...
...
views/modals/admin-createuser.pug
View file @
ec6f32d2
.modal#modal-admin-
createuser
.modal#modal-admin-
users-create
.modal-background
.modal-background
.modal-container
.modal-container
.modal-content
.modal-content
...
...
views/modals/admin-deleteuser.pug
0 → 100644
View file @
ec6f32d2
.modal#modal-admin-users-delete
.modal-background
.modal-container
.modal-content
header.is-red Delete User Account?
section
span Are you sure you want to delete this user account? This action cannot be undone!
footer
a.button.is-grey.is-outlined(v-on:click="cancel") Abort
a.button.is-red(v-on:click="deleteUser") Delete
\ No newline at end of file
views/pages/admin/users-edit.pug
View file @
ec6f32d2
...
@@ -8,7 +8,7 @@ block rootNavRight
...
@@ -8,7 +8,7 @@ block rootNavRight
span Return to Users
span Return to Users
block adminContent
block adminContent
#page-type-admin
#page-type-admin
-users-edit
.hero
.hero
h1.title#title Edit User
h1.title#title Edit User
h2.subtitle= usr.email
h2.subtitle= usr.email
...
@@ -16,14 +16,12 @@ block adminContent
...
@@ -16,14 +16,12 @@ block adminContent
thead
thead
tr
tr
th Unique ID
th Unique ID
th Email
th Provider
th Provider
th Created On
th Created On
th Updated On
th Updated On
tbody
tbody
tr
tr
td.is-centered= usr._id
td.is-centered= usr._id
td.is-centered= usr.email
td.is-centered.has-icons
td.is-centered.has-icons
case usr.provider
case usr.provider
when 'local'
when 'local'
...
@@ -43,14 +41,18 @@ block adminContent
...
@@ -43,14 +41,18 @@ block adminContent
td.is-centered= userMoment(usr.updatedAt).format('lll')
td.is-centered= userMoment(usr.updatedAt).format('lll')
.form-sections
.form-sections
section
section
label.label Email Address
p.control.is-fullwidth
input.input(type='text', placeholder='john.smith@example.com', v-model='email', disabled=!usrOpts.canChangeEmail)
section
label.label Display Name
label.label Display Name
p.control.is-fullwidth
p.control.is-fullwidth
input.input(type='text', placeholder='John Smith', v
alue=usr.n
ame)
input.input(type='text', placeholder='John Smith', v
-model='name', disabled=!usrOpts.canChangeN
ame)
if usr
.provider == 'local'
if usr
Opts.canChangePassword
section
section
label.label Password
label.label Password
p.control.is-fullwidth
p.control.is-fullwidth
input.input(type='password', placeholder='Password', value='********')
input.input(type='password', placeholder='Password', v
-model='password', v
alue='********')
section
section
label.label Access Rights
label.label Access Rights
table.table
table.table
...
@@ -62,7 +64,7 @@ block adminContent
...
@@ -62,7 +64,7 @@ block adminContent
th(style={width: '150px'}) Access
th(style={width: '150px'}) Access
th(style={width: '50px'})
th(style={width: '50px'})
tbody
tbody
tr(v-for='right in rights')
tr(v-for='right in rights'
, v-cloak
)
td.is-icon
td.is-icon
i.icon-marquee-plus.is-green(v-if='!right.deny')
i.icon-marquee-plus.is-green(v-if='!right.deny')
i.icon-marquee-minus.is-red(v-if='right.deny')
i.icon-marquee-minus.is-red(v-if='right.deny')
...
@@ -87,28 +89,38 @@ block adminContent
...
@@ -87,28 +89,38 @@ block adminContent
option(value='false') Allow
option(value='false') Allow
option(value='true') Deny
option(value='true') Deny
td.is-centered.has-action-icons
td.is-centered.has-action-icons
i.icon-delete.is-red
i.icon-delete.is-red(v-on:click='removeRightsRow(right._id)')
tr(v-if='rights.length < 1', v-cloak)
td.is-icon
td.is-centered(colspan='3'): em No additional access rights
td.is-centered.has-action-icons
.table-actions
.table-actions
button.button.is-blue
button.button.is-blue
(v-on:click='addRightsRow')
i.icon-plus
i.icon-plus
span Add New Row
span Add New Row
section
section
label.label Role Override
label.label Role Override
p.control.is-fullwidth
p.control.is-fullwidth
select(v-model='roleoverride')
select(v-model='roleoverride'
, disabled=!usrOpts.canChangeRole
)
option(value='none') None
option(value='none') None
option(value='admin') Global Administrator
option(value='admin') Global Administrator
.columns.is-gapless
.columns.is-gapless
.column
.column
section
section
button.button.is-green
button.button.is-green
(v-on:click='saveUser')
i.icon-check
i.icon-check
span Save Changes
span Save Changes
button.button.is-grey.is-outlined
a.button.button.is-grey.is-outlined(href='/admin/users')
i.icon-cancel
i.icon-cancel
span Discard
span Discard
.column.is-narrow
.column.is-narrow
section
section
button.button.is-red
if usrOpts.canBeDeleted
i.icon-trash2
button.button.is-red.btn-deluser-prompt
span Delete Account
i.icon-trash2
span Delete Account
include ../../modals/admin-deleteuser.pug
script(type='text/javascript').
var usrData = !{JSON.stringify(usr)};
\ No newline at end of file
views/pages/admin/users.pug
View file @
ec6f32d2
...
@@ -8,7 +8,7 @@ block rootNavRight
...
@@ -8,7 +8,7 @@ block rootNavRight
span Create / Authorize User
span Create / Authorize User
block adminContent
block adminContent
#page-type-admin
#page-type-admin
-users
.hero
.hero
h1.title#title Users
h1.title#title Users
h2.subtitle Manage users and access rights
h2.subtitle Manage users and access rights
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment