|
|
@@ -2,7 +2,7 @@
|
|
|
include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_right.php");
|
|
|
?>
|
|
|
<!doctype html>
|
|
|
-<html class="fixed">
|
|
|
+<html class="fixed sidebar-left-collapsed">
|
|
|
|
|
|
<head>
|
|
|
<!-- Basic -->
|
|
|
@@ -36,6 +36,9 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
<!-- Theme Custom CSS -->
|
|
|
<link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
|
|
|
|
|
|
+ <!-- Role Custom CSS -->
|
|
|
+ <link rel="stylesheet" href="assets/stylesheets/role.css" />
|
|
|
+
|
|
|
<!-- Head Libs -->
|
|
|
<script src="assets/vendor/modernizr/modernizr.js"></script>
|
|
|
<script src="assets/vendor/jquery/jquery.js"></script>
|
|
|
@@ -49,13 +52,19 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
<script src="./script/js/global.js"></script>
|
|
|
|
|
|
<style>
|
|
|
- td{
|
|
|
- font-size:20px;
|
|
|
- color:black;
|
|
|
+ td {
|
|
|
+ font-size: 20px;
|
|
|
+ color: black;
|
|
|
+ }
|
|
|
+
|
|
|
+ select {
|
|
|
+ font-size: 12px;
|
|
|
+ color: black;
|
|
|
}
|
|
|
- select{
|
|
|
- font-size:12px;
|
|
|
- color:black;
|
|
|
+
|
|
|
+ .right {
|
|
|
+ position: absolute;
|
|
|
+ right: 8px;
|
|
|
}
|
|
|
</style>
|
|
|
|
|
|
@@ -64,54 +73,132 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
var pageHeader = '帳號權限管理系統';
|
|
|
var role = '<?php echo ($groupName); ?>';
|
|
|
var roles;
|
|
|
- getDeptUser();
|
|
|
+ var users;
|
|
|
+ var groups;
|
|
|
+ var groupDropdown;
|
|
|
|
|
|
+ var test;
|
|
|
|
|
|
function getDeptUser() {
|
|
|
$.ajax({
|
|
|
- url: "./script/php/get_data/get_dept_user.php",
|
|
|
+ url: "./script/php/API/get_dept_user.php",
|
|
|
type: "POST",
|
|
|
dataType: "json"
|
|
|
}).done(function(result) {
|
|
|
- console.log(result);
|
|
|
- result.forEach(function(data){
|
|
|
+ roles = result.permissions;
|
|
|
+ users = result.users;
|
|
|
+ users.forEach(function(data) {
|
|
|
+ let btn = getPermissions(data.GroupID, data.GroupName);
|
|
|
$('#table-data').append(`<tr>
|
|
|
<td>${data.UserID}</td>
|
|
|
<td>${data.Account}</td>
|
|
|
<td>${data.UserName}</td>
|
|
|
<td>${data.DepartmentID}</td>
|
|
|
- <td>
|
|
|
- <select name="right" id="right">
|
|
|
- <option value="User">一般用戶</option>
|
|
|
- <option value="Editor">上傳人員</option>
|
|
|
- <option value="Dadmin">部門管理員</option>
|
|
|
- </select>
|
|
|
+ <td id="${data.UserID}">
|
|
|
+ <div class="btn-group">
|
|
|
+ <button type="button" class="mb-xs mt-xs mr-xs btn btn-default dropdown-toggle" data-toggle="dropdown">新增身分 <span class="caret"></span></button>
|
|
|
+ <ul class="dropdown-menu" role="menu" style="cursor: default;">
|
|
|
+ ${groupDropdown}
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ ${btn}
|
|
|
</td>
|
|
|
- </tr>`);
|
|
|
+ </tr>`);
|
|
|
+
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}).error(function(error) {
|
|
|
console.log(error);
|
|
|
+ }).complete(function(e) {
|
|
|
+ $('#datatable').DataTable({
|
|
|
+ bProcessing: true,
|
|
|
+ responsive: true,
|
|
|
+ "searching": true,
|
|
|
+ "pageLength": 10,
|
|
|
+ "language": {
|
|
|
+ "processing": "處理中...",
|
|
|
+ "loadingRecords": "載入中...",
|
|
|
+ "lengthMenu": "顯示 _MENU_ 項結果",
|
|
|
+ "zeroRecords": "沒有符合的結果或是沒有資料",
|
|
|
+ "info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
|
|
+ "infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
|
|
+ "infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
|
|
+ "infoPostFix": "",
|
|
|
+ "search": "",
|
|
|
+ "paginate": {
|
|
|
+ "first": '<i class="fa fa-step-backward"></i>',
|
|
|
+ "previous": '<i class="fa fa-backward"></i>',
|
|
|
+ "next": '<i class="fa fa-forward"></i>',
|
|
|
+ "last": '<i class="fa fa-step-forward"></i>'
|
|
|
+ },
|
|
|
+ "aria": {
|
|
|
+ "sortAscending": ": 升冪排列",
|
|
|
+ "sortDescending": ": 降冪排列"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ $('body .dropdown-toggle').dropdown();
|
|
|
+ $("body").on('click', '.groupDropdown', function(e) {
|
|
|
+ let groupName = $(this).text();
|
|
|
+ let groupID = $(this).attr('groupID');
|
|
|
+ let userAccount = $(this).closest("td").attr('id');
|
|
|
+ $(this).closest("td").append(addPermission(groupID, groupName, userAccount));
|
|
|
+ })
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function getPageGroup() {
|
|
|
+ function getGroup() {
|
|
|
$.ajax({
|
|
|
- url: "./script/php/get_data/get_page_group.php",
|
|
|
+ url: "./script/php/API/get_group.php",
|
|
|
type: "POST",
|
|
|
dataType: "json"
|
|
|
}).done(function(result) {
|
|
|
- for (const [key, value] of Object.entries(result)) {
|
|
|
- object = {};
|
|
|
- object['id'] = 't';
|
|
|
- object['idd'] = 'tt';
|
|
|
- object["title"] = key;
|
|
|
- roles.push(object);
|
|
|
- result[key].forEach(function(item) {
|
|
|
-
|
|
|
- })
|
|
|
- }
|
|
|
+ groups = result;
|
|
|
+ groupDropdown = '';
|
|
|
+ groups.forEach(function(group) {
|
|
|
+ groupDropdown += `<li class="li-${group.GroupID}"><a groupID="${group.GroupID}" class="groupDropdown" >${group.GroupName}</a></li>`;
|
|
|
+ });
|
|
|
+ }).error(function(error) {
|
|
|
+ console.log(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
+ function getPermissions(id, roles) {
|
|
|
+ var result = "";
|
|
|
+
|
|
|
+ roles.forEach(function(role, index) {
|
|
|
+ disabled = (role == '一般用戶' || role == '來賓') ? '' : '';
|
|
|
+ result += `<button class="btn btn-${id[index]}" ${disabled}>${role}</button> `;
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ function addPermission(id, role, userID) {
|
|
|
+ var result = "";
|
|
|
+ user = users.find(user => user.UserID == userID);
|
|
|
+ if (!user.GroupName.includes(role)) {
|
|
|
+ result += `<button class="btn btn-${id}">${role}</button> `;
|
|
|
+ addPermissionDB(user.UserID, id);
|
|
|
+ user.GroupName.push(role);
|
|
|
+ user.GroupID.push(id);
|
|
|
+ return result;
|
|
|
+ } else {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function addPermissionDB(userID, groupID) {
|
|
|
+ $.ajax({
|
|
|
+ url: "./script/php/API/insert_role.php",
|
|
|
+ type: "POST",
|
|
|
+ dataType: "text",
|
|
|
+ data: {
|
|
|
+ UserID: userID,
|
|
|
+ GroupID:groupID,
|
|
|
+ }
|
|
|
+ }).done(function(result) {
|
|
|
+ console.log(result);
|
|
|
}).error(function(error) {
|
|
|
console.log(error);
|
|
|
});
|
|
|
@@ -126,13 +213,13 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
<!-- end: header -->
|
|
|
<div class="inner-wrapper">
|
|
|
<!-- start: sidebar -->
|
|
|
- <side-bar></side-bar>
|
|
|
+ <side-bar-hide></side-bar-hide>
|
|
|
<!-- end: sidebar -->
|
|
|
<section role="main" class="content-body" id="contentBody">
|
|
|
<header class="page-header">
|
|
|
<h2>{{pageHeader}}</h2>
|
|
|
</header>
|
|
|
- <role-block v-for="item in roles" v-bind:tbodyId='item.id' v-bind:title='item.title' v-bind:tableId='item.idd'></role-block>
|
|
|
+ <!-- <role-block v-for="item in roles" v-bind:tbodyId='item.id' v-bind:title='item.title' v-bind:tableId='item.idd'></role-block> -->
|
|
|
|
|
|
<section class="panel">
|
|
|
<header class="panel-heading">
|
|
|
@@ -140,7 +227,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
<a href="#" class="fa fa-caret-down"></a>
|
|
|
<a href="#" class="fa fa-times"></a>
|
|
|
</div>
|
|
|
- <h2 class="panel-title">設計資料庫查詢系統</h2>
|
|
|
+ <h2 id="testID" class="panel-title">所有系統</h2>
|
|
|
</header>
|
|
|
<div class="panel-body">
|
|
|
<table class="table table-bordered table-striped mb-none" id="datatable">
|
|
|
@@ -167,10 +254,12 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
|
|
|
|
|
|
<script>
|
|
|
vm.mount('.body');
|
|
|
+ getGroup();
|
|
|
+ getDeptUser();
|
|
|
+ $(function() {
|
|
|
+
|
|
|
|
|
|
- $(document).ready(function() {
|
|
|
- $('#datatable').dataTable();
|
|
|
- })
|
|
|
+ });
|
|
|
</script>
|
|
|
|
|
|
|