Skip to content

Commit 927e59b

Browse files
MillenniumFalconMechanicNoopDog
authored andcommitted
Added matrix mouse functionality. Resolves #895. (#957)
* Spawned request for each non-human request. Resolves #895. * Test for hca-get-matrix component. First pass. * Updated UI. * Test for hca-get-matrix component. Second pass. * Test for hca-get-matrix component. Third pass. * Test for matrix-url-request-form component. * Test for matrix-url-request-completed component. * Updated UI for multiple requests. * Test for hca-get-matrix component. Second pass. * Test for matrix-url-request-form component. Second pass. * Test for matrix-url-request-completed component. Second pass. * Test for hca-get-matrix component. Third pass. * Updated failed logic. Updated tests. Resolves #895.
1 parent 72c141c commit 927e59b

32 files changed

+2340
-393
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
5+
* Action that is triggered when a successful response is received when requesting the matrix URL and we need to set up
6+
* the state for each species contained in the response.
7+
*/
8+
9+
// Core dependencies
10+
import { Action } from "@ngrx/store";
11+
import { MatrixUrlRequestSpecies } from "../../shared/matrix-url-request-species.model";
12+
13+
export class FetchMatrixUrlSpeciesSuccessAction implements Action {
14+
public static ACTION_TYPE = "FILE.FETCH_MATRIX_URL_SPECIES_SUCCESS";
15+
public readonly type = FetchMatrixUrlSpeciesSuccessAction.ACTION_TYPE;
16+
constructor(public readonly response: MatrixUrlRequestSpecies) {}
17+
}

spa/src/app/files/_ngrx/matrix/fetch-matrix-url-success.action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
// Core dependencies
1111
import { Action } from "@ngrx/store";
12-
import { MatrixResponse } from "../../shared/matrix-response.model";
12+
import { MatrixUrlRequest } from "../../shared/matrix-url-request.model";
1313

1414
export class FetchMatrixUrlSuccessAction implements Action {
1515
public static ACTION_TYPE = "FILE.FETCH_MATRIX_URL_SUCCESS";
1616
public readonly type = FetchMatrixUrlSuccessAction.ACTION_TYPE;
17-
constructor(public readonly response: MatrixResponse) {}
17+
constructor(public readonly response: MatrixUrlRequest) {}
1818
}

spa/src/app/files/_ngrx/matrix/matrix.effects.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { FetchMatrixPartialQueryMatchSuccessAction } from "./fetch-matrix-partia
1919
import { FetchMatrixPartialQueryMatchRequestAction } from "./fetch-matrix-partial-query-match-request.action";
2020
import { FetchMatrixUrlRequestAction } from "./fetch-matrix-url-request.action";
2121
import { FetchMatrixUrlSuccessAction } from "./fetch-matrix-url-success.action";
22+
import { FetchMatrixUrlSpeciesSuccessAction } from "./fetch-matrix-url-species-success.action";
2223
import { FetchProjectMatrixUrlsRequestAction } from "./fetch-project-matrix-urls-request.action";
2324
import { FetchProjectMatrixUrlsSuccessAction } from "./fetch-project-matrix-urls-success.action";
2425
import { MatrixService } from "../../shared/matrix.service";
@@ -28,14 +29,16 @@ import { selectSelectedSearchTerms, selectSelectedSearchTermsBySearchKey } from
2829
import { FilesService } from "../../shared/files.service";
2930
import { DEFAULT_TABLE_PARAMS } from "../../table/table-params.model";
3031
import { SearchTerm } from "../../search/search-term.model";
32+
import { MatrixUrlRequest } from "../../shared/matrix-url-request.model";
33+
import { MatrixUrlRequestSpecies } from "../../shared/matrix-url-request-species.model";
3134

3235
@Injectable()
3336
export class MatrixEffects {
3437

3538
/**
3639
* @param {Store<AppState>} store
3740
* @param {Actions} actions$
38-
* @param {FilesService} filesService
41+
* @param {FilesService} fileService
3942
* @param {MatrixService} matrixService
4043
*/
4144
constructor(private store: Store<AppState>,
@@ -99,7 +102,15 @@ export class MatrixEffects {
99102
const {fileFormat, killSwitch$} = (action as FetchMatrixUrlRequestAction);
100103
return this.matrixService.requestMatrixUrl(searchTerms, fileFormat, killSwitch$);
101104
}),
102-
map(response => new FetchMatrixUrlSuccessAction(response))
105+
map(response => {
106+
107+
// Response can be of type MatrixUrlRequest or MatrixUrlRequestSpecies
108+
if ( response["matrixUrlRequestsBySpecies"] ) {
109+
return new FetchMatrixUrlSpeciesSuccessAction(response as MatrixUrlRequestSpecies)
110+
}
111+
112+
return new FetchMatrixUrlSuccessAction(response as MatrixUrlRequest);
113+
})
103114
);
104115

105116
/**

spa/src/app/files/_ngrx/matrix/matrix.model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
*/
77

88
// App dependencies
9-
import { MatrixResponse } from "../../shared/matrix-response.model";
9+
import { MatrixUrlRequest } from "../../shared/matrix-url-request.model";
1010
import { ProjectMatrixUrls } from "../../shared/project-matrix-urls.model";
1111

1212
export interface Matrix {
1313
fileFormats: string[];
1414
partialQueryMatch: boolean;
15-
matrixResponse: MatrixResponse;
16-
matrixUrlsByProjectId: Map<string, ProjectMatrixUrls>
15+
matrixUrlRequestsBySpecies: Map<string, MatrixUrlRequest>;
16+
matrixUrlsByProjectId: Map<string, ProjectMatrixUrls>;
1717
}

spa/src/app/files/_ngrx/matrix/matrix.reducer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { FetchMatrixUrlSuccessAction } from "./fetch-matrix-url-success.action";
1717
import { FetchProjectMatrixUrlsSuccessAction } from "./fetch-project-matrix-urls-success.action";
1818
import { CancelFetchMatrixUrlRequestAction } from "./cancel-fetch-matrix-url-request.action";
1919
import { MatrixState } from "./matrix.state";
20+
import { FetchMatrixUrlSpeciesSuccessAction } from "./fetch-matrix-url-species-success.action";
2021

2122
export function reducer(state: MatrixState = MatrixState.getDefaultState(), action: Action): MatrixState {
2223

@@ -38,7 +39,11 @@ export function reducer(state: MatrixState = MatrixState.getDefaultState(), acti
3839

3940
// Matrix URL request status has been updated
4041
case FetchMatrixUrlSuccessAction.ACTION_TYPE:
41-
return state.fetchMatrixUrlSuccess(action as FetchMatrixUrlSuccessAction);
42+
return state.fetchMatrixUrlRequestSuccess(action as FetchMatrixUrlSuccessAction);
43+
44+
// Initial Matrix URL request status for each species has been received
45+
case FetchMatrixUrlSpeciesSuccessAction.ACTION_TYPE:
46+
return state.fetchMatrixUrlRequestSpeciesSuccess(action as FetchMatrixUrlSpeciesSuccessAction);
4247

4348
// Matrix URL request has been canceled
4449
case CancelFetchMatrixUrlRequestAction.ACTION_TYPE:

spa/src/app/files/_ngrx/matrix/matrix.selectors.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ export const selectMatrix = createFeatureSelector<MatrixState>("matrix");
2222
export const selectMatrixFileFormats = createSelector(selectMatrix, (state) => state.fileFormats);
2323

2424
/**
25-
* Returns the status of the current matrix URL request.
25+
* Returns the status of the current matrix URL requests, for each species.
2626
*/
27-
export const selectMatrixResponse = createSelector(selectMatrix, (state) => state.matrixResponse);
27+
export const selectMatrixUrlRequestsBySpecies =
28+
createSelector(selectMatrix, (state) => state.matrixUrlRequestsBySpecies);
2829

2930
/**
3031
* Returns the current set of cached per-project matrix URLs
3132
*/
32-
export const selectProjectMatrixUrlsByProjectId = createSelector(selectMatrix, (state) => state.matrixUrlsByProjectId);
33+
export const selectProjectMatrixUrlsByProjectId =
34+
createSelector(selectMatrix, (state) => state.matrixUrlsByProjectId);
3335

3436
/**
3537
* Returns the matrix partial query match. That is, return true when not all of the data for the current search terms

spa/src/app/files/_ngrx/matrix/matrix.state.ts

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,28 @@
77

88
// App dependencies
99
import { FetchMatrixFileFormatsSuccessAction } from "./fetch-matrix-file-formats-success.action";
10+
import { FetchMatrixUrlSpeciesSuccessAction } from "./fetch-matrix-url-species-success.action";
1011
import { FetchFileManifestUrlSuccessAction } from "../file-manifest/fetch-file-manifest-url-success.action";
1112
import { FileManifestState } from "../file-manifest/file-manifest.state";
1213
import { FetchMatrixUrlSuccessAction } from "./fetch-matrix-url-success.action";
1314
import { FetchMatrixPartialQueryMatchSuccessAction } from "./fetch-matrix-partial-query-match-success.action";
1415
import { FetchProjectMatrixUrlsSuccessAction } from "./fetch-project-matrix-urls-success.action";
1516
import { Matrix } from "./matrix.model";
16-
import { MatrixResponse } from "../../shared/matrix-response.model";
17-
import { MatrixStatus } from "../../shared/matrix-status.model";
17+
import { MatrixUrlRequest } from "../../shared/matrix-url-request.model";
1818
import { ProjectMatrixUrls } from "../../shared/project-matrix-urls.model";
1919

2020
const DEFAULT_MATRIX = {
2121
fileFormats: [],
2222
partialQueryMatch: null,
23-
matrixResponse: {
24-
status: MatrixStatus.NOT_STARTED
25-
} as MatrixResponse,
23+
matrixUrlRequestsBySpecies: new Map<string,MatrixUrlRequest>(),
2624
matrixUrlsByProjectId: new Map<string, ProjectMatrixUrls>()
2725
};
2826

2927
export class MatrixState implements Matrix {
3028

3129
fileFormats: string[];
3230
partialQueryMatch: boolean;
33-
matrixResponse: MatrixResponse;
31+
matrixUrlRequestsBySpecies: Map<string,MatrixUrlRequest>;
3432
matrixUrlsByProjectId: Map<string, ProjectMatrixUrls>;
3533

3634
/**
@@ -50,9 +48,7 @@ export class MatrixState implements Matrix {
5048
return new MatrixState({
5149
fileFormats: this.fileFormats,
5250
partialQueryMatch: this.partialQueryMatch,
53-
matrixResponse: {
54-
status: MatrixStatus.NOT_STARTED
55-
} as MatrixResponse,
51+
matrixUrlRequestsBySpecies: new Map(),
5652
matrixUrlsByProjectId: this.matrixUrlsByProjectId
5753
});
5854
}
@@ -67,7 +63,7 @@ export class MatrixState implements Matrix {
6763
return new MatrixState({
6864
fileFormats: this.fileFormats,
6965
partialQueryMatch: null,
70-
matrixResponse: this.matrixResponse,
66+
matrixUrlRequestsBySpecies: this.matrixUrlRequestsBySpecies,
7167
matrixUrlsByProjectId: this.matrixUrlsByProjectId
7268
});
7369
}
@@ -84,11 +80,12 @@ export class MatrixState implements Matrix {
8480
* @returns {MatrixState}
8581
*/
8682
public fetchMatrixFileFormatsSuccess(action: FetchMatrixFileFormatsSuccessAction) {
83+
8784
const fileFormats = action.fileFormats;
8885
return new MatrixState({
8986
fileFormats,
9087
partialQueryMatch: this.partialQueryMatch,
91-
matrixResponse: this.matrixResponse,
88+
matrixUrlRequestsBySpecies: this.matrixUrlRequestsBySpecies,
9289
matrixUrlsByProjectId: this.matrixUrlsByProjectId
9390
});
9491
}
@@ -104,7 +101,7 @@ export class MatrixState implements Matrix {
104101
return new MatrixState({
105102
fileFormats: this.fileFormats,
106103
partialQueryMatch: action.partialQueryMatch,
107-
matrixResponse: this.matrixResponse,
104+
matrixUrlRequestsBySpecies: this.matrixUrlRequestsBySpecies,
108105
matrixUrlsByProjectId: this.matrixUrlsByProjectId
109106
});
110107
}
@@ -124,7 +121,7 @@ export class MatrixState implements Matrix {
124121
return new MatrixState({
125122
fileFormats: this.fileFormats,
126123
partialQueryMatch: this.partialQueryMatch,
127-
matrixResponse: this.matrixResponse,
124+
matrixUrlRequestsBySpecies: this.matrixUrlRequestsBySpecies,
128125
matrixUrlsByProjectId: updatedMatrixUrlsByProjectId
129126
});
130127
}
@@ -137,11 +134,32 @@ export class MatrixState implements Matrix {
137134
* @param {FetchFileManifestUrlSuccessAction} action
138135
* @returns {FileManifestState}
139136
*/
140-
public fetchMatrixUrlSuccess(action: FetchMatrixUrlSuccessAction) {
137+
public fetchMatrixUrlRequestSuccess(action: FetchMatrixUrlSuccessAction) {
138+
139+
const requestsBySpecies = new Map(this.matrixUrlRequestsBySpecies);
140+
requestsBySpecies.set(action.response.species, action.response);
141+
142+
return new MatrixState({
143+
fileFormats: this.fileFormats,
144+
partialQueryMatch: this.partialQueryMatch,
145+
matrixUrlRequestsBySpecies: requestsBySpecies,
146+
matrixUrlsByProjectId: this.matrixUrlsByProjectId
147+
});
148+
}
149+
150+
/**
151+
* Manifest URL request response has been received from server and we have determined the set of species for the
152+
* request.
153+
*
154+
* @param {FetchFileManifestUrlSuccessAction} action
155+
* @returns {FileManifestState}
156+
*/
157+
public fetchMatrixUrlRequestSpeciesSuccess(action: FetchMatrixUrlSpeciesSuccessAction) {
158+
141159
return new MatrixState({
142160
fileFormats: this.fileFormats,
143161
partialQueryMatch: this.partialQueryMatch,
144-
matrixResponse: action.response,
162+
matrixUrlRequestsBySpecies: action.response.matrixUrlRequestsBySpecies,
145163
matrixUrlsByProjectId: this.matrixUrlsByProjectId
146164
});
147165
}

spa/src/app/files/files.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ import { HCAGetDataFileSummaryComponent } from "./hca-get-data/hca-get-data-file
5454
import { HCAGetDataSummaryComponent } from "./hca-get-data/hca-get-data-summary/hca-get-data-summary.component";
5555
import { HCAGetManifestComponent } from "./hca-get-data/hca-get-manifest/hca-get-manifest.component";
5656
import { HCAGetMatrixComponent } from "./hca-get-data/hca-get-matrix/hca-get-matrix.component";
57+
import { MatrixPartialQueryMatchWarningComponent } from "./hca-get-data/matrix-partial-query-match-warning/matrix-partial-query-match-warning.component";
58+
import { MatrixUrlRequestFormComponent } from "./hca-get-data/matrix-url-request-form/matrix-url-request-form.component";
59+
import { MatrixUrlRequestCompletedComponent } from "./hca-get-data/matrix-url-request-completed/matrix-url-request-completed.component";
5760
import { HCAEllipsisTextComponent } from "./hca-content-ellipsis/hca-ellipsis-text.component";
5861
import { HCAProjectComponent } from "./hca-project/hca-project.component";
5962
import { HCATableColumnHeaderComponent } from "./hca-table-column-header/hca-table-column-header.component";
@@ -137,6 +140,9 @@ import { TableScroll } from "./table-scroll/table-scroll.component";
137140
HCAFileFilterComponent,
138141
HCAFileFilterResultComponent,
139142
HCAFileFilterWrapperComponent,
143+
MatrixPartialQueryMatchWarningComponent,
144+
MatrixUrlRequestFormComponent,
145+
MatrixUrlRequestCompletedComponent,
140146
ProjectDeprecatedComponent,
141147
ProjectDownloadsComponent,
142148
ProjectGuardComponent,

spa/src/app/files/hca-download-file/hca-download-file.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class HCADownloadFileComponent implements OnDestroy, OnInit {
161161

162162
return this.isDownloadInitiated(response) ||
163163
this.isDownloadInProgress(response) ||
164-
// Include COMPLETE here as there is a delay between when the "complete" status is received
164+
// Include COMPLETED here as there is a delay between when the "complete" status is received
165165
// from the server and when the browser initiates the actual download.
166166
this.isDownloadComplete(response);
167167
}

0 commit comments

Comments
 (0)