diff --git a/config/permission.php b/config/permission.php index 3ebc85a..82a78aa 100644 --- a/config/permission.php +++ b/config/permission.php @@ -1,7 +1,7 @@ 'admin', + 'prefix' => '/admin', 'namespace' => '\CodexShaper\Permission', 'controller_namespace' => '\CodexShaper\Permission\Http\Controllers', 'models' => [ diff --git a/resources/assets/dashboard/js/app.js b/resources/assets/dashboard/js/app.js index 4f2f116..6ab732e 100644 --- a/resources/assets/dashboard/js/app.js +++ b/resources/assets/dashboard/js/app.js @@ -2036,7 +2036,7 @@ __webpack_require__.r(__webpack_exports__); // // /* harmony default export */ __webpack_exports__["default"] = ({ - props: ['addAction', 'editAction'], + props: ['addAction', 'editAction', 'prefix'], data: function data() { return { users: [], @@ -2060,7 +2060,8 @@ __webpack_require__.r(__webpack_exports__); var _this = this; var parent = this; - fetch('/admin/users/all').then(function (res) { + var url = this.prefix + '/users/all'; + fetch(url).then(function (res) { return res.json(); }).then(function (res) { _this.destroyDataTables(); @@ -2075,7 +2076,8 @@ __webpack_require__.r(__webpack_exports__); fetchRoles: function fetchRoles() { var _this2 = this; - fetch('/admin/roles/all').then(function (res) { + var url = this.prefix + '/roles/all'; + fetch(url).then(function (res) { return res.json(); }).then(function (res) { _this2.destroyDataTables(); @@ -2085,6 +2087,9 @@ __webpack_require__.r(__webpack_exports__); return console.log(err); }); }, + showAddUserModal: function showAddUserModal(event) { + this.resetForm(); + }, addUser: function addUser(event) { var self = this; axios({ @@ -2101,14 +2106,15 @@ __webpack_require__.r(__webpack_exports__); editUser: function editUser(event) { var id = event.target.getAttribute('data-id'); var self = this; + var url = this.prefix + '/user/' + id; axios({ method: 'get', - url: '/admin/user/edit/' + id, + url: url, responseType: 'json' }).then(function (response) { // console.log( response.data ); self.user = response.data.user; - self.user.checkedRoles = response.data.userRoles; + self.user.checkedRoles = response.data.checkedRoles; }); }, updateUser: function updateUser(event) { @@ -2127,9 +2133,10 @@ __webpack_require__.r(__webpack_exports__); viewUser: function viewUser(event) { var id = event.target.getAttribute('data-id'); var parent = this; + var url = this.prefix + '/user/' + id; axios({ method: 'get', - url: '/admin/user/' + id, + url: url, responseType: 'json' }).then(function (response) { // console.log( response.data ); @@ -2138,6 +2145,8 @@ __webpack_require__.r(__webpack_exports__); }); }, deleteUser: function deleteUser(event) { + var _this3 = this; + event.preventDefault(); var id = event.target.getAttribute('data-id'); var self = this; @@ -2150,9 +2159,10 @@ __webpack_require__.r(__webpack_exports__); cancelButtonText: 'No, keep it' }).then(function (result) { if (result.value) { + var url = _this3.prefix + '/user/' + id; axios({ method: 'delete', - url: '/admin/user/delete/' + id + url: url }).then(function (response) { // console.log( response.data ); // self.resetForm(); @@ -40454,7 +40464,27 @@ var render = function() { var _c = _vm._self._c || _h return _c("div", { staticClass: "users-container" }, [ _c("div", { staticClass: "card shadow mb-4" }, [ - _vm._m(0), + _c("div", { staticClass: "card-header py-3" }, [ + _c("h6", { staticClass: "m-0 font-weight-bold text-primary" }, [ + _c( + "a", + { + staticClass: "btn btn-success btn-icon-split", + attrs: { + href: "#", + "data-toggle": "modal", + "data-target": "#addUserModal" + }, + on: { click: _vm.showAddUserModal } + }, + [ + _vm._m(0), + _vm._v(" "), + _c("span", { staticClass: "text" }, [_vm._v("Add User")]) + ] + ) + ]) + ]), _vm._v(" "), _c("div", { staticClass: "card-body" }, [ _c("div", { staticClass: "table-responsive" }, [ @@ -41146,27 +41176,8 @@ var staticRenderFns = [ var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h - return _c("div", { staticClass: "card-header py-3" }, [ - _c("h6", { staticClass: "m-0 font-weight-bold text-primary" }, [ - _c( - "a", - { - staticClass: "btn btn-success btn-icon-split", - attrs: { - href: "#", - "data-toggle": "modal", - "data-target": "#addUserModal" - } - }, - [ - _c("span", { staticClass: "icon text-white-50" }, [ - _c("i", { staticClass: "fas fa-plus" }) - ]), - _vm._v(" "), - _c("span", { staticClass: "text" }, [_vm._v("Add User")]) - ] - ) - ]) + return _c("span", { staticClass: "icon text-white-50" }, [ + _c("i", { staticClass: "fas fa-plus" }) ]) }, function() { @@ -53697,8 +53708,8 @@ __webpack_require__.r(__webpack_exports__); /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(/*! G:\laravel\dashboard\packages\package\laravel-permission\resources\assets\js\app.js */"./resources/assets/js/app.js"); -module.exports = __webpack_require__(/*! G:\laravel\dashboard\packages\package\laravel-permission\resources\assets\sass\app.scss */"./resources/assets/sass/app.scss"); +__webpack_require__(/*! G:\laravel\packages\package\laravel-permission\resources\assets\js\app.js */"./resources/assets/js/app.js"); +module.exports = __webpack_require__(/*! G:\laravel\packages\package\laravel-permission\resources\assets\sass\app.scss */"./resources/assets/sass/app.scss"); /***/ }) diff --git a/resources/assets/dashboard/js/custom.js b/resources/assets/dashboard/js/custom.js index fa55cb5..aee43fd 100644 --- a/resources/assets/dashboard/js/custom.js +++ b/resources/assets/dashboard/js/custom.js @@ -21,7 +21,7 @@ if( result.success == true ) { var viewBtn = 'View '; - var editBtn = 'Edit '; + var editBtn = 'Edit '; var deleteBtn = 'Delete '; $('#role_table').DataTable().row.add([ @@ -36,7 +36,7 @@ } }, error: function(err){ - console.log( err ); + // console.log( err ); } }); }); @@ -48,7 +48,7 @@ // var action = $(this).data('action'); $.ajax({ - url: '/admin/role/'+id, + url: permission_prefix+'/role/'+id, method: 'GET', dataType: 'json', data: { @@ -76,7 +76,7 @@ } }, error: function( err ){ - console.log(err); + // console.log(err); } }); }); @@ -95,7 +95,7 @@ 'id' : id }, success: function(result){ - console.log( result ); + // console.log( result ); if( result.success == true ){ document.getElementById("edit_role_form").reset(); var form = $('#edit_role_form'); @@ -119,7 +119,7 @@ } }, error: function( err ){ - console.log(err); + // console.log(err); } }); }); @@ -147,7 +147,7 @@ var row_id = $('#row_'+result.role.id).data("row"); var viewBtn = 'View '; - var editBtn = 'Edit '; + var editBtn = 'Edit '; var deleteBtn = 'Delete '; $('#role_table').DataTable().row(row_id).data([ @@ -162,7 +162,7 @@ } }, error: function( err ) { - console.log( err ); + // console.log( err ); } }); }); @@ -179,7 +179,7 @@ }).then((result) => { if (result.value) { $.ajax({ - url: '/admin/role/delete', + url: permission_prefix+'/role', method: 'POST', dataType: 'json', data: { @@ -188,7 +188,7 @@ 'role_id': $(this).data('id'), }, success: function(result){ - console.log( result ); + // console.log( result ); if( result.success == true ) { // console.log( data ); Swal.fire( @@ -207,7 +207,7 @@ } }, error: function(err){ - console.log( err ); + // console.log( err ); } }); } else if (result.dismiss === Swal.DismissReason.cancel) { @@ -242,11 +242,11 @@ cache: false, processData: false, success: function(result){ - console.log( result ); + // console.log( result ); if( result.success == true ) { var viewBtn = 'View '; - var editBtn = 'Edit '; + var editBtn = 'Edit '; var deleteBtn = 'Delete '; $('#permission_table').DataTable().row.add([ @@ -261,7 +261,7 @@ } }, error: function(err){ - console.log( err ); + // console.log( err ); } }); }); @@ -273,14 +273,14 @@ // var action = $(this).data('action'); $.ajax({ - url: '/admin/permission/'+id, + url: permission_prefix+'/permission/'+id, method: 'GET', dataType: 'json', data: { 'id' : id }, success: function(result){ - console.log( result ); + // console.log( result ); if( result.success == true ){ var form = $('#edit_permission_form'); $("#permission_id").val(id); @@ -291,7 +291,7 @@ } }, error: function( err ){ - console.log(err); + // console.log(err); } }); }); @@ -310,7 +310,7 @@ 'id' : id }, success: function(result){ - console.log( result ); + // console.log( result ); if( result.success == true ){ document.getElementById("edit_permission_form").reset(); @@ -335,7 +335,7 @@ } }, error: function( err ){ - console.log(err); + // console.log(err); } }); }); @@ -358,12 +358,12 @@ cache: false, processData: false, success: function( result ){ - console.log( result ); + // console.log( result ); if( result.success == true ) { var row_id = $('#row_'+result.permission.id).data("row"); var viewBtn = 'View '; - var editBtn = 'Edit '; + var editBtn = 'Edit '; var deleteBtn = 'Delete '; $('#permission_table').DataTable().row(row_id).data([ @@ -378,7 +378,7 @@ } }, error: function( err ) { - console.log( err ); + // console.log( err ); } }); }); @@ -395,7 +395,7 @@ }).then((result) => { if (result.value) { $.ajax({ - url: '/admin/permission/delete', + url: permission_prefix+'/permission', method: 'POST', dataType: 'json', data: { @@ -404,7 +404,7 @@ 'permission_id': $(this).data('id'), }, success: function(result){ - console.log( result ); + // console.log( result ); if( result.success == true ) { // console.log( data ); Swal.fire( @@ -423,7 +423,7 @@ } }, error: function(err){ - console.log( err ); + // console.log( err ); } }); } else if (result.dismiss === Swal.DismissReason.cancel) { diff --git a/resources/assets/js/components/Users.vue b/resources/assets/js/components/Users.vue index 82dde24..9d852eb 100644 --- a/resources/assets/js/components/Users.vue +++ b/resources/assets/js/components/Users.vue @@ -3,7 +3,7 @@
- + Add User @@ -164,7 +164,7 @@