Skip to content

Commit

Permalink
Automatically add Project as an prov attachment of Insight (server side)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Oct 25, 2019
1 parent 1c10f31 commit e1914f7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class ActivitySidenavComponent implements OnInit, AfterViewInit {

close(): void {
this.sidenavService.close();
this.sidenavService.destroyContentComponent();
}

onResized(event: ResizedEvent) {
Expand Down
63 changes: 39 additions & 24 deletions server/api/insight/insight.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
import DataCatalog from '../data-catalog/data-catalog.model';
import Tool from '../tool/tool.model';
import Resource from '../resource/models/resource.model';
import { entityTypes } from '../../config/environment';
import Project from '../project/project.model';

// Returns the Resources visible to the user.
export function index(req, res) {
Expand Down Expand Up @@ -78,31 +80,44 @@ export function create(req, res) {
})
.then(insight => {
if (insight) {
let activity = {
agents: [
{
userId: user._id,
name: user.name,
role: user.role,
},
],
description: '',
class: `${insight.insightType}Creation`, // TODO Use enum
generated: [
{
name: insight.title,
role: '',
targetId: insight._id,
targetVersionId: '1',
class: 'Insight', // TODO Use enum
subclass: insight.insightType,
},
],
name: `Creation of ${insight.title}`,
used: [],
};
// TODO Hopefully getting the project name will no longer be needed in the future (no duplicated data)
return Project.findById(insight.projectId)
.then(project => {
let activity = {
agents: [
{
userId: user._id,
name: user.name,
role: user.role,
},
],
description: '',
class: `${insight.insightType}Creation`, // TODO Use enum
generated: [
{
name: insight.title,
role: '',
targetId: insight._id,
targetVersionId: '1',
class: 'Insight', // TODO Use enum
subclass: insight.insightType,
},
],
name: `Creation of ${insight.title}`,
used: [
{
name: project.title,
role: '',
targetId: insight.projectId,
targetVersionId: '1',
class: entityTypes.PROJECT.value,
subsclass: '',
},
],
};

return createProvenanceActivityCore(activity).then(() => insight);
return createProvenanceActivityCore(activity).then(() => insight);
});
}
return null;
})
Expand Down

0 comments on commit e1914f7

Please sign in to comment.