Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
d044f847
Commit
d044f847
authored
Feb 27, 2018
by
cygnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes done for changing user javascript to one admin.js
parent
25fa8361
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
432 additions
and
391 deletions
+432
-391
composer.lock
composer.lock
+262
-202
admin.js
public/js/backend/admin.js
+151
-47
create.blade.php
resources/views/backend/access/users/create.blade.php
+4
-58
deactivated.blade.php
resources/views/backend/access/users/deactivated.blade.php
+1
-37
deleted.blade.php
resources/views/backend/access/users/deleted.blade.php
+8
-44
edit.blade.php
resources/views/backend/access/users/edit.blade.php
+6
-3
No files found.
composer.lock
View file @
d044f847
This diff is collapsed.
Click to expand it.
public/js/backend/admin.js
View file @
d044f847
...
...
@@ -109,21 +109,131 @@ var Backend = {}; // common variable used in all the files of the backend
{
selectors
:
{
select2
:
$
(
"
.select2
"
),
getPremissionURL
:
""
,
Areyousure
:
""
,
delete_user_confirm
:
""
,
continue
:
""
,
cancel
:
""
,
restore_user_confirm
:
""
,
},
init
:
function
()
init
:
function
(
page
)
{
this
.
setSelectors
();
this
.
addHandlers
();
this
.
addHandlers
(
page
);
},
setSelectors
:
function
(){
this
.
selectors
.
select2
=
$
(
"
.select2
"
);
},
addHandlers
:
function
()
addHandlers
:
function
(
page
)
{
/**
* This function is used to get clicked element role id and return required result
*/
document
.
querySelectorAll
(
"
.get-role-for-permissions
"
).
forEach
(
function
(
element
){
element
.
onclick
=
function
(
event
){
callback
=
{
success
:
function
(
request
){
console
.
log
(
"
request
"
,
request
,
request
.
status
);
if
(
request
.
status
>=
200
&&
request
.
status
<
400
)
{
// Success!
var
response
=
JSON
.
parse
(
request
.
responseText
);
var
p
=
response
.
permissions
;
var
q
=
response
.
rolePermissions
;
var
qAll
=
response
.
allPermissions
;
document
.
querySelector
(
"
.get-available-permissions
"
).
innerHTML
=
""
;
htmlstring
=
""
;
if
(
p
.
length
==
0
)
{
document
.
querySelector
(
"
.get-available-permissions
"
).
innerHTML
=
'
<p>There are no available permissions.</p>
'
;
}
else
{
for
(
var
key
in
p
)
{
var
addChecked
=
''
;
if
(
qAll
==
1
&&
q
.
length
==
0
)
{
addChecked
=
'
checked="checked"
'
;
}
else
{
if
(
typeof
q
[
key
]
!==
"
undefined
"
)
{
addChecked
=
'
checked="checked"
'
;
}
}
htmlstring
+=
'
<label class="control control--checkbox"> <input type="checkbox" name="permissions[
'
+
key
+
'
]" value="
'
+
key
+
'
" id="perm_
'
+
key
+
'
"
'
+
addChecked
+
'
/> <label for="perm_
'
+
key
+
'
">
'
+
p
[
key
]
+
'
</label> <div class="control__indicator"></div> </label> <br>
'
;
}
}
document
.
querySelector
(
"
.get-available-permissions
"
).
innerHTML
=
htmlstring
;
Backend
.
Utils
.
removeClass
(
document
.
getElementById
(
"
available-permissions
"
),
'
hidden
'
);
}
else
{
// We reached our target server, but it returned an error
console
.
log
(
"
errror in request
"
);
document
.
querySelector
(
"
.get-available-permissions
"
).
innerHTML
=
'
<p>There are no available permissions.</p>
'
;
}
},
error
:
function
(){
console
.
log
(
"
errror
"
);
document
.
querySelector
(
"
.get-available-permissions
"
).
innerHTML
=
'
<p>There are no available permissions.</p>
'
;
}
};
Backend
.
Utils
.
ajaxrequest
(
Backend
.
Access
.
selectors
.
getPremissionURL
,
"
post
"
,{
role_id
:
event
.
target
.
value
},
csrf
,
callback
);
}
});
if
(
page
==
"
create
"
){
document
.
getElementById
(
"
role-3
"
).
click
();
}
this
.
selectors
.
select2
.
select2
();
},
windowloadhandler
:
function
(){
/*
deleted page showing the swal when click on peremenenant delition
*/
document
.
querySelectorAll
(
"
a[name='delete_user_perm']
"
).
forEach
(
function
(
element
){
element
.
onclick
=
function
(
event
){
event
.
preventDefault
();
var
linkURL
=
event
.
target
.
getAttribute
(
"
href
"
);
swal
({
title
:
Backend
.
Access
.
selectors
.
Areyousure
,
text
:
Backend
.
Access
.
selectors
.
delete_user_confirm
,
type
:
"
warning
"
,
showCancelButton
:
true
,
confirmButtonColor
:
"
#DD6B55
"
,
confirmButtonText
:
Backend
.
Access
.
selectors
.
continue
,
cancelButtonText
:
Backend
.
Access
.
selectors
.
cancel
,
closeOnConfirm
:
false
},
function
(
isConfirmed
){
if
(
isConfirmed
){
window
.
location
.
href
=
linkURL
;
}
});
};
});
/**
* deleted user page handeler for user restore
*/
document
.
querySelectorAll
(
"
a[name='restore_user']
"
).
forEach
(
function
(
element
){
element
.
onclick
=
function
(
event
){
event
.
preventDefault
();
var
linkURL
=
event
.
target
.
getAttribute
(
"
href
"
);
swal
({
title
:
Backend
.
Access
.
selectors
.
Areyousure
,
text
:
Backend
.
Access
.
selectors
.
restore_user_confirm
,
type
:
"
warning
"
,
showCancelButton
:
true
,
confirmButtonColor
:
"
#DD6B55
"
,
confirmButtonText
:
Backend
.
Access
.
selectors
.
continue
,
cancelButtonText
:
Backend
.
Access
.
selectors
.
cancel
,
closeOnConfirm
:
false
},
function
(
isConfirmed
){
if
(
isConfirmed
){
window
.
location
.
href
=
linkURL
;
}
});
};
});
}
},
/**
...
...
@@ -133,26 +243,18 @@ var Backend = {}; // common variable used in all the files of the backend
Blog
:
{
selectors
:
{
tags
:
document
.
querySelector
(
"
.tags
"
),
categories
:
document
.
querySelector
(
"
.categories
"
),
toDisplay
:
document
.
querySelector
(
"
.toDisplay
"
),
status
:
document
.
querySelector
(
"
.status
"
),
tags
:
jQuery
(
"
.tags
"
),
categories
:
jQuery
(
"
.categories
"
),
toDisplay
:
jQuery
(
"
.toDisplay
"
),
status
:
jQuery
(
"
.status
"
),
},
init
:
function
()
{
this
.
setSelectors
();
init
:
function
()
{
this
.
addHandlers
();
Backend
.
tinyMCE
.
init
();
},
setSelectors
:
function
(){
tags
=
document
.
querySelector
(
"
.tags
"
);
categories
=
document
.
querySelector
(
"
.categories
"
);
toDisplay
=
document
.
querySelector
(
"
.toDisplay
"
);
status
=
document
.
querySelector
(
"
.status
"
);
},
addHandlers
:
function
()
{
addHandlers
:
function
()
{
this
.
selectors
.
tags
.
select2
({
tags
:
true
,
});
...
...
@@ -162,6 +264,7 @@ var Backend = {}; // common variable used in all the files of the backend
}
},
/**
* Tiny MCE
*/
...
...
@@ -224,19 +327,20 @@ var Backend = {}; // common variable used in all the files of the backend
// ! Backend.emailTemplate.addHandlers
addHandlers
:
function
()
{
$
(
"
.select2
"
).
select2
();
// to add placeholder in to active textarea
$
(
"
#addPlaceHolder
"
).
on
(
'
click
'
,
function
(
event
)
{
document
.
getElementById
(
"
addPlaceHolder
"
).
onclick
=
function
(
event
)
{
Backend
.
emailTemplate
.
addPlaceHolder
(
event
);
}
)
;
$
(
"
#showPreview
"
).
on
(
'
click
'
,
function
(
event
)
{
};
document
.
getElementById
(
"
showPreview
"
).
onclick
=
function
(
event
)
{
Backend
.
emailTemplate
.
showPreview
(
event
);
}
)
;
this
.
selectors
.
emailtemplateSelection
.
select2
();
};
},
// ! Backend.emailTemplate.addPlaceHolder
addPlaceHolder
:
function
(
event
)
{
var
placeHolder
=
$
(
'
#placeHolder
'
).
val
()
;
var
placeHolder
=
document
.
getElementById
(
'
placeHolder
'
).
value
;
if
(
placeHolder
!=
''
)
{
tinymce
.
activeEditor
.
execCommand
(
'
mceInsertContent
'
,
false
,
"
[
"
+
$
(
'
#placeHolder :selected
'
).
text
()
+
"
]
"
);
}
...
...
@@ -244,9 +348,9 @@ var Backend = {}; // common variable used in all the files of the backend
// ! Backend.emailTemplate.showPreview
showPreview
:
function
(
event
)
{
document
.
querySelector
(
"
.modal-body
"
).
innerHTML
=
tinyMCE
.
get
(
'
txtBody
'
).
getContent
(
);
document
.
querySelector
(
"
.modal-body
"
).
modal
(
'
show
'
);
document
.
querySelector
(
"
.modal-body
"
).
innerHTML
=
tinyMCE
.
get
(
'
txtBody
'
).
getContent
();
//jQuery( ".modal-body" ).html(tinyMCE.get('txtBody').getContent()
);
$
(
"
.model-wrapper
"
).
modal
(
'
show
'
);
},
},
...
...
resources/views/backend/access/users/create.blade.php
View file @
d044f847
...
...
@@ -184,63 +184,9 @@
Backend.Utils.documentReady(function(){
Backend.Access.init();
csrf = $('meta[name="
csrf
-
token
"]').attr('content');
/**
* This function is used to get clicked element role id and return required result
*/
document.querySelectorAll("
.
get
-
role
-
for
-
permissions
").forEach(function(element){
element.onclick =function(event){
callback = {
success:function(request){
console.log("
request
",request,request.status);
if (request.status >= 200 && request.status < 400) {
// Success!
var response = JSON.parse(request.responseText);
var p = response.permissions;
var q = response.rolePermissions;
var qAll = response.allPermissions;
document.querySelector("
.
get
-
available
-
permissions
").innerHTML = "";
htmlstring = "";
if (p.length == 0) {
document.querySelector("
.
get
-
available
-
permissions
").innerHTML = '<p>There are no available permissions.</p>';
} else {
for (var key in p) {
var addChecked = '';
if (qAll == 1 && q.length == 0) {
addChecked = 'checked="
checked
"';
} else {
if (typeof q[key] !== "
undefined
") {
addChecked = 'checked="
checked
"';
}
}
htmlstring += '<label class="
control
control
--
checkbox
"> <input type="
checkbox
" name="
permissions
[
' + key + '
]
" value="
' + key + '
" id="
perm_
' + key + '
" ' + addChecked + ' /> <label for="
perm_
' + key + '
">' + p[key] + '</label> <div class="
control__indicator
"></div> </label> <br>';
}
}
document.querySelector("
.
get
-
available
-
permissions
").innerHTML = htmlstring;
Backend.Utils.removeClass(document.getElementById("
available
-
permissions
"),'hidden');
} else {
// We reached our target server, but it returned an error
console.log("
errror
in
request
");
document.querySelector("
.
get
-
available
-
permissions
").innerHTML = '<p>There are no available permissions.</p>';
}
},
error:function(){
console.log("
errror
");
document.querySelector("
.
get
-
available
-
permissions
").innerHTML = '<p>There are no available permissions.</p>';
}
};
Backend.Utils.ajaxrequest("
{{
route
(
'admin.get.permission'
)
}}
","
post
",{role_id: event.target.value ,"
_tocken
":csrf},csrf,callback);
}
});
document.getElementById("
role
-
3
").click();
csrf = document.querySelector('meta[name="
csrf
-
token
"]').getAttribute('content');
Backend.Access.selectors.getPremissionURL = "
{{
route
(
'admin.get.permission'
)
}}
";
Backend.Access.init("
create
");
});
</script>
...
...
resources/views/backend/access/users/deactivated.blade.php
View file @
d044f847
...
...
@@ -75,7 +75,6 @@
'X-CSRF-TOKEN': $('meta[name="
csrf
-
token
"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
...
...
@@ -110,41 +109,6 @@
Backend.DataTableSearch.init(dataTable);
})();
/*
$(function() {
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("
admin
.
access
.
user
.
get
") }}',
type: 'post',
data: {status: 0, trashed: false}
},
columns: [
{data: 'first_name', name: '
{
{config('access.users_table')}}.first_name'
}
,
{data: 'last_name', name: '
{
{config('access.users_table')}}.last_name'
}
,
{data: 'email', name: '
{
{config('access.users_table')}}.email'
}
,
{data: 'confirmed', name: '
{
{config('access.users_table')}}.confirmed'
}
,
{data: 'roles', name: '
{
{config('access.roles_table')}
}
.name', sortable: false},
{data: 'created_at', name: '
{
{config('access.users_table')}}.created_at'
}
,
{data: 'updated_at', name: '
{
{config('access.users_table')}}.updated_at'
}
,
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[0, "
asc
"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }}
]
}
});
Backend.DataTableSearch.init(dataTable);
});*/
</script>
@endsection
resources/views/backend/access/users/deleted.blade.php
View file @
d044f847
...
...
@@ -109,55 +109,19 @@
Backend.DataTableSearch.init(dataTable);
Backend.Access.selectors.Areyousure = "
{{
trans
(
'strings.backend.general.are_you_sure'
)
}}
";
Backend.Access.selectors.delete_user_confirm = "
{{
trans
(
'strings.backend.access.users.delete_user_confirm'
)
}}
";
Backend.Access.selectors.continue = "
{{
trans
(
'strings.backend.general.continue'
)
}}
";
Backend.Access.selectors.cancel ="
{{
trans
(
'buttons.general.cancel'
)
}}
";
Backend.Access.selectors.restore_user_confirm ="
{{
trans
(
'strings.backend.access.users.restore_user_confirm'
)
}}
";
})();
window.onload = function(){
document.querySelectorAll("
a
[
name
=
'delete_user_perm'
]
").forEach(function(element){
element.onclick = function(event){
event.preventDefault();
var linkURL = event.target.getAttribute("
href
");
swal({
title: "
{{
trans
(
'strings.backend.general.are_you_sure'
)
}}
",
text: "
{{
trans
(
'strings.backend.access.users.delete_user_confirm'
)
}}
",
type: "
warning
",
showCancelButton: true,
confirmButtonColor: "
#DD6B55",
confirmButtonText
:
"{{ trans('strings.backend.general.continue') }}"
,
cancelButtonText
:
"{{ trans('buttons.general.cancel') }}"
,
closeOnConfirm
:
false
},
function
(
isConfirmed
){
if
(
isConfirmed
){
window
.
location
.
href
=
linkURL
;
Backend.Access.windowloadhandler();
}
});
}
})
document
.
querySelectorAll
(
"a[name='restore_user']"
)
.
forEach
(
function
(
element
){
element
.
onclick
=
function
(
event
){
event
.
preventDefault
();
var
linkURL
=
event
.
target
.
getAttribute
(
"href"
);
swal
({
title
:
"{{ trans('strings.backend.general.are_you_sure') }}"
,
text
:
"{{ trans('strings.backend.access.users.restore_user_confirm') }}"
,
type
:
"warning"
,
showCancelButton
:
true
,
confirmButtonColor
:
"#DD6B55"
,
confirmButtonText
:
"{{ trans('strings.backend.general.continue') }}"
,
cancelButtonText
:
"{{ trans('buttons.general.cancel') }}"
,
closeOnConfirm
:
false
},
function
(
isConfirmed
){
if
(
isConfirmed
){
window
.
location
.
href
=
linkURL
;
}
});
}
})
};
</script>
@endsection
resources/views/backend/access/users/edit.blade.php
View file @
d044f847
...
...
@@ -211,14 +211,17 @@
*/
Backend.Utils.documentReady(function(){
csrf = document.querySelector('meta[name="
csrf
-
token
"]').getAttribute('content');
Backend.Access.selectors.getPremissionURL = "
{{
route
(
'admin.get.permission'
)
}}
";
Backend.Access.init("
edit
");
/*
Backend.Access.init();
csrf = $('meta[name="
csrf
-
token
"]').attr('content');
/**
* This function is used to get clicked element role id and return required result
*/
document.querySelectorAll("
.
get
-
role
-
for
-
permissions
").forEach(function(element){
/*
document.querySelectorAll("
.
get
-
role
-
for
-
permissions
").forEach(function(element){
element.onclick =function(event){
callback = {
success:function(request){
...
...
@@ -266,7 +269,7 @@
Backend.Utils.ajaxrequest("
{{
route
(
'admin.get.permission'
)
}}
","
post
",{role_id: event.target.value ,"
_tocken
":csrf},csrf,callback);
}
});
*/
});
...
...
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