Commit 30d0e77f authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος

Merge branch 'develop' of https://git.minedu.gov.gr/itminedu/e-epal into component_updates

parents cfabdf81 cc188496
......@@ -207,7 +207,7 @@ epal.ministry.storesettings:
requirements:
_user_is_logged_in: 'TRUE'
regionview:
path: '/epal/ScoolperPerf'
path: '/epal/ScoolperPerf/{check_status}'
options:
_auth: [ 'basic_auth' ]
defaults:
......
......@@ -427,7 +427,7 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
public function getSchoolsPerPerfetcure(Request $request)
public function getSchoolsPerPerfetcure(Request $request, $check_status)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......@@ -436,14 +436,20 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
$user = reset($users);
if ($user)
{
$perfectureId = $user -> init -> value;
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('region_edu_admin_id'=> $perfectureId ));
$selectionId = $user -> init -> value;
if ($check_status == 1){
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('region_edu_admin_id'=> $selectionId ));
}
else
{
$schools = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('edu_admin_id'=> $selectionId ));
}
if ($schools)
{
$list = array();
foreach ($schools as $object) {
$status = $this->returnstatus(147);
$status = $this->returnstatus($object -> id());
$list[] = array(
'id' =>$object -> id(),
'name' => $object -> name ->value,
......@@ -595,10 +601,74 @@ public function SaveCapacity(Request $request,$taxi,$tomeas,$specialit)
public function returnstatus($id)
{
if ($id == 147)
return true ;
return false;
$schoolid = $id;
$SchoolCats = $this->entityTypeManager->getStorage('eepal_school')->loadByProperties(array('id'=> $schoolid ));
$SchoolCat = reset($SchoolCats);
if ($SchoolCat){
$categ = $SchoolCat-> metathesis_region -> value;
}
$CourseA = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('id'=> $schoolid ));
if ($CourseA)
{
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 1, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => -1, 'currentclass' => 1 ));
//foreach ($CourseA as $object) {
if (sizeof($studentPerSchool) < $limit){
return false;
exit;
}
} // }
$CourseB = $this->entityTypeManager->getStorage('eepal_sectors_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseB)
{
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 2, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
foreach ($CourseB as $object) {
$sectorid = $object -> sector_id -> entity -> id();
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $sectorid, 'currentclass' => 2 ));
if (sizeof($studentPerSchool) < $limit){
return false;
exit;
}
}
}
$CourseC = $this->entityTypeManager->getStorage('eepal_specialties_in_epal')->loadByProperties(array('epal_id' => $schoolid ));
if ($CourseC)
{
$limit_down = $this->entityTypeManager->getStorage('epal_class_limits')->loadByProperties(array('name'=> 3, 'category' => $categ ));
$limitdown = reset($limit_down);
if ($limitdown)
{
$limit = $limitdown -> limit_down -> value;
}
foreach ($CourseC as $object) {
$specialityid = $object -> specialty_id -> entity -> id() ;
$studentPerSchool = $this->entityTypeManager->getStorage('epal_student_class')->loadByProperties(array('currentepal'=> $schoolid, 'specialization_id' => $specialityid, 'currentclass' => 3 ));
if (sizeof($studentPerSchool) < $limit){
return false;
exit;
}
}
}
return true;
exit;
}
......
......@@ -128,116 +128,111 @@ class CBController extends ControllerBase
public function authenticatePhase2($request, $authToken, $authVerifier)
{
$taxis_userid = null;
$trx = $this->connection->startTransaction();
try {
$oauth = new OAuth($this->consumer_key, $this->consumer_secret, OAUTH_SIG_METHOD_PLAINTEXT, OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->setToken($authToken, $this->requestTokenSecret);
$accessToken = $oauth->getAccessToken($this->access_token_url, '', $authVerifier);
$oauth->setToken($accessToken['oauth_token'], $accessToken['oauth_token_secret']);
$oauth->fetch($this->api_url);
$this->logger->warning($oauth->getLastResponse());
$taxis_userid = $this->xmlParse($oauth->getLastResponse(), 'messageText');
$currentTime = time();
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('taxis_userid' => $taxis_userid));
$epalUser = reset($epalUsers);
$epalToken = md5(uniqid(mt_rand(), true));
if ($epalUser) {
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
if ($user) {
// $user->setPassword('harispass');
// $user->setUsername('harisp');
$user->setPassword($epalToken);
$user->setUsername($epalToken);
$user->save();
$epalUser->set('authtoken', $epalToken);
$epalUser->set('accesstoken', $accessToken['oauth_token']);
$epalUser->set('accesstoken_secret', $accessToken['oauth_token_secret']);
$epalUser->set('requesttoken',$this->requestToken);
$epalUser->set('requesttoken_secret', $this->requestTokenSecret);
$epalUser->set('timelogin', $currentTime);
$epalUser->set('userip', $request->getClientIp());
$epalUser->save();
$taxis_userid = null;
$trx = $this->connection->startTransaction();
try {
$oauth = new OAuth($this->consumer_key, $this->consumer_secret, OAUTH_SIG_METHOD_PLAINTEXT, OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->setToken($authToken, $this->requestTokenSecret);
$accessToken = $oauth->getAccessToken($this->access_token_url, '', $authVerifier);
$oauth->setToken($accessToken['oauth_token'], $accessToken['oauth_token_secret']);
$oauth->fetch($this->api_url);
$this->logger->warning($oauth->getLastResponse());
$taxis_userid = $this->xmlParse($oauth->getLastResponse(), 'messageText');
$currentTime = time();
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('taxis_userid' => $taxis_userid));
$epalUser = reset($epalUsers);
$epalToken = md5(uniqid(mt_rand(), true));
if ($epalUser) {
$user = $this->entityTypeManager->getStorage('user')->load($epalUser->user_id->target_id);
if ($user) {
$user->setPassword($epalToken);
$user->setUsername($epalToken);
$user->save();
$epalUser->set('authtoken', $epalToken);
$epalUser->set('accesstoken', $accessToken['oauth_token']);
$epalUser->set('accesstoken_secret', $accessToken['oauth_token_secret']);
$epalUser->set('requesttoken',$this->requestToken);
$epalUser->set('requesttoken_secret', $this->requestTokenSecret);
$epalUser->set('timelogin', $currentTime);
$epalUser->set('userip', $request->getClientIp());
$epalUser->save();
}
}
}
if ($epalUser === null || !$epalUser) {
//Create a User
$user = User::create();
//Mandatory settings
$unique_id = uniqid('####');
$user->setPassword($epalToken);
$user->enforceIsNew();
$user->setEmail($unique_id);
$user->setUsername($epalToken); //This username must be unique and accept only a-Z,0-9, - _ @ .
$user->activate();
$user->set('init', $unique_id);
//Set Language
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$user->set('langcode', $language_interface->getId());
$user->set('preferred_langcode', $language_interface->getId());
$user->set('preferred_admin_langcode', $language_interface->getId());
//Adding default user role
$user->addRole('applicant');
$user->save();
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('mail' => $unique_id));
$user = reset($users);
if ($user) {
$this->logger->warning('userid 190='.$user->id().'*** name='.$user->name->value);
$epalUser = $this->entityTypeManager()->getStorage('epal_users')->create(array(
// 'langcode' => $language_interface->getId(),
'langcode' => 'el',
'user_id' => $user->id(),
'drupaluser_id' => $user->id(),
'taxis_userid' => $taxis_userid,
'taxis_taxid' => $unique_id,
'name' => $unique_id,
'surname' => $unique_id,
'fathername' => $unique_id,
'mothername' => $unique_id,
'accesstoken' => $accessToken['oauth_token'],
'accesstoken_secret' => $accessToken['oauth_token_secret'],
'authtoken' => $epalToken,
'requesttoken' => $this->requestToken,
'requesttoken_secret' => $this->requestTokenSecret,
'timelogin' => $currentTime,
'timeregistration' => $currentTime,
'timetokeninvalid' => 0,
'userip' => $request->getClientIp(),
'status' => 1
));
$epalUser->save();
} else {
return false;
}
if ($epalUser === null || !$epalUser) {
}
$this->oauthostSession->set('authtoken', $epalToken);
$this->oauthostSession->save();
// $this->oauthostSession->delete();
//Create a User
$user = User::create();
//Mandatory settings
$unique_id = uniqid('####');
$user->setPassword($epalToken);
$user->enforceIsNew();
$user->setEmail($unique_id);
$user->setUsername($epalToken); //This username must be unique and accept only a-Z,0-9, - _ @ .
$user->activate();
$user->set('init', $unique_id);
//Set Language
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$user->set('langcode', $language_interface->getId());
$user->set('preferred_langcode', $language_interface->getId());
$user->set('preferred_admin_langcode', $language_interface->getId());
//Adding default user role
$user->addRole('applicant');
$user->save();
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('mail' => $unique_id));
$user = reset($users);
if ($user) {
$this->logger->warning('userid 190='.$user->id().'*** name='.$user->name->value);
$epalUser = $this->entityTypeManager()->getStorage('epal_users')->create(array(
'langcode' => 'el',
'user_id' => $user->id(),
'drupaluser_id' => $user->id(),
'taxis_userid' => $taxis_userid,
'taxis_taxid' => $unique_id,
'name' => $unique_id,
'surname' => $unique_id,
'fathername' => $unique_id,
'mothername' => $unique_id,
'accesstoken' => $accessToken['oauth_token'],
'accesstoken_secret' => $accessToken['oauth_token_secret'],
'authtoken' => $epalToken,
'requesttoken' => $this->requestToken,
'requesttoken_secret' => $this->requestTokenSecret,
'timelogin' => $currentTime,
'timeregistration' => $currentTime,
'timetokeninvalid' => 0,
'userip' => $request->getClientIp(),
'status' => 1
));
$epalUser->save();
} else {
return false;
}
return $epalToken;
} catch (OAuthException $e) {
$this->logger->warning($e->getMessage());
$trx->rollback();
return false;
} catch (\Exception $ee) {
$this->logger->warning($ee->getMessage());
$trx->rollback();
return false;
}
}
$this->oauthostSession->set('authtoken', $epalToken);
$this->oauthostSession->save();
// $this->oauthostSession->delete();
return $epalToken;
} catch (OAuthException $e) {
$this->logger->warning($e->getMessage());
$trx->rollback();
return false;
} catch (\Exception $ee) {
$this->logger->warning($ee->getMessage());
$trx->rollback();
return false;
}
return false;
}
......
......@@ -56,6 +56,27 @@ import {
</form>
</div>
<div id="checksaved" (onHidden)="onHidden('#checksaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header modal-header-danger">
<h3 class="modal-title pull-left"><i class="fa fa-check-square-o"></i>&nbsp;&nbsp;Πρέπει να συπληρώσετε όλα τα πεδία</h3>
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal('#checksaved')">
<span aria-hidden="true"><i class="fa fa-times"></i></span>
</button>
</div>
<div class="modal-body">
<p>Η αποθήκευση δε μπορεί να γίνει αν δεν συμπληρώσετε όλα τα στοιχεία της φόρμας!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div id="capacitysaved" (onHidden)="onHidden('#capacitysaved')"
class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
......@@ -77,6 +98,9 @@ import {
</div>
`
})
......@@ -98,10 +122,13 @@ import {
private classCapacity$: BehaviorSubject<any>;
private classCapacitySub: Subscription;
private retrievedStudent: BehaviorSubject<boolean>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
constructor(private fb: FormBuilder,
private _hds: HelperDataService,
private activatedRoute: ActivatedRoute,
......@@ -114,6 +141,9 @@ import {
this.selectionCClass = new BehaviorSubject(false);
this.retrievedStudent = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
this.formGroup = this.fb.group({
tomeas: ['', []],
taxi: ['', []],
......@@ -155,6 +185,7 @@ import {
ngOnInit() {
(<any>$('#capacitysaved')).appendTo("body");
(<any>$('#checksaved')).appendTo("body");
this.retrievedStudent.next(false);
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
......@@ -298,11 +329,20 @@ import {
saveCapacity() {
var taxi = +this.formGroup.value.taxi;
var tomeas = +this.formGroup.value.tomeas;
var specialit = +this.formGroup.value.specialit;
var capc = +this.formGroup.value.capacity;
if ((taxi === 2 && tomeas === 0) || (taxi === 3 && tomeas === 0 ) || (taxi ===3 && specialit === 0 )
|| (taxi === 4 && tomeas === 0 ) || (taxi ===4 && specialit === 0 ) || (taxi = 0) || (capc ===0))
{
this.showModal("#checksaved");
} else
{
this.saveCapacitySub = this._hds.saveCapacity(this.formGroup.value.taxi, tomeas, specialit, this.formGroup.value.capacity).subscribe(data => {
},
error => {
......@@ -312,9 +352,11 @@ import {
console.log("Saved Capacity");
this.showModal("#capacitysaved");
});
}
}
}
import { Component, OnInit, OnDestroy, ElementRef, ViewChild, 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 {
FormBuilder,
FormGroup,
FormControl,
FormArray,
Validators,
} from '@angular/forms';
@Component({
selector: 'eduadmin-view',
template: `
<h3> Αριθμός Μαθητών ανα τμήμα σχολείου </h3>
<ul class="list-group main-view">
<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" >
<h5> {{SchoolNames$.name}}</h5>
</li>
<div *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)" [hidden]="SchoolNames$.id !== regionActive" >
<div> {{CoursesNames$.name}}</div> <div class= "aastyle"><strong>Αριθμός Μαθητών:</strong>{{CoursesNames$.size}} </div>
</div>
</div>
</ul>
<div class="col-md-6">
<button type="button" class="btn-primary btn-lg pull-right" (click)="navigateToApplication()" >
<i class="fa fa-forward"></i>
</button>
</div>
`
})
@Injectable() export default class EduadminView implements OnInit, OnDestroy {
public formGroup: FormGroup;
private SchoolsPerPerf$: BehaviorSubject<any>;
private SchoolPerPerfSub: Subscription;
private LimitPerCateg$: BehaviorSubject<any>;
private LimitPerCategSub: Subscription;
private CoursesPerPerf$: BehaviorSubject<any>;
private CoursesPerPerfSub: Subscription;
private StudentsSize$: BehaviorSubject<any>;
private StudentsSizeSub: Subscription;
public perfecture ;
private regionActive = <number>-1;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
constructor(private fb: FormBuilder,
private router: Router,
private _hds: HelperDataService,
) {
this.SchoolsPerPerf$ = new BehaviorSubject([{}]);
this.LimitPerCateg$ = new BehaviorSubject([{}]);
this.CoursesPerPerf$ = new BehaviorSubject([{}]);
this.StudentsSize$ = new BehaviorSubject({});
this.School$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
});
}
ngOnDestroy() {
}
ngOnInit() {
this.SchoolSub = this._hds.getSchoolId().subscribe(x => {
this.School$.next(x);
console.log(x[0].id, "perfectureID");
this.perfecture = x[0].id;
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(0).subscribe(data => {
this.SchoolsPerPerf$.next(data);
},
error => {
this.SchoolsPerPerf$.next([{}]);
console.log("Error Getting Schools");
},
() => console.log("Getting Schools"));
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
}
setActiveRegion(ind) {
if (ind === this.regionActive)
ind = -1;
this.regionActive = ind;
this.CoursesPerPerfSub = this._hds.getCoursePerPerfecture(this.regionActive).subscribe(data => {
this.CoursesPerPerf$.next(data);
},
error => {
this.CoursesPerPerf$.next([{}]);
console.log("Error Getting Courses");
},
() => console.log("Getting Courses Per Perf"));
}
navigateToApplication()
{
var id: string= String(this.regionActive);
this.router.navigate(['', {ids:id}]);
}
calccolor(size, limit)
{
if (size < limit)
return true;
else
return false;
}
}
......@@ -23,7 +23,7 @@ import {
<ul class="list-group main-view">
<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 === true" [class.oddout]="isOdd" [class.evenout]="isEven" [class.selectedout]="regionActive === SchoolNames$.id" >
<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" >
<h5> {{SchoolNames$.name}}</h5>
</li>
<div *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)" [hidden]="SchoolNames$.id !== regionActive" >
......@@ -85,7 +85,7 @@ import {
this.School$.next(x);
console.log(x[0].id, "perfectureID");
this.perfecture = x[0].id;
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture().subscribe(data => {
this.SchoolPerPerfSub = this._hds.getSchoolPerPerfecture(1).subscribe(data => {
this.SchoolsPerPerf$.next(data);
},
error => {
......
......@@ -90,6 +90,9 @@ export default class SchoolHome implements OnInit, OnDestroy {
}
else if (this.authRole === 'pde')
this.router.navigate(['/school/perfecture-view']);
else if (this.authRole === 'dide')
this.router.navigate(['/school/eduadmin-view']);
}
return loginInfoToken;
}, {});
......
......@@ -26,6 +26,7 @@ import AfterSubmit from '../components/student-application-form/after.submit';
import DirectorView from '../components/director/director-view';
import DirectorButtons from '../components/director/director.buttons';
import PerfectureView from '../components/infoviews/perfecture-view';
import EduadminView from '../components/infoviews/eduadmin-view';
import DirectorClassCapacity from '../components/director/director-classcapacity';
import MinisterView from '../components/minister/minister-view';
import MinisterReports from '../components/minister/minister-reports';
......@@ -37,6 +38,8 @@ import MinisterSettings from '../components/minister/minister-settings';
import SchoolAuthGuard from '../guards/school.auth.guard';
import StudentAuthGuard from '../guards/student.auth.guard';
import RegionEduAuthGuard from '../guards/regionedu.auth.guard';
import EduAdminAuthGuard from '../guards/eduadmin.auth.guard';
import MinistryAuthGuard from '../guards/ministry.auth.guard';
import Breadcrumbs from '../components/main/breadcrumbs';
......@@ -74,6 +77,7 @@ export const MainRoutes: Routes = [
{ path: 'ministry/minister-informstudents', component: InformStudents, canActivate: [MinistryAuthGuard] },
{ path: 'ministry/minister-settings', component: MinisterSettings, canActivate: [MinistryAuthGuard] },
{ path: 'school/perfecture-view', component: PerfectureView, canActivate: [RegionEduAuthGuard] },
{ path: 'school/eduadmin-view', component: EduadminView, canActivate: [EduAdminAuthGuard] },
];
export const MainDeclarations = [
......@@ -108,5 +112,6 @@ export const MainDeclarations = [
MinisterSettings,
PerfectureView,
Breadcrumbs,
DirectorButtons
DirectorButtons,
EduadminView,
];
......@@ -663,7 +663,7 @@ export class HelperDataService implements OnInit, OnDestroy {
}
getSchoolPerPerfecture() {
getSchoolPerPerfecture(status) {
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
......@@ -674,7 +674,7 @@ export class HelperDataService implements OnInit, OnDestroy {
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/ScoolperPerf/` , options)
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/ScoolperPerf/` + status , options)
.map(response => response.json());
}
......
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