Initial commit
This commit is contained in:
1 parent
bd472155ce
commit
a1ea747e34
8 files changed
+5167
-1
No files matched your search
File diff suppressed because it is too large.
Load diff
Vendored
+1
@@ -0,0 +1 @@
|
||||
:root .wl{--font-family:system-ui,-apple-system,"Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--line-height:1.5em;--font-weight:400;--font-size:16px;--border-radius:0.25em;--border-width:1px;--outline-width:3px;--spacing:1em;--typography-spacing-vertical:1.5em;--block-spacing-vertical:calc(var(--spacing) * 2);--block-spacing-horizontal:var(--spacing);--grid-spacing-vertical:0;--grid-spacing-horizontal:var(--spacing);--form-element-spacing-vertical:0.75em;--form-element-spacing-horizontal:1em;--box-header-spaceing:0.25em;--transition:0.2s ease-in-out;--nav-color:#f5f5f5;--icon-external:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(115,130,140,0.999)' opacity='0.66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E");--icon-check:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FFF' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-check-dark:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.75)' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-chevron-white:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");--icon-date:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");--icon-time:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");--icon-search:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(65,84,98,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");--icon-checkbox:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FFF' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-minus:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FFF' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'%3E%3C/line%3E%3C/svg%3E");--icon-valid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(56,142,60,0.999)' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");--icon-invalid:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(198,40,40,0.999)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E")}@media (min-width:36em){:root .wl{--font-size:17px}}@media (min-width:48em){:root .wl{--font-size:18px}}@media (min-width:62em){:root .wl{--font-size:19px}}@media (min-width:75em){:root .wl{--font-size:20px}}[data-theme=light] .wl,.wl [data-theme=light],:not([data-theme=dLine truncated
|
||||
@@ -0,0 +1,210 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
var changes = {};
|
||||
$('body').on('click', '#add-role', function (e) {
|
||||
e.preventDefault();
|
||||
var end_point = wl_rm.ajax_url;
|
||||
var val = $('#add-role-name').val();
|
||||
$.post(end_point, {'action': 'add_role', 'new_role': val, security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
alert(response.message);
|
||||
$('#add-role-name').val('');
|
||||
laod_data();
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
});
|
||||
$('body').on('click', '#remove-role', function (e) {
|
||||
e.preventDefault();
|
||||
var end_point = wl_rm.ajax_url;
|
||||
var val = $('#remove-role-name').val();
|
||||
$.post(end_point, {'action': 'remove_role', 'remove_role': val, security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
alert(response.message);
|
||||
laod_data();
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
});
|
||||
$('body').on('click', '#add-capability', function (e) {
|
||||
e.preventDefault();
|
||||
var end_point = wl_rm.ajax_url;
|
||||
var val = $('#add-capability-name').val();
|
||||
$.post(end_point, {'action': 'add_capability', 'add_capability': val, security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
alert(response.message);
|
||||
laod_data();
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
});
|
||||
$('body').on('click', '#remove-capability', function (e) {
|
||||
e.preventDefault();
|
||||
var end_point = wl_rm.ajax_url;
|
||||
var val = $('#remove-capability-name').val();
|
||||
$.post(end_point, {'action': 'remove_capability', 'remove_capability': val, security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
alert(response.message);
|
||||
laod_data();
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
});
|
||||
$('body').on('click', '#submit', function (e) {
|
||||
e.preventDefault();
|
||||
var end_point = wl_rm.ajax_url;
|
||||
var val = JSON.stringify(changes);
|
||||
console.log(val);
|
||||
input = {'action': 'save_capability', 'data': changes, security: wl_rm.security};
|
||||
console.log(input);
|
||||
$.post(end_point, input, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
console.log(response.message);
|
||||
alert(response.message);
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
console.log(response);
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
});
|
||||
$('body').on('change', 'input[type="checkbox"]', function (e) {
|
||||
role = $(this).attr('data-role');
|
||||
capability = $(this).attr('data-capability');
|
||||
if (!(role in changes)) {
|
||||
changes[role] = {};
|
||||
}
|
||||
if (capability in changes[role]) {
|
||||
delete changes[role][capability];
|
||||
} else {
|
||||
if ($(this).is(':checked')) {
|
||||
|
||||
changes[role][capability] = 1;
|
||||
} else {
|
||||
changes[role][capability] = 0;
|
||||
|
||||
}
|
||||
}
|
||||
if (Object.keys(changes[role]).length == 0) {
|
||||
delete changes[role];
|
||||
}
|
||||
console.log(JSON.stringify(changes));
|
||||
});
|
||||
function load_combo_roles() {
|
||||
comboRoles = '<option value="0"> -------- </option>';
|
||||
var end_point = wl_rm.ajax_url;
|
||||
$.post(end_point, {'action': 'get_editable_roles', security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
roles = response.data;
|
||||
for (var key in roles) {
|
||||
comboRoles = comboRoles + '<option value="' + key + '">' + roles[key] + '</option>';
|
||||
}
|
||||
$('#remove-role-name').html(comboRoles);
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
}
|
||||
function load_combo_capabilities() {
|
||||
comboCapabilities = '<option value="0"> -------- </option>';
|
||||
var end_point = wl_rm.ajax_url;
|
||||
$.post(end_point, {'action': 'get_capabilities', security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
capabilities = response.data;
|
||||
for (var key in capabilities) {
|
||||
comboCapabilities = comboCapabilities + '<option value="' + key + '">' + key + '</option>';
|
||||
}
|
||||
$('#remove-capability-name').html(comboCapabilities);
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
}
|
||||
function load_role_tabs() {
|
||||
navContent = '';
|
||||
tabContent = '';
|
||||
var end_point = wl_rm.ajax_url;
|
||||
$.post(end_point, {'action': 'get_roles', security: wl_rm.security}, function (response) {
|
||||
|
||||
var response = JSON.parse(response);
|
||||
if (response.result == 'success') {
|
||||
allCap = response.data.administrator.capabilities || {};
|
||||
delete response.data.administrator;
|
||||
roles = response.data;
|
||||
capability = '';
|
||||
i = 1;
|
||||
for (var role in roles) {
|
||||
hidden = (i == 1) ? "" : "hidden";
|
||||
checked = (i == 1) ? 'checked = "checked"' : "";
|
||||
active = (i == 1) ? "nav-tab-active" : "";
|
||||
navContent += '<a href="javascript: void(0)" onclick="showTab(this, ' + i + ')" class="nav-tab ' + active + '">' + roles[role].name + '</a>';
|
||||
tabContent += '<input id="tab-' + i + '" type="radio" name="roles" ' + checked + ' >' +
|
||||
'<label for="tab-' + i + '">' + roles[role].name + '</label>' +
|
||||
'<div class ="tab">';
|
||||
|
||||
for (var key in allCap) {
|
||||
checked = roles[role].capabilities[key] ? ' checked="checked"' : '';
|
||||
capability = '<span class="inb">' +
|
||||
'<label for="' + role + '-' + key + '" >' +
|
||||
'<input id="' + role + '-' + key + '" type="checkbox" name="' + role + '-' + key + '"' + checked + ' data-role="' + role + '" data-capability="' + key + '" ' + ' role="switch" >' +
|
||||
key +
|
||||
'</label>' +
|
||||
'</span>';
|
||||
tabContent += capability;
|
||||
}
|
||||
tabContent += '</div>';
|
||||
i++;
|
||||
}
|
||||
$('#tab_wrapper').html(tabContent);
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
}).fail(function (response) {
|
||||
alert(wl_rm.error_refresh);
|
||||
});
|
||||
}
|
||||
|
||||
function laod_data() {
|
||||
load_combo_roles();
|
||||
load_combo_capabilities();
|
||||
load_role_tabs();
|
||||
}
|
||||
laod_data();
|
||||
});
|
||||
Reference in new issue
Block a user