Advanced html | ||
---|---|---|
| ||
{"htmlContent":"<div id=\"group-audit-container\" class=\"aui\">\n <label for=\"groupName\">Select Group: </label>\n <select id=\"groupName\" class=\"select\">\n <option value=\"confluence-users-cloud-testing-910\">confluence-users-cloud-testing-910<1\">administrators</option>\n <option value=\"org-admins2\">org>site-admins</option>\n <option value=\"confluence-users3\">confluence-users</option>\n </select>\n <button id=\"fetchGroupDetails\">Fetch Group Details</button>\ class=\"aui-button\">Fetch Group Details</button>\n <div id=\"groupDetails\" style=\"margin-top: 20px; border: 1px solid #ddd; padding: 10px;\"></div>\n</div>\n\n<script>\n \n fetchGroups();\n async function fetchGroups(){\n\n let groups = [];\n let url = `/rest/api/group`;\n while(url){\n\n try{\n const response = await AP.request({\n url: url, \n type: \"GET\",\n contentType: \"application/json\"\n });\n\n let data = JSON.parse(response.body);\n\n if (!data.results || data.results.length === 0) {\n break;\n }\n\n groups = groups.concat(data.results);\n url = data._links.next; \n\n } catch (error) {\n console.error(\"Error:\", error);\n url = undefined;\n } \n }\n\n //console.log(groups);\n\n const groupSelect = document.getElementById(\"groupName\");\nif(groups.length === 0){\n groupSelect.innerHTML = //alert(\"No groups found\");\n // Clear existing options\n\n return;\n groups.forEach(group => {\n }\n\n const optiongroupSelect = document.createElementgetElementById(\"optiongroupName\");\n option.valuegroupSelect.innerHTML = group.id;\n \"\"; // Clear existing options\n\n optiongroups.textContentforEach(group => group.name;{\n const option = groupSelectdocument.appendChildcreateElement(\"option\");\n });\n option.value = }group.id;\n \n\n async function fetchGroupMembers(groupId) { option.textContent = group.name;\n const groupDetailsDiv = documentgroupSelect.getElementById(\"groupDetails\"appendChild(option);\n groupDetailsDiv.textContent = \"Fetching group details...\";});\n }\n \n\n async function fetchGroupMembers(groupId) let groupMembers = [];\n{\n const groupDetailsDiv = document.getElementById(\"groupDetails\");\n groupDetailsDiv.textContent = \"Fetching group details...\";\n\n let groupMembers = [];\n let url = `/rest/api/group/${groupId}/membersByGroupId`;\n\n while(url){\n\n try {\n const response = await AP.request({\n url: url, \n type: \"GET\",\n contentType: \"application/json\"\n });\n\n if (response.xhr.status !== 200) {\n throw new Error(`Error fetching group members: ${response.statusText}`);\n }\n\n let data = JSON.parse(response.body);\n\n if (!data.results || data.results.length === 0) { \n break;\n }\n\n groupMembers = groupMembers.concat(data.results);\n url = data._links.next; \n\n } catch (error) {\n console.error(\"Error:\", error);\n groupDetailsDiv.textContent = \"Failed to fetch group members. Check the console for details.\";\n url = undefined;\n }\n }\n\n if (groupMembers.length === 0) {\n //groupDetailsDiv.textContent = \"No members found for this group.\";\n //return;\n if(groupId == 1){ \n groupMembers = [\n {\n \"displayName\": \"John Doe\",\n \"emailAddress\": \"john@example.com\"\n },\n {\n \"displayName\": \"Jane Smith\",\n \"emailAddress\": \"janeĢ@example.com\"\n },\n let url = `/rest/api/group/${groupId}/membersByGroupId`;\n\n while(url){\n\n try {\n\"displayName\": \"Alice Brown\",\n const response = await AP.request({\n \"emailAddress\": \"alice@example.com\"\n url: url,}\n ];\n }\n else type: \"GET\",if(groupId == 2){\n groupMembers = [\n contentType: \"application/json\"\n });{\n\n if (response.xhr.status !== 200) { \"displayName\": \"Bob Johnson\",\n throw new Error(`Error fetching group members: ${response.statusText}`);\n \"emailAddress\": \"bob@example.com\"\n }\n,\n let data = JSON.parse(response.body);\n\n {\n if (!data.results || data.results.length === 0) { \"displayName\": \"Charlie White\",\n \n \"emailAddress\": \"charlie@example.com\"\n break;\n }\n\n groupMembers = groupMembers.concat(data.results)];\n }\n url = data._links.next; else{\n \n\n groupMembers } catch (error) {= [\n console.error(\"Error:\", error); {\n groupDetailsDiv.textContent = \"Failed to fetch group members. Check the console for details.\";\n \"displayName\": \"David Black\",\n url = undefined;\n }\"emailAddress\": \"david@example.com\"\n }\n\n if (groupMembers.length === 0) {}\n groupDetailsDiv.textContent = \"No members found for this group.\" ];\n return;}\n }\n\n // Build and display the table\n let table = `\n <table class=\"aui\" border=\"1\" style=\"width: 100%; border-collapse: collapse;\">\n <thead>\n <tr>\n <th>Name</th>\n <th>Email</th>\n <th>Product Access</th>\n </tr>\n </thead>\n <tbody>\n `;\n\n for (const member of groupMembers) {\n // Display member info (dummy product access added for simplicity)\n table += `\n <tr>\n <td>${member.displayName}</td>\n <td>${member.emailAddress || \"N/A\"}</td>\n <td>No Product Access API in Confluence Cloud</td>\n </tr>\n `;\n }\n\n table += \"</tbody></table>\";\n groupDetailsDiv.innerHTML = table;\n }\n\n document.getElementById(\"fetchGroupDetails\").addEventListener(\"click\", () => {\n const groupId = document.getElementById(\"groupName\").value.trim();\n\n if (!groupId) {\n alert(\"Please select a group.\");\n return;\n }\n\n fetchGroupMembers(groupId);\n });\n</script>"} |
Page Comparison
General
Content
Integrations