Advertisement
Guest User

Scheduler Component

a guest
Nov 23rd, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, OnDestroy, OnInit} from '@angular/core';
  2. import {Response} from '@angular/http';
  3. import {JhiAlertService, JhiEventManager, JhiParseLinks} from 'ng-jhipster';
  4. import {NgProgressService} from 'ng2-progressbar';
  5. import {ITEMS_PER_PAGE} from '../../../shared/constants/pagination.constants';
  6. import {ActivatedRoute, Router} from '@angular/router';
  7. import {fadeInAnimation, slideDownAnimation} from '../../../shared/animation/custom.animation';
  8. import {SelectItem} from 'primeng/primeng';
  9. import {Principal} from '../../../shared/auth/principal.service';
  10. import {Account} from '../../../shared/user/account.model';
  11. import {TranslateService} from '@ngx-translate/core';
  12. import {DictService} from '../../../shared/services/dict.service';
  13. import {DictItem} from '../../../shared/services/dictitem.model';
  14. import {Subscription} from 'rxjs/Subscription';
  15. import {BaseListComponent} from '../../../shared/components/baselist.component';
  16. import {Scheduler} from '../model/scheduler.model';
  17. import {SchedulerService} from '../service/scheduler.service';
  18.  
  19. @Component({
  20.     templateUrl: './scheduler.component.html',
  21.     animations: [
  22.         slideDownAnimation,
  23.         fadeInAnimation
  24.     ],
  25.     providers: [DictService]
  26. })
  27.  
  28. export class SchedulerComponent extends BaseListComponent<Scheduler> implements OnInit, OnDestroy {
  29.  
  30.     private selectedItems: any[] = [];
  31.     private manualChangeOptions: SelectItem[];
  32.    
  33.  
  34.     constructor(private schedulerService: SchedulerService,
  35.                 protected translateService: TranslateService,
  36.                 protected alertService: JhiAlertService,
  37.                 protected router: Router,
  38.                 protected principal: Principal,
  39.                 protected parseLinks: JhiParseLinks,
  40.                 protected activatedRoute: ActivatedRoute,
  41.                 protected pbService: NgProgressService,
  42.                 private dictService: DictService) {
  43.         super('admin/scheduler', alertService, router, principal, parseLinks, activatedRoute, pbService, translateService);
  44.     }
  45.  
  46.     ngOnInit() {
  47.         this.manualChangeOptions = [];
  48.         this.translateService.get('hamsterApp.scheduler.buttons.stop').subscribe((itemLabel) => {
  49.             this.manualChangeOptions.push({value: '0', label: itemLabel});
  50.         });
  51.         this.translateService.get('hamsterApp.scheduler.buttons.resume').subscribe((itemLabel) => {
  52.             this.manualChangeOptions.push({value: '1', label: itemLabel});
  53.         });
  54.         this.loadAll();
  55.     }
  56.  
  57.     // Funkcja powinna ładować listę
  58.     loadAll() {
  59.         this.pbService.start();
  60.         this.selectedItems = [];
  61.         this.schedulerService.getSchedulers().subscribe(
  62.             res => this.onSuccess(res.json(), null),
  63.             err => this.onError(err)
  64.         );      
  65.     }
  66.  
  67.     // Inicjalizujemy filtr (w schedulerach nie bedzie potrzebne)
  68.     initFilter(): void {
  69.         this.filter = null
  70.     }
  71.  
  72.     stopScheduler(name: string) {
  73.         this.schedulerService.stopScheduler(name).subscribe(
  74.             res => this.loadAll(),
  75.             err => this.onError(err)
  76.         );
  77.     }
  78.  
  79.     resumeScheduler(name: string) {
  80.         this.schedulerService.resumeScheduler(name).subscribe(
  81.             res => this.loadAll(),
  82.             err => this.onError(err)
  83.         );
  84.     }
  85.    
  86.     ngOnDestroy() {}
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement