File

src/app/project-overview/project-overview.component.ts

Description

This component offers a view showing the project name, owner, id and description.

Implements

OnInit AfterViewInit

Metadata

selector app-project-overview
styleUrls ./project-overview.component.scss
templateUrl ./project-overview.component.html

Index

Properties
Methods

Constructor

constructor(dataService: DataService, projectStore: ProjectStoreService, route: ActivatedRoute, router: Router, changeDetector: ChangeDetectorRef, dialog: MatDialog, notify: UserNotifyService)
Parameters :
Name Type Optional
dataService DataService No
projectStore ProjectStoreService No
route ActivatedRoute No
router Router No
changeDetector ChangeDetectorRef No
dialog MatDialog No
notify UserNotifyService No

Methods

deleteProject
deleteProject()
Returns : void
projectNameEdited
projectNameEdited(saved: boolean)
Parameters :
Name Type Optional
saved boolean No
Returns : void

Properties

description
Type : string
Default value : ''
Public project
Type : DataNode<Project>
Public projectId
Type : string
queryComponent
Type : QueryComponent
Decorators :
@ViewChild(QueryComponent)
import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {ProjectStoreService} from '@app/data/project/project-store.service';
import {MatDialog} from '@angular/material/dialog';
import {UserNotifyService} from '@app/user-notify/user-notify.service';
import {RemoveDialogComponent} from '@app/dialogs/remove-dialog/remove-dialog.component';
import {DataNode} from '@app/data-dgql/query';
import {Project} from '../../generated/graphql-dgql';
import DataService from '@app/data-dgql';
import {NodeType} from '@app/data-dgql/id';
import {QueryComponent} from '@app/utils/query-component/query.component';

/**
 * This component offers a view showing the project name,
 * owner, id and description.
 */
@Component({
  selector: 'app-project-overview',
  templateUrl: './project-overview.component.html',
  styleUrls: ['./project-overview.component.scss']
})
export class ProjectOverviewComponent implements OnInit, AfterViewInit {
  @ViewChild(QueryComponent) queryComponent: QueryComponent;

  public projectId: string;
  public project: DataNode<Project>;
  description = '';

  constructor(
    private dataService: DataService,
    private projectStore: ProjectStoreService,
    private route: ActivatedRoute,
    private router: Router,
    private changeDetector: ChangeDetectorRef,
    private dialog: MatDialog,
    private notify: UserNotifyService
  ) {}

  ngOnInit(): void {
    this.projectId = this.route.snapshot.paramMap.get('id');
    this.project = this.dataService.getNode({
      type: NodeType.Project,
      id: this.projectId
    });
  }

  ngAfterViewInit() {
    this.queryComponent.listenTo(this.project, (project) => (this.description = project.description));
  }

  projectNameEdited(saved: boolean): void {
    if (!saved) {
      return;
    }

    alert('TODO: Save');
  }

  deleteProject(): void {
    const confirmDeleteDialogRef = this.dialog.open(RemoveDialogComponent, {
      data: {
        title: `Really delete project "${this.project.current.name}"?`,
        messages: [`Are you sure you want to delete the project "${this.project.current.name}"?`, 'This action cannot be undone!'],
        verificationName: this.project.current.name
      }
    });
    confirmDeleteDialogRef.afterClosed().subscribe((del) => {
      if (del) {
        this.projectStore.delete(this.projectId).subscribe(
          () => {
            this.notify.notifyInfo(`Successfully deleted project "${this.project.current.name}"`);
            this.router.navigate(['/']);
          },
          (error) => this.notify.notifyError('Failed to delete project!', error)
        );
      }
    });
  }
}
<app-query-component errorMessage="Failed to load project information">
  <ng-template appQueryBody>
    <div class="project-overview-container">
      <div class="delete-button-container">
        <app-project-header [projectName]="project.current.name" [projectId]="project.current.id"> </app-project-header>
        <span style="flex: 1 1 auto"></span>

        <!-- delete project button -->
        <button id="button" mat-raised-button (click)="deleteProject()" color="warn">Delete</button>
      </div>

      <app-text-display
        [text]="description"
        [onEditFinished]="projectNameEdited"
        placeholder="No project description!"
        labelText="Project description"
      ></app-text-display>
    </div>
  </ng-template>
</app-query-component>

./project-overview.component.scss

.delete-button-container {
  width: 100%;
  display: flex;
  align-items: center;
}

.project-overview-container {
  margin: 4px;
}

#button {
  margin: 5px;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""