Sikuliaq IT Asset Manager (skqitam)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

247 lines
10 KiB

var HttpClient = function() {
this.get = function(aUrl, aCallback) {
var anHttpRequest = new XMLHttpRequest();
anHttpRequest.onreadystatechange = function() {
if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
aCallback(anHttpRequest.responseText);
}
anHttpRequest.open( "GET", aUrl, true );
anHttpRequest.send( null );
}
}
let groupdiv = ''
if (document.getElementById('basegroup')) { groupdiv = 'basegroup'}
if (document.getElementById('byrolegroup')) { groupdiv = 'byrolegroup'}
if (document.getElementById('bylocgroup')) { groupdiv = 'bylocgroup'}
if (groupdiv) {
var client = new HttpClient();
client.get('data/cfosgroups.json', function(response) {
let groups = JSON.parse(response)
let html = ''
html += '<div class=".container-fluid">' + "\n"
html += '<div class="row" style="width: 990px; min-width: 990px;">' + "\n"
for (r in groups['DIV_TABLE']) {
for (c in groups['DIV_TABLE'][r]) {
let email = groups['DIV_TABLE'][r][c]['EMAIL_ADDRESS']
if (groups['DIV_TABLE'][r][c]['ALIAS_ADDRESS']) { email = groups['DIV_TABLE'][r][c]['ALIAS_ADDRESS'] }
// if(email == 'everyone@cfos.uaf.edu') { console.log(JSON.stringify(groups['DIV_TABLE'][r][c], null, 2)) }
let id = email.replace(/\@\S+$/, '')
let title = groups['DIV_TABLE'][r][c]['NAME'] + "\nGroup: " + groups['DIV_TABLE'][r][c]['EMAIL_ADDRESS'] + "\n"
if (!groups['DIV_TABLE'][r][c]['ACTIVE']) { title += "INACTIVE"}
let classes = ""
let style = ""
for (cls in groups['DIV_TABLE'][r][c]['CLASSES']) {
classes += groups['DIV_TABLE'][r][c]['CLASSES'][cls] + ' '
switch (groups['DIV_TABLE'][r][c]['CLASSES'][cls]) {
case 'bylocgroup':
style = 'style="visibility:hidden;"'
break;
case 'byrolegroup':
style = 'style="visibility:hidden;"'
break;
case 'topgroup':
style = 'style="visibility:hidden;"'
break;
default:
}
}
classes = classes.replace(/\s+$/, '')
let icon_class= ''
for (di in groups['META']['DIV_ICONS']) {
let regx = RegExp('^' + di)
if (email.match(regx)) {
for (ic in groups['META']['DIV_ICONS'][di])
icon_class += groups['META']['DIV_ICONS'][di][ic] + ' '
}
}
icon_class = icon_class.replace(/\s+$/, '')
// console.log(r + ':' + c + ' ' + email + ' [' + classes + ']')
let mouseinout = ""
mouseinout = 'onmouseover="highlight_distribution(' + "'" + id + "'" + ')"' + ' ' + 'onmouseout="unhighlight_distribution(' + "'" + id + "'" + ')"'
html += '<div id="' + id + '" class="' + classes + '" ' + style + ' ' + mouseinout + '>' + "\n"
html += '<span title="' + title + '" style="font-size: 1.5em;" class="' + icon_class + '"></span><br>' + "\n"
if (groups['DIV_TABLE'][r][c]['ACTIVE']) {
html += '<a title="' + title + '" target="_blank" style="font-weight: bold;" href="mailto:' + email +'">' + email + '</a>' + "\n"
} else {
html += '<span title="' + title + '" style="font-weight: bold; color: #999;">' + email + '</span>'
}
// html += email + "\n"
// html += "\n"
for (cls in groups['DIV_TABLE'][r][c]['CLASSES']) {
classes += groups['DIV_TABLE'][r][c]['CLASSES'][cls] + ' '
switch (groups['DIV_TABLE'][r][c]['CLASSES'][cls]) {
case 'bylocgroup':
html += '<div style="text-align: right; color: #090;"><span style="font-size: 1.5em;" class="fas fa-long-arrow-alt-right"></span></div>' + "\n"
break;
case 'byrolegroup':
html += '<div><span style="font-size: 2em; color: #08a0c0;" class="fas fa-long-arrow-alt-down"></span></div>' + "\n"
break;
case 'topgroup':
html += '<div style="text-align: right;"><span style="font-size: 2em; color: #08a0c0;" class="fas fa-long-arrow-alt-right"></span></div>' + "\n"
break;
default:
}
}
html += '</div>' + "\n"
}
}
html += '</div>' + "\n"
html += '</div>' + "\n"
// console.log(groupdiv + ' => ' + html)
document.getElementById(groupdiv).innerHTML = html
});
}
if (document.getElementById('jsondebug')) {
debug()
}
// ----------------------------------------------------------------
function debug() {
var client = new HttpClient();
client.get('data/cfosgroups.json', function(response) {
let input = JSON.parse(response)
document.getElementById('jsondebug').innerHTML = '<pre id="json-viewer">' + '</pre>'
$('#json-viewer').jsonViewer(input, {withLinks: true})
});
}
function toggle_byloc() {
if (document.getElementById('btn_byloc')) {
// console.log(JSON.stringify(document.getElementById('btn_byloc').classList, null, 2))
// console.log(JSON.stringify(document.getElementsByClassName('bylocgroup'), null, 2))
switch (document.getElementById('btn_byloc').classList[1]) {
case 'fa-toggle-on':
for (e in document.getElementsByClassName('bylocgroup')) {
// console.log(e)
if (e.match(/^\d+$/)) {
document.getElementsByClassName('bylocgroup')[e].style.visibility = 'hidden'
}
}
document.getElementById('btn_byloc').classList.remove('fa-toggle-on')
document.getElementById('btn_byloc').classList.add('fa-toggle-off')
break;
case 'fa-toggle-off':
for (e in document.getElementsByClassName('bylocgroup')) {
// console.log(e)
if (e.match(/^\d+$/)) {
document.getElementsByClassName('bylocgroup')[e].style.visibility = 'visible'
}
}
document.getElementById('btn_byloc').classList.remove('fa-toggle-off')
document.getElementById('btn_byloc').classList.add('fa-toggle-on')
break;
default:
console.log("ERROR: Invalid Class: " + document.getElementById('btn_byloc').classList[1])
}
}
}
function toggle_byrole() {
if (document.getElementById('btn_byrole')) {
// console.log(JSON.stringify(document.getElementById('btn_byrole').classList, null, 2))
// console.log(JSON.stringify(document.getElementsByClassName('byrolegroup'), null, 2))
switch (document.getElementById('btn_byrole').classList[1]) {
case 'fa-toggle-on':
for (e in document.getElementsByClassName('byrolegroup')) {
if (e.match(/^\d+$/)) {
document.getElementsByClassName('byrolegroup')[e].style.visibility = 'hidden'
// document.getElementsByClassName('byrolegroup')[e].style.display = 'none'
}
}
for (e in document.getElementsByClassName('topgroup')) {
if (e.match(/^\d+$/)) {
document.getElementsByClassName('topgroup')[e].style.visibility = 'hidden'
}
}
document.getElementById('btn_byrole').classList.remove('fa-toggle-on')
document.getElementById('btn_byrole').classList.add('fa-toggle-off')
break;
case 'fa-toggle-off':
for (e in document.getElementsByClassName('byrolegroup')) {
if (e.match(/^\d+$/)) {
document.getElementsByClassName('byrolegroup')[e].style.visibility = 'visible'
}
}
for (e in document.getElementsByClassName('topgroup')) {
if (e.match(/^\d+$/)) {
document.getElementsByClassName('topgroup')[e].style.visibility = 'visible'
}
}
document.getElementById('btn_byrole').classList.remove('fa-toggle-off')
document.getElementById('btn_byrole').classList.add('fa-toggle-on')
break;
default:
console.log("ERROR: Invalid Class: " + document.getElementById('btn_byrole').classList[1])
}
}
}
var mailflow = {}
mailflow['everyone'] = ['faculty', 'staff', 'students', 'faculty-fairbanks', 'staff-fairbanks', 'students-fairbanks', 'undergrads', 'faculty-juneau', 'staff-juneau', 'students-juneau', 'faculty-kodiak', 'staff-kodiak', 'students-kodiak', 'faculty-seward', 'staff-seward', 'students-seward', 'faculty-map', 'staff-map', 'postdocs', 'skq-crew', 'faculty-other', 'staff-other', 'students-other']
mailflow['faculty'] = ['faculty-fairbanks', 'faculty-juneau', 'faculty-kodiak', 'faculty-seward', 'faculty-map', 'postdocs', 'faculty-other']
mailflow['staff'] = ['staff-fairbanks', 'staff-juneau', 'staff-kodiak', 'staff-seward', 'staff-map', 'skq-crew', 'staff-other']
mailflow['students'] = ['students-fairbanks', 'undergrads', 'students-juneau', 'students-kodiak', 'students-seward', 'students-other']
mailflow['fairbanks'] = ['faculty-fairbanks', 'staff-fairbanks', 'students-fairbanks', 'undergrads']
mailflow['juneau'] = ['faculty-juneau', 'staff-juneau', 'students-juneau']
mailflow['kodiak'] = ['faculty-kodiak', 'staff-kodiak', 'students-kodiak']
mailflow['seward'] = ['faculty-seward', 'staff-seward', 'students-seward']
function highlight_distribution(distgroup) {
if (document.getElementById(distgroup)) {
// console.log(distgroup)
// document.getElementById(distgroup).style.backgroundColor = '#d9eff7'
document.getElementById(distgroup).style.backgroundColor = '#83eefc'
// console.log(distgroup + ' => ' + JSON.stringify(mailflow[distgroup], null, 2))
for (g in mailflow[distgroup]) {
// console.log(mailflow[distgroup][g])
// document.getElementById(mailflow[distgroup][g]).style.backgroundColor = '#d9eff7'
document.getElementById(mailflow[distgroup][g]).style.backgroundColor = '#83eefc'
}
}
}
function unhighlight_distribution(distgroup) {
if (document.getElementById(distgroup)) {
// console.log(distgroup)
document.getElementById(distgroup).style.backgroundColor = '#fff'
for (g in mailflow[distgroup]) {
document.getElementById(mailflow[distgroup][g]).style.backgroundColor = '#fff'
}
}
}