Review reports 0,1

parent 744c333c
...@@ -147,7 +147,7 @@ epal.ministry.general_report: ...@@ -147,7 +147,7 @@ epal.ministry.general_report:
options: options:
_auth: [ 'basic_auth' ] _auth: [ 'basic_auth' ]
defaults: defaults:
_controller: '\Drupal\epal\Controller\ReportsCreator::makegGeneralReport' _controller: '\Drupal\epal\Controller\ReportsCreator::makeGeneralReport'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.ministry.report-completeness: epal.ministry.report-completeness:
......
import { Component, OnInit, OnDestroy } from "@angular/core"; import { Component, OnInit, OnDestroy } from "@angular/core";
import { Injectable } from "@angular/core"; import { 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 { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state'; import { LOGININFO_INITIAL_STATE } from "../../store/logininfo/logininfo.initial-state";
import { MINISTRY_ROLE, PDE_ROLE, DIDE_ROLE } from '../../constants'; import { MINISTRY_ROLE, PDE_ROLE, DIDE_ROLE } from "../../constants";
import { import {
FormBuilder, FormBuilder,
...@@ -18,13 +18,13 @@ import { ...@@ -18,13 +18,13 @@ import {
FormControl, FormControl,
FormArray, FormArray,
Validators, Validators,
} from '@angular/forms'; } from "@angular/forms";
import { API_ENDPOINT } from '../../app.settings'; import { API_ENDPOINT } from "../../app.settings";
@Component({ @Component({
selector: 'minister-reports', selector: "minister-reports",
//encapsulation: ViewEncapsulation.None, // encapsulation: ViewEncapsulation.None,
template: ` template: `
...@@ -35,34 +35,6 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -35,34 +35,6 @@ import { API_ENDPOINT } from '../../app.settings';
<div class="col-md-1"> <div class="col-md-1">
<!--
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(1)" [hidden]="minedu_userName == '' || userRole == 'pde' || userRole == 'dide'" >
<i class="fa fa-file-text"></i>
Κατανομή Μαθητών με Βάση τη Σειρά Προτίμησης
</button>
<br><br>
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(2)" [hidden]="minedu_userName == ''" >
<i class="fa fa-file-text"></i>
Συνολική Πληρότητα σχολικών μονάδων ΕΠΑΛ ανά τάξη
</button>
<br><br>
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(3)" [hidden]="minedu_userName == ''" >
<i class="fa fa-file-text"></i>
Αριθμός Μαθητών και Πληρότητα σχολικών μονάδων ΕΠΑΛ
</button>
<br><br>
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(4)" [hidden]="minedu_userName == '' || userRole == 'pde' || userRole == 'dide' " >
<i class="fa fa-file-text"></i>
Σχολικές μονάδες που δεν έχουν δηλώσει Χωρητικότητα τμημάτων
</button>
<br><br>
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(5)" [hidden]="minedu_userName == '' || userRole == 'pde' || userRole == 'dide' " >
<i class="fa fa-file-text"></i>
Ολιγομελή τμήματα (Προσωρινά τοποθετημένοι μαθητές)
</button>
<br><br>
</div>
-->
<div *ngIf = "minedu_userName != '' && userRole != 'pde' && userRole != 'dide'"> <div *ngIf = "minedu_userName != '' && userRole != 'pde' && userRole != 'dide'">
<button type="button" class="btn btn-alert" (click)="nav_to_reportpath(0)" > <button type="button" class="btn btn-alert" (click)="nav_to_reportpath(0)" >
<i class="fa fa-file-text"></i> <i class="fa fa-file-text"></i>
...@@ -131,13 +103,13 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -131,13 +103,13 @@ import { API_ENDPOINT } from '../../app.settings';
private router: Router) { private router: Router) {
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
region: ['', []], region: ["", []],
adminarea: ['', []], adminarea: ["", []],
schoollist: ['', []], schoollist: ["", []],
}); });
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE); this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.minedu_userName = ''; this.minedu_userName = "";
this.userRole = MINISTRY_ROLE; this.userRole = MINISTRY_ROLE;
} }
...@@ -149,7 +121,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -149,7 +121,7 @@ import { API_ENDPOINT } from '../../app.settings';
state.loginInfo.reduce(({}, loginInfoToken) => { state.loginInfo.reduce(({}, loginInfoToken) => {
this.minedu_userName = loginInfoToken.minedu_username; this.minedu_userName = loginInfoToken.minedu_username;
this.minedu_userPassword = loginInfoToken.minedu_userpassword; this.minedu_userPassword = loginInfoToken.minedu_userpassword;
if (loginInfoToken.auth_role == PDE_ROLE || loginInfoToken.auth_role == DIDE_ROLE) { if (loginInfoToken.auth_role === PDE_ROLE || loginInfoToken.auth_role === DIDE_ROLE) {
this.userRole = loginInfoToken.auth_role; this.userRole = loginInfoToken.auth_role;
this.minedu_userName = loginInfoToken.auth_token; this.minedu_userName = loginInfoToken.auth_token;
this.minedu_userPassword = loginInfoToken.auth_token; this.minedu_userPassword = loginInfoToken.auth_token;
...@@ -163,25 +135,24 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -163,25 +135,24 @@ import { API_ENDPOINT } from '../../app.settings';
} }
ngOnDestroy() { ngOnDestroy() {
if (this.loginInfoSub) {
if (this.loginInfoSub)
this.loginInfoSub.unsubscribe(); this.loginInfoSub.unsubscribe();
if (this.loginInfo$) }
if (this.loginInfo$) {
this.loginInfo$.unsubscribe(); this.loginInfo$.unsubscribe();
}
} }
nav_to_reportpath(repId) { nav_to_reportpath(repId) {
if (repId === 0) {
if (repId == 0) this.router.navigate(["/ministry/report-users", repId]);
this.router.navigate(['/ministry/report-users', repId]); } else if (repId === 1) {
if (repId == 1) this.router.navigate(["/ministry/report-general"]);
this.router.navigate(['/ministry/report-general', repId]); } else if (repId === 2 || repId === 3 || repId === 5) {
else if (repId == 2 || repId == 3 || repId == 5) this.router.navigate(["/ministry/report-all-stat", repId]);
this.router.navigate(['/ministry/report-all-stat', repId]); } else if (repId === 4) {
else if (repId == 4) this.router.navigate(["/ministry/report-no-capacity", repId]);
this.router.navigate(['/ministry/report-no-capacity', repId]); }
} }
} }
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Input } from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Input } from "@angular/core";
import { Injectable } from "@angular/core"; import { 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 { Ng2SmartTableModule, LocalDataSource } from 'ng2-smart-table'; import { Ng2SmartTableModule, LocalDataSource } from "ng2-smart-table";
import {reportsSchema, TableColumn} from './reports-schema'; import { reportsSchema, TableColumn } from "./reports-schema";
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state'; import { LOGININFO_INITIAL_STATE } from "../../store/logininfo/logininfo.initial-state";
import {csvCreator} from './csv-creator'; import { csvCreator } from "./csv-creator";
import {chartCreator} from './chart-creator'; import { chartCreator } from "./chart-creator";
import { import {
FormBuilder, FormBuilder,
...@@ -21,13 +21,12 @@ import { ...@@ -21,13 +21,12 @@ import {
FormControl, FormControl,
FormArray, FormArray,
Validators, Validators,
} from '@angular/forms'; } from "@angular/forms";
import { API_ENDPOINT } from "../../app.settings";
import { API_ENDPOINT } from '../../app.settings';
@Component({ @Component({
selector: 'report-general', selector: "report-general",
template: ` template: `
<div> <div>
...@@ -40,7 +39,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -40,7 +39,7 @@ import { API_ENDPOINT } from '../../app.settings';
<h5> >Επιλογή Φίλτρων <br><br></h5> <h5> >Επιλογή Φίλτρων <br><br></h5>
<h6> Δεν υπάρχουν διαθέσιμα φίλτρα <br><br><br></h6> <h6> Δεν υπάρχουν διαθέσιμα φίλτρα <br><br><br></h6>
<button type="submit" class="btn btn-alert" (click)="createReport(regsel)" [hidden]="minedu_userName == ''" > <button type="submit" class="btn btn-alert" (click)="createReport()" [hidden]="minedu_userName == ''" >
<i class="fa fa-file-text"></i> <i class="fa fa-file-text"></i>
Δημιουργία Αναφοράς Δημιουργία Αναφοράς
</button> </button>
...@@ -89,8 +88,6 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -89,8 +88,6 @@ import { API_ENDPOINT } from '../../app.settings';
private data; private data;
private validCreator: number; private validCreator: number;
private createGraph: boolean; private createGraph: boolean;
private reportId: number;
private routerSub: any;
private source: LocalDataSource; private source: LocalDataSource;
columnMap: Map<string, TableColumn> = new Map<string, TableColumn>(); columnMap: Map<string, TableColumn> = new Map<string, TableColumn>();
...@@ -99,7 +96,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -99,7 +96,7 @@ import { API_ENDPOINT } from '../../app.settings';
private csvObj = new csvCreator(); private csvObj = new csvCreator();
private chartObj = new chartCreator(); private chartObj = new chartCreator();
@ViewChild('chart') public chartContainer: ElementRef; @ViewChild("chart") public chartContainer: ElementRef;
private d3data: Array<any>; private d3data: Array<any>;
...@@ -110,14 +107,14 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -110,14 +107,14 @@ import { API_ENDPOINT } from '../../app.settings';
private router: Router) { private router: Router) {
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
region: ['', []], region: ["", []],
adminarea: ['', []], adminarea: ["", []],
schoollist: ['', []], schoollist: ["", []],
}); });
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE); this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.generalReport$ = new BehaviorSubject([{}]); this.generalReport$ = new BehaviorSubject([{}]);
this.minedu_userName = ''; this.minedu_userName = "";
this.validCreator = -1; this.validCreator = -1;
this.createGraph = false; this.createGraph = false;
...@@ -127,7 +124,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -127,7 +124,7 @@ import { API_ENDPOINT } from '../../app.settings';
this.loginInfoSub = this._ngRedux.select(state => { this.loginInfoSub = this._ngRedux.select(state => {
if (state.loginInfo.size > 0) { if (state.loginInfo.size > 0) {
state.loginInfo.reduce(({}, loginInfoToken) => { state.loginInfo.reduce(({ }, loginInfoToken) => {
this.minedu_userName = loginInfoToken.minedu_username; this.minedu_userName = loginInfoToken.minedu_username;
this.minedu_userPassword = loginInfoToken.minedu_userpassword; this.minedu_userPassword = loginInfoToken.minedu_userpassword;
return loginInfoToken; return loginInfoToken;
...@@ -136,11 +133,6 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -136,11 +133,6 @@ import { API_ENDPOINT } from '../../app.settings';
return state.loginInfo; return state.loginInfo;
}).subscribe(this.loginInfo$); }).subscribe(this.loginInfo$);
this.routerSub = this.activatedRoute.params.subscribe(params => {
this.reportId = +params['reportId'];
});
} }
ngOnDestroy() { ngOnDestroy() {
...@@ -156,41 +148,28 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -156,41 +148,28 @@ import { API_ENDPOINT } from '../../app.settings';
} }
createReport() {
createReport(regionSel) {
this.validCreator = 0; this.validCreator = 0;
this.createGraph = false; this.createGraph = false;
let route; let route = "/ministry/general-report/";
if (this.reportId === 1) { this.settings = this.reportSchema.genReportSchema;
route = "/ministry/general-report/";
this.settings = this.reportSchema.genReportSchema; this.generalReportSub = this._hds.makeReport(this.minedu_userName, this.minedu_userPassword, route, 0, 0, 0, 0, 0, 0, 0)
} .subscribe(data => {
else if (this.reportId === 2) { this.generalReport$.next(data);
route = "/ministry/report-completeness/"; this.data = data;
this.settings = this.reportSchema.reportCompletenessSchema; this.validCreator = 1;
} this.source = new LocalDataSource(this.data);
else if (this.reportId === 3) { this.columnMap = new Map<string, TableColumn>();
route = "/ministry/report-all-stat/";
this.settings = this.reportSchema.reportAllStatSchema; // pass parametes to csv class object
} this.csvObj.columnMap = this.columnMap;
this.csvObj.source = this.source;
let regSel = 0; this.csvObj.settings = this.settings;
this.csvObj.prepareColumnMap();
this.generalReportSub = this._hds.makeReport(this.minedu_userName, this.minedu_userPassword, route, 0, 0, 0, 0, 0, 0, 0).subscribe(data => { },
this.generalReport$.next(data);
this.data = data;
this.validCreator = 1;
this.source = new LocalDataSource(this.data);
this.columnMap = new Map<string, TableColumn>();
//pass parametes to csv class object
this.csvObj.columnMap = this.columnMap;
this.csvObj.source = this.source;
this.csvObj.settings = this.settings;
this.csvObj.prepareColumnMap();
},
error => { error => {
this.generalReport$.next([{}]); this.generalReport$.next([{}]);
this.validCreator = -1; this.validCreator = -1;
...@@ -200,20 +179,15 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -200,20 +179,15 @@ import { API_ENDPOINT } from '../../app.settings';
} }
navigateBack() { navigateBack() {
this.router.navigate(['/ministry/minister-reports']); this.router.navigate(["/ministry/minister-reports"]);
} }
onSearch(query: string = "") {
onSearch(query: string = '') {
this.csvObj.onSearch(query); this.csvObj.onSearch(query);
} }
export2Csv() { export2Csv() {
this.csvObj.export2Csv(); this.csvObj.export2Csv();
} }
...@@ -229,33 +203,20 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -229,33 +203,20 @@ import { API_ENDPOINT } from '../../app.settings';
} }
generateGraphData() { generateGraphData() {
this.d3data = []; this.d3data = [];
if (this.reportId === 1) { let labelsX = [];
let labelsX = []; labelsX.push("1η Προτίμηση");
labelsX.push("1η Προτίμηση"); labelsX.push("2η Προτίμηση");
labelsX.push("2η Προτίμηση"); labelsX.push("3η Προτίμηση");
labelsX.push("3η Προτίμηση"); labelsX.push("Μη τοποθετημένοι");
labelsX.push("Μη τοποθετημένοι"); labelsX.push("Προσωρινά τοποθετημένοι σε ολιγομελή");
labelsX.push("Προσωρινά τοποθετημένοι σε ολιγομελή"); for (let i = 1; i <= 5; i++) {
for (let i = 1; i <= 5; i++) { this.d3data.push([
this.d3data.push([ labelsX[i - 1],
labelsX[i - 1], this.data[i].numStudents / this.data[0].numStudents,
this.data[i].numStudents / this.data[0].numStudents, ]);
]);
}
} }
} }
} }
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Input } from "@angular/core"; import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Input } from "@angular/core";
import { Injectable } from "@angular/core"; import { 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 { Ng2SmartTableModule, LocalDataSource } from 'ng2-smart-table'; import { Ng2SmartTableModule, LocalDataSource } from "ng2-smart-table";
import {reportsSchema, TableColumn} from './reports-schema'; import {reportsSchema, TableColumn} from "./reports-schema";
import { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state'; import { LOGININFO_INITIAL_STATE } from "../../store/logininfo/logininfo.initial-state";
import {csvCreator} from './csv-creator'; import {csvCreator} from "./csv-creator";
import { API_ENDPOINT } from '../../app.settings'; import { API_ENDPOINT } from "../../app.settings";
@Component({ @Component({
selector: 'report-users', selector: "report-users",
template: ` template: `
<div> <div>
...@@ -66,7 +66,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -66,7 +66,7 @@ import { API_ENDPOINT } from '../../app.settings';
private distStatus = "READY"; private distStatus = "READY";
private data; private data;
private validCreator: number; private validCreator: number;
//private reportId: number; // private reportId: number;
private routerSub: any; private routerSub: any;
private source: LocalDataSource; private source: LocalDataSource;
...@@ -75,17 +75,16 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -75,17 +75,16 @@ import { API_ENDPOINT } from '../../app.settings';
private reportSchema = new reportsSchema(); private reportSchema = new reportsSchema();
private csvObj = new csvCreator(); private csvObj = new csvCreator();
constructor(
constructor(private _ngRedux: NgRedux<IAppState>, private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService, private _hds: HelperDataService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router) { private router: Router
) {
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE); this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.generalReport$ = new BehaviorSubject([{}]); this.generalReport$ = new BehaviorSubject([{}]);
this.minedu_userName = ''; this.minedu_userName = "";
this.validCreator = -1; this.validCreator = -1;
} }
ngOnInit() { ngOnInit() {
...@@ -120,23 +119,23 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -120,23 +119,23 @@ import { API_ENDPOINT } from '../../app.settings';
this.validCreator = 0; this.validCreator = 0;
let route; let route = "/ministry/report-users/";
route = "/ministry/report-users/";
this.settings = this.reportSchema.ReportUsersSchema; this.settings = this.reportSchema.ReportUsersSchema;
this.generalReportSub = this._hds.makeReport(this.minedu_userName, this.minedu_userPassword, route, 0, 0, 0, 0, 0, 0, 0).subscribe(data => { this.generalReportSub = this._hds.makeReport(this.minedu_userName, this.minedu_userPassword, route, 0, 0, 0, 0, 0, 0, 0)
this.generalReport$.next(data); .subscribe(data => {
this.data = data; this.generalReport$.next(data);
this.validCreator = 1; this.data = data;
this.source = new LocalDataSource(this.data); this.validCreator = 1;
this.columnMap = new Map<string, TableColumn>(); this.source = new LocalDataSource(this.data);
this.columnMap = new Map<string, TableColumn>();
//pass parametes to csv class object
this.csvObj.columnMap = this.columnMap; // pass parametes to csv class object
this.csvObj.source = this.source; this.csvObj.columnMap = this.columnMap;
this.csvObj.settings = this.settings; this.csvObj.source = this.source;
this.csvObj.prepareColumnMap(); this.csvObj.settings = this.settings;
}, this.csvObj.prepareColumnMap();
},
error => { error => {
this.generalReport$.next([{}]); this.generalReport$.next([{}]);
this.validCreator = -1; this.validCreator = -1;
...@@ -146,20 +145,15 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -146,20 +145,15 @@ import { API_ENDPOINT } from '../../app.settings';
} }
navigateBack() { navigateBack() {
this.router.navigate(['/ministry/minister-reports']); this.router.navigate(["/ministry/minister-reports"]);
} }
onSearch(query: string = "") {
onSearch(query: string = '') {
this.csvObj.onSearch(query); this.csvObj.onSearch(query);
} }
export2Csv() { export2Csv() {
this.csvObj.export2Csv(); this.csvObj.export2Csv();
} }
}