Merge branch 'component_updates' into 'develop'

Component updates

See merge request !67
parents ecf690c8 adc40507
......@@ -145,6 +145,14 @@ epal.ministry.general_report:
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\Distribution::makegGeneralReport'
_controller: '\Drupal\epal\Controller\ReportsCreator::makegGeneralReport'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.report1:
path: '/ministry/report-completeness'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\ReportsCreator::makeReportCompleteness'
requirements:
_user_is_logged_in: 'TRUE'
......@@ -46,7 +46,7 @@ class MinistryLogin extends ControllerBase
public function loginGo(Request $request)
{
try {
if (!$request->isMethod('POST')) {
......@@ -87,9 +87,9 @@ class MinistryLogin extends ControllerBase
$postData = json_decode($content);
//return new RedirectResponse("/drupal-8.2.6/eepal/dist/" . '?auth_token=' . $postData->username .'&auth_role=supervisor', 302, []);
return $this->respondWithStatus([
'auth_token' => $postData->username,
'userpassword' => $postData->userpassword,
'auth_role' => $currentRoleName,
//'auth_token' => $postData->username,
//'userpassword' => $postData->userpassword,
//'auth_role' => $currentRoleName,
], Response::HTTP_OK);
}
else {
......
This diff is collapsed.
......@@ -34,7 +34,7 @@ import StudentAuthGuard from './guards/student.auth.guard';
import { ACTION_PROVIDERS } from './actions';
import Home from './components/home';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { Ng2SmartTableModule, LocalDataSource } from 'ng2-smart-table';
import HeaderComponent from './components/header/header.component';
import NavbarComponent from './components/navbar/navbar.component';
......
......@@ -27,4 +27,4 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
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 { LOGININFO_INITIAL_STATE } from '../../store/logininfo/logininfo.initial-state';
import {
FormBuilder,
FormGroup,
FormControl,
FormArray,
} from '@angular/forms';
import { API_ENDPOINT } from '../../app.settings';
@Component({
selector: 'minister-informstudents',
template: `
`
})
@Injectable() export default class InformStudents implements OnInit, OnDestroy {
public formGroup: FormGroup;
//private loginInfo$: Observable<ILoginInfo>;
loginInfo$: BehaviorSubject<ILoginInfo>;
loginInfoSub: Subscription;
private apiEndPoint = API_ENDPOINT;
private minedu_userName: string;
private minedu_userPassword: string;
constructor(private fb: FormBuilder,
// private _ata: LoginInfoActions,
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService,
private activatedRoute: ActivatedRoute,
private router: Router) {
this.formGroup = this.fb.group({
});
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
}
ngOnDestroy() {
if (this.loginInfoSub) this.loginInfoSub.unsubscribe();
this.loginInfo$.unsubscribe();
}
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$);
}
}
export class TableColumn {
field: string;
title: string;
type: string;
isDisplay: boolean;
isExport: boolean;
valuePrepareFunction: Function;
}
export class reportsSchema {
/*
defaultSettings = {
actions: {
columnTitle: 'Actions',
add: false,
edit: false,
delete: false
},
pager: {
display: true,
perPage: 50
}
};
*/
genReportSchema = {
actions: false,
columns: {
name: {
title: 'Κατηγορία',
filter: false
},
numStudents: {
title: 'Αριθμός',
filter: false
}
}
};
reportCompletenessSchemaFull = {
actions: false,
columns: {
name: {
title: 'Σχολείο',
filter: false,
hide: true
},
numStudents: {
title: 'Αριθμός',
filter: false
},
capacityTotal: {
title: 'Χωρ/τα',
filter: false
},
percTotal: {
title: 'Πληρότητα',
filter: false
},
numStudentsA: {
title: 'Α Τάξη',
filter: false
},
capacityA: {
title: 'Χωρ/τα',
filter: false
},
percA: {
title: 'Πληρότητα',
filter: false
},
numStudentsB: {
title: 'Β Τάξη',
filter: false
},
capacityB: {
title: 'Χωρ/τα',
filter: false
},
percB: {
title: 'Πληρότητα',
filter: false
},
numStudentsC: {
title: 'Γ Τάξη',
filter: false
},
capacityC: {
title: 'Χωρ/τα',
filter: false
},
percC: {
title: 'Πληρότητα',
filter: false
}
}
};
reportCompletenessSchema = {
actions: false,
columns: {
name: {
title: 'Σχολείο',
filter: false,
hide: true
},
percTotal: {
title: 'Πληρότητα Σχολείου',
filter: false
},
percA: {
title: 'Πληρότητα Α\' τάξης',
filter: false
},
percB: {
title: 'Πληρότητα Β\' τάξης',
filter: false
},
percC: {
title: 'Πληρότητα Γ\' τάξης',
filter: false
}
}
};
constructor() {}
}
......@@ -22,7 +22,9 @@ import { API_ENDPOINT } from '../app.settings';
template: `
<div>
<form novalidate [formGroup]="userDataGroup" #form>
<div
class = "loading" *ngIf="validLogin === -1" >
</div>
<div class="form-group">
<label for="minedu_username">Όνομα διαχειριστή</label><input class="form-control" type="text" formControlName="minedu_username">
</div>
......@@ -61,7 +63,7 @@ export default class MinistryHome implements OnInit {
private mineduUsername: string;
//private mineduPassword: string;
//private cuName: string;
private validLogin: boolean;
private validLogin: number;
private loginInfo$: Observable<ILoginInfo>;
private apiEndPoint = API_ENDPOINT;
......@@ -77,7 +79,9 @@ export default class MinistryHome implements OnInit {
//this.mineduPassword = '';
this.authRole = '';
//this.cuName = '';
this.validLogin = true;
//this.validLogin = true;
this.validLogin = 1;
this.userDataGroup = this.fb.group({
minedu_username: ['minedu01', [Validators.required]],
......@@ -104,15 +108,17 @@ export default class MinistryHome implements OnInit {
}
submitCredentials() {
this.validLogin = -1;
let success = true;
this._hds.sendMinisrtyCredentials(this.userDataGroup.value['minedu_username'],this.userDataGroup.value['minedu_userpassword'])
.catch(err => {console.log(err); success = false; this.validLogin = false; })
.catch(err => {console.log(err); success = false; this.validLogin = 0; })
.then(msg => {
if (success) {
this.authRole = 'supervisor';
this._hds.setMineduCurrentUser(this.userDataGroup.value['minedu_username'], this.userDataGroup.value['minedu_userpassword'], this.authRole);
console.log("MPHKA");
this.validLogin = true;
//this.validLogin = true;
this.validLogin = 1;
this.userDataGroup.value['cu_name'] = this.userDataGroup.value['minedu_username'];
this.userDataGroup.value['auth_role'] = 'supervisor';
this._ata.saveMinEduloginInfo([this.userDataGroup.value]);
......
......@@ -48,6 +48,11 @@
<a class="nav-link" [routerLink]="['/ministry/minister-reports']" [routerLinkActive]="['active']"><b>Αναφορές</b></a>
</li>
</div>
<div *ngIf="(loginInfo$ | async).size > 0" class="nav-item" >
<li *ngIf="authRole=='supervisor'" class="nav-item" >
<a class="nav-link" [routerLink]="['/ministry/minister-informstudents']" [routerLinkActive]="['active']"><b>Αποστολή Ειδοποιήσεων</b></a>
</li>
</div>
</div>
</ul>
......
......@@ -191,3 +191,7 @@
padding: 0px 10px 0px 10px;
text-align: center;
}
.reportScroll {
overflow-x: scroll;
}
......@@ -25,6 +25,7 @@ import DirectorView from '../components/director/director-view';
import DirectorClassCapacity from '../components/director/director-classcapacity';
import MinisterView from '../components/minister/minister-view';
import MinisterReports from '../components/minister/minister-reports';
import InformStudents from '../components/minister/minister-informstudents';
import SchoolAuthGuard from '../guards/school.auth.guard';
import StudentAuthGuard from '../guards/student.auth.guard';
......@@ -49,6 +50,7 @@ export const MainRoutes: Routes = [
{ path: 'school/director-classcapacity', component: DirectorClassCapacity, canActivate: [SchoolAuthGuard] },
{ path: 'ministry/minister-view', component: MinisterView },
{ path: 'ministry/minister-reports', component: MinisterReports },
{ path: 'ministry/minister-informstudents', component: InformStudents },
];
export const MainDeclarations = [
......@@ -73,5 +75,6 @@ export const MainDeclarations = [
DirectorView,
DirectorClassCapacity,
MinisterView,
MinisterReports
MinisterReports,
InformStudents
];
......@@ -664,7 +664,8 @@ export class HelperDataService implements OnInit, OnDestroy {
}
makeGeneralReport(username, userpassword) {
makeReport(username, userpassword, routepath) {
let headers = new Headers({
"Content-Type": "application/json",
......@@ -673,23 +674,9 @@ export class HelperDataService implements OnInit, OnDestroy {
this.createMinistryAuthorizationHeader(headers, username, userpassword );
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/ministry/general-report/` , options)
return this.http.get(`${AppSettings.API_ENDPOINT}` + routepath , options)
.map(response => response.json());
/*
return new Promise((resolve, reject) => {
this.http.post(`${AppSettings.API_ENDPOINT}/epal/distribution`, {username: username, userpassword: userpassword}, options)
.map(response => response.json())
.subscribe(data => {
resolve(data);
},
error => {
reject("Error POST in makeDistribution");
},
() => console.log(""));
});
*/
}
......
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