Skip to content

Commit 05c1092

Browse files
added changes to help, about, and config service
1 parent 4ff2d96 commit 05c1092

File tree

64 files changed

+1944
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1944
-580
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.main-app {
22
height: 100%;
3-
min-height: calc(100vh - 6.5rem);
3+
min-height: calc(100vh - 3.5rem);
44
padding: 1.5rem;
55
}

src/app/about/about/about.component.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<ul>
1111
<li>
1212
<a
13-
*ngIf="facility === 'PSI'"
1413
href="{{ SciCatGitHub }}"
1514
target="blank"
1615
>SciCat Github Project.</a
@@ -24,20 +23,22 @@
2423
<mat-card-header>
2524
<mat-card-title>Access Conditions</mat-card-title>
2625
</mat-card-header>
27-
<mat-card-content> {{ accessText }}</mat-card-content>
26+
<mat-card-content>
27+
<span [innerHTML]="accessText | linky"></span>
28+
</mat-card-content>
2829
</mat-card>
2930

3031
<mat-card class="example-card">
3132
<mat-card-header>
3233
<mat-card-title>Terms of Use</mat-card-title>
3334
</mat-card-header>
3435
<mat-card-content>
35-
{{ termsText }}
36+
<span [innerHTML]="termsText | linky"></span>
3637
<a *ngIf="facility === 'PSI'" href="{{ SNFLink }}" target="blank"
3738
>Open Research Data.</a
3839
>
3940
<br /><br />
40-
{{ termsTextContinued }}
41+
<span [innerHTML]="termsTextContinued | linky"></span>
4142
<a *ngIf="facility === 'PSI'" href="{{ PSIDataPolicy }}" target="blank"
4243
>Data Policy.</a
4344
>

src/app/about/about/about.component.ts

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,10 @@ export class AboutComponent implements OnInit {
3131
this.SNFLink =
3232
"http://www.snf.ch/en/theSNSF/research-policies/open_research_data/Pages/default.aspx#Guidelines%20and%20Regulations";
3333
this.PSIDataPolicy = "https://www.psi.ch/en/science/psi-data-policy";
34-
this.aboutText =
35-
"Scicat allows users to access data and metadata from experiments";
36-
this.accessText = "Users must comply with access policy of instruments";
37-
this.termsText = "Data can be used freely under the CC-BY-4.0 licence";
38-
if (this.facility === "ESS") {
39-
this.aboutText =
40-
"Scicat is a metadata catalogue allows users to access information about experimental results, " +
41-
"measured at the European Spallation Source, " +
42-
"(https://esss.se/). " +
43-
"Scientific datasets are linked to proposals and samples. " +
44-
"Scientific datasets are linked to publications (DOI, PID). " +
45-
"SciCat helps to keep track of data provenance (i.e. the steps leading to the final results). " +
46-
"Scicat allows users to find data based on the metadata (both your own data and other peoples’ public data). " +
47-
"In the long term, SciCat will help to automate scientific analysis workflows.";
48-
this.accessText =
49-
"Access to the online catalogue of open data will be given to a user," +
50-
" providing the user registers with ESS " +
51-
" and accepts the terms of the ESS scientific data policy ";
52-
this.termsText =
53-
"All scientific datasets are licensed under the CC-BY-4.0 license ";
54-
} else if (this.facility === "PSI") {
55-
this.aboutText =
56-
"SciCat is a metadata catalog. At PSI, SciCat works in conjunction with a PetaByte archive and remote accesss system." +
57-
" Together these components provide users with the ability to store, search and access their data." +
58-
" SciCat is an open source project in collaboration with ESS and Max IV";
34+
this.aboutText = this.appConfig.aboutText || "Scicat allows users to access data and metadata from experiments";
35+
this.accessText = this.appConfig.accessText || "Users must comply with access policy of instruments";
36+
this.termsText = this.appConfig.termsText || "Data can be used freely under the CC-BY-4.0 license";
37+
this.termsTextContinued = this.appConfig.termsTextContinued || "";
5938

60-
this.accessText =
61-
"Access to SciCat is granted to users by the Digital User Office.";
62-
this.termsTextContinued = "Additionally, PSI defines it's own ";
63-
this.termsText =
64-
"The Swiss National Science Foundation describes policy and guidelines on ";
65-
} else if (this.facility === "MAX IV") {
66-
this.aboutText =
67-
"Scicat allows users to access data and metadata from experiments at MAX IV.";
68-
this.accessText = "Users must comply with access policy of instruments";
69-
this.termsText = "Data can be used freely under the CC-BY-4.0 licence";
70-
}
7139
}
7240
}

src/app/app-config.service.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ const appConfig: AppConfig = {
4545
multipleDownloadAction: "http://localhost:3012/zip",
4646
multipleDownloadEnabled: true,
4747
multipleDownloadUseAuthToken: false,
48+
aboutText: "Configured about text",
49+
accessText: "Configured access policy",
50+
termsText: "Configured terms of use",
51+
termsTextContinued: "Configured additional terms text",
52+
docText: "Configured documentation Text",
53+
gettingStartedExtraText: "Configured gettingStarted Text",
54+
whereIsMyDataText: "Configured whereIsMyDataText",
55+
howToPublishDataText: "Configured howToPublishDataText",
56+
ingestManualExtraText = "Configured ingestManualExtraText",
57+
whereAreMyProposalsExtraText = "Configured whereAreMyProposalsExtraText",
58+
whereAreMySamplesExtraText = "Configured whereAreMySamplesExtraText",
4859
oAuth2Endpoints: [],
4960
policiesEnabled: true,
5061
retrieveDestinations: [],

src/app/app-config.service.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { HttpClient } from "@angular/common/http";
22
import { Injectable } from "@angular/core";
33
import { timeout } from "rxjs/operators";
44
import {
5-
DatasetDetailComponentConfig,
5+
datasetDetailViewLabelOption,
66
DatasetsListSettings,
77
LabelMaps,
8-
LabelsLocalization,
98
TableColumn,
109
} from "state-management/models";
1110

@@ -103,9 +102,18 @@ export interface AppConfig {
103102
labelMaps: LabelMaps;
104103
thumbnailFetchLimitPerPage: number;
105104
maxFileUploadSizeInMb?: string;
106-
datasetDetailComponent?: DatasetDetailComponentConfig;
107-
labelsLocalization?: LabelsLocalization;
108-
dateFormat?: string;
105+
datasetDetailViewLabelOption?: datasetDetailViewLabelOption;
106+
aboutText?: string;
107+
accessText?: string;
108+
termsText?: string;
109+
termsTextContinued?: string;
110+
docText?: string;
111+
gettingStartedExtraText?: string;
112+
whereIsMyDataText?: string;
113+
howToPublishDataText?: string;
114+
ingestManualExtraText?: string;
115+
whereAreMyProposalsExtraText?: string;
116+
whereAreMySamplesExtraText?: string;
109117
}
110118

111119
@Injectable()
@@ -133,10 +141,6 @@ export class AppConfigService {
133141
}
134142

135143
getConfig(): AppConfig {
136-
if (!this.appConfig) {
137-
console.error("AppConfigService: Configuration not loaded!");
138-
}
139-
140144
return this.appConfig as AppConfig;
141145
}
142146
}

src/app/app-routing/lazy/dataset-details-dashboard-routing/dataset-details-dashboard.routing.module.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ import { NgModule } from "@angular/core";
22
import { RouterModule, Routes } from "@angular/router";
33
import { AdminGuard } from "app-routing/admin.guard";
44
import { AuthGuard } from "app-routing/auth.guard";
5+
import { LeavingPageGuard } from "app-routing/pending-changes.guard";
56
import { ServiceGuard } from "app-routing/service.guard";
67
import { AdminTabComponent } from "datasets/admin-tab/admin-tab.component";
78
import { DatafilesComponent } from "datasets/datafiles/datafiles.component";
89
import { JsonScientificMetadataComponent } from "datasets/jsonScientificMetadata/jsonScientificMetadata.component";
10+
import { DatasetDetailComponent } from "datasets/dataset-detail/dataset-detail.component";
911
import { DatasetFileUploaderComponent } from "datasets/dataset-file-uploader/dataset-file-uploader.component";
1012
import { DatasetLifecycleComponent } from "datasets/dataset-lifecycle/dataset-lifecycle.component";
1113
import { ReduceComponent } from "datasets/reduce/reduce.component";
1214
import { RelatedDatasetsComponent } from "datasets/related-datasets/related-datasets.component";
1315
import { LogbooksDashboardComponent } from "logbooks/logbooks-dashboard/logbooks-dashboard.component";
14-
import { DatasetDetailWrapperComponent } from "datasets/dataset-detail/dataset-detail-wrapper.component";
15-
1616
const routes: Routes = [
1717
{
1818
path: "",
19-
component: DatasetDetailWrapperComponent,
19+
component: DatasetDetailComponent,
20+
canDeactivate: [LeavingPageGuard],
2021
},
2122
{
2223
path: "jsonScientificMetadata",
@@ -27,7 +28,7 @@ const routes: Routes = [
2728
component: DatafilesComponent,
2829
},
2930
{
30-
path: "relatedDatasets",
31+
path: "related-datasets",
3132
component: RelatedDatasetsComponent,
3233
},
3334
// For reduce && logbook this is a work around because guard priority somehow doesn't work and this work around make guards excuted sequencial

src/app/app-routing/lazy/instruments-routing/instruments.routing.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgModule } from "@angular/core";
22
import { RouterModule, Routes } from "@angular/router";
33
import { AuthGuard } from "app-routing/auth.guard";
4-
import { leavingPageGuard } from "app-routing/pending-changes.guard";
4+
import { LeavingPageGuard } from "app-routing/pending-changes.guard";
55
import { InstrumentDetailsComponent } from "instruments/instrument-details/instrument-details.component";
66
import { InstrumentsDashboardComponent } from "instruments/instruments-dashboard/instruments-dashboard.component";
77

@@ -15,7 +15,7 @@ const routes: Routes = [
1515
path: ":id",
1616
component: InstrumentDetailsComponent,
1717
canActivate: [AuthGuard],
18-
canDeactivate: [leavingPageGuard],
18+
canDeactivate: [LeavingPageGuard],
1919
},
2020
];
2121
@NgModule({

src/app/app-routing/lazy/samples-routing/samples.routing.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgModule } from "@angular/core";
22
import { RouterModule, Routes } from "@angular/router";
33
import { AuthGuard } from "app-routing/auth.guard";
4-
import { leavingPageGuard } from "app-routing/pending-changes.guard";
4+
import { LeavingPageGuard } from "app-routing/pending-changes.guard";
55
import { SampleDashboardComponent } from "samples/sample-dashboard/sample-dashboard.component";
66
import { SampleDetailComponent } from "samples/sample-detail/sample-detail.component";
77

@@ -15,7 +15,7 @@ const routes: Routes = [
1515
path: ":id",
1616
component: SampleDetailComponent,
1717
canActivate: [AuthGuard],
18-
canDeactivate: [leavingPageGuard],
18+
canDeactivate: [LeavingPageGuard],
1919
},
2020
];
2121
@NgModule({
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
1-
import { CanDeactivateFn } from "@angular/router";
1+
import { Injectable } from "@angular/core";
2+
import { CanDeactivate } from "@angular/router";
23
import { Observable } from "rxjs";
34

45
export interface EditableComponent {
56
hasUnsavedChanges: () => boolean | Observable<boolean>;
7+
// openLeavingPageGuardDialog(): () => void;
68
}
7-
8-
export const leavingPageGuard: CanDeactivateFn<EditableComponent> = (
9-
component,
10-
) => {
11-
const hasUnsavedChanges = component.hasUnsavedChanges();
12-
13-
if (typeof hasUnsavedChanges === "boolean") {
14-
return hasUnsavedChanges
9+
/**
10+
* Ensure that the user knowns about pending changes before leaving the page
11+
* @export
12+
* @class LeavingPageGuard
13+
* @implements {CanDeactivate}
14+
*/
15+
@Injectable({
16+
providedIn: "root",
17+
})
18+
export class LeavingPageGuard implements CanDeactivate<EditableComponent> {
19+
/**
20+
* Needs to return either a boolean or an observable that maps to a boolean
21+
*/
22+
canDeactivate(component: EditableComponent): Observable<boolean> | boolean {
23+
return component.hasUnsavedChanges()
1524
? confirm(
16-
"You have unsaved changes. Press Cancel to go back and save these changes, or OK to leave without saving.",
25+
"You have unsaved changes. Press Cancel to go back and save these changes, or OK to leave without saving",
1726
)
1827
: true;
1928
}
20-
21-
if (hasUnsavedChanges instanceof Observable) {
22-
return new Observable<boolean>((subscriber) => {
23-
hasUnsavedChanges.subscribe((unsaved) => {
24-
subscriber.next(
25-
!unsaved ||
26-
confirm(
27-
"You have unsaved changes. Press Cancel to go back and save these changes, or OK to leave without saving.",
28-
),
29-
);
30-
subscriber.complete();
31-
});
32-
});
33-
}
34-
35-
return true;
36-
};
29+
}

src/app/app.module.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,6 @@ const apiConfigurationFn = (
121121
subscriptSizing: "dynamic",
122122
},
123123
},
124-
{
125-
provide: DATE_PIPE_DEFAULT_OPTIONS,
126-
useFactory: (appConfigService: AppConfigService) => {
127-
return {
128-
dateFormat:
129-
appConfigService.getConfig().dateFormat || "yyyy-MM-dd HH:mm",
130-
};
131-
},
132-
deps: [AppConfigService],
133-
},
134124
AuthService,
135125
AppThemeService,
136126
Title,

src/app/datasets/batch-view/batch-view.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</div>
117117
</mat-header-cell>
118118
<mat-cell *matCellDef="let dataset">
119-
{{ dataset.creationTime | date }}
119+
{{ dataset.creationTime | date: "yyyy-MM-dd HH:mm" }}
120120
</mat-cell>
121121
</ng-container>
122122

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@use "sass:map";
2+
@use "@angular/material" as mat;
3+
4+
@mixin color($theme) {
5+
$color-config: map.get($theme, "color");
6+
$primary: map.get($color-config, "primary");
7+
$header-1: map.get($color-config, "header-1");
8+
$accent: map.get($color-config, "accent");
9+
$header-2: map.get($color-config, "header-2");
10+
$header-3: map.get($color-config, "header-3");
11+
$header-4: map.get($color-config, "header-4");
12+
mat-card {
13+
.general-header {
14+
background-color: mat.get-color-from-palette($primary, "lighter");
15+
}
16+
17+
.creator-header {
18+
background-color: mat.get-color-from-palette($header-1, "lighter");
19+
}
20+
21+
.file-header {
22+
background-color: mat.get-color-from-palette($accent, "lighter");
23+
}
24+
25+
.related-header {
26+
background-color: mat.get-color-from-palette($header-2, "lighter");
27+
}
28+
29+
.derived-header {
30+
background-color: mat.get-color-from-palette($header-3, "lighter");
31+
}
32+
33+
.scientific-header {
34+
background-color: mat.get-color-from-palette($header-4, "lighter");
35+
}
36+
}
37+
}
38+
39+
@mixin theme($theme) {
40+
$color-config: mat.get-color-config($theme);
41+
@if $color-config != null {
42+
@include color($theme);
43+
}
44+
}

0 commit comments

Comments
 (0)