forked from enviPath/enviPy
[Feature] Modern UI roll out (#236)
This PR moves all the collection pages into the new UI in a rough push. I did not put the same amount of care into these as into search, index, and predict. ## Major changes - All modals are now migrated to a state based alpine.js implementation. - jQuery is no longer present in the base layout; ajax is replace by native fetch api - most of the pps.js is now obsolte (as I understand it; the code is not referenced any more @jebus please double check) - in-memory pagination for large result lists (set to 50; we can make that configurable later; performance degrades at around 1k) stukk a bit rough tracked in #235 ## Minor things - Sarch and index also use alpine now - The loading spinner is now CSS animated (not sure if it currently gets correctly called) ## Not done - Ihave not even cheked the admin pages. Not sure If these need migrations - The temporary migration pages still use the old template. Not sure what is supposed to happen with those? @jebus ## What I did to test - opend all pages in browse, and user ; plus all pages reachable from there. - Interacted and tested the functionality of each modal superfically with exception of the API key modal (no functional test). --- This PR is massive sorry for that; just did not want to push half-brokenn state. @jebus @liambrydon I would be glad if you could click around and try to break it :) Finally closes #133 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#236 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
This commit is contained in:
@ -1,264 +1,271 @@
|
||||
{% load static %}
|
||||
<!-- Edit Package Permission -->
|
||||
<div id="edit_package_permissions_modal" class="modal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Grant or Revoke Permissions</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="close"
|
||||
data-dismiss="modal"
|
||||
aria-label="Close"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
Modify permissions for this package. Note that if you give
|
||||
<code>write</code> permissions to a user or group,
|
||||
<code>read</code> permissions will be granted automatically.
|
||||
<br />
|
||||
To allow users to perform destructive actions, such as deleting the
|
||||
package, <code>owner</code>
|
||||
permissions must be granted.
|
||||
</p>
|
||||
<!-- Edit Package Permissions -->
|
||||
<dialog
|
||||
id="edit_package_permissions_modal"
|
||||
class="modal"
|
||||
x-data="{
|
||||
updatePermissions(checkbox) {
|
||||
const parts = checkbox.id.split('_');
|
||||
const perm = parts[0];
|
||||
const id = parts[1];
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<legend>User or Group</legend>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<legend>Read</legend>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<legend>Write</legend>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<legend>Owner</legend>
|
||||
</div>
|
||||
</div>
|
||||
const readBox = document.getElementById('read_' + id);
|
||||
const writeBox = document.getElementById('write_' + id);
|
||||
const ownerBox = document.getElementById('owner_' + id);
|
||||
|
||||
<div class="row">
|
||||
<form
|
||||
id="modal-form-permissions"
|
||||
class="form-inline"
|
||||
role="form"
|
||||
accept-charset="UTF-8"
|
||||
action=""
|
||||
data-remote="true"
|
||||
method="post"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<div class="col-xs-4">
|
||||
<select
|
||||
id="select_grantee"
|
||||
name="grantee"
|
||||
data-actions-box="true"
|
||||
class="selPackages"
|
||||
data-width="100%"
|
||||
>
|
||||
<option disabled selected>User</option>
|
||||
if (perm === 'read' && !readBox.checked) {
|
||||
writeBox.checked = false;
|
||||
ownerBox.checked = false;
|
||||
}
|
||||
|
||||
if (perm === 'write') {
|
||||
if (writeBox.checked) {
|
||||
readBox.checked = true;
|
||||
} else {
|
||||
ownerBox.checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (perm === 'owner' && ownerBox.checked) {
|
||||
readBox.checked = true;
|
||||
writeBox.checked = true;
|
||||
}
|
||||
}
|
||||
}"
|
||||
>
|
||||
<div class="modal-box max-w-2xl">
|
||||
<!-- Header -->
|
||||
<h3 class="text-lg font-bold">Grant or Revoke Permissions</h3>
|
||||
|
||||
<!-- Close button (X) -->
|
||||
<form method="dialog">
|
||||
<button class="btn btn-sm btn-circle btn-ghost absolute top-2 right-2">
|
||||
✕
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- Body -->
|
||||
<div class="py-4">
|
||||
<p class="mb-4">
|
||||
Modify permissions for this package. Note that if you give
|
||||
<code class="badge badge-ghost">write</code> permissions to a user or
|
||||
group, <code class="badge badge-ghost">read</code> permissions will be
|
||||
granted automatically.
|
||||
<br />
|
||||
To allow users to perform destructive actions, such as deleting the
|
||||
package, <code class="badge badge-ghost">owner</code> permissions must
|
||||
be granted.
|
||||
</p>
|
||||
|
||||
<!-- Add New Permission -->
|
||||
<form
|
||||
id="modal-form-permissions"
|
||||
accept-charset="UTF-8"
|
||||
action=""
|
||||
method="post"
|
||||
class="mb-4"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<div class="grid grid-cols-12 gap-2 items-end">
|
||||
<div class="col-span-5">
|
||||
<label class="label">
|
||||
<span class="label-text">User or Group</span>
|
||||
</label>
|
||||
<select
|
||||
id="select_grantee"
|
||||
name="grantee"
|
||||
class="select select-bordered w-full select-sm"
|
||||
required
|
||||
>
|
||||
<optgroup label="Users">
|
||||
{% for u in users %}
|
||||
<option value="{{ u.url }}">{{ u.username }}</option>
|
||||
{% endfor %}
|
||||
<option disabled>Groups</option>
|
||||
</optgroup>
|
||||
<optgroup label="Groups">
|
||||
{% for g in groups %}
|
||||
<option value="{{ g.url }}">{{ g.name|safe }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input type="checkbox" name="read" id="read_new" />
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input type="checkbox" name="write" id="write_new" />
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input type="checkbox" name="owner" id="owner_new" />
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<button
|
||||
type="submit"
|
||||
style="width:60%;"
|
||||
class="btn col-xs-2 modify-perm-button"
|
||||
>
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<label class="label justify-center">
|
||||
<span class="label-text">Read</span>
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="read"
|
||||
id="read_new"
|
||||
class="checkbox"
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<label class="label justify-center">
|
||||
<span class="label-text">Write</span>
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="write"
|
||||
id="write_new"
|
||||
class="checkbox"
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<label class="label justify-center">
|
||||
<span class="label-text">Owner</span>
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="owner"
|
||||
id="owner_new"
|
||||
class="checkbox"
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-1">
|
||||
<button type="submit" class="btn btn-primary btn-sm">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<p></p>
|
||||
{% for up in user_permissions %}
|
||||
<div class="row">
|
||||
</form>
|
||||
|
||||
<!-- User Permissions -->
|
||||
{% if user_permissions %}
|
||||
<div class="divider">User Permissions</div>
|
||||
<div class="space-y-2">
|
||||
{% for up in user_permissions %}
|
||||
<form
|
||||
id="modal-form-permissions_{{ up.user.uuid }}"
|
||||
class="form-inline"
|
||||
role="form"
|
||||
accept-charset="UTF-8"
|
||||
action=""
|
||||
data-remote="true"
|
||||
method="post"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<div class="col-xs-4">
|
||||
{{ up.user.username }}
|
||||
<input type="hidden" name="grantee" value="{{ up.user.url }}" />
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="read"
|
||||
id="read_{{ up.user.uuid }}"
|
||||
{% if up.has_read %}checked{% endif %}
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="write"
|
||||
id="write_{{ up.user.uuid }}"
|
||||
{% if up.has_write %}checked{% endif %}
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="owner"
|
||||
id="owner_{{ up.user.uuid }}"
|
||||
{% if up.has_all %}checked{% endif %}
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<button
|
||||
type="submit"
|
||||
style="width:60%;"
|
||||
class="btn col-xs-2 modify-perm-button"
|
||||
>
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
</button>
|
||||
<div class="grid grid-cols-12 gap-2 items-center">
|
||||
<div class="col-span-5 truncate">
|
||||
{{ up.user.username }}
|
||||
<input
|
||||
type="hidden"
|
||||
name="grantee"
|
||||
value="{{ up.user.url }}"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="read"
|
||||
id="read_{{ up.user.uuid }}"
|
||||
class="checkbox"
|
||||
{% if up.has_read %}checked{% endif %}
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="write"
|
||||
id="write_{{ up.user.uuid }}"
|
||||
class="checkbox"
|
||||
{% if up.has_write %}checked{% endif %}
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="owner"
|
||||
id="owner_{{ up.user.uuid }}"
|
||||
class="checkbox"
|
||||
{% if up.has_all %}checked{% endif %}
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-1">
|
||||
<button type="submit" class="btn btn-sm btn-ghost">✓</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<p></p>
|
||||
{% for gp in group_permissions %}
|
||||
<div class="row">
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Group Permissions -->
|
||||
{% if group_permissions %}
|
||||
<div class="divider">Group Permissions</div>
|
||||
<div class="space-y-2">
|
||||
{% for gp in group_permissions %}
|
||||
<form
|
||||
id="modal-form-permissions_{{ gp.user.uuid }}"
|
||||
class="form-inline"
|
||||
role="form"
|
||||
id="modal-form-permissions_{{ gp.group.uuid }}"
|
||||
accept-charset="UTF-8"
|
||||
action=""
|
||||
data-remote="true"
|
||||
method="post"
|
||||
>
|
||||
{% csrf_token %}
|
||||
<div class="col-xs-4">
|
||||
{{ gp.group.name|safe }}
|
||||
<input
|
||||
type="hidden"
|
||||
name="grantee"
|
||||
value="{{ gp.group.url }}"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="read"
|
||||
id="read_{{ gp.group.uuid }}"
|
||||
{% if gp.has_read %}checked{% endif %}
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="write"
|
||||
id="write_{{ gp.group.uuid }}"
|
||||
{% if gp.has_write %}checked{% endif %}
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="owner"
|
||||
id="owner_{{ gp.group.uuid }}"
|
||||
{% if gp.has_all %}checked{% endif %}
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<button
|
||||
type="submit"
|
||||
style="width:60%;"
|
||||
class="btn col-xs-2 modify-perm-button"
|
||||
>
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
</button>
|
||||
<div class="grid grid-cols-12 gap-2 items-center">
|
||||
<div class="col-span-5 truncate">
|
||||
{{ gp.group.name|safe }}
|
||||
<input
|
||||
type="hidden"
|
||||
name="grantee"
|
||||
value="{{ gp.group.url }}"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="read"
|
||||
id="read_{{ gp.group.uuid }}"
|
||||
class="checkbox"
|
||||
{% if gp.has_read %}checked{% endif %}
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="write"
|
||||
id="write_{{ gp.group.uuid }}"
|
||||
class="checkbox"
|
||||
{% if gp.has_write %}checked{% endif %}
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="owner"
|
||||
id="owner_{{ gp.group.uuid }}"
|
||||
class="checkbox"
|
||||
{% if gp.has_all %}checked{% endif %}
|
||||
@click="updatePermissions($el)"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-span-1">
|
||||
<button type="submit" class="btn btn-sm btn-ghost">✓</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
id="edit-package-modal-submit"
|
||||
>
|
||||
Update
|
||||
</button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="modal-action">
|
||||
<button
|
||||
type="button"
|
||||
class="btn"
|
||||
onclick="this.closest('dialog').close()"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function checkboxClick() {
|
||||
// id looks like read_3cadef24-220e-4587-9fa5-0e9a17aca2da
|
||||
parts = this.id.split("_");
|
||||
perm = parts[0];
|
||||
id = parts[1];
|
||||
|
||||
readbox = "#read_" + id;
|
||||
writebox = "#write_" + id;
|
||||
ownerbox = "#owner_" + id;
|
||||
|
||||
if (perm == "read" && !$(readbox).prop("checked")) {
|
||||
$(writebox).prop("checked", false);
|
||||
$(ownerbox).prop("checked", false);
|
||||
}
|
||||
|
||||
if (perm == "write") {
|
||||
if ($(writebox).prop("checked")) {
|
||||
$(readbox).prop("checked", true);
|
||||
}
|
||||
if (!$(writebox).prop("checked")) {
|
||||
$(ownerbox).prop("checked", false);
|
||||
}
|
||||
}
|
||||
|
||||
if (perm == "owner") {
|
||||
if ($(ownerbox).prop("checked")) {
|
||||
$(readbox).prop("checked", true);
|
||||
$(writebox).prop("checked", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$("#edit-package-modal-submit").click(function (e) {
|
||||
e.preventDefault();
|
||||
$("#edit-package-modal-form").submit();
|
||||
});
|
||||
|
||||
$("#select_grantee").selectpicker();
|
||||
|
||||
// Add click functions to permission checkboxes
|
||||
$('[id^="read_"]').on("click", checkboxClick);
|
||||
$('[id^="write_"]').on("click", checkboxClick);
|
||||
$('[id^="owner_"]').on("click", checkboxClick);
|
||||
});
|
||||
</script>
|
||||
<!-- Backdrop -->
|
||||
<form method="dialog" class="modal-backdrop">
|
||||
<button>close</button>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
Reference in New Issue
Block a user