diff --git a/apps/a2agc/src/app/core/components/page-menu/page-menu.component.html b/apps/a2agc/src/app/core/components/page-menu/page-menu.component.html
index 81908248..5cba2453 100644
--- a/apps/a2agc/src/app/core/components/page-menu/page-menu.component.html
+++ b/apps/a2agc/src/app/core/components/page-menu/page-menu.component.html
@@ -16,19 +16,19 @@
Data Distributions
-
+
info_outlined
About
-
+
Data Schema Browser
-
+
bar_chart_outline
diff --git a/apps/a2agc/src/app/core/components/page-menu/page-menu.component.scss b/apps/a2agc/src/app/core/components/page-menu/page-menu.component.scss
index 3f4b987f..880d3eea 100644
--- a/apps/a2agc/src/app/core/components/page-menu/page-menu.component.scss
+++ b/apps/a2agc/src/app/core/components/page-menu/page-menu.component.scss
@@ -1,7 +1,7 @@
:host {
display: block;
width: 30rem;
- padding-bottom: 2rem;
+ margin-bottom: 2rem;
.header,
.pages .link :not(mat-divider),
diff --git a/apps/a2agc/src/app/core/services/dataset-loader/dataset-loader.service.ts b/apps/a2agc/src/app/core/services/dataset-loader/dataset-loader.service.ts
index 32a7d0a4..8291a5dc 100644
--- a/apps/a2agc/src/app/core/services/dataset-loader/dataset-loader.service.ts
+++ b/apps/a2agc/src/app/core/services/dataset-loader/dataset-loader.service.ts
@@ -100,6 +100,10 @@ export class DatasetLoaderService {
* @returns parsed results
*/
private parseRawData(data: RawData): ParseResults {
+ if (!data) {
+ return { datasets: [], variables: [] };
+ }
+
const datasets: Dataset[] = [];
const variables: DatasetVariable[] = [];
diff --git a/apps/a2agc/src/app/core/state/data/data.state.ts b/apps/a2agc/src/app/core/state/data/data.state.ts
index a3c721e1..14eea946 100644
--- a/apps/a2agc/src/app/core/state/data/data.state.ts
+++ b/apps/a2agc/src/app/core/state/data/data.state.ts
@@ -1,29 +1,24 @@
-import { Injectable } from '@angular/core';
import { StateRepository } from '@angular-ru/ngxs/decorators';
import { NgxsImmutableDataRepository } from '@angular-ru/ngxs/repositories';
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
import { State } from '@ngxs/store';
+import { catchError, map, Observable, of } from 'rxjs';
import { DATA_CONFIG } from '../../../../configs/config';
import { DatasetLoaderService, RawData } from '../../services/dataset-loader/dataset-loader.service';
import { DatasetVariablesState } from './dataset-variables.state';
import { DatasetsState } from './datasets.state';
-import { Observable, catchError, map, of } from 'rxjs';
-import { HttpClient } from '@angular/common/http';
-
export type DataStateModel = Record;
-
/**
* Data state, contains datasets state and dataset variables state
*/
@StateRepository()
@State({
name: 'data',
- children: [
- DatasetsState,
- DatasetVariablesState
- ]
+ children: [DatasetsState, DatasetVariablesState],
})
@Injectable()
export class DataState extends NgxsImmutableDataRepository {
@@ -49,22 +44,22 @@ export class DataState extends NgxsImmutableDataRepository {
ngxsOnInit(): void {
super.ngxsOnInit();
- this.datasetLoader.load(DATA_CONFIG.datasetsPath).subscribe(result => {
+ this.datasetLoader.load(DATA_CONFIG.datasetsPath).subscribe((result) => {
this.datasetsState.addMany(result.datasets);
this.variablesState.addMany(result.variables);
});
}
-
/**
- * Determines whether app is inprivate mode
- * @returns true if the data config datasets path is valid, otherwise returns false
+ * Determines whether app is in private mode
+ * Searches for aggregate-table-data.json in assets/generated and checks if it's empty
+ * @returns true if the file contains data, false if empty
*/
isPrivate(): Observable {
const response = this.http.get(DATA_CONFIG.datasetsPath, { responseType: 'json' });
return response.pipe(
- catchError((this.handleError)),
- map(result => Object.keys(result).length > 0)
+ map((result) => this.isNotEmpty(result)),
+ catchError(this.handleError)
);
}
@@ -75,4 +70,13 @@ export class DataState extends NgxsImmutableDataRepository {
private handleError(): Observable {
return of(false);
}
+
+ /**
+ * Checks if object is not empty
+ * @param input object
+ * @returns true if not empty
+ */
+ private isNotEmpty(input: RawData): boolean {
+ return Object.keys(input).length !== 0;
+ }
}