perfecture-view.ts 3.12 KB
Newer Older
Open Source Developer's avatar
trans  
Open Source Developer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
import { Component, OnInit, OnDestroy, ElementRef, ViewChild} from "@angular/core";
import { Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings';
import { HelperDataService } from '../../services/helper-data-service';
import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http';
import { NgRedux, select } from 'ng2-redux';
import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import { ILoginInfo } from '../../store/logininfo/logininfo.types';

import {
    FormBuilder,
    FormGroup,
    FormControl,
    FormArray,
    Validators,
} from '@angular/forms';
@Component({
    selector: 'perfecture-view',
    template: `
     
            
            <ul class="list-group main-view">
              <div *ngFor="let SchoolNames$  of SchoolsPerPerf$  | async; let i=index; let isOdd=odd; let isEven=even"  >
Open Source Developer's avatar
trans  
Open Source Developer committed
27 28
                  <li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"  [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id ">
                     <h5> {{SchoolNames$.name}}</h5>
Open Source Developer's avatar
trans  
Open Source Developer committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
                  </li>
              </div>
             </ul>  
             <div class="col-md-6">
                <button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" >
                <i class="fa fa-forward"></i>
                </button>
            </div>  


   `
})

@Injectable() export default class PerfectureView implements OnInit, OnDestroy {

    public formGroup: FormGroup;
    private SchoolsPerPerf$: BehaviorSubject<any>;
    private SchoolPerPerfSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
47 48
    private StudentsSize$: BehaviorSubject<any>;
    private StudentsSizeSub: Subscription;
Open Source Developer's avatar
trans  
Open Source Developer committed
49 50 51 52 53 54 55 56 57
    public perfecture = 1;
    private regionActive = <number>-1;
    

    constructor(private fb: FormBuilder,
      private router: Router,
      private _hds: HelperDataService,
      ) {
        this.SchoolsPerPerf$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
trans  
Open Source Developer committed
58
        this.StudentsSize$ = new BehaviorSubject({});
Open Source Developer's avatar
trans  
Open Source Developer committed
59 60 61 62 63 64 65 66 67 68 69
        this.formGroup = this.fb.group({
        });

    }

    ngOnDestroy() {
      }

    ngOnInit() {


Open Source Developer's avatar
trans  
Open Source Developer committed
70
        this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(147).subscribe(data => {
Open Source Developer's avatar
trans  
Open Source Developer committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
            this.SchoolsPerPerf$.next(data);
        },
            error => {
                this.SchoolsPerPerf$.next([{}]);
                console.log("Error Getting Schools");
            },
            () => console.log("Getting Schools"));



    }


     setActiveRegion(ind) {
      console.log(ind,"ind");
      if (ind === this.regionActive)
        ind = -1;
      this.regionActive = ind;
    }


    navigateToApplication()
    {
     
     var id: string= String(this.regionActive);
     this.router.navigate(['', {ids:id}]); 

    }

Open Source Developer's avatar
trans  
Open Source Developer committed
100 101 102

    calccolor(id)
    {
Open Source Developer's avatar
trans  
Open Source Developer committed
103 104
      var newid = +id;
  //  this.StudentsSizeSub = this._hds.getStudentPerSchool(147, 1, 2, 0, 0).subscribe(this.StudentsSize$);            
Open Source Developer's avatar
trans  
Open Source Developer committed
105 106 107 108 109 110 111 112

      if (id == 147)
        return true;
      if (id == 150)
        return true;

    }

Open Source Developer's avatar
trans  
Open Source Developer committed
113
}