File

src/app/tasks/task-schedule/task-schedule.component.ts

Description

Task Schedule Component

Implements

OnInit

Example

Metadata

encapsulation ViewEncapsulation.None
selector app-task-schedule
styleUrls styles.scss
templateUrl task-schedule.component.html

Index

Properties
Methods

Constructor

constructor(route: ActivatedRoute, routingStateService: RoutingStateService, modalService: BsModalService, loggerService: LoggerService, tasksService: TasksService)

Constructor

Parameters :
Name Type Optional Description
route ActivatedRoute
routingStateService RoutingStateService
modalService BsModalService
loggerService LoggerService
tasksService TasksService

Methods

cancel
cancel()

Back action Navigate to the previous URL or /tasks/schedules

Returns : void
destroy
destroy(taskSchedule: TaskSchedule)

Destroy the task schedule

Parameters :
Name Type Optional Description
taskSchedule TaskSchedule
Returns : void
ngOnInit
ngOnInit()

Init

Returns : void

Properties

modal
modal: BsModalRef
Type : BsModalRef

Modal reference

taskSchedule$
taskSchedule$: Observable<TaskSchedule>
Type : Observable<TaskSchedule>

Observable of Task Schedule

import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { TasksService } from '../tasks.service';
import { mergeMap } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { RoutingStateService } from '../../shared/services/routing-state.service';
import { TaskSchedule } from '../model/task-schedule';
import { BsModalRef, BsModalService } from 'ngx-bootstrap';
import { TaskSchedulesDestroyComponent } from '../task-schedules-destroy/task-schedules-destroy.component';
import { LoggerService } from '../../shared/services/logger.service';

/**
 * Task Schedule Component
 * @author Damien Vitrac
 */
@Component({
  selector: 'app-task-schedule',
  templateUrl: 'task-schedule.component.html',
  styleUrls: ['styles.scss'],
  encapsulation: ViewEncapsulation.None
})
export class TaskScheduleComponent implements OnInit {

  /**
   * Observable of Task Schedule
   */
  taskSchedule$: Observable<TaskSchedule>;

  /**
   * Modal reference
   */
  modal: BsModalRef;

  /**
   * Constructor
   *
   * @param {ActivatedRoute} route
   * @param {RoutingStateService} routingStateService
   * @param {BsModalService} modalService
   * @param {LoggerService} loggerService
   * @param {TasksService} tasksService
   */
  constructor(private route: ActivatedRoute,
              private routingStateService: RoutingStateService,
              private modalService: BsModalService,
              private loggerService: LoggerService,
              private tasksService: TasksService) {
  }

  /**
   * Init
   */
  ngOnInit() {
    this.taskSchedule$ = this.route.params
      .pipe(mergeMap(
        (params: Params) => this.tasksService.getSchedule(params.id)
      ));
  }

  /**
   * Destroy the task schedule
   *
   * @param {TaskSchedule} taskSchedule
   */
  destroy(taskSchedule: TaskSchedule) {
    this.loggerService.log(`Destroy ${taskSchedule.name} task schedule.`, taskSchedule.name);
    this.modal = this.modalService.show(TaskSchedulesDestroyComponent, { class: 'modal-md' });
    this.modal.content.open({ taskSchedules: [taskSchedule] }).subscribe(() => {
      this.cancel();
    });
  }

  /**
   * Back action
   * Navigate to the previous URL or /tasks/schedules
   */
  cancel() {
    this.routingStateService.back('/tasks/schedules', /^(\/tasks\/schedules\/)/);
  }

}
<app-page *ngIf="taskSchedule$ | async as taskSchedule; else loading">

  <app-page-head>
    <app-page-head-back [defaultUrl]="'/tasks/schedules'"
                        [isNotRegex]="'^(\/tasks\/schedules\/)'"></app-page-head-back>
    <app-page-head-title>Schedule <strong>{{ taskSchedule.name }}</strong></app-page-head-title>
    <app-page-head-actions [dataflowAppRoles]="['ROLE_CREATE']">
      <button id="schedule-remove" name="schedule-remove" type="button" [dataflowAppRoles]="['ROLE_CREATE']"
              (click)="destroy(taskSchedule)" class="btn btn-danger btn-fa" title="Destroy">
        <span class="fa fa-trash"></span>
        Delete
      </button>
    </app-page-head-actions>
  </app-page-head>

  <p>This section shows the details of a schedule.</p>

  <div class="tab-simple">
    <ul class="nav nav-tabs">
      <li role="presentation" routerLinkActive="active">
        <a routerLink="summary" id="btn-schedule-summary">Summary</a>
      </li>
    </ul>
    <div class="tab-content">
      <div class="tab-pane in active">
        <router-outlet></router-outlet>
      </div>
    </div>
  </div>

</app-page>

<ng-template #loading>
  <app-loader></app-loader>
</ng-template>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""