Fix minor issues; enhance frontend

parent ec835b35
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Injectable} from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Injectable } from "@angular/core";
import { AppSettings } from '../../app.settings'; import { AppSettings } from "../../app.settings";
import { HelperDataService } from '../../services/helper-data-service'; import { HelperDataService } from "../../services/helper-data-service";
import {Observable} from "rxjs/Observable"; import { Observable } from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http'; import { Http, Headers, RequestOptions } from "@angular/http";
import { NgRedux, select } from 'ng2-redux'; import { NgRedux, select } from "ng2-redux";
import { IAppState } from '../../store/store'; import { IAppState } from "../../store/store";
import {Router, ActivatedRoute, Params} from '@angular/router'; import { Router, ActivatedRoute, Params } from "@angular/router";
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { ILoginInfo } from "../../store/logininfo/logininfo.types";
import { import {
FormBuilder, FormBuilder,
...@@ -15,34 +15,46 @@ import { ...@@ -15,34 +15,46 @@ import {
FormControl, FormControl,
FormArray, FormArray,
Validators, Validators,
} from '@angular/forms'; } from "@angular/forms";
@Component({ @Component({
selector: 'eduadmin-view', selector: "eduadmin-view",
template: ` template: `
<div class = "loading" *ngIf="(showLoader | async) === true"></div> <div class = "loading" *ngIf="(showLoader | async) === true"></div>
<div id="informationfeedback" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header {{modalHeader | async}}">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body"><p>{{ modalText | async }}</p></div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="hideModal()">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div style="min-height: 500px;"> <div style="min-height: 500px;">
<form [formGroup]="formGroup"> <form [formGroup]="formGroup">
<p style="margin-top: 20px; line-height: 2em;">Στην παρακάτω λίστα βλέπετε τα σχολεία ευθύνης σας. <p style="margin-top: 20px; line-height: 2em;">Στην παρακάτω λίστα βλέπετε τα σχολεία ευθύνης σας.
</p> <br/>Επιλέξτε σχολείο για να εμφανιστούν τα τμήματα του σχολείου.</p>
<div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Τα τμήματα. </b> <div class="row" style="margin-top: 20px; line-height: 2em;"><p><strong>Τα τμήματα</strong></p></div>
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;">
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"
[class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<div class="col-md-12">{{SchoolNames$.name}}</div>
<div class = "row" *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even"
[class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)"
[class.selectedappout]="regionActive === j"
[hidden]="SchoolNames$.id !== regionActive" style="margin: 0px 2px 0px 2px;">
<div class="col-md-9">{{CoursesNames$.name}}</div>
<div class="col-md-3">{{CoursesNames$.size}}</div>
</div>
</li>
</div> </div>
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"
[class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<div class="col-md-12" style="font-size: 0.8em; font-weight: bold;" >{{SchoolNames$.name}}</div>
</li>
<div class = "row" *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even"
[class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)"
[class.selectedappout]="regionActive === j"
[hidden]="SchoolNames$.id !== regionActive" style="margin: 0px 2px 0px 2px;">
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;" >{{CoursesNames$.name}}</div>
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;" >{{CoursesNames$.size}}</div>
</div>
</div>
</form> </form>
</div> </div>
...@@ -65,8 +77,9 @@ import { ...@@ -65,8 +77,9 @@ import {
private regionActive = <number>-1; private regionActive = <number>-1;
private School$: BehaviorSubject<any>; private School$: BehaviorSubject<any>;
private SchoolSub: Subscription; private SchoolSub: Subscription;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private router: Router, private router: Router,
...@@ -80,63 +93,74 @@ import { ...@@ -80,63 +93,74 @@ import {
this.showLoader = new BehaviorSubject(false); this.showLoader = new BehaviorSubject(false);
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
}); });
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
} }
ngOnDestroy() { ngOnDestroy() {
(<any>$("#informationfeedback")).remove();
} }
ngOnInit() { ngOnInit() {
(<any>$("#informationfeedback")).appendTo("body");
this.showLoader.next(true); this.showLoader.next(true);
this.SchoolPerPerfSub = this._hds.getSchools().subscribe(data => { this.SchoolPerPerfSub = this._hds.getSchools()
this.SchoolsPerPerf$.next(data); .subscribe(data => {
this.showLoader.next(false); this.SchoolsPerPerf$.next(data);
}, this.showLoader.next(false);
},
error => { error => {
this.SchoolsPerPerf$.next([{}]); this.SchoolsPerPerf$.next([{}]);
console.log("Error Getting Schools"); console.log("Error Getting Schools");
this.modalHeader.next("modal-header-danger");
this.modalTitle.next("Αδυναμία άντλησης στοιχείων");
this.modalText.next("Προέκυψε σφάλμα κατά την άντληση των στοιχείων. Παρακαλώ δοκιμάστε ξανά. Εφόσον το πρόβλημα συνεχίσει να υφίσταται, επικοινωνήστε με την ομάδα υποστήριξης.");
this.showModal();
this.showLoader.next(false);
}); });
} }
calccolor(size, limit) { calccolor(size, limit) {
if (size < limit) if (size < limit)
return true; return true;
else else
return false; return false;
} }
setActiveRegion(ind) { setActiveRegion(ind) {
this.CoursesPerPerf$.next([{}]);
if (ind === this.regionActive) { if (ind === this.regionActive) {
ind = -1; ind = -1;
this.regionActive = ind; this.regionActive = ind;
} }
else { else {
this.regionActive = ind; this.regionActive = ind;
this.showLoader.next(true); this.showLoader.next(true);
this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive).subscribe(data => { this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive)
this.CoursesPerPerf$.next(data); .subscribe(data => {
this.showLoader.next(false); this.CoursesPerPerf$.next(data);
}, this.showLoader.next(false);
},
error => { error => {
this.CoursesPerPerf$.next([{}]); this.CoursesPerPerf$.next([{}]);
console.log("Error Getting Courses"); console.log("Error Getting Courses");
this.modalHeader.next("modal-header-danger");
this.modalTitle.next("Αδυναμία άντλησης στοιχείων");
this.modalText.next("Προέκυψε σφάλμα κατά την άντληση των στοιχείων. Παρακαλώ δοκιμάστε ξανά. Εφόσον το πρόβλημα συνεχίσει να υφίσταται, επικοινωνήστε με την ομάδα υποστήριξης.");
this.showModal();
this.showLoader.next(false); this.showLoader.next(false);
}); });
} }
this.regionActive = ind; }
public showModal(): void {
(<any>$("#informationfeedback")).modal("show");
} }
public hideModal(): void {
(<any>$("#informationfeedback")).modal("hide");
}
} }
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Injectable} from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Injectable} from "@angular/core";
import { AppSettings } from '../../app.settings'; import { AppSettings } from "../../app.settings";
import { HelperDataService } from '../../services/helper-data-service'; import { HelperDataService } from "../../services/helper-data-service";
import {Observable} from "rxjs/Observable"; import {Observable} from "rxjs/Observable";
import {Http, Headers, RequestOptions} from '@angular/http'; import {Http, Headers, RequestOptions} from "@angular/http";
import { NgRedux, select } from 'ng2-redux'; import { NgRedux, select } from "ng2-redux";
import { IAppState } from '../../store/store'; import { IAppState } from "../../store/store";
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from "@angular/router";
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from "rxjs/Rx";
import { ILoginInfo } from '../../store/logininfo/logininfo.types'; import { ILoginInfo } from "../../store/logininfo/logininfo.types";
import { import {
FormBuilder, FormBuilder,
...@@ -15,34 +15,46 @@ import { ...@@ -15,34 +15,46 @@ import {
FormControl, FormControl,
FormArray, FormArray,
Validators, Validators,
} from '@angular/forms'; } from "@angular/forms";
@Component({ @Component({
selector: 'perfecture-view', selector: "perfecture-view",
template: ` template: `
<div class = "loading" *ngIf="(showLoader | async) === true"></div> <div class="loading" *ngIf="(showLoader | async) === true"></div>
<div id="informationfeedback" class="modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header {{modalHeader | async}}">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;{{ modalTitle | async }}</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body"><p>{{ modalText | async }}</p></div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" (click)="hideModal()">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div style="min-height: 500px;"> <div style="min-height: 500px;">
<form [formGroup]="formGroup"> <form [formGroup]="formGroup">
<p style="margin-top: 20px; line-height: 2em;">Στην παρακάτω λίστα βλέπετε τα σχολεία ευθύνης σας. <p style="margin-top: 20px; line-height: 2em;">Στην παρακάτω λίστα βλέπετε τα σχολεία ευθύνης σας.
</p> <br/>Επιλέξτε σχολείο για να εμφανιστούν τα τμήματα του σχολείου.</p>
<div class="row" style="margin-top: 20px; line-height: 2em;" > <b> Τα τμήματα. </b> <div class="row" style="margin-top: 20px; line-height: 2em;"><p><strong>Τα τμήματα</strong></p></div>
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" style="font-size: 0.8em; font-weight: bold;">
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"
[class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<div class="col-md-12">{{SchoolNames$.name}}</div>
<div class = "row" *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even"
[class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)"
[class.selectedappout]="regionActive === j"
[hidden]="SchoolNames$.id !== regionActive" style="margin: 0px 2px 0px 2px;">
<div class="col-md-9">{{CoursesNames$.name}}</div>
<div class="col-md-3">{{CoursesNames$.size}}</div>
</div>
</li>
</div> </div>
<div *ngFor="let SchoolNames$ of SchoolsPerPerf$ | async; let i=index; let isOdd=odd; let isEven=even" >
<li class="list-group-item isclickable" (click)="setActiveRegion(SchoolNames$.id)"
[class.changelistcolor]= "SchoolNames$.status === false" [class.oddout]="isOdd"
[class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<div class="col-md-12" style="font-size: 0.8em; font-weight: bold;" >{{SchoolNames$.name}}</div>
</li>
<div class = "row" *ngFor="let CoursesNames$ of CoursesPerPerf$ | async; let j=index; let isOdd2=odd; let isEven2=even"
[class.oddin]="isOdd2" [class.evenin]="isEven2" [class.changecolor]="calccolor(CoursesNames$.size,CoursesNames$.limitdown)"
[class.selectedappout]="regionActive === j"
[hidden]="SchoolNames$.id !== regionActive" style="margin: 0px 2px 0px 2px;">
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;" >{{CoursesNames$.name}}</div>
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;" >{{CoursesNames$.size}}</div>
</div>
</div>
</form> </form>
</div> </div>
...@@ -65,8 +77,9 @@ import { ...@@ -65,8 +77,9 @@ import {
private regionActive = <number>-1; private regionActive = <number>-1;
private School$: BehaviorSubject<any>; private School$: BehaviorSubject<any>;
private SchoolSub: Subscription; private SchoolSub: Subscription;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private router: Router, private router: Router,
...@@ -80,63 +93,73 @@ import { ...@@ -80,63 +93,73 @@ import {
this.showLoader = new BehaviorSubject(false); this.showLoader = new BehaviorSubject(false);
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
}); });
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
} }
ngOnDestroy() { ngOnDestroy() {
(<any>$("#informationfeedback")).remove();
} }
ngOnInit() { ngOnInit() {
(<any>$("#informationfeedback")).appendTo("body");
this.showLoader.next(true); this.showLoader.next(true);
this.SchoolPerPerfSub = this._hds.getSchools().subscribe(data => { this.SchoolPerPerfSub = this._hds.getSchools()
this.SchoolsPerPerf$.next(data); .subscribe(data => {
this.showLoader.next(false); this.SchoolsPerPerf$.next(data);
}, this.showLoader.next(false);
},
error => { error => {
this.SchoolsPerPerf$.next([{}]); this.SchoolsPerPerf$.next([{}]);
console.log("Error Getting Schools"); console.log("Error Getting Schools");
this.modalHeader.next("modal-header-danger");
this.modalTitle.next("Αδυναμία άντλησης στοιχείων");
this.modalText.next("Προέκυψε σφάλμα κατά την άντληση των στοιχείων. Παρακαλώ δοκιμάστε ξανά. Εφόσον το πρόβλημα συνεχίσει να υφίσταται, επικοινωνήστε με την ομάδα υποστήριξης.");
this.showModal();
this.showLoader.next(false);
}); });
} }
calccolor(size, limit) { calccolor(size, limit) {
if (size < limit) if (size < limit)
return true; return true;
else else
return false; return false;
} }
setActiveRegion(ind) { setActiveRegion(ind) {
this.CoursesPerPerf$.next([{}]);
if (ind === this.regionActive) { if (ind === this.regionActive) {
ind = -1; ind = -1;
this.regionActive = ind; this.regionActive = ind;
} }
else { else {
this.regionActive = ind; this.regionActive = ind;
this.showLoader.next(true); this.showLoader.next(true);
this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive).subscribe(data => { this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive)
this.CoursesPerPerf$.next(data); .subscribe(data => {
this.showLoader.next(false); this.CoursesPerPerf$.next(data);
}, this.showLoader.next(false);
},
error => { error => {
this.CoursesPerPerf$.next([{}]);
console.log("Error Getting Courses"); console.log("Error Getting Courses");
this.modalHeader.next("modal-header-danger");
this.modalTitle.next("Αδυναμία άντλησης στοιχείων");
this.modalText.next("Προέκυψε σφάλμα κατά την άντληση των στοιχείων. Παρακαλώ δοκιμάστε ξανά. Εφόσον το πρόβλημα συνεχίσει να υφίσταται, επικοινωνήστε με την ομάδα υποστήριξης.");
this.showModal();
this.showLoader.next(false); this.showLoader.next(false);
}); });
} }
this.regionActive = ind; }
public showModal(): void {
(<any>$("#informationfeedback")).modal("show");
} }
public hideModal(): void {
(<any>$("#informationfeedback")).modal("hide");
}
} }
...@@ -703,7 +703,6 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -703,7 +703,6 @@ export class HelperDataService implements OnInit, OnDestroy {
getCoursePerPerfecture(PerfectureId) { getCoursePerPerfecture(PerfectureId) {
let PerfectureIdNew = PerfectureId.toString(); let PerfectureIdNew = PerfectureId.toString();
this.loginInfo$.getValue().forEach(loginInfoToken => { this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token; this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role; this.authRole = loginInfoToken.auth_role;
...@@ -1011,7 +1010,4 @@ export class HelperDataService implements OnInit, OnDestroy { ...@@ -1011,7 +1010,4 @@ export class HelperDataService implements OnInit, OnDestroy {
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment