Skip to content

Commit 26baae8

Browse files
authored
Merge pull request #284 from nexB/239-display-scancode-options
239 display scancode options
2 parents 3bd78f1 + 6d8a847 commit 26baae8

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

assets/app/css/main.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,21 @@ div.dataTables_scrollHead th:first-child {
558558
.select2-container .select2-search__field{
559559
width: 100% !important;
560560
}
561+
562+
/*---------------------------------------
563+
ScanCode modal custom
564+
-----------------------------------------*/
565+
566+
body .modal-scancode {
567+
width: 800px;
568+
}
569+
#scancode-info {
570+
text-align: left;
571+
}
572+
#scancode-label {
573+
text-align: left;
574+
padding: 10px 0px 10px 0px;
575+
}
576+
#scancode-display {
577+
display: block;
578+
}

assets/app/js/renderer.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ $(document).ready(() => {
162162
ipcRenderer.on('import-JSON', importJson);
163163
ipcRenderer.on('export-JSON', exportJson);
164164
ipcRenderer.on('export-JSON-components-only', exportJsonComponents);
165+
ipcRenderer.on('get-ScanInfo', getScanInfo);
165166

166167
// Opens the dashboard view when the app is first opened
167168
showDashboardButton.trigger('click');
@@ -204,6 +205,25 @@ $(document).ready(() => {
204205
return updateViews();
205206
}
206207

208+
// Get the ScanCode version and options data from the DB and populate and open the modal
209+
function getScanInfo() {
210+
return aboutCodeDB.sync
211+
.then((db) => db.Header.findById(1)
212+
.then((header) => {
213+
const scancode_label = $('#scancode-info').find('#scancode-label');
214+
const scancode_display = $('#scancode-info').find('#scancode-display');
215+
if (header === null || header.scancode_version === null || header.scancode_options === null) {
216+
scancode_label.text('Please import a ScanCode results file or an AboutCode Manager sqlite file to see the scan options.');
217+
scancode_display.css('display', 'none');
218+
} else {
219+
scancode_label.text('This information has been extracted from your imported ScanCode JSON file:');
220+
scancode_display.text('ScanCode version: ' + header.scancode_version + '\n\nScanCode options: ' + JSON.stringify(header.scancode_options, null, 2));
221+
scancode_display.css('display', 'block');
222+
}
223+
}))
224+
.then($('#myModal').modal('show'));
225+
}
226+
207227
/** Loads data for all views based on the current data */
208228
function updateViews() {
209229
return aboutCodeDB.sync

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,27 @@ <h3>Debugging</h3>
416416
</div>
417417
</div>
418418

419+
<!-- ScanCode info modal -->
420+
<div class="modal fade" id="myModal" role="dialog" tabindex="-1">
421+
<div class="modal-dialog modal-scancode">
422+
<div class="modal-content">
423+
<div class="modal-header">
424+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
425+
<h4 class="modal-title">ScanCode Version and Options</h4>
426+
</div>
427+
<div class="modal-body">
428+
<div id="scancode-info">
429+
<div id="scancode-label"></div>
430+
<pre id="scancode-display"></pre>
431+
</div>
432+
</div>
433+
<div class="modal-footer">
434+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
435+
</div>
436+
</div><!-- /.modal-content -->
437+
</div><!-- /.modal-dialog -->
438+
</div><!-- /.modal -->
439+
419440
<script>require('./assets/app/js/renderer.js');</script>
420441
</body>
421442
</html>

main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ function getTemplate() {
202202
label: `AboutCode Manager Version ${packageJson.version}`,
203203
enabled: false
204204
},
205+
{
206+
label: 'Get ScanCode Version and Options',
207+
accelerator: 'CmdOrCtrl+G',
208+
click: sendEventToRenderer('get-ScanInfo')
209+
},
205210
{
206211
type: 'separator'
207212
},

0 commit comments

Comments
 (0)