Skip to content

Commit

Permalink
chore(project landing page): solved lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Snehal Kumbhar committed Feb 26, 2021
1 parent 81b0e5b commit 37b3dce
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component, Input } from '@angular/core';
import { Address } from "@dasch-swiss/dsp-js";
import { Address } from '@dasch-swiss/dsp-js';

@Component({
selector: 'app-address-template',
template: `
<div class="metadata-property">
<div class="property-label display-inline-block">
<div class='metadata-property'>
<div class='property-label display-inline-block'>
Address:
</div>
<div class="display-inline-block add-left-margin">
<div class='display-inline-block add-left-margin'>
<span>{{ address.streetAddress }}, {{ address.postalCode }} {{ address.addressLocality }}</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ export class AttributionTabViewComponent {
let atype = this.getAgentType(agent);
if (atype) {
this.currentAgent = agent;
return atype;
}
else {
this.currentAgent = this.subProperties[agent.id];
atype = this.getAgentType(this.currentAgent);
}
this.currentAgent = this.subProperties[agent.id];
atype = this.getAgentType(this.currentAgent);
return atype;
}

getAgentType (agent: Person | Organization | IId) {
if (agent instanceof Person){
if (agent instanceof Person) {
return 'person';
}
else if (agent instanceof Organization){
if (agent instanceof Organization) {
return 'organisation';
}
}
return undefined;
}

Expand Down
12 changes: 5 additions & 7 deletions src/app/project/board/board.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,10 @@ export class BoardComponent implements OnInit {
if (obj instanceof Dataset) {
this.datasetList.push(obj);
}
else if (obj instanceof SingleProject) {
if (obj instanceof SingleProject) {
this.singleProjectList.push(obj);
}
else {
this.subProperties[obj.id] = obj;
}
this.subProperties[obj.id] = obj;
});

const dsOptions = [];
Expand All @@ -161,7 +159,7 @@ export class BoardComponent implements OnInit {
// by default display first dataset
this.selectedDataset = this.datasetList[0];

// get project
// get project
this.getProjectForDataset();
},
(error: ApiResponseError) => {
Expand All @@ -175,12 +173,12 @@ export class BoardComponent implements OnInit {
getProjectForDataset() {
// get selected project for this dataset
// note that dataset always contains only one SingleProject
for (let proj of this.singleProjectList) {
for (const proj of this.singleProjectList) {
if (this.selectedDataset.project.id === proj.id) {
this.selectedProject = proj;
break;
}
};
}
}

getSubProperty(id: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IId, Organization, Person } from '@dasch-swiss/dsp-js';
templateUrl: './contacts-tab-view.component.html',
styleUrls: ['./contacts-tab-view.component.scss']
})
export class ContactsTabViewComponent implements OnInit{
export class ContactsTabViewComponent implements OnInit {
// contact details
@Input() contactDetails: Person[] | Organization[] | IId[];

Expand All @@ -20,26 +20,27 @@ export class ContactsTabViewComponent implements OnInit{
if (this.contactDetails) {
// check which type of array is present
this.contactType = this.getContactType(this.contactDetails[0]);

// if contactType is person or organization
if (this.contactType) {
this.contactsList = this.contactDetails;
return;
}
else {
// if contactType is undefined, it means it contains the array of IId objects
for (let contact of this.contactDetails) {
this.contactsList.push(this.subProperties[contact.id]);
}
this.contactType = this.getContactType(this.contactsList[0]);

// if contactType is undefined, it means it contains the array of IId objects
for (const contact of this.contactDetails) {
this.contactsList.push(this.subProperties[contact.id]);
}
this.contactType = this.getContactType(this.contactsList[0]);

}
}

getContactType(obj: Person | Organization | IId) {
if (obj instanceof Person) {
return 'person';
}
else if (obj instanceof Organization) {
if (obj instanceof Organization) {
return 'organization';
}
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class TestHostBoardComponent {
@ViewChild('datasetTabView') datasetTabView: DatasetTabViewComponent;

// metadata object
datasetMetadata = {'projectsMetadata':[{'type':'http://ns.dasch.swiss/repository#Dataset','id':'http://ns.dasch.swiss/repository#test-dataset','abstract':['Dies ist ein Testprojekt.'],'alternativeTitle':'test','conditionsOfAccess':'Open Access','dateCreated':'2001-09-26','dateModified':'2020-04-26','datePublished':'2002-09-24','distribution':{'type':'https://schema.org/DataDownload','url':'https://test.dasch.swiss'},'documentation':['Work in progress'],'howToCite':'Testprojekt (test), 2002, https://test.dasch.swiss','language':['EN','DE','FR'],'license':[{'type':'https://schema.org/URL','url':'https://creativecommons.org/licenses/by/3.0'}],'qualifiedAttribution':[{'type':'http://www.w3.org/ns/prov#Attribution','role':['contributor'],'agent':[{'id':'http://ns.dasch.swiss/repository#test-berry'}]},{'type':'http://www.w3.org/ns/prov#Attribution','role':['contributor'],'agent':[{'id':'http://ns.dasch.swiss/repository#test-hart'}]},{'type':'http://www.w3.org/ns/prov#Attribution','role':['editor'],'agent':[{'id':'http://ns.dasch.swiss/repository#test-abraham'}]},{'type':'http://www.w3.org/ns/prov#Attribution','role':['editor'],'agent':[{'id':'http://ns.dasch.swiss/repository#test-jones'}]},{'type':'http://www.w3.org/ns/prov#Attribution','role':['editor'],'agent':[{'id':'http://ns.dasch.swiss/repository#test-coleman'}]}],'status':'Ongoing','title':'Testprojekt','typeOfData':['Image','Text'],'project':{'id':'http://ns.dasch.swiss/repository#test-project'},'sameAs':[{'type':'https://schema.org/URL','url':'https://test.dasch.swiss/'}]},{'type':'http://ns.dasch.swiss/repository#Person','id':'http://ns.dasch.swiss/repository#test-hart','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Basel','postalCode':'4000','streetAddress':'Teststrasse'},'email':['leonhard.hart@test.ch'],'familyName':'Hart','givenName':'Leonhard;Aaron','jobTitle':['Prof.'],'memberOf':[{'id':'http://ns.dasch.swiss/repository#test-dasch'}]},{'type':'http://ns.dasch.swiss/repository#Person','id':'http://ns.dasch.swiss/repository#test-abraham','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Basel','postalCode':'4000','streetAddress':'Teststrasse'},'email':['stewart.abraham@test.ch'],'familyName':'Abraham','givenName':'Steward','jobTitle':['Dr.'],'memberOf':[{'id':'http://ns.dasch.swiss/repository#test-dasch'}],'sameAs':[{'type':'https://schema.org/URL','url':'https://orcid.org/0000-0002-1825-0097'}]},{'type':'http://ns.dasch.swiss/repository#Person','id':'http://ns.dasch.swiss/repository#test-berry','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Basel','postalCode':'4000','streetAddress':'Teststrasse'},'email':['lauren.berry@unibas.ch'],'familyName':'Berry;Mackenzie','givenName':'Lauren','jobTitle':['Dr.'],'memberOf':[{'id':'http://ns.dasch.swiss/repository#test-dasch'}]},{'type':'http://ns.dasch.swiss/repository#Project','id':'http://ns.dasch.swiss/repository#test-project','alternateName':['test'],'contactPoint':[{'id':'http://ns.dasch.swiss/repository#test-abraham'}],'dataManagementPlan':[{'id':'http://ns.dasch.swiss/repository#test-plan'}],'description':'Dies ist ein Testprojekt...alle Properties wurden verwendet, um diese zu testen','discipline':[{'name':'SKOS UNESCO Nomenclature','type':'https://schema.org/URL','url':'http://skos.um.es/unesco6/11'}],'endDate':'2001-01-26','funder':[{'id':'http://ns.dasch.swiss/repository#test-funder'}],'grant':[{'id':'http://ns.dasch.swiss/repository#test-grant'}],'keywords':['science','mathematics','history of science','history of mathematics'],'name':'Testprojektname (test)','publication':['testpublication'],'shortcode':'0000','spatialCoverage':[{'place':{'name':'Geonames','url':'https://www.geonames.org/2017370/russian-federation.html'}},{'place':{'name':'Geonames','url':'https://www.geonames.org/2658434/switzerland.html'}},{'place':{'name':'Geonames','url':'https://www.geonames.org/3175395/italian-republic.html'}},{'place':{'name':'Geonames','url':'https://www.geonames.org/2921044/federal-republic-of-germany.html'}},{'place':{'name':'Geonames','url':'https://www.geonames.org/3017382/republic-of-france.html'}},{'place':{'name':'Geonames','url':'https://www.geonames.org/6269131/england.html'}},{'place':{'name':'Geonames','url':'https://www.geonames.org/6255148/europe.html'}}],'startDate':'2000-07-26','temporalCoverage':[{'name':'Chronontology Dainst','type':'https://schema.org/URL','url':'http://chronontology.dainst.org/period/Ef9SyESSafJ1'}],'url':[{'type':'https://schema.org/URL','url':'https://test.dasch.swiss/'}]},{'type':'http://ns.dasch.swiss/repository#DataManagementPlan','id':'http://ns.dasch.swiss/repository#test-plan','url':[{'type':'https://schema.org/URL','url':'https://snf.ch'}],'isAvailable':false},{'type':'http://ns.dasch.swiss/repository#Person','id':'http://ns.dasch.swiss/repository#test-coleman','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Basel','postalCode':'4000','streetAddress':'Teststrasse'},'email':['james.coleman@dasch.swiss'],'familyName':'Coleman','givenName':'James','jobTitle':['Dr. des.'],'memberOf':[{'id':'http://ns.dasch.swiss/repository#test-dasch'}]},{'type':'http://ns.dasch.swiss/repository#Organization','id':'http://ns.dasch.swiss/repository#test-dasch','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Basel','postalCode':'4000','streetAddress':'Teststrasse'},'email':'info@dasch.swiss','name':['TEST'],'url':[{'type':'https://schema.org/URL','url':'https://test.swiss'}]},{'type':'http://ns.dasch.swiss/repository#Grant','id':'http://ns.dasch.swiss/repository#test-grant','funder':[{'id':'http://ns.dasch.swiss/repository#test-funder'}],'name':'Prof. test test, Prof. test Harbtestrecht','number':'0123456789','url':[{'type':'https://schema.org/URL','url':'http://p3.snf.ch/testproject'}]},{'type':'http://ns.dasch.swiss/repository#Organization','id':'http://ns.dasch.swiss/repository#test-funder','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Toronto','postalCode':'40000','streetAddress':'University of Toronto Street'},'email':'info@universityoftoronto.ca','name':['University of Toronto'],'url':[{'type':'https://schema.org/URL','url':'http://www.utoronto.ca/'}]},{'type':'http://ns.dasch.swiss/repository#Person','id':'http://ns.dasch.swiss/repository#test-jones','address':{'type':'https://schema.org/PostalAddress','addressLocality':'Basel','postalCode':'4000','streetAddress':'Teststrasse'},'email':['benjamin.jones@test.ch'],'familyName':'Jones','givenName':'Benjamin','jobTitle':['Dr. des.'],'memberOf':[{'id':'http://ns.dasch.swiss/repository#test-dasch'}]}]};
// datasetMetadata = {};
}

describe('DatasetTabViewComponent', () => {
let testHostComponent: TestHostBoardComponent;
let testHostFixture: ComponentFixture<TestHostBoardComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
Expand All @@ -31,14 +31,15 @@ describe('DatasetTabViewComponent', () => {
})
.compileComponents();
}));

beforeEach(() => {
testHostFixture = TestBed.createComponent(TestHostBoardComponent);
testHostComponent = testHostFixture.componentInstance;
testHostFixture.detectChanges();
});

it('should create', () => {

// todo: add test case when test data is ready
/* it('should create', () => {
expect(testHostComponent).toBeTruthy();
});
}); */
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class PersonTemplateComponent implements OnInit {
let isOrganizationType: boolean = false;

// if it is [Organization]
if (this.person.memberOf[0] instanceof Organization){
if (this.person.memberOf[0] instanceof Organization) {
isOrganizationType = true;
this.organizationList = this.person.memberOf;
}

// if it is [Iid], get data for every organization
if (!isOrganizationType) {
for (let entry of this.person.memberOf) {
for (const entry of this.person.memberOf) {
this.organizationList.push(this.subProperties[entry.id]);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component, Input, OnInit } from '@angular/core';
import {
SingleProject,
DataManagementPlan,
Person,
Organization,
IId,
Grant
import {
SingleProject,
DataManagementPlan,
Person,
Organization,
IId,
Grant
} from '@dasch-swiss/dsp-js';

@Component({
Expand All @@ -27,7 +27,7 @@ export class ProjectTabViewComponent implements OnInit {
dateKeys = ['startDate', 'endDate'];

dmps: DataManagementPlan[] = [];
funders: Person[] | Organization [] = [];
funders: Person[] | Organization[] = [];
funderType: string;
grants = [];

Expand All @@ -48,58 +48,58 @@ export class ProjectTabViewComponent implements OnInit {

}

getDMP(currenDmps) {
if (currenDmps instanceof DataManagementPlan){
getDMP(currenDmps: DataManagementPlan | IId[]) {
if (currenDmps instanceof DataManagementPlan) {
return [currenDmps];
}
else {
let tmp: DataManagementPlan[] = [];
for (let iid of currenDmps) {
tmp.push(this.subProperties[iid.id]);
}
return tmp;

const tmp: DataManagementPlan[] = [];
for (const iid of currenDmps) {
tmp.push(this.subProperties[iid.id]);
}
return tmp;
}

getFunders(flist) {
getFunders(flist: any[]) {
// check if it is person, organization or IId
this.funderType = this.getFunderType(flist[0]);

if (this.funderType) {
this.funders = flist;
return;
}
else {
for (let funder of flist) {
this.funders.push(this.subProperties[funder.id]);
}
this.funderType = this.getFunderType(this.funders[0]);

for (const funder of flist) {
this.funders.push(this.subProperties[funder.id]);
}
this.funderType = this.getFunderType(this.funders[0]);
}

getFunderType(funder: Person | Organization | IId) {
if (funder instanceof Person){
if (funder instanceof Person) {
return 'person';
}
else if (funder instanceof Organization){
if (funder instanceof Organization) {
return 'organization';
}
return undefined;
}

getGrants(glist) {
getGrants(glist: any[]) {
let tmpGrants: Grant[] = [];

if (glist[0] instanceof Grant) {
tmpGrants = glist;
}
// if it is IId objects array, retrive it's details
// tslint:disable-next-line
else {
for (let iid of glist) {
for (const iid of glist) {
tmpGrants.push(this.subProperties[iid.id]);
}
}
// get funder details along with other details
for (let grant of tmpGrants) {
for (const grant of tmpGrants) {
let tmpGrantObj: object;

// checck if grant contains person, organization or IId objects
Expand All @@ -109,10 +109,11 @@ export class ProjectTabViewComponent implements OnInit {
// it is a person of organization object
flist = grant.funder;
}
// tslint:disable-next-line
else {
// it means it is a IId object. So we need to retrive the details
// it means it is a IId object. So we need to retrive the details
// of every funder using the id provided here
for (let fund of grant.funder) {
for (const fund of grant.funder) {
flist.push(this.subProperties[fund.id]);
}
ftype = this.getFunderType(flist[0]);
Expand All @@ -121,9 +122,9 @@ export class ProjectTabViewComponent implements OnInit {
tmpGrantObj = {
funder : flist,
funderType: ftype,
name: grant.name? grant.name : undefined,
number: grant.number? grant.number : undefined,
url: grant.url? grant.url : undefined
name: grant.name ? grant.name : undefined,
number: grant.number ? grant.number : undefined,
url: grant.url ? grant.url : undefined
};

this.grants.push(tmpGrantObj);
Expand Down

0 comments on commit 37b3dce

Please sign in to comment.