core&ui: add manage user priv (#433)

This commit is contained in:
panda authored and GitHub committed 2022-10-06 21:22:24 +08:00
1 parent b36adcdf13
commit a5494b1345
13 files changed
+274 -11

No files matched your search

@@ -15,6 +15,7 @@
{{ sidemenu.render_item(null, 'manage_dashboard') }}
{{ sidemenu.render_item(null, 'manage_script') }}
{{ sidemenu.render_item(null, 'manage_user_import') }}
{{ sidemenu.render_item(null, 'manage_user_priv') }}
{{ sidemenu.render_item(null, 'manage_setting') }}
{{ sidemenu.render_item(null, 'manage_config') }}
</ol>
@@ -0,0 +1,76 @@
{% extends "manage_base.html" %}
{% block manage_content %}
<div style="display: none" class="dialog__body--set-priv">
<div>
<div class="row"><div class="columns">
<h1>{{ _('Set Privilege') }}</h1>
</div></div>
{% set _mark = Math.ceil(Object.keys(Priv).length/3) %}
{% macro col(PRIVS) %}
<div class="medium-4 columns">
<table class="data-table priv_table">
<colgroup>
<col class="col--description">
<col class="col--p">
</colgroup>
<thead>
<tr>
<th class="col--description">{{ _('Name') }}</th>
<th class="col--p">{{ _('Privilege') }}</th>
</tr>
</thead>
<tbody>
{%- for p in PRIVS -%}
<tr>
<td class="col--description">
{{ _(p) }}
</td>
<td class="col--p">
<label class="compact checkbox">
<input class="priv" name="{{ p }}" data-checkbox-group="priv" data-checkbox-range value="{{ Priv[p] }}" type="checkbox">
</label>
</td>
</tr>
{%- endfor -%}
</tbody>
</table>
</div>
{% endmacro %}
<div class="row">
{{ col(Object.keys(Priv).slice(0, _mark)) }}
{{ col(Object.keys(Priv).slice(_mark, _mark*2)) }}
{{ col(Object.keys(Priv).slice(_mark*2, _mark*3)) }}
</div>
</div>
</div>
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('User Privilege') }}</h1>
<div class="section__tools">
<button class="primary rounded button" name="select_user"><span class="icon icon-search"></span>{{ _('Select User') }}</button>
</div>
</div>
{{ noscript_note.render() }}
<div class="section__body no-padding">
<table class="data-table">
<colgroup>
<col class="col--uid">
<col class="col--user">
<col class="col--priv_info">
<col class="col--priv">
<col class="col--actions">
</colgroup>
<thead>
<tr>
<th class="col--uid">{{ _('User ID') }}</th>
<th class="col--user">{{ _('Username') }}</th>
<td class="col--priv_info">{{ _('Privilege') }}</th>
<th class="col--priv">{{ _('Value') }}</th>
<th class="col--actions">{{ _('Actions') }}</th>
</tr>
</thead>
{% include "partials/manage_user_priv.html" %}
</table>
</div>
</div>
{% endblock %}
@@ -0,0 +1,55 @@
{% import "components/user.html" as user with context %}
<tbody data-fragment-id="user_priv-tbody">
<tr data-uid="{{ udoc._id }}">
<td class="col--uid">
#
</td>
<td class="col--user">
Default Privilege
</td>
<td class="col--priv_info">
{%- for name, priv in Priv -%}
{%- if defaultPriv|bitand(priv) -%}
{{ name }}<br>
{%- endif -%}
{%- endfor -%}
</td>
<td class="col--priv" title="{{ defaultPriv }}">
{{ defaultPriv }}
</td>
<td class="col--actions">
<a name="set_priv" data-uid="default" data-priv="{{ defaultPriv }}">{{ _('Edit') }}</a>
</td>
</tr>
{%- for udoc in udocs -%}
<tr data-uid="{{ udoc._id }}">
<td class="col--uid">
{{ udoc._id }}
</td>
<td class="col--user">
{{ user.render_inline(udoc, badge=false) }}
</td>
<td class="col--priv_info">
{%- if udoc.priv == 0 -%}
PRIV_NONE
{%- elif udoc.priv == -1 -%}
PRIV_ALL
{%- else -%}
{%- for name, priv in Priv -%}
{%- if priv|bitand(udoc.priv) and not priv|bitand(defaultPriv) -%}
<p class="priv_plus">+{{ name }}</p>
{%- elif priv|bitand(defaultPriv) and not priv|bitand(udoc.priv) -%}
<p class="priv_minus">-{{ name }}</p>
{%- endif -%}
{%- endfor -%}
{%- endif -%}
</td>
<td class="col--priv" title="{{ udoc.priv }}">
{{ udoc.priv }}
</td>
<td class="col--actions">
<a name="set_priv" data-uid="{{ udoc._id }}" data-priv="{{ udoc.priv }}">{{ _('Edit') }}</a>
</td>
</tr>
{%- endfor -%}
</tbody>