fix(usermanager): generate static images on launch
This commit is contained in:
parent
a082af09c3
commit
8e9777353e
@ -45,6 +45,5 @@ def create_app(test_config=None):
|
|||||||
app.add_url_rule('/', endpoint='index')
|
app.add_url_rule('/', endpoint='index')
|
||||||
|
|
||||||
# TODO create OUs
|
# TODO create OUs
|
||||||
# TODO create static files
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
@ -17,6 +17,7 @@ function removeUserFromFormField(username) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
formField.value = JSON.stringify(newMembersList);
|
formField.value = JSON.stringify(newMembersList);
|
||||||
|
adjustLastMemberButtonState();
|
||||||
};
|
};
|
||||||
|
|
||||||
function addUserToFormField(username) {
|
function addUserToFormField(username) {
|
||||||
@ -24,6 +25,7 @@ function addUserToFormField(username) {
|
|||||||
let oldMembersList = JSON.parse(formField.value);
|
let oldMembersList = JSON.parse(formField.value);
|
||||||
oldMembersList.push(username);
|
oldMembersList.push(username);
|
||||||
formField.value = JSON.stringify(oldMembersList);
|
formField.value = JSON.stringify(oldMembersList);
|
||||||
|
adjustLastMemberButtonState();
|
||||||
};
|
};
|
||||||
|
|
||||||
class MemberEntry extends AbstractUserEntry {
|
class MemberEntry extends AbstractUserEntry {
|
||||||
@ -68,9 +70,9 @@ function createRemovedMemberRow(username) {
|
|||||||
let newTableDataButton = document.createElement("td");
|
let newTableDataButton = document.createElement("td");
|
||||||
let newTableButton = document.createElement("button");
|
let newTableButton = document.createElement("button");
|
||||||
newTableButton.type = "button";
|
newTableButton.type = "button";
|
||||||
newTableButton.className = "toggleMembershipButton btn btn-outline-light";
|
newTableButton.className = "toggleMembershipButton inProgress btn btn-outline-light";
|
||||||
newTableButton.disabled = true;
|
newTableButton.disabled = true;
|
||||||
newTableButton.textContent = "Being removed...";
|
newTableButton.textContent = "Will be removed";
|
||||||
newTableDataButton.appendChild(newTableButton);
|
newTableDataButton.appendChild(newTableButton);
|
||||||
newTableRow.appendChild(newTableDataButton);
|
newTableRow.appendChild(newTableDataButton);
|
||||||
};
|
};
|
||||||
@ -101,13 +103,31 @@ function createAddedMemberRow(username) {
|
|||||||
let newTableDataButton = document.createElement("td");
|
let newTableDataButton = document.createElement("td");
|
||||||
let newTableButton = document.createElement("button");
|
let newTableButton = document.createElement("button");
|
||||||
newTableButton.type = "button";
|
newTableButton.type = "button";
|
||||||
newTableButton.className = "toggleMembershipButton btn btn-outline-light";
|
newTableButton.className = "toggleMembershipButton inProgress btn btn-outline-light";
|
||||||
newTableButton.disabled = true;
|
newTableButton.disabled = true;
|
||||||
newTableButton.textContent = "Being added...";
|
newTableButton.textContent = "Will be added";
|
||||||
newTableDataButton.appendChild(newTableButton);
|
newTableDataButton.appendChild(newTableButton);
|
||||||
newTableRow.appendChild(newTableDataButton);
|
newTableRow.appendChild(newTableDataButton);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there is only one member in the group member table, disables that member's
|
||||||
|
* remove button.
|
||||||
|
* If there is more than one member, activates the removal button.
|
||||||
|
*/
|
||||||
|
function adjustLastMemberButtonState() {
|
||||||
|
memberRows = membersTable.querySelectorAll(".userEntry");
|
||||||
|
if (memberRows.length == 1) {
|
||||||
|
memberRows[0].querySelector(".toggleMembershipButton").disabled = true;
|
||||||
|
} else {
|
||||||
|
for (let button of membersTable.querySelectorAll(".toggleMembershipButton")) {
|
||||||
|
if (!button.className.includes("inProgress")) {
|
||||||
|
button.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const membersTable = document.getElementById("groupMembers");
|
const membersTable = document.getElementById("groupMembers");
|
||||||
const nonMembersTable = document.getElementById("groupNonMembers");
|
const nonMembersTable = document.getElementById("groupNonMembers");
|
||||||
let memberEntries = new Set();
|
let memberEntries = new Set();
|
||||||
@ -120,3 +140,4 @@ for (let userEntry of document.body.querySelectorAll(".userEntry")) {
|
|||||||
nonMemberEntries.add(new NonMemberEntry(userEntry.id, userEntry));
|
nonMemberEntries.add(new NonMemberEntry(userEntry.id, userEntry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
adjustLastMemberButtonState();
|
@ -4,6 +4,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h1>Editing group: {{ groupname }}</h1>
|
<h1>Editing group: {{ groupname }}</h1>
|
||||||
|
<p class="text-muted">Add or remove members from <i>{{ groupname }}</i> here. Hit the <kbd>Apply</kbd> button to save your changes.</p>
|
||||||
|
<p class="text-muted">Note that Groups must always have at least one member.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -80,5 +82,5 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="{{ url_for('static', filename='js/groupEdit.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/group_edit.js') }}"></script>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
@ -23,6 +23,16 @@ from lumi2.exceptions import InvalidStringFormatException, InvalidImageException
|
|||||||
bp = Blueprint('usermanager', __name__)
|
bp = Blueprint('usermanager', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.before_app_first_request
|
||||||
|
def _init_static_images():
|
||||||
|
conn = ldap.get_connection()
|
||||||
|
users = ldap.get_users(conn)
|
||||||
|
conn.unbind()
|
||||||
|
for user in users:
|
||||||
|
user._generate_static_images()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/')
|
@bp.route('/')
|
||||||
def index():
|
def index():
|
||||||
"""Home page view."""
|
"""Home page view."""
|
||||||
|
Loading…
Reference in New Issue
Block a user