add blocks
This commit is contained in:
23
static/blocks/pages/ACL/content.md
Normal file
23
static/blocks/pages/ACL/content.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Панель администратора ACL
|
||||
|
||||
## Создать роль
|
||||
|
||||
<input id="roleName" placeholder="имя роли" />
|
||||
<button onclick="createRole()">Создавать</button>
|
||||
|
||||
## Создать разрешение
|
||||
|
||||
<input id="permKey" placeholder="ключ разрешения" />
|
||||
<button onclick="createPerm()">Создавать</button>
|
||||
|
||||
## Назначить разрешение роли
|
||||
|
||||
<input id="roleIdPerm" placeholder="идентификатор роли" />
|
||||
<input id="permIdRole" placeholder="идентификатор разрешения" />
|
||||
<button onclick="assignPermission()">Назначать</button>
|
||||
|
||||
## Назначить роль пользователю
|
||||
|
||||
<input id="roleIdUser" placeholder="идентификатор роли" />
|
||||
<input id="userIdRole" placeholder="идентификатор пользователя" />
|
||||
<button onclick="assignRole()">Назначать</button>
|
||||
27
static/blocks/pages/ACL/script.js
Normal file
27
static/blocks/pages/ACL/script.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const api = (url, data, m) => fetch(url, {
|
||||
method: m,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(data)
|
||||
}).then(r => r.text());
|
||||
|
||||
|
||||
|
||||
|
||||
function createRole() {
|
||||
api('/api/acl-admin/create-role', { name: roleName.value }, "POST").then(alert);
|
||||
}
|
||||
function createPerm() {
|
||||
api('/api/acl-admin/create-permission', { name: permKey.value }, "POST").then(alert);
|
||||
}
|
||||
function assignPermission() {
|
||||
api('/api/acl-admin/assign-permission', {
|
||||
role_id: Number(roleIdPerm.value),
|
||||
perm_id: Number(permIdRole.value)
|
||||
}, "POST").then(alert);
|
||||
}
|
||||
function assignRole() {
|
||||
api('/api/acl-admin/assign-role', {
|
||||
role_id: Number(roleIdUser.value),
|
||||
user_id: Number(userIdRole.value)
|
||||
}, "POST").then(alert);
|
||||
}
|
||||
2
static/blocks/pages/ACL/style.css
Normal file
2
static/blocks/pages/ACL/style.css
Normal file
@@ -0,0 +1,2 @@
|
||||
#app { background: white; padding: 20px; border-radius: 8px; max-width: 700px; }
|
||||
input, select, button { padding: 8px; margin: 4px 0; }
|
||||
Reference in New Issue
Block a user