From 00264806e50e6e7bc6dec85e83696b7356406c13 Mon Sep 17 00:00:00 2001 From: Omkar Phansopkar Date: Thu, 21 Apr 2022 23:13:19 +0530 Subject: [PATCH 1/3] Removed conclusions module Signed-off-by: Omkar Phansopkar --- assets/app/css/main.css | 9 - .../app/js/controllers/conclusionDataTable.js | 203 -------- assets/app/js/controllers/conclusionDialog.js | 467 ------------------ assets/app/js/controllers/jsTree.js | 9 +- assets/app/js/models/conclusion.js | 52 -- assets/app/js/models/database.js | 6 +- assets/app/js/renderer.js | 79 +-- assets/app/js/workbenchDB.js | 78 +-- index.html | 120 ----- main.js | 11 - samples/conclusions.json | 1 + test/workbenchDB.test.js | 3 - 12 files changed, 14 insertions(+), 1024 deletions(-) delete mode 100644 assets/app/js/controllers/conclusionDataTable.js delete mode 100644 assets/app/js/controllers/conclusionDialog.js delete mode 100644 assets/app/js/models/conclusion.js create mode 100644 samples/conclusions.json diff --git a/assets/app/css/main.css b/assets/app/css/main.css index 53de0c96..7f352f59 100644 --- a/assets/app/css/main.css +++ b/assets/app/css/main.css @@ -180,8 +180,6 @@ body { overflow: hidden; } -.conclusion-status-dropdown { padding-left: 5px; } - .status-dropdown-menu { min-width: 110px; } #zoom-controls { @@ -687,13 +685,6 @@ div.dataTables_wrapper div.dataTables_processing { font-family: 'Lato', Helvetica, san-serif; } -/*--------------------------------------- - Conclusion DataTable ------------------------------------------*/ -.conclusions-table-container { - width: 100%; - height: 100%; -} /*--------------------------------------- Select2 custom diff --git a/assets/app/js/controllers/conclusionDataTable.js b/assets/app/js/controllers/conclusionDataTable.js deleted file mode 100644 index 268d230b..00000000 --- a/assets/app/js/controllers/conclusionDataTable.js +++ /dev/null @@ -1,203 +0,0 @@ -/* - # - # Copyright (c) 2017 nexB Inc. and others. All rights reserved. - # https://nexb.com and https://github.com/nexB/scancode-workbench/ - # The ScanCode Workbench software is licensed under the Apache License version 2.0. - # ScanCode is a trademark of nexB Inc. - # - # You may not use this software except in compliance with the License. - # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 - # Unless required by applicable law or agreed to in writing, software distributed - # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - # CONDITIONS OF ANY KIND, either express or implied. See the License for the - # specific language governing permissions and limitations under the License. - # - */ - -const Utils = require('../helpers/utils'); -const Controller = require('./controller'); - -// There must be a table element within the container element with this class -const CONCLUSION_TABLE = 'table.conclusions-table'; - -/** - * The view responsible for displaying the DataTable containing the concluded - * data created for Conclusions - */ -class ConclusionDataTable extends Controller { - constructor(tableID, workbenchDB) { - super(tableID, workbenchDB); - } - - reload() { - this.needsReload(false); - this.db().sync - .then((db) => db.Conclusion.findAll({where: {path: {$like: `${this.selectedPath()}%`}}})) - .then((conclusions) => { - this.dataTable().clear(); - this.dataTable().rows.add(conclusions); - this.dataTable().draw(); - }); - } - - redraw() { - if (this.needsReload()) { - this.reload(); - } - this.dataTable().draw(); - } - - dataTableSelector() { - return `${this.id()} ${CONCLUSION_TABLE}`; - } - - dataTable() { - if (this._dataTable) { - return this._dataTable; - } - - $('

Conclusions

').prependTo($('#conclusions-table_wrapper')); - this._dataTable = $(this.dataTableSelector()).DataTable({ - scrollX: true, - scrollResize: true, - columns: ConclusionDataTable.COLUMNS, - buttons: [ - { // Do not allow the first 2 columns to be hidden - extend: 'colvis', - columns: ':gt(1)', - collectionLayout: 'fixed two-column' - }, - { - extend: 'csv', - text: 'Export CSV' - }, - { - extend: 'excel', - text: 'Export Excel' - }, - { - name: 'json', - text: 'Export JSON', - titleAttr: 'Export JSON file', - action: () => this.getHandler('export-json')() - } - ], - language: { - 'emptyTable': 'No Conclusions created.' - }, - dom: // Needed to keep datatables buttons and search inline - "<'row'<'col-sm-9'B><'col-sm-3'f>>" + - "<'row'<'col-sm-12'tr>>" + - "<'row'<'col-sm-3'l><'col-sm-4'i><'col-sm-5'p>>", - }); - - return this._dataTable; - } - - static get COLUMNS() { - return [ - { - data: 'review_status', - title: 'Status', - name: 'status' - }, - { - data: 'path', - title: 'Path', - name: 'path' - }, - { - data: 'name', - title: 'Name', - name: 'name' - }, - { - data: 'version', - title: 'Version', - name: 'version' - }, - { - data: 'owner', - title: 'Owner', - name: 'owner' - }, - { - data: 'license_expression[
].license_expression', - title: 'License Expression', - name: 'license_expression' - }, - { - 'data': 'copyrights[
].statements[]', - 'title': 'Copyright', - 'name': 'copyright_statements' - }, - { - 'data': 'is_modified', - 'title': 'Modified', - 'name': 'is_modified' - }, - { - 'data': 'is_deployed', - 'title': 'Deployed', - 'name': 'is_deployed' - }, - { - data: 'code_type', - title: 'Code Type', - name: 'code_type', - }, - { - data: 'programming_language', - title: 'Programming Language', - name: 'programming_language' - }, - { - 'data': 'homepage_url', - 'title': 'Homepage URL', - 'name': 'homepage_url', - 'render': Utils.anchorTag - }, - { - 'data': 'download_url', - 'title': 'Download URL', - 'name': 'download_url', - 'render': Utils.anchorTag - }, - { - 'data': 'license_url', - 'title': 'License URL', - 'name': 'license_url', - 'render': Utils.anchorTag - }, - { - 'data': 'notice_url', - 'title': 'Notice URL', - 'name': 'notice_url', - 'render': Utils.anchorTag - }, - { - 'data': 'purl', - 'title': 'Package URL', - 'name': 'purl', - 'render': Utils.anchorTag - }, - { - data: 'feature', - title: 'Feature', - name: 'feature' - }, - { - data: 'purpose', - title: 'Purpose', - name: 'purpose' - }, - { - data: 'notes', - title: 'Notes', - name: 'notes', - }, - ]; - } -} - -module.exports = ConclusionDataTable; diff --git a/assets/app/js/controllers/conclusionDialog.js b/assets/app/js/controllers/conclusionDialog.js deleted file mode 100644 index 87c9008c..00000000 --- a/assets/app/js/controllers/conclusionDialog.js +++ /dev/null @@ -1,467 +0,0 @@ -/* - # - # Copyright (c) 2017 nexB Inc. and others. All rights reserved. - # https://nexb.com and https://github.com/nexB/scancode-toolkit/ - # The ScanCode software is licensed under the Apache License version 2.0. - # ScanCode is a trademark of nexB Inc. - # - # You may not use this software except in compliance with the License. - # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 - # Unless required by applicable law or agreed to in writing, software distributed - # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - # CONDITIONS OF ANY KIND, either express or implied. See the License for the - # specific language governing permissions and limitations under the License. - # - */ - -const Controller = require('./controller'); - -/** - * The view responsible for displaying the Conclusion modal dialog - */ -class ConclusionDialog extends Controller { - constructor(dialogId, workbenchDB) { - super(dialogId, workbenchDB); - - // Define DOM element constants for the modal dialog. - // TODO: Use nested ids to avoid collisions, e.g. #nodeModal .nodeModalLabel - this.dialog = this.element(); - this.title = this.dialog.find('.modal-title'); - this.status = this.dialog.find('#conclusion-status'); - this.name = this.dialog.find('#conclusion-name'); - this.license_expression = this.dialog.find('#conclusion-license-expression'); - this.owner = this.dialog.find('#conclusion-owner'); - this.copyright = this.dialog.find('#conclusion-copyright'); - this.deployed = this.dialog.find('input[name=conclusion-deployed]'); - this.modified = this.dialog.find('input[name=conclusion-modified]'); - this.codeType = this.dialog.find('#conclusion-code-type'); - this.notes = this.dialog.find('#conclusion-notes'); - this.feature = this.dialog.find('#conclusion-feature'); - this.purpose = this.dialog.find('#conclusion-purpose'); - this.language = this.dialog.find('#conclusion-language'); - this.version = this.dialog.find('#conclusion-version'); - this.homepageUrl = this.dialog.find('#conclusion-homepage-url'); - this.downloadUrl = this.dialog.find('#conclusion-download-url'); - this.licenseUrl = this.dialog.find('#conclusion-license-url'); - this.noticeUrl = this.dialog.find('#conclusion-notice-url'); - this.packageUrl = null; - this.saveButton = this.dialog.find('button#conclusion-save'); - this.deleteButton = this.dialog.find('button#conclusion-delete'); - - // Define the buttons that can be used to close the dialog. - this.exitButton = this.dialog.find('button#conclusion-exit'); - this.closeButton = this.dialog.find('button#conclusion-close'); - - // Make node view modal box draggable - this.dialog.draggable({ handle: '.modal-header' }); - this.handlers = {}; - this.saveButton.click(() => this._saveConclusion()); - this.deleteButton.click(() => this._deleteConclusion()); - - // Link each close button's click event to a method that checks for unsaved edits. - this.exitButton.click(() => this._closeConclusion()); - this.closeButton.click(() => this._closeConclusion()); - - // Enables tooltips for conclusion field labels - $('[data-toggle="tooltip"]').tooltip(); - } - - // Check whether the user has made any new edits. - _closeConclusion() { - // Retrieve the current form values, i.e., including edits not yet saved. - this.currentSerialization = this.dialog.find('form').serialize(); - - if (this.initialSerialization !== this.currentSerialization) { - return confirm('Your new changes haven\'t been saved. \n\n' + - 'Are you sure you want to exit without saving?'); - } - } - - _saveConclusion() { - const path = this.title.text(); - this._conclusion(path) - .then((conclusion) => { - return this.db().db.File - .findOne({ - attributes: ['id'], - where: { path: { $eq: path } } - }) - .then((row) => { - // Set the file id on the conclusion. - conclusion.fileId = row.id; - return conclusion; - }); - }) - .then((conclusion) => { - const modifiedValue = $('input[name=conclusion-modified]:checked').val(); - const deployedValue = $('input[name=conclusion-deployed]:checked').val(); - - return { - path: path, - fileId: conclusion.fileId, - review_status: this.status.val(), - name: this.name.val(), - license_expression: $.map(this.license_expression.val() || [], (license_expression) => { - return { license_expression: license_expression }; - }), - copyrights: $.map(this.copyright.val() || [], (copyright) => { - return { statements: copyright.split('\n') }; - }), - code_type: (this.codeType.val() || [null])[0], - is_modified: modifiedValue ? (modifiedValue === 'yes') : null, - is_deployed: deployedValue ? (deployedValue === 'yes') : null, - version: this.version.val(), - owner: (this.owner.val() || [null])[0], - feature: this.feature.val(), - purpose: this.purpose.val(), - homepage_url: (this.homepageUrl.val() || [null])[0], - download_url: (this.downloadUrl.val() || [null])[0], - license_url: (this.licenseUrl.val() || [null])[0], - notice_url: (this.noticeUrl.val() || [null])[0], - purl: this.packageUrl, - programming_language: (this.language.val() || [null])[0], - notes: this.notes.val() - }; - }) - .then((conclusion) => this.db().setConclusion(conclusion)) - .then((conclusion) => this.getHandler('save')(conclusion)); - this.dialog.modal('hide'); - $('.jstree').jstree(true).refresh(true); - } - - // Delete a created Conclusion inside the Conclusion Modal - _deleteConclusion() { - const id = this.title.text(); - this.db().findConclusion({ where: { path: id }}) - .then((conclusion) => { - if (conclusion !== null) { - return conclusion.destroy() - .then(() => this.getHandler('delete')(conclusion)); - } - }); - $('.jstree').jstree(true).refresh(true); - } - - // Populate modal input fields with suggestions from ScanCode results - show(path) { - this._conclusion(path) - .then((conclusion) => { - this.title.text(path); - return Promise.all([ - this._setupStatus(conclusion), - this._setupName(conclusion), - this._setupVersion(conclusion), - this._setupLicenseExpression(conclusion), - this._setupCopyrights(conclusion), - this._setupOwners(conclusion), - this._setupLanguage(conclusion), - this._setupHomepageUrl(conclusion), - this._setupFeature(conclusion), - this._setupPurpose(conclusion), - this._setupCodeType(conclusion), - this._setupModified(conclusion), - this._setupDeployed(conclusion), - this._setupDownloadUrl(conclusion), - this._setupLicenseUrl(conclusion), - this._setupNoticeUrl(conclusion), - this._setupPackageUrl(conclusion), - this._setupNotes(conclusion) - ]); - }) - .then(() => { - // Notify only select2 of changes - $('select').trigger('change.select2'); - - // Disable the ability to close the dialog by clicking outside - // the dialog or pressing the escape key. - this.dialog.modal({ backdrop: 'static', keyboard: false }); - - // Retrieve any previously-saved values -- use below in _closeConclusion() - // to compare with any new edits before closing the dialog. - this.initialSerialization = this.dialog.find('form').serialize(); - - this.dialog.modal('show'); - }) - .catch((err) => { - console.error(err); - throw err; - }); - } - - _conclusion(path) { - return this.db() - .findConclusion({ where: { path: path } }) - // if the conclusion doesn't exist return an object with only the path - .then((conclusion) => conclusion ? conclusion : { path: path }); - } - - _setupLicenseExpression(conclusion) { - const saved = (conclusion.license_expression || []).map((license_expression) => license_expression); - return this._licenseExpressionQuery(conclusion.path, 'license_expression') - .then((license_expressions) => license_expressions.concat(saved)) - .then((license_expressions) => { - this.license_expression.html('').select2({ - data: $.unique(license_expressions), - multiple: true, - placeholder: 'Enter Expression', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any license expressions in the scan that applies to the current path'); - } - } - }, true); - this.license_expression.val(saved); - }); - } - - _setupCopyrights(conclusion) { - const saved = $.map((conclusion.copyrights || []), (copyright) => { - return copyright.statements; - }); - return this._copyrightQuery(conclusion.path, 'statements') - .then((copyright_statements) => copyright_statements.concat(saved)) - .then((copyright_statements) => { - this.copyright.html('').select2({ - data: $.unique(copyright_statements), - multiple: true, - placeholder: 'Enter copyright', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any copyright statements in the scan pertaining to the current path'); - } - } - }, true); - this.copyright.val(saved); - }); - } - - _setupOwners(conclusion) { - const saved = conclusion.owner || []; - return this._copyrightQuery(conclusion.path, 'holders') - .then((owners) => owners.concat(saved)) - .then((owners) => { - this.owner.html('').select2({ - data: $.unique(owners), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter owner', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any owners in the scan for the current path'); - } - } - }, true); - this.owner.val(saved); - }); - } - - _setupLanguage(conclusion) { - const saved = conclusion.programming_language || []; - return this.db() - .findAllUnique(conclusion.path, 'programming_language') - .then((languages) => languages.concat(saved)) - .then((languages) => { - this.language.html('').select2({ - data: $.unique(languages), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter language', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any primary programming languages in the scan associated with the current path'); - } - } - }, true); - this.language.val(saved); - }); - } - - _setupCodeType(conclusion) { - const saved = conclusion.code_type || [] ; - const codeTypes = ['Source', 'Binary', 'Mixed', 'Document'].concat(saved); - this.codeType.html('').select2({ - data: $.unique(codeTypes), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter code type', - tags: true - }, true); - this.codeType.val(saved); - } - - _setupHomepageUrl(conclusion) { - const saved = conclusion.homepage_url || []; - return this._urlQuery(conclusion.path, 'url') - .then((homepage_urls) => homepage_urls.concat(saved)) - .then((homepage_urls) => { - this.homepageUrl.html('').select2({ - data: $.unique(homepage_urls), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter Homepage URL', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any Homepage URL in the scan for the current path'); - } - } - }, true); - this.homepageUrl.val(saved); - }); - } - - _setupDownloadUrl(conclusion) { - const saved = conclusion.download_url || []; - return Promise.all([ - this._urlQuery(conclusion.path, 'url'), - this._packageQuery(conclusion.path, 'download_url'), - ]) - .then((rows) => $.map(rows, (row) => row)) - .then((download_urls) => download_urls.concat(saved)) - .then((download_urls) => { - this.downloadUrl.html('').select2({ - data: $.unique(download_urls), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter Download URL', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any download URL in the scan for obtaining the current path'); - } - } - }, true); - this.downloadUrl.val(saved); - }); - } - - _setupLicenseUrl(conclusion) { - const saved = conclusion.license_url || []; - return Promise.all([ - this._licenseQuery(conclusion.path, 'homepage_url'), - this._licenseQuery(conclusion.path, 'text_url'), - this._licenseQuery(conclusion.path, 'reference_url'), - this._licenseQuery(conclusion.path, 'spdx_url') - ]) - .then((rows) => $.map(rows, (row) => row)) - .then((licenese_urls) => licenese_urls.concat(saved)) - .then((licenese_urls) => { - this.licenseUrl.html('').select2({ - data: $.unique(licenese_urls), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter License URL', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any License url in the scan for the current path'); - } - } - }, true); - this.licenseUrl.val(saved); - }); - } - - _setupNoticeUrl(conclusion) { - const saved = conclusion.notice_url || []; - return this._licenseQuery(conclusion.path, 'text_url') - .then((notice_urls) => notice_urls.concat(saved)) - .then((notice_urls) => { - this.noticeUrl.html('').select2({ - data: $.unique(notice_urls), - multiple: true, - maximumSelectionLength: 1, - placeholder: 'Enter Notice URL', - tags: true, - language: { - 'noResults': function () { - return ('SCWB did not find any Notice URL in the scan for the current path'); - } - } - }, true); - this.noticeUrl.val(saved); - }); - } - - _setupPackageUrl(conclusion) { - return this.db().sync - .then((db) => db.File.findOne({where: {path: conclusion.path}})) - .then((file) => this.db().sync - .then((db) => db.Package.findOne({where: {fileId: file.id}})) - .then((pkg) => { - if (pkg) { - this.packageUrl = pkg.purl; - } - })); - } - - _setupModified(conclusion) { - if (conclusion.is_modified !== null && conclusion.is_modified !== undefined) { - const modifiedValue = conclusion.is_modified ? 'yes' : 'no'; - $(`input[name=conclusion-modified][value='${modifiedValue}']`) - .prop('checked', true); - } else { - this.modified.prop('checked', false); - } - } - - _setupDeployed(conclusion) { - if (conclusion.is_deployed !== null && conclusion.is_deployed !== undefined) { - const deployedValue = conclusion.is_deployed ? 'yes' : 'no'; - $(`input[name=conclusion-deployed][value='${deployedValue}']`) - .prop('checked', true); - } else { - this.deployed.prop('checked', false); - } - } - - _setupStatus(conclusion) { - this.status.val(conclusion.review_status || ''); - } - - _setupName(conclusion) { - this.name.val(conclusion.name || ''); - } - - _setupVersion(conclusion) { - this.version.val(conclusion.version || ''); - } - - _setupFeature(conclusion) { - this.feature.val(conclusion.feature || ''); - } - - _setupPurpose(conclusion) { - this.purpose.val(conclusion.purpose || ''); - } - - _setupNotes(conclusion) { - this.notes.val(conclusion.notes || ''); - } - - _copyrightQuery(path, field) { - return this.db().findAllUnique(path, field, this.db().db.Copyright); - } - - _urlQuery(path, field) { - return this.db().findAllUnique(path, field, this.db().db.Url); - } - - _packageQuery(path, field) { - return this.db().findAllUnique(path, field, this.db().db.Package); - } - - _licenseQuery(path, field) { - return this.db().findAllUnique(path, field, this.db().db.License); - } - - _licenseExpressionQuery(path, field) { - return this.db().findAllUnique(path, field, this.db().db.LicenseExpression); - } -} - -module.exports = ConclusionDialog; diff --git a/assets/app/js/controllers/jsTree.js b/assets/app/js/controllers/jsTree.js index 01d5af3d..bcdcf1dc 100644 --- a/assets/app/js/controllers/jsTree.js +++ b/assets/app/js/controllers/jsTree.js @@ -142,13 +142,8 @@ class JsTree extends Controller { } }, 'contextmenu': { - 'items': (node) => { - return { - 'edit_conclusion': { - 'label': 'Edit Conclusion', - 'action': () => this.getHandler('node-edit')(node) - } - }; + 'items': () => { + return {}; } } }) diff --git a/assets/app/js/models/conclusion.js b/assets/app/js/models/conclusion.js deleted file mode 100644 index 26df3d59..00000000 --- a/assets/app/js/models/conclusion.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - # - # Copyright (c) 2018 nexB Inc. and others. All rights reserved. - # https://nexb.com and https://github.com/nexB/scancode-workbench/ - # The ScanCode Workbench software is licensed under the Apache License version 2.0. - # ScanCode is a trademark of nexB Inc. - # - # You may not use this software except in compliance with the License. - # You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 - # Unless required by applicable law or agreed to in writing, software distributed - # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - # CONDITIONS OF ANY KIND, either express or implied. See the License for the - # specific language governing permissions and limitations under the License. - # - */ - -const {jsonDataType} = require('./databaseUtils'); - -module.exports = function(sequelize, DataTypes) { - return sequelize.define( - 'conclusions', - { - path: DataTypes.STRING, - review_status: DataTypes.STRING, - name: DataTypes.STRING, - version: DataTypes.STRING, - license_expression: jsonDataType('license_expression'), - copyrights: jsonDataType('copyrights'), - owner: DataTypes.STRING, - code_type: DataTypes.STRING, - is_modified: DataTypes.BOOLEAN, - is_deployed: DataTypes.BOOLEAN, - feature: DataTypes.STRING, - purpose: DataTypes.STRING, - homepage_url: DataTypes.STRING, - download_url: DataTypes.STRING, - license_url: DataTypes.STRING, - notice_url: DataTypes.STRING, - programming_language: DataTypes.STRING, - notes: DataTypes.STRING, - purl: DataTypes.STRING - }, - { - getterMethods: { - copyright: function() { - return $.map(this.copyrights, (copyright) => { - return copyright.statements.join(' '); - }).join('\n'); - } - } - }); -}; diff --git a/assets/app/js/models/database.js b/assets/app/js/models/database.js index afc75dd6..a80021e5 100644 --- a/assets/app/js/models/database.js +++ b/assets/app/js/models/database.js @@ -23,7 +23,6 @@ const copyrightModel = require('./copyright'); const packageModel = require('./package'); const emailModel = require('./email'); const urlModel = require('./url'); -const conclusionModel = require('./conclusion'); const flatFileModel = require('./flatFile'); const scanErrorModel = require('./scanError'); @@ -38,7 +37,6 @@ module.exports = function(sequelize, DataTypes) { this.Package = packageModel(sequelize, DataTypes); this.Email = emailModel(sequelize, DataTypes); this.Url = urlModel(sequelize, DataTypes); - this.Conclusion = conclusionModel(sequelize, DataTypes); this.ScanError = scanErrorModel(sequelize, DataTypes); this.FlatFile = flatFileModel(sequelize, DataTypes); @@ -53,7 +51,6 @@ module.exports = function(sequelize, DataTypes) { this.File.hasMany(this.Email); this.File.hasMany(this.Url); this.File.hasMany(this.ScanError); - this.File.hasOne(this.Conclusion); // Include Array for queries this.fileIncludes = [ @@ -64,8 +61,7 @@ module.exports = function(sequelize, DataTypes) { { model: this.Package, separate: true }, { model: this.Email, separate: true }, { model: this.Url, separate: true }, - { model: this.ScanError, separate: true }, - { model: this.Conclusion } + { model: this.ScanError, separate: true } ]; return this; diff --git a/assets/app/js/renderer.js b/assets/app/js/renderer.js index 57c43063..8c3f875e 100644 --- a/assets/app/js/renderer.js +++ b/assets/app/js/renderer.js @@ -18,14 +18,12 @@ const WorkbenchDB = require('./workbenchDB'); const Splitter = require('./helpers/splitter'); const Progress = require('./helpers/progress'); -const ConclusionDialog = require('./controllers/conclusionDialog'); const FileDashboard = require('./controllers/fileDashboard'); const LicenseDashboard = require('./controllers/licenseDashboard'); const PackageDashboard = require('./controllers/packageDashboard'); const BarChart = require('./controllers/barChart'); const JsTree = require('./controllers/jsTree'); const ScanDataTable = require('./controllers/scanDataTable'); -const ConclusionDataTable = require('./controllers/conclusionDataTable'); const dialog = require('@electron/remote').dialog; const fs = require('fs'); @@ -69,21 +67,9 @@ $(document).ready(() => { const scanDataTable = new ScanDataTable('#tab-scandata', workbenchDB); - const conclusionsTable = new ConclusionDataTable('#tab-conclusion', workbenchDB) - .on('export-json', exportJsonConclusions); - - const conclusionDialog = new ConclusionDialog('#conclusionDialog', workbenchDB) - .on('save', () => { - conclusionsTable.needsReload(true); - redrawCurrentView(); - }) - .on('delete', () => { - conclusionsTable.needsReload(true); - redrawCurrentView(); - }); + const jstree = new JsTree('#jstree', workbenchDB) - .on('node-edit', (node) => conclusionDialog.show(node.id)) .on('node-selected', (node) => { updateViewsByPath(node.id); }); @@ -120,7 +106,6 @@ $(document).ready(() => { const saveSQLiteFileButton = $('#save-file'); const openSQLiteFileButton = $('#open-file'); const showScanDataButton = $('#show-tab-scandata'); - const showConclusionButton = $('#show-tab-conclusion'); const showBarChartButton = $('#show-tab-barchart'); const showFileDashboardButton = $('#show-tab-file-dashboard'); const showLicenseDashboardButton = $('#show-tab-license-dashboard'); @@ -142,12 +127,6 @@ $(document).ready(() => { scanDataTable.redraw(); }); - // Show conclusion summary table. Hide DataTable and node view - showConclusionButton.click(() => { - splitter.show(); - conclusionsTable.redraw(); - }); - showBarChartButton.click(() => { splitter.show(); barChart.redraw(); @@ -180,13 +159,11 @@ $(document).ready(() => { }); ipcRenderer.on('table-view', () => showScanDataButton.trigger('click')); - ipcRenderer.on('conclusion-summary-view', () => showConclusionButton.trigger('click')); ipcRenderer.on('open-SQLite', () => openSQLiteFileButton.trigger('click')); ipcRenderer.on('chart-summary-view', () => showBarChartButton.trigger('click')); ipcRenderer.on('save-SQLite', () => saveSQLiteFileButton.trigger('click')); ipcRenderer.on('import-JSON', importJson); ipcRenderer.on('export-JSON', exportJson); - ipcRenderer.on('export-JSON-conclusions-only', exportJsonConclusions); ipcRenderer.on('get-ScanHeader', getScanHeader); ipcRenderer.on('zoom-reset', zoomReset); ipcRenderer.on('zoom-in', zoomIn); @@ -202,10 +179,8 @@ $(document).ready(() => { $('#package-dashboard-title-text').text('Package Info Dashboard - ' + path); scanDataTable.columns(0).search(path); - conclusionDialog.selectedPath(path); jstree.selectedPath(path); scanDataTable.selectedPath(path); - conclusionsTable.selectedPath(path); fileDashboard.selectedPath(path); licenseDashboard.selectedPath(path); packageDashboard.selectedPath(path); @@ -291,10 +266,8 @@ $(document).ready(() => { scanDataTable.clearColumnFilters(); // update all views with the new database. - conclusionDialog.db(workbenchDB); jstree.db(workbenchDB); scanDataTable.db(workbenchDB); - conclusionsTable.db(workbenchDB); fileDashboard.db(workbenchDB); licenseDashboard.db(workbenchDB); packageDashboard.db(workbenchDB); @@ -473,11 +446,6 @@ $(document).ready(() => { } }); - const conclusionsPromise = workbenchDB.findAllConclusions({ - attributes: { - exclude: ['id', 'createdAt', 'updatedAt'] - } - }); const filesCountPromise = workbenchDB.getFileCount({ attributes: { @@ -486,7 +454,7 @@ $(document).ready(() => { }); Promise.all([scanCodeInfoPromise, workbenchInfoPromise, - filesCountPromise, scanDataFilesPromise, conclusionsPromise]) + filesCountPromise, scanDataFilesPromise]) .then(([scanCodeInfo, workbenchInfo, filesCount, scanDataFiles, conclusions]) => { const json = { workbench_notice: workbenchInfo.workbench_notice, @@ -506,49 +474,6 @@ $(document).ready(() => { }); }); } - - /** Export JSON file with only conclusions that have been created */ - function exportJsonConclusions() { - dialog.showSaveDialog({ - properties: ['openFile'], - title: 'Save as JSON file', - filters: [{ - name: 'JSON File Type', - extensions: ['json'] - }] - }).then((fileName) => { - if (fileName === undefined) { - return; - } - - const workbenchInfoPromise = workbenchDB.getWorkbenchInfo({ - attributes: { - exclude: ['id', 'createdAt', 'updatedAt'] - } - }); - - const conclusionsPromise = workbenchDB.findAllConclusions({ - attributes: { - exclude: ['id', 'createdAt', 'updatedAt'] - } - }); - - Promise.all([workbenchInfoPromise, conclusionsPromise]) - .then(([workbenchInfo, conclusions]) => { - const json = { - workbench_notice: workbenchInfo.workbench_notice, - workbench_version: workbenchInfo.workbench_version, - conclusions: conclusions - }; - - fs.writeFile(fileName, JSON.stringify(json), (err) => { - if (err) { - throw err; - } - }); - }); - }); - } }); function zoomReset() { diff --git a/assets/app/js/workbenchDB.js b/assets/app/js/workbenchDB.js index 790e3a51..fb524790 100644 --- a/assets/app/js/workbenchDB.js +++ b/assets/app/js/workbenchDB.js @@ -85,28 +85,8 @@ class WorkbenchDB { .then((count) => count ? count.files_count : 0); } - // Uses the conclusions table to do a findAll query - findAllConclusions(query) { - return this.sync.then((db) => db.Conclusion.findAll(query)); - } - // Uses the conclusions table to do a findOne query - findConclusion(query) { - return this.sync.then((db) => db.Conclusion.findOne(query)); - } - // Uses the conclusions table to create or set a conclusion - setConclusion(conclusion) { - return this.findConclusion({ where: { path: conclusion.path } }) - .then((dbConclusion) => { - if (dbConclusion) { - return dbConclusion.update(conclusion); - } - else { - return this.db.Conclusion.create(conclusion); - } - }); - } // Uses the files table to do a findOne query findOne(query) { @@ -166,14 +146,6 @@ class WorkbenchDB { attributes: ['id', 'path', 'parent', 'name', 'type'] }); - const analyzedPromise = this.db.Conclusion.findAll({where: {review_status: 'Analyzed'}, attributes: ['fileId']}) - .then((concs) => concs.map((conc) => conc.fileId)); - const NAPromise = this.db.Conclusion.findAll({where: {review_status: 'Attention'}, attributes: ['fileId']}) - .then((concs) => concs.map((conc) => conc.fileId)); - const OCPromise = this.db.Conclusion.findAll({where: {review_status: 'Original'}, attributes: ['fileId']}) - .then((concs) => concs.map((conc) => conc.fileId)); - const NRPromise = this.db.Conclusion.findAll({where: {review_status: 'NR'}, attributes: ['fileId']}) - .then((concs) => concs.map((conc) => conc.fileId)); const pkgPromise = this.db.Package.findAll({attributes: ['fileId']}) .then((pkgs) => pkgs.map((pkg) => pkg.fileId)); const approvedPromise = this.db.LicensePolicy.findAll({where: {label: 'Approved License'}, attributes: ['fileId']}) @@ -185,7 +157,7 @@ class WorkbenchDB { const restrictedPromise = this.db.LicensePolicy.findAll({where: {label: 'Restricted License'}, attributes: ['fileId']}) .then((policies) => policies.map((policy) => policy.fileId)); - return Promise.all([analyzedPromise, NAPromise, OCPromise, NRPromise, pkgPromise, approvedPromise, prohibitedPromise, recommendedPromise, restrictedPromise]).then((promises) => this.sync + return Promise.all([pkgPromise, approvedPromise, prohibitedPromise, recommendedPromise, restrictedPromise]).then((promises) => this.sync .then((db) => db.File.findAll(query)) .then((files) => { return files.map((file) => { @@ -209,41 +181,12 @@ class WorkbenchDB { determineJSTreeType(file, promises) { let type = ''; - const analyzed = promises[0]; - const na = promises[1]; - const oc = promises[2]; - const nr = promises[3]; - const packages = promises[4]; - const approvedPolicies = promises[5]; - const prohibitedPolicies = promises[6]; - const recommendedPolicies = promises[7]; - const restrictedPolicies = promises[8]; - - if (analyzed.includes(file.id)) { - if (file.type === 'file') { - type = 'analyzedFile'; - } else if (file.type === 'directory') { - type = 'analyzedDir'; - } - } else if (na.includes(file.id)) { - if (file.type === 'file') { - type = 'naFile'; - } else if (file.type === 'directory') { - type = 'naDir'; - } - } else if (oc.includes(file.id)) { - if (file.type === 'file') { - type = 'ocFile'; - } else if (file.type === 'directory') { - type = 'ocDir'; - } - } else if (nr.includes(file.id)) { - if (file.type === 'file') { - type = 'nrFile'; - } else if (file.type === 'directory') { - type = 'nrDir'; - } - } else if (packages.includes(file.id)) { + const packages = promises[0]; + const approvedPolicies = promises[1]; + const prohibitedPolicies = promises[2]; + const recommendedPolicies = promises[3]; + const restrictedPolicies = promises[4]; + if (packages.includes(file.id)) { if (file.type === 'file') { type = 'packageFile'; } else if (file.type === 'directory') { @@ -415,12 +358,7 @@ class WorkbenchDB { .then(() => this.db.Package.bulkCreate(this._addExtraFields(files, 'packages'), options)) .then(() => this.db.Email.bulkCreate(this._addExtraFields(files, 'emails'), options)) .then(() => this.db.Url.bulkCreate(this._addExtraFields(files, 'urls'), options)) - .then(() => this.db.ScanError.bulkCreate(this._addExtraFields(files, 'scan_errors'), options)) - .then(() => this.sequelize.Promise.each(files, (file) => { - if (file.conclusion) { - return this.db.Conclusion.create(file.conclusion, options); - } - })); + .then(() => this.db.ScanError.bulkCreate(this._addExtraFields(files, 'scan_errors'), options)); }); } diff --git a/index.html b/index.html index ecd52231..fb392991 100644 --- a/index.html +++ b/index.html @@ -97,12 +97,6 @@ -
  • - - -
  • - - - - - - -