File

src/app/pages/home/home.page.ts

Description

Home-page of the app. Contains a list of (locally) saved graphs and the GraphImportComponent.

Metadata

Index

Properties
Methods

Constructor

Public constructor(store: Store<State>, router: Router, snackBarService: SnackBarService)
Parameters :
Name Type Optional
store Store<State> No
router Router No
snackBarService SnackBarService No

Methods

Public navigateToExampleGraph
navigateToExampleGraph()
Returns : void
Public onGraphDeletionRequested
onGraphDeletionRequested(graph: FOLGraph)
Parameters :
Name Type Optional
graph FOLGraph No
Returns : void
Public onGraphImport
onGraphImport(graph: FOLGraph)
Parameters :
Name Type Optional
graph FOLGraph No
Returns : void
Public onGraphSelected
onGraphSelected(graph: FOLGraph)
Parameters :
Name Type Optional
graph FOLGraph No
Returns : void

Properties

Public Readonly storedGraphs
Default value : this.store.select('graphStore').pipe(map((graphs) => Object.values(graphs)))
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;
      }
    }
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""