@@ -14,19 +14,20 @@ import { Config } from "./config.model";
1414import { environment } from "../../environments/environment" ;
1515import { AppState } from "../_ngrx/app.state" ;
1616import { FetchConfigRequestSuccessAction } from "./_ngrx/config.actions" ;
17+ import { APIEndpoints } from "./api-endpoints.model" ;
1718
1819@Injectable ( )
1920export class ConfigService {
2021
2122 // Locals
22- private dataURL : string ; // Pulled from config store, saved as local state here on service
23- private dcpHealthCheckUrl : string ;
24- private matrixURL : string ;
25- private portalURL : string ;
26- private deployment : string ;
27- private projectMetaURL : string ;
28- private store : Store < AppState > ;
29- private version : string ;
23+ protected dataURL : string ; // Pulled from config store, saved as local state here on service
24+ protected dcpHealthCheckUrl : string ;
25+ protected matrixURL : string ;
26+ protected portalURL : string ;
27+ protected deployment : string ;
28+ protected projectMetaURL : string ;
29+ protected store : Store < AppState > ;
30+ protected version : string ;
3031
3132 /**
3233 * @param store {Store<AppState>}
@@ -37,41 +38,55 @@ export class ConfigService {
3738 }
3839
3940 /**
40- * Build full end point URL, from API URL and specified path .
41- *
42- * @param path
41+ * Returns the URL for an entities end point (projects, files, samples) .
42+ *
43+ * @param { string } entityName
4344 * @returns {string }
4445 */
45- public buildApiUrl ( path : string ) {
46+ public getEntitiesUrl ( entityName : string ) : string {
4647
47- const domain = this . getAPIURL ( ) ;
48- return `${ domain } ${ path } ` ;
48+ const pathBase = this . getIndexBasePath ( ) ;
49+ return `${ this . dataURL } ${ pathBase } / ${ entityName } ` ;
4950 }
5051
5152 /**
52- * Hit API end point to retrieve configuration information for this HCA instance. Must return promise here
53- * as this method is called during Angular's app initialization and we need to resolve the config details (eg
54- * data URL) before any components are instantiated. The config details returned from the server are saved on
55- * this config service as local state (for easy access from calling classes where we don't want to handle
56- * Observables) as well as in the store.
53+ * Returns the URL for the integrations end point.
5754 *
58- * Note: if we add a fetch method at a later stage (eg to retrieve updated config), the local data URL value on this
59- * service must be updated as well as the value in the store.
55+ * @returns {string }
56+ */
57+ public getFileManifestUrl ( ) : string {
58+
59+ const fileManifestSummaryPath = APIEndpoints . FILE_MANIFEST_SUMMARY ;
60+ return `${ this . dataURL } ${ fileManifestSummaryPath } ` ;
61+ }
62+
63+ /**
64+ * Returns the URL for checking the system status and indexing status of Azul.
65+ *
66+ * @returns {string }
67+ */
68+ public getIndexStatusUrl ( ) : string {
69+
70+ return `${ this . dataURL } ${ APIEndpoints . INDEX_STATUS } ` ;
71+ }
72+
73+ /**
74+ * Returns the URL for the integrations end point.
6075 *
61- * @returns {Promise<Config> }
76+ * @returns {string }
6277 */
63- public initConfig ( ) : Promise < Config > {
78+ public getIntegrationsUrl ( ) : string {
6479
65- this . storeConfig ( environment as Config ) ;
66- return Promise . resolve ( environment as Config ) ;
80+ const integrationsPath = APIEndpoints . INTEGRATIONS ;
81+ return ` ${ this . dataURL } ${ integrationsPath } ` ;
6782 }
6883
6984 /**
7085 * Return the data URL.
7186 *
7287 * @returns {string }
7388 */
74- public getDataURL ( ) : string {
89+ public getDataUrl ( ) : string {
7590
7691 return this . dataURL ;
7792 }
@@ -81,7 +96,7 @@ export class ConfigService {
8196 *
8297 * @returns {string }
8398 */
84- public getDCPHealthCheckURL ( ) : string {
99+ public getDCPHealthCheckUrl ( ) : string {
85100
86101 return this . dcpHealthCheckUrl ;
87102 }
@@ -91,17 +106,38 @@ export class ConfigService {
91106 *
92107 * @returns {string }
93108 */
94- public getMatrixURL ( ) : string {
109+ public getMatrixUrl ( ) : string {
95110
96111 return this . matrixURL ;
97112 }
98113
114+ /**
115+ * Returns the matrix formats URL.
116+ *
117+ * @returns {string }
118+ */
119+ public getMatrixFormatsUrl ( ) : string {
120+
121+ return `${ this . matrixURL } ${ APIEndpoints . MATRIX_FORMATS } ` ;
122+ }
123+
124+ /**
125+ * Returns the matrix request URL.
126+ *
127+ * @param {string } requestId
128+ * @returns {string }
129+ */
130+ public getMatrixRequestUrl ( requestId : string ) : string {
131+
132+ return `${ this . matrixURL } /${ requestId } ` ;
133+ }
134+
99135 /**
100136 * Returns the portal URL.
101137 *
102138 * @returns {string }
103139 */
104- public getPortalURL ( ) : string {
140+ public getPortalUrl ( ) : string {
105141
106142 return this . portalURL ;
107143 }
@@ -111,7 +147,7 @@ export class ConfigService {
111147 *
112148 * @returns {string }
113149 */
114- public getProjectMetaURL ( ) : string {
150+ public getProjectMetaUrl ( ) : string {
115151
116152 return this . projectMetaURL ;
117153 }
@@ -122,9 +158,9 @@ export class ConfigService {
122158 * @param {string } projectId
123159 * @returns {string }
124160 */
125- public getProjectMetaDownloadURL ( projectId : string ) : string {
161+ public getProjectMetaDownloadUrl ( projectId : string ) : string {
126162
127- return `${ this . getProjectMetaURL ( ) } /project-assets/project-metadata /${ projectId } .tsv` ;
163+ return `${ this . getProjectMetaUrl ( ) } ${ APIEndpoints . PROJECT_METADATA } /${ projectId } .tsv` ;
128164 }
129165
130166 /**
@@ -133,23 +169,63 @@ export class ConfigService {
133169 * @param {string } fileName
134170 * @returns {string }
135171 */
136- public getProjectPreparedMatrixDownloadURL ( fileName : string ) : string {
172+ public getProjectPreparedMatrixDownloadUrl ( fileName : string ) : string {
137173
138- return `${ this . getProjectMetaURL ( ) } /project-assets/project-matrices /${ fileName } ` ;
174+ return `${ this . getProjectMetaUrl ( ) } ${ APIEndpoints . PROJECT_MATRICES } /${ fileName } ` ;
139175 }
140176
141177 /**
142- * Return the full data API URL for this HCA instance .
178+ * Returns the URL for the project end point .
143179 *
180+ * @param {string } projectId
144181 * @returns {string }
145182 */
146- public getAPIURL ( ) : string {
183+ public getProjectUrl ( projectId : string ) : string {
147184
148- if ( this . dataURL ) {
149- return this . dataURL ;
150- }
151-
152- return "" ;
185+ const pathBase = this . getIndexBasePath ( ) ;
186+ const projectsPath = APIEndpoints . PROJECTS ;
187+ return `${ this . dataURL } ${ pathBase } ${ projectsPath } /${ projectId } ` ;
188+ }
189+
190+ /**
191+ * Return the full URL for the specified release file URL.
192+ *
193+ * @param {string } releaseFileUrl
194+ * @returns {string }
195+ */
196+ public getReleaseFileUrl ( releaseFileUrl : string ) : string {
197+
198+ return `${ this . getProjectMetaUrl ( ) } ${ APIEndpoints . RELEASES } /${ releaseFileUrl } ` ;
199+ }
200+
201+ /**
202+ * Returns the URL for the summary end point.
203+ *
204+ * @returns {string }
205+ */
206+ public getSummaryUrl ( ) : string {
207+
208+ const pathBase = this . getIndexBasePath ( ) ;
209+ const summaryPath = APIEndpoints . SUMMARY ;
210+ return `${ this . dataURL } ${ pathBase } ${ summaryPath } ` ;
211+ }
212+
213+ /**
214+ * Hit API end point to retrieve configuration information for this HCA instance. Must return promise here
215+ * as this method is called during Angular's app initialization and we need to resolve the config details (eg
216+ * data URL) before any components are instantiated. The config details returned from the server are saved on
217+ * this config service as local state (for easy access from calling classes where we don't want to handle
218+ * Observables) as well as in the store.
219+ *
220+ * Note: if we add a fetch method at a later stage (eg to retrieve updated config), the local data URL value on this
221+ * service must be updated as well as the value in the store.
222+ *
223+ * @returns {Promise<Config> }
224+ */
225+ public initConfig ( ) : Promise < Config > {
226+
227+ this . storeConfig ( environment as Config ) ;
228+ return Promise . resolve ( environment as Config ) ;
153229 }
154230
155231 /**
@@ -182,6 +258,18 @@ export class ConfigService {
182258 return this . version === "2.0" ;
183259 }
184260
261+ /**
262+ * Returns the "base path" for index/repository API calls.
263+ */
264+ private getIndexBasePath ( ) : string {
265+
266+ if ( this . isV2 ( ) ) {
267+ return "/index" ;
268+ }
269+
270+ return "/repository" ;
271+ }
272+
185273 /**
186274 * Save the data URL as a local variable ogetAPIURLn this instance, and update the corresponding config value in the store.
187275 *
0 commit comments