Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WG-261: Using mock v3 DS project data response #218

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions angular/src/app/fixtures/projectv3.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const projectFixturev3 = {
result: [
{
uuid: '4983294419299528210-242ac118-0001-012',
name: 'designsafe.project',
value: {
ef: '',
dois: [],
title: 'TEST: Hazmapper/TapisV3 project',
users: [
{
role: 'pi',
user: null,
username: 'nathanf',
authorship: null,
},
{
role: 'co_pi',
user: null,
username: 'tgrafft',
authorship: null,
},
{
role: 'co_pi',
user: null,
username: 'thbrown',
authorship: null,
},
{
role: 'team_member',
user: null,
username: 'sal',
authorship: null,
},
{
role: 'team_member',
user: null,
username: 'khan263s',
authorship: null,
},
{
role: 'team_member',
user: null,
username: 'wbomar',
authorship: null,
},
{
role: 'team_member',
user: null,
username: 'jgentle',
authorship: null,
},
{
role: 'team_member',
user: null,
username: 'smassie',
authorship: null,
},
],
projectId: 'PRJ-2224',
description: '',
hazmapperMaps: [],
},
created: '2024-02-28T14:28:24.101-06:00',
lastUpdated: '2024-02-28T14:28:24.101-06:00',
associationIds: [],
},
],
total: 1,
};

export { projectFixturev3 };
57 changes: 39 additions & 18 deletions angular/src/app/services/agave-systems.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { map } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { EnvService } from '../services/env.service';
import { DesignSafeProjectCollection, Project } from '../models/models';
import { projectFixturev3 } from '../fixtures/projectv3.fixture';

export interface AgaveProjectsData {
projects: SystemSummary[];
Expand Down Expand Up @@ -58,26 +59,46 @@ export class AgaveSystemsService {
this._loadingProjects.next(true);
this._loadingProjectsFailedMessage.next(null);

this.http.get<DesignSafeProjectCollection>(this.envService.designSafeUrl + `/projects/v2/`).subscribe(
(resp) => {
const projectSystems = resp.projects.map((project) => {
return {
id: 'project-' + project.uuid,
name: project.value.projectId,
description: project.value.title,
};
});
this._projects.next(projectSystems);
this._loadingProjects.next(false);
},
(error) => {
this._projects.next(null);
this._loadingProjectsFailedMessage.next(error.message || 'An error occured.');
this._loadingProjects.next(false);
}
);
const useMockSuccess = true; // Change this to false to simulate an error
if (useMockSuccess) {
const mockResponse = projectFixturev3;
const projectSystems = mockResponse.result.map((project) => {
return {
id: 'project-' + project.uuid,
name: project.value.projectId,
description: project.value.title,
};
});
this._projects.next(projectSystems);
this._loadingProjects.next(false);
} else {
const errorMessage = 'An error occurred. Contact support';
this._projects.next(null);
this._loadingProjectsFailedMessage.next(errorMessage);
this._loadingProjects.next(false);
}
}

// this.http.get<DesignSafeProjectCollection>(this.envService.designSafeUrl + `/projects/v2/`).subscribe(
// (resp) => {
// const projectSystems = resp.projects.map((project) => {
// return {
// id: 'project-' + project.uuid,
// name: project.value.projectId,
// description: project.value.title,
// };
// });
// this._projects.next(projectSystems);
// this._loadingProjects.next(false);
// },
// (error) => {
// this._projects.next(null);
// this._loadingProjectsFailedMessage.next(error.message || 'An error occured.');
// this._loadingProjects.next(false);
// }
// );
// }

getProjectMetadata(projects: Project[], dsProjects: SystemSummary[]): Project[] {
if (dsProjects && dsProjects.length > 0) {
return projects.map((p) => {
Expand Down
Loading