minister-reports.ts 3.62 KB
Newer Older
1
import { Component, OnInit, OnDestroy } from "@angular/core";
2 3 4 5 6 7 8 9 10 11 12 13
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 { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';

14 15 16 17 18 19 20 21
import {
    FormBuilder,
    FormGroup,
    FormControl,
    FormArray,
    Validators,
} from '@angular/forms';

22 23 24 25
import { API_ENDPOINT } from '../../app.settings';

@Component({
    selector: 'minister-reports',
26
    //encapsulation: ViewEncapsulation.None,
27 28
    template: `

29
  <div>
30

31 32 33
        <h5><br> >Επιλογή Αναφοράς<br><br></h5>

        <div class="col-md-1">
34
          <button type="button" class="btn btn-alert"  (click)="nav_to_reportpath(1)" [hidden]="minedu_userName == ''" >
35 36 37 38
          <i class="fa fa-file-text"></i>
              Κατανομή Μαθητών με Βάση τη Σειρά Προτίμησης
          </button>
          <br><br>
39
          <button type="button" class="btn btn-alert"  (click)="nav_to_reportpath(2)" [hidden]="minedu_userName == ''" >
40
          <i class="fa fa-file-text"></i>
41
              Συνολική Πληρότητα σχολικών μονάδων ΕΠΑΛ ανά τάξη 
42 43
          </button>
          <br><br>
44
          <button type="button" class="btn btn-alert"  (click)="nav_to_reportpath(3)" [hidden]="minedu_userName == ''" >
45
          <i class="fa fa-file-text"></i>
46
              Αριθμός Μαθητών και Πληρότητα σχολικών μονάδων ΕΠΑΛ
47 48 49 50
          </button>
          <br><br>
        </div>

51 52
    </div>

53 54 55 56 57
   `
})

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

58
    public formGroup: FormGroup;
59 60 61 62 63 64
    loginInfo$: BehaviorSubject<ILoginInfo>;
    loginInfoSub: Subscription;
    private apiEndPoint = API_ENDPOINT;
    private minedu_userName: string;
    private minedu_userPassword: string;
    private distStatus = "READY";
65

66
    constructor(private fb: FormBuilder,
67 68 69 70 71
        private _ngRedux: NgRedux<IAppState>,
        private _hds: HelperDataService,
        private activatedRoute: ActivatedRoute,
        private router: Router) {

72 73 74 75 76
          this.formGroup = this.fb.group({
              region: ['', []],
              adminarea: ['', []],
              schoollist: ['', []],
          });
77 78

          this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
79
          this.minedu_userName = '';
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

    }

    ngOnInit() {

      this.loginInfoSub = this._ngRedux.select(state => {
          if (state.loginInfo.size > 0) {
              state.loginInfo.reduce(({}, loginInfoToken) => {
                this.minedu_userName = loginInfoToken.minedu_username;
                this.minedu_userPassword = loginInfoToken.minedu_userpassword;
                  return loginInfoToken;
              }, {});
          }
          return state.loginInfo;
      }).subscribe(this.loginInfo$);

    }
97

98
    ngOnDestroy() {
99

100 101
      if (this.loginInfoSub)
        this.loginInfoSub.unsubscribe();
102 103
    }

104

105
    nav_to_reportpath(repId) {
106

107 108 109 110
      if (repId == 1)
        this.router.navigate(['/ministry/report-general', repId]);
      if (repId == 2 || repId == 3)
        this.router.navigate(['/ministry/report-all-stat', repId]);
111 112 113

    }

114 115 116


}