Skip to content

Commit

Permalink
Merge pull request #365 from nexB/337-add-purl-to-conclusion
Browse files Browse the repository at this point in the history
Add pURL support for Conclusions
  • Loading branch information
steven-esser authored Apr 19, 2019
2 parents 247dcfc + 8976672 commit 7f4edc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions assets/app/js/controllers/conclusionDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ class ConclusionDataTable extends Controller {
'name': 'notice_url',
'render': Utils.anchorTag
},
{
'data': 'purl',
'title': 'Package URL',
'name': 'purl',
'render': Utils.anchorTag
},
{
data: 'feature',
title: 'Feature',
Expand Down
15 changes: 15 additions & 0 deletions assets/app/js/controllers/conclusionDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ConclusionDialog extends Controller {
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');

Expand Down Expand Up @@ -117,6 +118,7 @@ class ConclusionDialog extends Controller {
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()
};
Expand Down Expand Up @@ -161,6 +163,7 @@ class ConclusionDialog extends Controller {
this._setupDownloadUrl(conclusion),
this._setupLicenseUrl(conclusion),
this._setupNoticeUrl(conclusion),
this._setupPackageUrl(conclusion),
this._setupNotes(conclusion)
]);
})
Expand Down Expand Up @@ -343,6 +346,18 @@ class ConclusionDialog extends Controller {
});
}

_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';
Expand Down
3 changes: 2 additions & 1 deletion assets/app/js/models/conclusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ module.exports = function(sequelize, DataTypes) {
license_url: DataTypes.STRING,
notice_url: DataTypes.STRING,
programming_language: DataTypes.STRING,
notes: DataTypes.STRING
notes: DataTypes.STRING,
purl: DataTypes.STRING
},
{
getterMethods: {
Expand Down

0 comments on commit 7f4edc2

Please sign in to comment.