director-view.ts 4.9 KB
Newer Older
Open Source Developer's avatar
Open Source Developer committed
1
2
3
4
5
6
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';
Open Source Developer's avatar
tran    
Open Source Developer committed
7
import { NgRedux, select } from 'ng2-redux';
Open Source Developer's avatar
Open Source Developer committed
8
9
10
import { IAppState } from '../../store/store';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
Open Source Developer's avatar
transf    
Open Source Developer committed
11
import { ILoginInfo } from '../../store/logininfo/logininfo.types';
Open Source Developer's avatar
trans    
Open Source Developer committed
12
13
14
15
16
17
18
import {
    FormBuilder,
    FormGroup,
    FormControl,
    FormArray,
    Validators,
} from '@angular/forms';
Open Source Developer's avatar
Open Source Developer committed
19
20
21
@Component({
    selector: 'director-view',
    template: `
Open Source Developer's avatar
transf    
Open Source Developer committed
22

Open Source Developer's avatar
trans    
Open Source Developer committed
23
        <form [formGroup]="formGroup">
Open Source Developer's avatar
transf    
Open Source Developer committed
24
            <div class="form-group" >
Open Source Developer's avatar
trans    
Open Source Developer committed
25
              <label for="name">Τάξη</label><br/>
Open Source Developer's avatar
trans    
Open Source Developer committed
26
                    <select #txoption [(ngModel)]="taxi" [ngModelOptions]="{standalone: true}" (change)="verifyclass(txoption)" >
Open Source Developer's avatar
transf    
Open Source Developer committed
27
28
29
                        <option value="1" >Α' Λυκείου</option>
                        <option value="2" >Β' Λυκείου</option>
                        <option value="3" >Γ' Λυκείου</option>
Open Source Developer's avatar
trans    
Open Source Developer committed
30
31
                    </select>

Open Source Developer's avatar
transf    
Open Source Developer committed
32
            <div>
Open Source Developer's avatar
trans    
Open Source Developer committed
33
            <div class="form-group" *ngIf="StudentSelected$ != {}"  >
Open Source Developer's avatar
transf    
Open Source Developer committed
34
                    <label for="tomeas">Τομέας</label><br/>
Open Source Developer's avatar
trans    
Open Source Developer committed
35
                     <select #tmop [(ngModel)]="tomeas" [ngModelOptions]="{standalone: true}"  (change) ="checkbclass(tmop,txoption)" >
Open Source Developer's avatar
transf    
Open Source Developer committed
36
                      <option *ngFor="let SectorSelection$  of StudentSelected$ | async" [ngValue]="SectorSelection$.id">{{SectorSelection$.sector_id}}</option>
Open Source Developer's avatar
tran    
Open Source Developer committed
37
                    </select>
Open Source Developer's avatar
transf    
Open Source Developer committed
38
             <div>
Open Source Developer's avatar
trans    
Open Source Developer committed
39
40
41
42
43
44
45
46
47
48
49

            <div class="form-group" *ngIf="StudentSelectedSpecial$ != {}">
                    <label for="special">Ειδικότητα</label><br/>
                     <select #spop [(ngModel)]="specialit" [ngModelOptions]="{standalone: true}"  >
                      <option *ngFor="let SpecialSelection$  of StudentSelectedSpecial$ | async" [ngValue]="SpecialSelection$.id">{{SpecialSelection$.specialty_id}}</option>
                    </select>
             <div>
             <button type="button" class="btn-primary btn-sm pull-right" (click)="findstudent()">
                Αναζήτηση
             </button>

Open Source Developer's avatar
transf    
Open Source Developer committed
50
              
Open Source Developer's avatar
Open Source Developer committed
51
52
53
54
55
   `
})

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

Open Source Developer's avatar
trans    
Open Source Developer committed
56
    public formGroup: FormGroup;
Open Source Developer's avatar
Open Source Developer committed
57
58
    private StudentSelected$: BehaviorSubject<any>;
    private StudentSelectedSub: Subscription;
Open Source Developer's avatar
trans    
Open Source Developer committed
59
60
61
    private StudentSelectedSpecial$: BehaviorSubject<any>;
    private StudentSelectedSpecialSub: Subscription;

Open Source Developer's avatar
trans    
Open Source Developer committed
62
    public bClassEnabled: boolean;
Open Source Developer's avatar
transf    
Open Source Developer committed
63
    public gClassEnabled: boolean;
Open Source Developer's avatar
trans    
Open Source Developer committed
64
65
    private SchoolId = 147 ;

Open Source Developer's avatar
trans    
Open Source Developer committed
66
67
68

    constructor(private fb: FormBuilder,
                private _hds: HelperDataService, 
Open Source Developer's avatar
Open Source Developer committed
69
70
71
72
                private activatedRoute: ActivatedRoute,
                private router: Router )
    {
       this.StudentSelected$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
trans    
Open Source Developer committed
73
       this.StudentSelectedSpecial$ = new BehaviorSubject([{}]);
Open Source Developer's avatar
trans    
Open Source Developer committed
74
       this.formGroup = this.fb.group({
Open Source Developer's avatar
transf    
Open Source Developer committed
75
                taxi:[],
Open Source Developer's avatar
trans    
Open Source Developer committed
76
77
                tomeas: [],
                specialit :[]
Open Source Developer's avatar
trans    
Open Source Developer committed
78
                 });
Open Source Developer's avatar
Open Source Developer committed
79
80
81
82
83
84
    }

    ngOnDestroy()
    {
        if (this.StudentSelectedSub)
            this.StudentSelectedSub.unsubscribe();
Open Source Developer's avatar
trans    
Open Source Developer committed
85
86
87
        if (this.StudentSelectedSpecialSub)
            this.StudentSelectedSpecialSub.unsubscribe();

Open Source Developer's avatar
Open Source Developer committed
88
89

    }
Open Source Developer's avatar
tran    
Open Source Developer committed
90
 
Open Source Developer's avatar
Open Source Developer committed
91
92
    ngOnInit() {
     
Open Source Developer's avatar
transf    
Open Source Developer committed
93
94
       this.bClassEnabled = false;    
       this.gClassEnabled = false;   
Open Source Developer's avatar
trans    
Open Source Developer committed
95
96
97
98
       this.StudentSelectedSub = this._hds.getSectorPerSchool(this.SchoolId).subscribe(this.StudentSelected$);


           
Open Source Developer's avatar
transf    
Open Source Developer committed
99
       console.log(this.StudentSelected$);        
Open Source Developer's avatar
Open Source Developer committed
100
101
102
103

    }


Open Source Developer's avatar
trans    
Open Source Developer committed
104
    verifyclass(txop)
Open Source Developer's avatar
trans    
Open Source Developer committed
105
    {
Open Source Developer's avatar
trans    
Open Source Developer committed
106
107
            console.log(txop.value);
            if (txop.value === "1")
Open Source Developer's avatar
transf    
Open Source Developer committed
108
109
110
            {     this.bClassEnabled = false;
                  this.gClassEnabled = false;
            }
Open Source Developer's avatar
trans    
Open Source Developer committed
111
            else if (txop.value === "2")
Open Source Developer's avatar
transf    
Open Source Developer committed
112
            {
Open Source Developer's avatar
trans    
Open Source Developer committed
113
                console.log(txop.value,"aaaaaa");
Open Source Developer's avatar
transf    
Open Source Developer committed
114
115
116
                this.bClassEnabled = true;
                this.gClassEnabled = false;
            }
Open Source Developer's avatar
trans    
Open Source Developer committed
117
            else if (txop.value === "3")
Open Source Developer's avatar
transf    
Open Source Developer committed
118
119
120
            {   this.bClassEnabled = true;
                this.gClassEnabled = true;
            }            
Open Source Developer's avatar
trans    
Open Source Developer committed
121
122
    }

Open Source Developer's avatar
Open Source Developer committed
123

Open Source Developer's avatar
trans    
Open Source Developer committed
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    checkbclass(tmop,txop)
    {
        const [id, sector] = tmop.value.split(': ');
        var sectorint = +sector; 
        if (txop.value === "3")
        {
            this.StudentSelectedSpecialSub = this._hds.getSpecialityPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);        
        }
    }

    findstudent(tmop,txop)
    {
        let sectorint = 8;
        {
            this.StudentSelectedSpecialSub = this._hds.getStudentPerSchool(this.SchoolId, sectorint).subscribe(this.StudentSelectedSpecial$);        
        }
    }




Open Source Developer's avatar
Open Source Developer committed
145
}