-
Notifications
You must be signed in to change notification settings - Fork 1
/
report_artifacts_html.py
547 lines (423 loc) · 25.3 KB
/
report_artifacts_html.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
'''
Copyright 2021 Flexera Software LLC
See LICENSE.TXT for full license text
SPDX-License-Identifier: MIT
Author : sgeary
Created On : Wed Dec 08 2021
File : report_artifacts_html.py
'''
import logging, os, base64
import _version
logger = logging.getLogger(__name__)
#------------------------------------------------------------------#
def generate_html_report(reportData):
logger.info(" Entering generate_html_report")
reportName = reportData["reportName"]
reportFileNameBase = reportData["reportFileNameBase"]
reportTimeStamp = reportData["reportTimeStamp"]
primaryProjectName = reportData["primaryProjectName"]
primaryProjectInventoryCount = reportData["primaryProjectInventoryCount"]
otherProjectName = reportData["otherProjectName"]
otherProjectInventoryCount = reportData["otherProjectInventoryCount"]
largestHierachy = reportData["largestHierachy"]
reportOptions = reportData["reportOptions"]
includeUnpublishedInventory = reportOptions["includeUnpublishedInventory"] # True/False
tableData = reportData["tableData"]
scriptDirectory = os.path.dirname(os.path.realpath(__file__))
cssFile = os.path.join(scriptDirectory, "common/branding/css/revenera_common.css")
logoImageFile = os.path.join(scriptDirectory, "common/branding/images/logo_reversed.svg")
iconFile = os.path.join(scriptDirectory, "common/branding/images/favicon-revenera.ico")
#########################################################
# Encode the image files
encodedLogoImage = encodeImage(logoImageFile)
encodedfaviconImage = encodeImage(iconFile)
htmlFile = reportFileNameBase + ".html"
logger.debug(" htmlFile: %s" %htmlFile)
#---------------------------------------------------------------------------------------------------
# Create a simple HTML file to display
#---------------------------------------------------------------------------------------------------
try:
html_ptr = open(htmlFile,"w")
except:
logger.error("Failed to open htmlfile %s:" %htmlFile)
raise
html_ptr.write("<html>\n")
html_ptr.write(" <head>\n")
html_ptr.write(" <!-- Required meta tags --> \n")
html_ptr.write(" <meta charset='utf-8'> \n")
html_ptr.write(" <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'> \n")
html_ptr.write('''
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.2/css/bootstrap.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.8/css/dataTables.bootstrap4.min.css">
<link rel="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.16/themes/default/style.min.css">
''')
html_ptr.write(" <style>\n")
# Add the contents of the css file to the head block
try:
f_ptr = open(cssFile)
logger.debug(" Adding css file details")
for line in f_ptr:
html_ptr.write(" %s" %line)
f_ptr.close()
except:
logger.error("Unable to open %s" %cssFile)
print("Unable to open %s" %cssFile)
# TODO Add to css file
html_ptr.write(" .tr-notExactMatch { background-color: #F0F0F0;}\n")
html_ptr.write(" .td-nomatch { color: #F80000;}\n")
html_ptr.write(" .btn-comparison { width:250px; background-color: #323E48; color: #FFFFFF;}\n")
# To keep the filter button a different color after it was clicked
html_ptr.write(".active { background-color: #89EE46; color: #000000; outline-color: red;}")
html_ptr.write(" </style>\n")
html_ptr.write(" <link rel='icon' type='image/png' href='data:image/png;base64, {}'>\n".format(encodedfaviconImage.decode('utf-8')))
html_ptr.write(" <title>%s</title>\n" %(reportName))
html_ptr.write(" </head>\n")
html_ptr.write("<body>\n")
html_ptr.write("<div class=\"container-fluid\">\n")
#---------------------------------------------------------------------------------------------------
# Report Header
#---------------------------------------------------------------------------------------------------
html_ptr.write("<!-- BEGIN HEADER -->\n")
html_ptr.write("<div class='header'>\n")
html_ptr.write(" <div class='logo'>\n")
html_ptr.write(" <img src='data:image/svg+xml;base64,{}' style='height: 5%'>\n".format(encodedLogoImage.decode('utf-8')))
html_ptr.write(" </div>\n")
html_ptr.write("<div class='report-title'>%s</div>\n" %reportName)
html_ptr.write("</div>\n")
html_ptr.write("<!-- END HEADER -->\n")
#---------------------------------------------------------------------------------------------------
# Body of Report
#---------------------------------------------------------------------------------------------------
html_ptr.write("<!-- BEGIN BODY -->\n")
# Is there at least one hierarchy that is being displayed?
if largestHierachy > 1:
html_ptr.write("<hr class='small'>\n")
#######################################################################
# Create table to hold the project summary charts.
# js script itself is added later
html_ptr.write("<div class='container'>\n")
html_ptr.write(" <div class='row'>\n")
html_ptr.write(" <div class='col-sm'>\n")
html_ptr.write("<h6 class='gray' style='padding-top: 10px;'><center>%s<br>Project Hierarchy<br>(%s Total Items)</center></h6>" %(otherProjectName, otherProjectInventoryCount["total"]) )
html_ptr.write(" <div id='project_hierarchy1'></div>\n")
html_ptr.write(" </div>\n")
html_ptr.write(" <div class='col-sm'>\n")
html_ptr.write("<h6 class='gray' style='padding-top: 10px;'><center>%s<br>Project Hierarchy<br>(%s Total Items)</center></h6>" %(primaryProjectName, primaryProjectInventoryCount["total"]) )
html_ptr.write(" <div id='project_hierarchy2'></div>\n")
html_ptr.write(" </div>\n")
html_ptr.write(" </div>\n")
html_ptr.write("</div>\n")
html_ptr.write("<hr class='small'>")
html_ptr.write('''<div style="text-align: center;">''')
html_ptr.write(''' <div class="btn-group" role="group" aria-label="data filters"">\n''')
html_ptr.write(''' <button id="showAll" type="button" class="btn-comparison mx-1 my-2">Show All Items</button>\n''')
html_ptr.write(''' <button id="showUnchanged" type="button" class="btn btn-comparison mx-2 my-2">Show Unchanged Items</button>\n''')
html_ptr.write(''' <div class="btn-group " role="group">\n''')
html_ptr.write(''' <button id="showDifferences" type="button" class="btn btn-comparison mx-1 my-2 dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Show Differences</button>\n''')
html_ptr.write(''' <div class="dropdown-menu" role="group" aria-labelledby="dropdownMenu">\n''')
html_ptr.write(''' <button id="showAllDifferences" class="dropdown-item" type="button" onclick="showDifference(this)">All Differences</button>\n''')
html_ptr.write(''' <button id="showVersionDifferences" class="dropdown-item" type="button" onclick="showDifference(this)">Versions Differences</button>\n''')
html_ptr.write(''' <button id="showLicenseDifferences" class="dropdown-item" type="button" onclick="showDifference(this)">Licenses Differences</button>\n''')
if includeUnpublishedInventory:
html_ptr.write(''' <button id="showPublishedDifferences" class="dropdown-item" type="button" onclick="showDifference(this)">Published State</button>\n''')
html_ptr.write(''' <button id="showUnreconcilable" class="dropdown-item" type="button" onclick="showDifference(this)">Unreconcilable Items</button>\n''')
html_ptr.write(''' </div>\n''')
html_ptr.write(''' </div>\n''')
html_ptr.write(''' </div>\n''')
html_ptr.write(''' <button id="showRemoved" type="button" class="btn btn-comparison mx-1 my-2">Show Removed Items</button>\n''')
html_ptr.write(''' <button id="showAdded" type="button" class="btn btn-comparison mx-1 my-2">Show Added Items</button>\n''')
html_ptr.write('''</div>\n''')
html_ptr.write('''<p>\n''')
html_ptr.write('''<p>\n''')
html_ptr.write("<table id='comparisonData' class='table table-hover row-border table-sm' style='width:90%'>\n")
html_ptr.write("<colgroup>\n")
html_ptr.write("<col span=\"1\" style=\"width: 20%;\">\n") # Component
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Other Version
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Other License
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Other Projects
if includeUnpublishedInventory:
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Other Published State
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Primary Version
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Primary License
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Primary Projects
if includeUnpublishedInventory:
html_ptr.write("<col span=\"1\" style=\"width: 10%;\">\n") # Primary Published State
html_ptr.write("</colgroup>\n")
html_ptr.write(" <thead>\n")
html_ptr.write(" <tr>\n")
html_ptr.write(" <th colspan='1' class='text-center'> </th>\n")
if includeUnpublishedInventory:
headerColSpan = 4
else:
headerColSpan = 3
html_ptr.write(" <th colspan='%s' class='text-center'><h4>%s</h4></th>\n" %(headerColSpan, otherProjectName))
html_ptr.write(" <th colspan='%s' class='text-center'><h4>%s</h4></th>\n" %(headerColSpan, primaryProjectName))
html_ptr.write(" </tr>\n")
html_ptr.write(" <tr>\n")
html_ptr.write(" <th class='text-center'>COMPONENT</th>\n")
html_ptr.write(" <th class='text-center'>VERSION</th>\n")
html_ptr.write(" <th class='text-center'>LICENSE</th>\n")
html_ptr.write(" <th class='text-center'>PROJECTS</th>\n")
if includeUnpublishedInventory:
html_ptr.write(" <th class='text-center'>PUBLISHED STATE</th>\n")
html_ptr.write(" <th class='text-center'>VERSION</th>\n")
html_ptr.write(" <th class='text-center'>LICENSE</th>\n")
html_ptr.write(" <th class='text-center'>PROJECTS</th>\n")
if includeUnpublishedInventory:
html_ptr.write(" <th class='text-center'>PUBLISHED STATE</th>\n")
html_ptr.write(" </tr>\n")
html_ptr.write(" </thead>\n")
html_ptr.write(" <tbody>\n")
for row in tableData:
component = row[0]
otherProjectVersion = " " if row[1] is None else row[1]
otherProjectLicense = " " if row[2] is None else row[2]
otherProjectProjects = [" "] if row[3] is None else row[3]
otherProjectPublicationState = " " if row[4] is None else row[4]
primaryProjectVersion = " " if row[5] is None else row[5]
primaryProjectLicense = " " if row[6] is None else row[6]
primaryProjectProjects = [" "] if row[7] is None else row[7]
primaryProjectPublicationState = " " if row[8] is None else row[8]
matchType = row[9]
html_ptr.write(" <tr matchType='%s'> \n" %matchType)
html_ptr.write(" <td class='text-left'>%s</th>\n" %(component))
tdclass = 'text-left' if "V" in matchType or "added" in matchType or "removed" in matchType or "unreconcilable" in matchType else "td-nomatch text-left"
html_ptr.write(" <td class='%s'>%s</th>\n" %(tdclass, otherProjectVersion))
tdclass = 'text-left' if "L" in matchType or "added" in matchType or "removed" in matchType or "unreconcilable" in matchType else "td-nomatch text-left"
html_ptr.write(" <td class='%s'>%s</th>\n" %(tdclass, otherProjectLicense))
# Provide hyperlinks to inventory item for each item within the projct
if otherProjectProjects == [" "]:
html_ptr.write(" <td class='text-left'> </th>\n")
else:
html_ptr.write(" <td class='text-left'>")
projectNames = otherProjectProjects.keys()
for projectName in projectNames:
inventoryLinks = otherProjectProjects[projectName]
for inventoryLink in inventoryLinks:
html_ptr.write("<a href='%s' target='_blank' >%s</a><br>" %(inventoryLink, projectName))
html_ptr.write("</th>\n")
if includeUnpublishedInventory:
tdclass = 'text-left' if "P" in matchType or "added" in matchType or "removed" in matchType or "unreconcilable" in matchType else "td-nomatch text-left"
html_ptr.write(" <td class='%s'>%s</th>\n" %(tdclass, otherProjectPublicationState))
tdclass = 'text-left' if "V" in matchType or "added" in matchType or "removed" in matchType or "unreconcilable" in matchType else "td-nomatch text-left"
html_ptr.write(" <td class='%s'>%s</th>\n" %(tdclass, primaryProjectVersion))
tdclass = 'text-left' if "L" in matchType or "added" in matchType or "removed" in matchType or "unreconcilable" in matchType else "td-nomatch text-left"
html_ptr.write(" <td class='%s'>%s</th>\n" %(tdclass, primaryProjectLicense))
# Provide hyperlinks to inventory item for each item within the projct
if primaryProjectProjects == [" "]:
html_ptr.write(" <td class='text-left'> </th>\n")
else:
html_ptr.write(" <td class='text-left'\n>")
projectNames = primaryProjectProjects.keys()
for projectName in projectNames:
inventoryLinks = primaryProjectProjects[projectName]
for inventoryLink in inventoryLinks:
html_ptr.write("<a href='%s' target='_blank' >%s</a><br>\n" %(inventoryLink, projectName))
html_ptr.write("</th>\n")
if includeUnpublishedInventory:
tdclass = 'text-left' if "P" in matchType or "added" in matchType or "removed" in matchType or "unreconcilable" in matchType else "td-nomatch text-left"
html_ptr.write(" <td class='%s'>%s</th>\n" %(tdclass, primaryProjectPublicationState))
html_ptr.write(" </tr>\n")
html_ptr.write(" </tbody>\n")
html_ptr.write("</table>\n")
html_ptr.write("<!-- END BODY -->\n")
#---------------------------------------------------------------------------------------------------
# Report Footer
#---------------------------------------------------------------------------------------------------
html_ptr.write("<!-- BEGIN FOOTER -->\n")
html_ptr.write("<div class='report-footer'>\n")
html_ptr.write(" <div style='float:right'>Generated on %s</div>\n" %reportTimeStamp)
html_ptr.write("<br>\n")
html_ptr.write(" <div style='float:right'>Report Version: %s</div>\n" %_version.__version__)
html_ptr.write("</div>\n")
html_ptr.write("<!-- END FOOTER -->\n")
html_ptr.write("</div>\n")
#---------------------------------------------------------------------------------------------------
# Add javascript
#---------------------------------------------------------------------------------------------------
html_ptr.write('''
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js" integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.8/js/dataTables.bootstrap4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.16/jstree.min.js"></script>
''')
html_ptr.write("<script>\n")
if largestHierachy > 1:
# Add the js for the project summary stacked bar charts
generate_project_hierarchy_tree(html_ptr, reportData["otherProjectList"], otherProjectInventoryCount, primaryProjectInventoryCount, "project_hierarchy1")
generate_project_hierarchy_tree(html_ptr, reportData["primaryProjectList"], primaryProjectInventoryCount, otherProjectInventoryCount, "project_hierarchy2")
html_ptr.write('''
var table = $('#comparisonData').DataTable(
{"lengthMenu": [ [25, 50, 100, -1], [25, 50, 100, "All"] ],}
);
// Used to change the button text to the value of the selected filter
// from within the dropdown list
function showDifference(item) {
document.getElementById('showDifferences').innerHTML = item.innerHTML;
}
$("#showAll").click(function() {
$.fn.dataTable.ext.search.pop();
document.getElementById('showDifferences').innerHTML = "Show Differences";
table.draw();
});
$("#showUnchanged").click(function() {
$.fn.dataTable.ext.search.pop();
document.getElementById('showDifferences').innerHTML = "Show Differences";
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).attr('matchType') == "CVLP";
}
);
table.draw();
});
$("#showAllDifferences").click(function() {
$.fn.dataTable.ext.search.pop();
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).attr('matchType') != "CVLP";
}
);
table.draw();
});
$("#showVersionDifferences").click(function() {
$.fn.dataTable.ext.search.pop();
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return !($(table.row(dataIndex).node()).attr('matchType').includes("V") ||
$(table.row(dataIndex).node()).attr('matchType') == "addedToPrimaryProject" ||
$(table.row(dataIndex).node()).attr('matchType') == "removedFromOtherProject" ||
$(table.row(dataIndex).node()).attr('matchType') == "unreconcilable"
);
}
);
table.draw();
});
$("#showLicenseDifferences").click(function() {
$.fn.dataTable.ext.search.pop();
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return !($(table.row(dataIndex).node()).attr('matchType').includes("L") ||
$(table.row(dataIndex).node()).attr('matchType') == "addedToPrimaryProject" ||
$(table.row(dataIndex).node()).attr('matchType') == "removedFromOtherProject" ||
$(table.row(dataIndex).node()).attr('matchType') == "unreconcilable"
);
}
);
table.draw();
});
$("#showPublishedDifferences").click(function() {
$.fn.dataTable.ext.search.pop();
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return !($(table.row(dataIndex).node()).attr('matchType').includes("P") ||
$(table.row(dataIndex).node()).attr('matchType') == "addedToPrimaryProject" ||
$(table.row(dataIndex).node()).attr('matchType') == "removedFromOtherProject" ||
$(table.row(dataIndex).node()).attr('matchType') == "unreconcilable"
);
}
);
table.draw();
});
$("#showUnreconcilable").click(function() {
$.fn.dataTable.ext.search.pop();
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).attr('matchType') == "unreconcilable"; }
);
table.draw();
});
$("#showAdded").click(function() {
$.fn.dataTable.ext.search.pop();
document.getElementById('showDifferences').innerHTML = "Show Differences";
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).attr('matchType') == "addedToPrimaryProject";
}
);
table.draw();
});
$("#showRemoved").click(function() {
$.fn.dataTable.ext.search.pop();
document.getElementById('showDifferences').innerHTML = "Show Differences";
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(table.row(dataIndex).node()).attr('matchType') == "removedFromOtherProject";
}
);
table.draw();
});
$(document).ready(function () {
$('button').on('click', function() {
$('button').removeClass('active');
if (this.id === 'showAllDifferences' || this.id == 'showVersionDifferences' || this.id == 'showLicenseDifferences' || this.id == 'showUnreconcilable') {
$('#showDifferences').addClass('active');
}
$(this).addClass('active');
});
});
''')
html_ptr.write("</script>\n")
html_ptr.write("</body>\n")
html_ptr.write("</html>\n")
html_ptr.close()
logger.info(" Exiting generate_html_report")
return htmlFile
####################################################################
def encodeImage(imageFile):
#############################################
# Create base64 variable for branding image
try:
with open(imageFile,"rb") as image:
encodedImage = base64.b64encode(image.read())
return encodedImage
except:
logger.error("Unable to open %s" %imageFile)
raise
#----------------------------------------------------------------------------------------#
def generate_project_hierarchy_tree(html_ptr, projectHierarchy, thisProjectInventoryCount, otherProjectInventoryCount, chartIdentifier):
logger.info("Entering generate_project_hierarchy_tree")
projectIDList = list((otherProjectInventoryCount.keys())) # Get the project IDs for the comparison project
html_ptr.write('''var hierarchy = [\n''')
for project in projectHierarchy:
projectID = project["projectID"]
# is this the top most parent or a child project with a parent
if "uniqueID" in project:
projectIdentifier = project["uniqueID"]
else:
projectIdentifier = projectID
inventoryCount = thisProjectInventoryCount[projectID]
if projectID in projectIDList:
linkColor = "lime"
else:
linkColor = "black"
html_ptr.write('''{
'id': '%s',
'parent': '%s',
'text': '%s (%s items)',
'a_attr': {
'href': '%s'
},
'li_attr' : {
'style' : 'color: %s;'
}
},\n''' %(projectIdentifier, project["parent"], project["projectName"], inventoryCount, project["projectLink"], linkColor))
html_ptr.write('''\n]''')
html_ptr.write('''
$('#''' + chartIdentifier + '''').jstree({ 'core' : {
'data' : hierarchy
} });
''')
html_ptr.write('''
$('#''' + chartIdentifier + '''').on('ready.jstree', function() {
$("#''' + chartIdentifier + '''").jstree("open_all");
$("#''' + chartIdentifier + '''").on("click", ".jstree-anchor", function(evt)
{
var link = $(evt.target).attr("href");
window.open(link, '_blank');
});
});
''' )