Cluster Administration
+Admin
Users
-
@@ -41,15 +41,15 @@
-
+
Actions
Groups
-
@@ -58,9 +58,9 @@
-
+
Actions
+
+ `;
+
+ const configButton = this.shadowRoot.querySelector("#config-btn");
+ configButton.onclick = this.handleConfigButton.bind(this);
+
+ const deleteButton = this.shadowRoot.querySelector("#delete-btn");
+ deleteButton.onclick = this.handleDeleteButton.bind(this);
+ }
+
+ get data () {
+ return {
+ username: this.username,
+ groups: this.groups,
+ admin: this.admin
+ };
+ }
+
+ set data (data) {
+ this.username = data.username;
+ this.groups = this.#getGroupsFromAttribute(data.attributes.memberOf);
+ this.admin = data.cluster.admin;
+ this.update();
+ }
+
+ #getGroupsFromAttribute (attribute) {
+ return Array.from(attribute, (e) => e.split("cn=")[1].split(",")[0]);
+ }
+
+ update () {
+ const nameParagraph = this.shadowRoot.querySelector("#user-name");
+ nameParagraph.innerText = this.username;
+
+ const groupsParagraph = this.shadowRoot.querySelector("#user-groups");
+ groupsParagraph.innerText = `${this.groups.toString()}`;
+
+ const adminParagraph = this.shadowRoot.querySelector("#user-admin");
+ adminParagraph.innerText = this.admin;
+ }
+
+ handleConfigButton () {
+ goToPage("user.html", { username: this.username });
+ }
+
+ handleDeleteButton () {
+ // TODO
+ }
+}
+
+class GroupCard extends HTMLElement {
+ constructor () {
+ super();
+ this.attachShadow({ mode: "open" });
+ this.shadowRoot.innerHTML = `
+
+
+
+
+ +
+
+
+
+
+
+ `;
+
+ const configButton = this.shadowRoot.querySelector("#config-btn");
+ configButton.onclick = this.handleConfigButton.bind(this);
+
+ const deleteButton = this.shadowRoot.querySelector("#delete-btn");
+ deleteButton.onclick = this.handleDeleteButton.bind(this);
+ }
+
+ get data () {
+ return {
+ groupname: this.groupname,
+ members: this.members
+ };
+ }
+
+ set data (data) {
+ this.groupname = data.groupname;
+ this.members = this.#getMembersFromAttribute(data.attributes.member);
+ this.update();
+ }
+
+ #getMembersFromAttribute (attribute) {
+ const filteredGroups = attribute.filter(e => e !== "");
+ return Array.from(filteredGroups, (e) => e.split("uid=")[1].split(",")[0]);
+ }
+
+ update () {
+ const nameParagraph = this.shadowRoot.querySelector("#group-name");
+ nameParagraph.innerText = this.groupname;
+
+ const membersParagraph = this.shadowRoot.querySelector("#group-members");
+ membersParagraph.innerText = `${this.members.toString()}`;
+ }
+
+ handleConfigButton () {
+ // TODO
+ }
+
+ handleDeleteButton () {
+ // TODO
+ }
+}
+
+customElements.define("user-card", UserCard);
+customElements.define("group-card", GroupCard);
+
+function handleUserAdd () {
+ // TODO
+}
+
+function handleGroupAdd () {
+ // TODO
}
+
+
+
+
+