Skip to content

Commit 25a6412

Browse files
committed
Added the option to generate a non-comparison web page to mock up roles
1 parent bb51225 commit 25a6412

File tree

4 files changed

+433
-2
lines changed

4 files changed

+433
-2
lines changed

main.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from src.working_scripts.findMyCapabilitySets import find_possible_compatibility_sets
1010
from src.working_scripts.generateWorkingWebPage import generate_web_page
1111
from src.working_scripts.processNewPermissions import reprocess_cap_sets
12+
from src.working_scripts.generateSelectWebPage import generate_mock_web_page
1213

1314
def main():
1415
main_menu_title = """
@@ -41,7 +42,7 @@ def main():
4142
sub_menu_items = [
4243
"Pull Reference Data - OKAPI Permissions", "Pull Reference Data - Capability Sets", "Pull Reference Data - Capabilities", "Pull Reference Data - OKAPI Permission Sets"
4344
"Expand Capability Sets", "Compare OKAPI Permissions to Eureka Capabilities", "Compare Current User Permission Sets to Eureka Capabilities",
44-
"Find Possible Capability Matches to OKAPI Permissions", "Build Web Interface - FOLIO Roles Simulator", "Reprocess the Capability Set Selection File (csv)", "Main Menu"
45+
"Find Possible Capability Matches to OKAPI Permissions", "Build Web Interface - FOLIO Roles Simulator", "Build Web Interface 2 - FOLIO Roles Simulator w/o comparison", "Reprocess the Capability Set Selection File (csv)", "Main Menu"
4546
]
4647
sub_menu_back = False
4748
sub_menu = TerminalMenu(
@@ -73,6 +74,7 @@ def main():
7374
print("Building Working CSV and HTML File")
7475
find_possible_compatibility_sets()
7576
generate_web_page()
77+
generate_mock_web_page()
7678
print("<<<<<<< Process Complete >>>>>>>")
7779
time.sleep(5)
7880
elif main_sel == 3:
@@ -120,10 +122,14 @@ def main():
120122
generate_web_page()
121123
time.sleep(5)
122124
elif sub_sel == 9:
125+
print("Build Web Interface - FOLIO Roles Simulator with out comparison >>>>>>>")
126+
generate_mock_web_page()
127+
time.sleep(5)
128+
elif sub_sel == 10:
123129
print("Reprocessing the CSV file to find more capability sets >>>>>>>")
124130
reprocess_cap_sets()
125131
time.sleep(5)
126-
elif sub_sel == 10 or sub_sel == None:
132+
elif sub_sel == 11 or sub_sel == None:
127133
sub_menu_back = True
128134
print("Back Selected")
129135
elif main_sel == 5 or main_sel == None:

src/includes/WebJsFile2.js

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
var globalList = []
2+
var globalSelList = []
3+
var globalSelInd = []
4+
var globalSel = ''
5+
function updateCheck1(name) {
6+
var checkBox = document.getElementById(name);
7+
checkBox.checked = true;
8+
updateCheckData();
9+
}
10+
function updateCheck(checkbox, name) {
11+
updateCheckData();
12+
}
13+
function updateCheckData() {
14+
const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
15+
const ary = [];
16+
checkboxes.forEach( (checkbox) => {
17+
var ckVal = checkbox.value
18+
if (!ckVal.endsWith("_b")) {
19+
ary.push(ckVal);
20+
}
21+
}
22+
);
23+
selectedValues = [...new Set(ary)]
24+
var cap_sets = JSON.parse(document.getElementById('cap_sets').textContent);
25+
var cap_data = JSON.parse(document.getElementById('cap_data').textContent);
26+
var caps = [];
27+
globalSelList = []
28+
globalSelInd = []
29+
selectedValues.forEach( (c) => {
30+
if (cap_sets[c]) {
31+
caps = [...caps, ...cap_sets[c]]
32+
globalSelList.push(cap_data[c])
33+
} else {
34+
caps.push(c)
35+
globalSelInd.push(c)
36+
}
37+
}
38+
);
39+
globalList = [...new Set(caps)];
40+
document.getElementById('assigned_items').innerHTML = buildList(globalList);
41+
document.getElementById('assigned_len').innerHTML = "(" + globalList.length + ")";
42+
}
43+
function buildList(data) {
44+
var cap_data = JSON.parse(document.getElementById('cap_data').textContent);
45+
var rtnHtml = "<ul>"
46+
data.forEach(item => {
47+
rtnHtml += `
48+
<li>${cap_data[item]['resource']} (<i>${cap_data[item]['type']}</i>) -> <b>${cap_data[item]['action']}</b>
49+
<br />
50+
<span style="font-size: small;" >${cap_data[item]['description']}</span></li>`;
51+
}
52+
)
53+
rtnHtml += "</ul>"
54+
return rtnHtml
55+
}
56+
function exportOne() {
57+
var cap_data = JSON.parse(document.getElementById('cap_data').textContent);
58+
var exportData = [
59+
['level', 'type', 'resource', 'action']
60+
]
61+
globalSelList.forEach(item => {
62+
exportData.push(['Capability set', item.type, item.resource, item.action])
63+
64+
})
65+
globalSelInd.forEach(item => {
66+
exportData.push(['Capability', cap_data[item]['type'], cap_data[item]['resource'], cap_data[item]['action']])
67+
})
68+
var okapi_data = JSON.parse(document.getElementById('okapi_data').textContent);
69+
downloadCSV(exportData, `export.csv`)
70+
}
71+
function downloadCSV(data, filename='data.csv') {
72+
const csvString = data.map(row => row.join(',')).join('\n');
73+
const blob = new Blob([csvString],{
74+
type: 'text/csv;charset=utf-8;'
75+
});
76+
77+
if (navigator.msSaveBlob) {
78+
// IE
79+
navigator.msSaveBlob(blob, filename);
80+
} else {
81+
const url = URL.createObjectURL(blob);
82+
const link = document.createElement('a');
83+
link.href = url;
84+
link.download = filename;
85+
document.body.appendChild(link);
86+
link.click();
87+
document.body.removeChild(link);
88+
URL.revokeObjectURL(url);
89+
}
90+
}
91+
function togglePanel(id) {
92+
const panelContent = document.querySelector(`#${id} .panel-content`);
93+
panelContent.classList.toggle('expanded');
94+
}

src/includes/webCss2.css

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
.table-container {
3+
width: 100%;
4+
height: 650px; /* Adjust the height as needed */
5+
overflow-y: scroll;
6+
border: 1px solid #ccc;
7+
}
8+
9+
table {
10+
width: 100%;
11+
border-collapse: collapse;
12+
font-family: Arial, Helvetica, sans-serif;
13+
font-size: small;
14+
}
15+
16+
th, td {
17+
padding: 8px;
18+
text-align: left;
19+
border-bottom: 1px solid #ddd;
20+
}
21+
22+
tr:hover {
23+
background-color: #ddd;
24+
}
25+
tr:nth-child(even){
26+
background-color: #f2f2f2;
27+
}
28+
thead th {
29+
position: sticky;
30+
top: 0;
31+
background-color: #04AA6D;
32+
color: white;
33+
z-index: 1;
34+
}
35+
.container {
36+
width: 100%;
37+
background: #f2f2f2;
38+
}
39+
.table_area, .section {
40+
float: left;
41+
padding: 20px;
42+
min-height: 170px;
43+
box-sizing: border-box;
44+
}
45+
.table_area {
46+
width: 60%;
47+
overflow: scroll;
48+
max-height: 90%;
49+
}
50+
.section {
51+
width: 40%;
52+
background: #d4d7dc;
53+
}
54+
.clearfix:after {
55+
content: ".";
56+
display: block;
57+
height: 0;
58+
clear: both;
59+
visibility: hidden;
60+
}
61+
.data_display {
62+
position: static;
63+
overflow: auto;
64+
max-height: 400px;
65+
width: 100%;
66+
}
67+
.panel {
68+
border:1px solid #ccc;
69+
border-radius: 4px;
70+
overflow: hidden;
71+
auto;
72+
}
73+
.panel-header {
74+
background-color:#f1f1f1;
75+
padding: 1px;
76+
cursor: pointer;
77+
}
78+
.panel-content{
79+
max-height: 0;
80+
overflow: hidden;
81+
transition: max-height .3s ease;
82+
}
83+
.panel-content.expanded{
84+
max-height: 700px
85+
}

0 commit comments

Comments
 (0)