merrged updates

parents 8154ea6f 64f0a4b0
...@@ -182,6 +182,22 @@ epal.ministry.massive_mail: ...@@ -182,6 +182,22 @@ epal.ministry.massive_mail:
_controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToStudents' _controller: '\Drupal\epal\Controller\InformUnlocatedStudents::sendMailToStudents'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.ministry.retrievesettings:
path: '/ministry/retrieve-settings'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\MinisterSettings::retrieveSettings'
requirements:
_user_is_logged_in: 'TRUE'
epal.ministry.storesettings:
path: '/ministry/store-settings/{capacityDisabled}/{directorViewDisabled}/{applicantsLoginDisabled}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\MinisterSettings::storeSettings'
requirements:
_user_is_logged_in: 'TRUE'
regionview: regionview:
path: '/epal/ScoolperPerf/{perfectureId}' path: '/epal/ScoolperPerf/{perfectureId}'
options: options:
......
...@@ -102,6 +102,29 @@ class Distribution extends ControllerBase { ...@@ -102,6 +102,29 @@ class Distribution extends ControllerBase {
], Response::HTTP_FORBIDDEN); ], Response::HTTP_FORBIDDEN);
} }
//check where distribution can be done now ($capacityDisabled / $directorViewDisabled settings)
$capacityDisabled = false;
$directorViewDisabled = false;
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('id' => 1));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("EpalConfig Enity not found"),
], Response::HTTP_FORBIDDEN);
}
else {
$capacityDisabled = $epalConfig->lock_school_capacity->getString();
$directorViewDisabled = $epalConfig->lock_school_students_view->getString();
}
if ($capacityDisabled === "0" or $directorViewDisabled === "0") {
return $this->respondWithStatus([
'message' => t("capacityDisabled and / or directorViewDisabled settings are false"),
], Response::HTTP_FORBIDDEN);
}
$transaction = $this->connection->startTransaction(); $transaction = $this->connection->startTransaction();
......
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace Drupal\epal\Controller;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
class MinisterSettings extends ControllerBase {
protected $entity_query;
protected $entityTypeManager;
protected $logger;
protected $connection;
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
QueryFactory $entity_query,
Connection $connection,
LoggerChannelFactoryInterface $loggerChannel)
{
$this->entityTypeManager = $entityTypeManager;
$this->entity_query = $entity_query;
$connection = Database::getConnection();
$this->connection = $connection;
$this->logger = $loggerChannel->get('epal');
}
public static function create(ContainerInterface $container)
{
return new static(
$container->get('entity_type.manager'),
$container->get('entity.query'),
$container->get('database'),
$container->get('logger.factory')
);
}
public function retrieveSettings(Request $request) {
try {
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
//user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//user role validation
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role)
if ($role === "ministry") {
$validRole = true;
break;
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
//minister settings retrieve
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('id' => 1));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("EpalConfig Enity not found"),
], Response::HTTP_FORBIDDEN);
}
else {
$capacityDisabled = $epalConfig->lock_school_capacity->getString();
$directorViewDisabled = $epalConfig->lock_school_students_view->getString();
$applicantsLoginDisabled = $epalConfig->lock_application->getString();
}
$config_storage->resetCache();
return $this->respondWithStatus([
//'message' => t("post successful"),
'capacityDisabled' => $capacityDisabled,
'directorViewDisabled' => $directorViewDisabled,
'applicantsLoginDisabled' => $applicantsLoginDisabled,
], Response::HTTP_OK);
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during retrieveSettings Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
public function storeSettings(Request $request, $capacityDisabled, $directorViewDisabled, $applicantsLoginDisabled ) {
try {
if (!$request->isMethod('GET')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
//user validation
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if (!$user) {
return $this->respondWithStatus([
'message' => t("User not found"),
], Response::HTTP_FORBIDDEN);
}
//user role validation
$roles = $user->getRoles();
$validRole = false;
foreach ($roles as $role)
if ($role === "ministry") {
$validRole = true;
break;
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
$config_storage = $this->entityTypeManager->getStorage('epal_config');
$epalConfigs = $config_storage->loadByProperties(array('id' => 1));
$epalConfig = reset($epalConfigs);
if (!$epalConfig) {
return $this->respondWithStatus([
'message' => t("EpalConfig Enity not found"),
], Response::HTTP_FORBIDDEN);
}
else {
$epalConfig->set('lock_school_capacity', $capacityDisabled);
$epalConfig->set('lock_school_students_view', $directorViewDisabled);
$epalConfig->set('lock_application', $applicantsLoginDisabled);
$epalConfig->save();
}
$config_storage->resetCache();
return $this->respondWithStatus([
//'message' => t("post successful"),
'capacityDisabled' => $capacityDisabled,
'directorViewDisabled' => $directorViewDisabled,
'applicantsLoginDisabled' => $applicantsLoginDisabled,
], Response::HTTP_OK);
} //end try
catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
"message" => t("An unexpected problem occured during storeSettings Method ")
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
return $res;
}
}
...@@ -514,7 +514,7 @@ class ReportsCreator extends ControllerBase { ...@@ -514,7 +514,7 @@ class ReportsCreator extends ControllerBase {
array_push($numClasses, $numClassCour); array_push($numClasses, $numClassCour);
array_push($numClasses, $numClassCour_D); array_push($numClasses, $numClassCour_D);
if ($sectorId === "0" && $courseId === 0) { if ($sectorId === "0" && $courseId === "0") {
$clidstart = 1; $clidstart = 1;
$clidend = 4; $clidend = 4;
......
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
<option value="1" >Α' Λυκείου</option> <option value="1" >Α' Λυκείου</option>
<option value="2" >Β' Λυκείου</option> <option value="2" >Β' Λυκείου</option>
<option value="3" >Γ' Λυκείου</option> <option value="3" >Γ' Λυκείου</option>
<option value="4" >Δ' Λυκείου</option> <option *ngIf="(selectiontype | async)" value="4" >Δ' Λυκείου</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
...@@ -121,6 +121,7 @@ import { ...@@ -121,6 +121,7 @@ import {
<br> <br>
<br> <br>
<div *ngIf="(retrievedStudent | async)">
<div class="form-group" class="row"> <div class="form-group" class="row">
Βρίσκεστε στη σελίδα: Βρίσκεστε στη σελίδα:
<div class="col-1"> <div class="col-1">
...@@ -144,6 +145,7 @@ import { ...@@ -144,6 +145,7 @@ import {
</ul> </ul>
</nav> </nav>
</div>
</form> </form>
</div> </div>
...@@ -169,6 +171,7 @@ import { ...@@ -169,6 +171,7 @@ import {
private SubmitedDetailsSub: Subscription; private SubmitedDetailsSub: Subscription;
private retrievedStudent: BehaviorSubject<boolean>; private retrievedStudent: BehaviorSubject<boolean>;
private selectionBClass: BehaviorSubject<boolean>; private selectionBClass: BehaviorSubject<boolean>;
private selectiontype: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>; private selectionCClass: BehaviorSubject<boolean>;
private SchoolId ; private SchoolId ;
private currentclass: Number; private currentclass: Number;
...@@ -196,6 +199,7 @@ import { ...@@ -196,6 +199,7 @@ import {
this.selectionBClass = new BehaviorSubject(false); this.selectionBClass = new BehaviorSubject(false);
this.selectionCClass = new BehaviorSubject(false); this.selectionCClass = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]); this.School$ = new BehaviorSubject([{}]);
this.selectiontype = new BehaviorSubject(true);
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
...@@ -226,11 +230,14 @@ import { ...@@ -226,11 +230,14 @@ import {
ngOnInit() { ngOnInit() {
this.SchoolSub = this._hds.getSchoolId().subscribe(x => {
this.SchoolSub = this._hds.gettypeofschool().subscribe(x => {
this.School$.next(x); this.School$.next(x);
console.log(x[0].id, "schoolid!"); console.log(x[0].type, "schoolid!");
this.SchoolId = x[0].id; this.SchoolId = x[0].type;
if (this.SchoolId == 'ΗΜΕΡΗΣΙΟ'){
this.selectiontype.next(false);
}
}, },
error => { error => {
...@@ -238,6 +245,7 @@ import { ...@@ -238,6 +245,7 @@ import {
console.log("Error Getting School"); console.log("Error Getting School");
}, },
() => console.log("Getting School ")); () => console.log("Getting School "));
} }
...@@ -315,7 +323,7 @@ import { ...@@ -315,7 +323,7 @@ import {
findstudent(txop, pageno) { findstudent(txop, pageno) {
var tot_pages: Number; var tot_pages: number;
var sectorint = +this.formGroup.value.tomeas; var sectorint = +this.formGroup.value.tomeas;
if (txop.value === "1") { if (txop.value === "1") {
this.currentclass = 1; this.currentclass = 1;
...@@ -339,6 +347,11 @@ import { ...@@ -339,6 +347,11 @@ import {
if (x.id % 5 > 0) { if (x.id % 5 > 0) {
tot_pages = (x.id - (x.id % 5)) / 5 + 1; tot_pages = (x.id - (x.id % 5)) / 5 + 1;
} }
console.log(tot_pages,"totpages")
if (isNaN(tot_pages)){
this.retrievedStudent.next(false);
tot_pages = 0;
}
this.formGroup.get('maxpage').setValue(tot_pages); this.formGroup.get('maxpage').setValue(tot_pages);
}); });
...@@ -346,7 +359,15 @@ import { ...@@ -346,7 +359,15 @@ import {
this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => { this.StudentInfoSub = this._hds.getStudentPerSchool(sectorint, this.currentclass, this.limitdown, this.limitup).subscribe(data => {
this.StudentInfo$.next(data); this.StudentInfo$.next(data);
this.retrievedStudent.next(true); if (tot_pages === 0){
console.log("tot.pages", this.formGroup.value.maxpage);
this.retrievedStudent.next(false);
}
else
{
console.log("tot.pages", this.formGroup.value.maxpage, "max", tot_pages);
this.retrievedStudent.next(true);
}
}, },
error => { error => {
this.StudentInfo$.next([{}]); this.StudentInfo$.next([{}]);
...@@ -379,8 +400,8 @@ import { ...@@ -379,8 +400,8 @@ import {
confirmStudent(txop) { confirmStudent(txop) {
this._hds.saveConfirmStudents(this.saved, this.type); this._hds.saveConfirmStudents(this.saved, this.type);
this.findstudent(txop, this.pageno) this.findstudent(txop, this.pageno);
console.log(txop, this.pageno, "aaaaaaa");
} }
checkcclass() { checkcclass() {
......
...@@ -39,6 +39,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -39,6 +39,7 @@ import { API_ENDPOINT } from '../../app.settings';
</div> </div>
</div> </div>
<h5> >Αποστολή ειδοποιήσεων <br></h5>
<br><br> <br><br>
<div class="col-md-12"> <div class="col-md-12">
<button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents()" > <button type="submit" class="btn btn-lg btn-block" *ngIf="(loginInfo$ | async).size !== 0" (click)="informUnlocatedStudents()" >
......
...@@ -29,7 +29,7 @@ import { API_ENDPOINT } from '../../app.settings'; ...@@ -29,7 +29,7 @@ import { API_ENDPOINT } from '../../app.settings';
<div> <div>
<h5><br> >Επιλογή Αναφοράς<br><br></h5> <h5> >Επιλογή Αναφοράς<br><br></h5>
<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'" > <button type="button" class="btn btn-alert" (click)="nav_to_reportpath(1)" [hidden]="minedu_userName == '' || userRole == 'pde' || userRole == 'dide'" >
......
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,
Validators,
} from '@angular/forms';
@Component({
selector: 'minister-settings',
template: `
<div
class = "loading" *ngIf="dataRetrieved == -1 " >
</div>
<div id="configNotice" (onHidden)="onHidden()" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<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">Κλείσιμο</button>
</div>
</div>
</div>
</div>
<div *ngIf="(loginInfo$ | async).size !== 0">
<form [formGroup]="formGroup" #form>
<h5> >Ρυθμίσεις <br><br></h5>
<div class="row">
<div class="col-md-1 ">
<input type="checkbox" [checked]="capacityDisabled" formControlName="capacityDisabled"
(click)="toggleCapacityFilter()" >
</div>
<div class="col-md-9">
<label for="capacityDisabled">Απενεργοποίηση δυνατότητας τροποποίησης χωρητικότητας από τους Διευθυντές σχολείων</label>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1 ">
<input type="checkbox" [checked]="directorViewDisabled" formControlName="directorViewDisabled"
(click)="toggleDirectorView()" >
</div>
<div class="col-md-9">
<label for="directorViewDisabled">Απενεργοποίηση δυνατότητας προβολής κατανομής μαθητών από τους Διευθυντές σχολείων</label>
</div>
</div>
<br>
<div class="row">
<div class="col-md-1 ">
<input type="checkbox" [checked]="applicantsLoginDisabled" formControlName="applicantsLoginDisabled"
(click)="toggleApplicantsLogin()" >
</div>
<div class="col-md-9">
<label for="applicantsLoginDisabled">Απενεργοποίηση δυνατότητας αίτησης μαθητών</label>
</div>
</div>
<br>
<button type="submit" class="btn btn-md pull-right" (click)="storeSettings()" >
Εφαρμογή
</button>
</form>
</div>
`
})
@Injectable() export default class MinisterSettings implements OnInit, OnDestroy {
public formGroup: FormGroup;
loginInfo$: BehaviorSubject<ILoginInfo>;
private modalTitle: BehaviorSubject<string>;
private modalText: BehaviorSubject<string>;
private modalHeader: BehaviorSubject<string>;
private settings$: BehaviorSubject<any>;
loginInfoSub: Subscription;
private settingsSub: Subscription;
//private data;
private capacityDisabled: boolean;
private directorViewDisabled: boolean;
private applicantsLoginDisabled: boolean;
private dataRetrieved: number;
private minedu_userName: string;
private minedu_userPassword: string;
constructor(private fb: FormBuilder,
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService,
private router: Router) {
this.formGroup = this.fb.group({
capacityDisabled: ['', []],
directorViewDisabled: ['', []],
applicantsLoginDisabled: ['', []],
});
this.loginInfo$ = new BehaviorSubject(LOGININFO_INITIAL_STATE);
this.settings$ = new BehaviorSubject([{}]);
this.modalTitle = new BehaviorSubject("");
this.modalText = new BehaviorSubject("");
this.modalHeader = new BehaviorSubject("");
}
public showModal():void {
console.log("about to show modal");
(<any>$('#configNotice')).modal('show');
}
public hideModal():void {
(<any>$('#configNotice')).modal('hide');
}
public onHidden():void {
//this.isModalShown.next(false);
}
ngOnDestroy() {
(<any>$('#configNotice')).remove();
if (this.loginInfoSub)
this.loginInfoSub.unsubscribe();
if (this.settingsSub)
this.settingsSub.unsubscribe();
}
ngOnInit() {
(<any>$('#configNotice')).appendTo("body");
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$);
this.retrieveSettings();
}
retrieveSettings() {
this.dataRetrieved = -1;
this.settingsSub = this._hds.retrieveAdminSettings(this.minedu_userName, this.minedu_userPassword).subscribe(data => {
this.settings$.next(data);
//this.data = data;
},
error =>