Skip to content

Commit

Permalink
Add TreeView to all views
Browse files Browse the repository at this point in the history
* Dashboard d3 charts update depending on selected path
* File Counts update depending on selected path
* Unique License and Copyright counts now filtered by selected path
* Package counts now filtered by selected path
* Update file counts in BarChart view
* Add TreeView support to Conclusions table

Addresses: #267

Signed-off-by: Steven Esser <[email protected]>
  • Loading branch information
steven-esser committed Oct 2, 2018
1 parent f7d7c6a commit 5764cce
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
6 changes: 3 additions & 3 deletions assets/app/js/controllers/aboutCodeBarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class AboutCodeBarChart extends Controller {
reload() {
this.needsReload(false);

this.db()
.getFileCount()
.then((value) => this.barChartTotalFiles.text(value));
this.db().sync
.then((db) => db.File.findOne({where: {path: this.selectedPath()}}))
.then((file) => this.barChartTotalFiles.text(file.files_count));

if (this.chartAttributesSelect.val()) {
const attribute = this.chartAttributesSelect.val();
Expand Down
3 changes: 2 additions & 1 deletion assets/app/js/controllers/aboutCodeConclusionDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class AboutCodeConclusionDataTable extends Controller {

reload() {
this.needsReload(false);
this.db().findAllConclusions({})
this.db().sync
.then((db) => db.Conclusion.findAll({where: {path: {$like: `${this.selectedPath()}%`}}}))
.then((conclusions) => {
this.dataTable().clear();
this.dataTable().rows.add(conclusions);
Expand Down
47 changes: 30 additions & 17 deletions assets/app/js/controllers/aboutCodeDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,45 +114,58 @@ class AboutCodeDashboard extends Controller {
reload() {
this.needsReload(false);

// Get total files scanned
// Get # files scanned at a certain path
this.totalFilesProgressbar.showIndeterminate();
this.db().sync
.then((db) => db.Header.findOne({ attributes: ['files_count'] }))
.then((db) => db.File.findOne({where: {path: this.selectedPath()}}))
.then((row) => this.totalFilesScanned.text(row ? row.files_count : '0'))
.then(() => this.totalFilesProgressbar.hide());

// Get total unique licenses detected
// Get total unique licenses detected at a certain path
this.uniqueLicensesProgressbar.showIndeterminate();
this.db().sync
.then((db) => db.License.aggregate('key', 'DISTINCT', {plain: false}))
.then((row) => this.uniqueLicenses.text(row ? row.length : '0'))
.then((db) => db.File.findAll({where: {path: {$like: `${this.selectedPath()}%`}}}))
.then((files) => files.map((val) => val.id))
.then((fileIds) => this.db().sync
.then((db) => db.License.findAll({where: {fileId: fileIds}}))
.then((licenses) => licenses.map((val) => val.key))
.then((keys) => this.uniqueLicenses.text(new Set(keys).size)))
.then(() => this.uniqueLicensesProgressbar.hide());

// Get total unique copyright statements detected
// Get total unique copyright statements detected at a certain path
this.uniqueCopyrightsProgressbar.showIndeterminate();
this.db().sync
.then((db) => db.Copyright.aggregate('holders', 'DISTINCT', { plain: false }))
.then((row) => this.uniqueCopyrights.text(row ? row.length : '0'))
.then((db) => db.File.findAll({where: {path: {$like: `${this.selectedPath()}%`}}}))
.then((files) => files.map((val) => val.id))
.then((fileIds) => this.db().sync
.then((db) => db.Copyright.findAll({where: {fileId: fileIds}}))
.then((copyrights) => copyrights.map((val) => val.statements))
.then((statements) => statements.map((val) => val.pop()))
.then((statements) => this.uniqueCopyrights.text(new Set(statements).size)))
.then(() => this.uniqueCopyrightsProgressbar.hide());

// Get total number of packages detected
this.totalPackagesProgressbar.showIndeterminate();
this.db().sync
.then((db) => db.Package.count('type'))
.then((count) => this.totalPackages.text(count ? count : '0'))
.then((db) => db.File.findAll({where: {path: {$like: `${this.selectedPath()}%`}}}))
.then((files) => files.map((val) => val.id))
.then((fileIds) => this.db().sync
.then((db) => db.Package.findAll({where: {fileId: fileIds}}))
.then((packages) => packages.map((val) => val.type))
.then((types) => this.totalPackages.text(types.length)))
.then(() => this.totalPackagesProgressbar.hide());

// Get unique programming languages detected
this.sourceLanguageChartData = this._loadData('programming_language');
this.sourceLanguageChartData = this._loadChartData('programming_language', this.selectedPath());

// Get license categories detected
this.licenseCategoryChartData = this._loadData('license_category');
this.licenseCategoryChartData = this._loadChartData('license_category', this.selectedPath());

// Get license keys detected
this.licenseKeyChartData = this._loadData('license_key');
this.licenseKeyChartData = this._loadChartData('license_key', this.selectedPath());

// Get package types detected
this.packagesTypeChartData = this._loadData('packages_type');
this.packagesTypeChartData = this._loadChartData('packages_type', this.selectedPath());
}

redraw() {
Expand Down Expand Up @@ -213,17 +226,17 @@ class AboutCodeDashboard extends Controller {
}));
}

_loadData(attribute, parentPath) {
_loadChartData(attribute, parentPath) {
const where = {
$and: [{
type: {
$eq: 'file'
}
}]
};

if (parentPath) {
where.path.$and.append({$like: `${parentPath}%`});
where.$and.push({path: {$like: `${parentPath}%`}});
}

return this.db().sync.then((db) => {
Expand Down
4 changes: 2 additions & 2 deletions assets/app/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ $(document).ready(() => {

// Show conclusion summary table. Hide DataTable and node view
showConclusionButton.click(() => {
splitter.hide();
splitter.show();
conclusionsTable.redraw();
});

Expand All @@ -144,7 +144,7 @@ $(document).ready(() => {
});

showDashboardButton.click(() => {
splitter.hide();
splitter.show();
dashboard.redraw();
});

Expand Down

0 comments on commit 5764cce

Please sign in to comment.