src/app/pages/home/home.page.ts
Home-page of the app. Contains a list of (locally) saved graphs and the GraphImportComponent.
selector | apollo-home |
styleUrls | ./home.page.scss |
templateUrl | ./home.page.html |
Properties |
|
Methods |
|
Public
constructor(store: Store<State>, router: Router, snackBarService: SnackBarService)
|
||||||||||||
Defined in src/app/pages/home/home.page.ts:23
|
||||||||||||
Parameters :
|
Public navigateToExampleGraph |
navigateToExampleGraph()
|
Defined in src/app/pages/home/home.page.ts:45
|
Returns :
void
|
Public onGraphDeletionRequested | ||||||
onGraphDeletionRequested(graph: FOLGraph)
|
||||||
Defined in src/app/pages/home/home.page.ts:35
|
||||||
Parameters :
Returns :
void
|
Public onGraphImport | ||||||
onGraphImport(graph: FOLGraph)
|
||||||
Defined in src/app/pages/home/home.page.ts:40
|
||||||
Parameters :
Returns :
void
|
Public onGraphSelected | ||||||
onGraphSelected(graph: FOLGraph)
|
||||||
Defined in src/app/pages/home/home.page.ts:31
|
||||||
Parameters :
Returns :
void
|
Public Readonly storedGraphs |
Default value : this.store.select('graphStore').pipe(map((graphs) => Object.values(graphs)))
|
Defined in src/app/pages/home/home.page.ts:23
|
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { map } from 'rxjs/operators';
import { exampleGraph } from 'src/app/model/domain/example-graph';
import { FOLGraph } from 'src/app/model/domain/fol.graph';
import { graphCollectionQueryParams } from 'src/app/model/domain/graph.collection';
import { SnackBarService } from 'src/app/services/snack-bar.service';
import { cacheGraph, removeGraphFromStore } from 'src/app/store/actions';
import { State } from 'src/app/store/state';
/**
* Home-page of the app.
* Contains a list of (locally) saved graphs and the GraphImportComponent.
*/
@Component({
selector: 'apollo-home',
templateUrl: './home.page.html',
styleUrls: ['./home.page.scss'],
})
export class HomePage {
public readonly storedGraphs = this.store.select('graphStore').pipe(map((graphs) => Object.values(graphs)));
public constructor(
private readonly store: Store<State>,
private readonly router: Router,
private readonly snackBarService: SnackBarService,
) {}
public onGraphSelected(graph: FOLGraph): void {
this.router.navigate(['model-checker'], { queryParams: graphCollectionQueryParams('graphStore', graph.name) });
}
public onGraphDeletionRequested(graph: FOLGraph): void {
this.store.dispatch(removeGraphFromStore({ key: graph.name }));
this.snackBarService.graphDeleted(graph);
}
public onGraphImport(graph: FOLGraph): void {
this.store.dispatch(cacheGraph(graph));
this.router.navigate(['model-checker'], { queryParams: graphCollectionQueryParams('graphCache', graph.name) });
}
public navigateToExampleGraph() {
this.router.navigate(['model-checker'], { queryParams: graphCollectionQueryParams('graphCache', exampleGraph.name) });
}
}
<section class="section graphs">
<h1>{{ 'home.saved-graphs' | translate }}</h1>
<apollo-graph-list [graphs]="storedGraphs | async" (graphSelected)="onGraphSelected($event)" (graphDeletionRequested)="onGraphDeletionRequested($event)"></apollo-graph-list>
</section>
<section class="section import">
<h1 style="margin-bottom: 0">{{ "import.title" | translate }}</h1>
<apollo-graph-import (graphImport)="onGraphImport($event)"></apollo-graph-import>
</section>
<section class="section quick-access">
<h1>{{ 'home.quick-access' | translate }}</h1>
<button mat-raised-button color="primary" (click)="navigateToExampleGraph()">
{{ "home.example-graph" | translate }}
<mat-icon>open_in_new</mat-icon>
</button>
<button mat-raised-button color="accent" [routerLink]="'/model-checker'">
{{ "model-checker.title" | translate }}
<mat-icon>open_in_new</mat-icon>
</button>
<button mat-raised-button color="accent" [routerLink]="'/assignments'">
{{ "assignments.title" | translate }}
<mat-icon>open_in_new</mat-icon>
</button>
</section>
./home.page.scss
:host {
display: block;
}
.section {
&:not(:last-child) {
margin-bottom: 3rem;
}
&.quick-access {
display: flex;
flex-direction: column;
> button {
max-width: fit-content;
&:not(:last-child) {
margin-bottom: 1rem;
}
}
}
}