Merge branch 'develop' into 'master'

Merge to master

See merge request !257
parents e897d6f4 7ea9ab97
......@@ -170,22 +170,21 @@ class DirectorView extends ControllerBase
);
}
}
return $this->respondWithStatus(
$list, Response::HTTP_OK);
return $this->respondWithStatus($list, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t('Students not found!'),
], Response::HTTP_FORBIDDEN);
return $this->respondWithStatus([
'message' => t('Students not found!'),
], Response::HTTP_NOT_FOUND);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found!'),
'message' => t('User not found!'),
], Response::HTTP_FORBIDDEN);
}
} catch (\Exception $e) {
$this->logger->warning($e->getMessage());
return $this->respondWithStatus([
'message' => t('Unexpected Error'),
'message' => t('Unexpected Error'),
], Response::HTTP_FORBIDDEN);
}
}
......
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
* Contains \Drupal\query_example\Controller\QueryExampleController
*/
namespace Drupal\epal\Controller;
......@@ -20,8 +20,6 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\TypedData\Plugin\DataType\TimeStamp;
use Drupal\Core\Language\LanguageManagerInterface;
class HelpDesk extends ControllerBase {
protected $entity_query;
......@@ -35,12 +33,11 @@ class HelpDesk extends ControllerBase {
Connection $connection,
LoggerChannelFactoryInterface $loggerChannel
) {
$this->entityTypeManager = $entityTypeManager;
$this->entity_query = $entity_query;
$connection = Database::getConnection();
$this->connection = $connection;
$this->logger = $loggerChannel->get('epal');
$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)
......@@ -53,44 +50,36 @@ class HelpDesk extends ControllerBase {
);
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
return $res;
}
public function sendEmail(Request $request)
public function sendEmail(Request $request)
{
if (!$request->isMethod('POST')) {
return $this->respondWithStatus([
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
"message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED);
}
$postData = null;
if ($content = $request->getContent()) {
$postData = json_decode($content);
$this->sendEmailToHelpDesk($postData->userEmail, $postData->userName, $postData->userMessage,$postData->userSurname);
return $this->respondWithStatus([
'error_code' => 0,
], Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("post with no data"),
], Response::HTTP_BAD_REQUEST);
}
$postData = null;
if ($content = $request->getContent()) {
$postData = json_decode($content);
$this->sendEmailToHelpDesk($postData->userEmail, $postData->userName, $postData->userMessage,$postData->userSurname);
return $this->respondWithStatus([
'error_code' => 0,
], Response::HTTP_OK);
}
else {
return $this->respondWithStatus([
'message' => t("post with no data"),
], Response::HTTP_BAD_REQUEST);
}
}
private function sendEmailToHelpDesk($email, $name, $cont_message, $surname) {
$mailManager = \Drupal::service('plugin.manager.mail');
......@@ -113,50 +102,26 @@ class HelpDesk extends ControllerBase {
return;
}
public function findTotalStudents(Request $request)
public function findTotalStudents(Request $request)
{
$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);
}
$list = array();
$sCon = $this->connection
->select('epal_student', 'eStudent')
->fields('eStudent', array('id'));
$numApplications = $sCon->countQuery()->execute()->fetchField();
array_push($list, (object) array('name' => "Αριθμός Αιτήσεων (συνολικά)", 'numStudents' => $numApplications));
$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 === "applicant") {
$validRole = true;
break;
}
}
if (!$validRole) {
return $this->respondWithStatus([
'message' => t("User Invalid Role"),
], Response::HTTP_FORBIDDEN);
}
$list = array();
$sCon = $this->connection
->select('epal_student', 'eStudent')
->fields('eStudent', array('id'));
$numApplications = $sCon->countQuery()->execute()->fetchField();
array_push($list, (object) array('name' => "Αριθμός Αιτήσεων (συνολικά)", 'numStudents' => $numApplications));
return $this->respondWithStatus($list, Response::HTTP_OK);
return $this->respondWithStatus($list, Response::HTTP_OK);
}
}
This diff is collapsed.
......@@ -12,54 +12,51 @@
"typings": "rimraf typings/ && typings install"
},
"devDependencies": {
"@types/d3": "^4.8.0",
"@types/node": "^6.0.48",
"@types/redux-logger": "^3.0.0",
"@types/systemjs": "^0.20.2",
"angular2-router-loader": "^0.3.4",
"angular2-template-loader": "^0.6.0",
"babel-core": "^6.20.0",
"babel-loader": "^6.2.9",
"babel-preset-env": "^1.1.4",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-1": "^6.16.0",
"babili-webpack-plugin": "^0.1.1",
"bootstrap-loader": "^2.0.0-beta.20",
"css-loader": "^0.25.0",
"node-sass": "^4.5.0",
"redux-logger": "^2.7.4",
"resolve-url-loader": "^1.6.1",
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5",
"tslint": "^3.15.1",
"tslint-loader": "^2.1.5",
"typescript": "^2.0.10",
"url-loader": "^0.5.7",
"webpack": "^1.14.0",
"webpack-cleanup-plugin": "^0.5.1",
"webpack-closure-compiler": "^2.1.4",
"webpack-dashboard": "^0.2.0",
"webpack-dev-server": "^1.16.2"
},
"dependencies": {
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/core": "^2.0.0",
"@angular/forms": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"@angular/platform-browser-dynamic": "^2.0.0",
"@angular/router": "^3.2.0",
"@angular-redux/store": "^6.5.7",
"@angular/animations": "^4.3.1",
"@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.1",
"@angular/compiler-cli": "^4.3.1",
"@angular/core": "^4.3.1",
"@angular/forms": "^4.3.1",
"@angular/http": "^4.3.1",
"@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.1",
"@angular/platform-server": "^4.3.1",
"@angular/router": "^4.3.1",
"@ngui/auto-complete": "^0.13.3",
"@types/d3": "^4.10.0",
"@types/file-saver": "0.0.1",
"@types/jquery": "^2.0.41",
"@types/node": "^6.0.60",
"@types/jquery": "^2.0.48",
"@types/node": "^6.0.85",
"@types/node-sass": "^3.10.32",
"babel-polyfill": "^6.20.0",
"babel-core": "^6.25.0",
"babel-loader": "^6.4.1",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"bootstrap": "^4.0.0-alpha.6",
"core-js": "^2.4.1",
"css-loader": "^0.25.0",
"d3": "^4.4.0",
"d3": "^4.10.0",
"es6-promise": "^4.0.5",
"es6-shim": "^0.35.0",
"file-loader": "^0.9.0",
......@@ -68,22 +65,25 @@
"fs-writefile-promise": "^2.0.0",
"html-webpack-plugin": "^2.24.1",
"immutable": "^3.8.1",
"jquery": "^3.1.1",
"mydatepicker": "^2.0.13",
"ng2-redux": "^5.1.0",
"ng2-smart-table": "^0.4.0-5",
"jquery": "^3.2.1",
"mydatepicker": "^2.0.26",
"ng2-smart-table": "^1.2.1",
"ngx-cookie": "^1.0.0",
"ngx-uploader": "^2.2.5",
"raw-loader": "^0.5.1",
"redux": "^3.6.0",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"reflect-metadata": "0.1.8",
"rimraf": "^2.4.3",
"roboto-fontface": "^0.7.0",
"roboto-fontface": "^0.7.1",
"rxjs": "^5.0.0-rc.3",
"style-loader": "^0.13.1",
"ts-loader": "^1.2.1",
"typed-immutable-record": "0.0.6",
"typescript": "^2.4.2",
"url-loader": "^0.5.7",
"webpack": "^1.13.3",
"zone.js": ">=0.6.26"
"webpack-closure-compiler": "^2.1.5",
"zone.js": "^0.8.14"
}
}
import { COURSEFIELDS_RECEIVED, COURSEFIELDS_SELECTED_SAVE } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
import { HelperDataService } from '../services/helper-data-service';
@Injectable()
export class CourseFieldsActions {
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {}
getCourseFields = () => {
const { courseFields } = this._ngRedux.getState();
if (courseFields.size === 0) {
return this._hds.getCourseFields().then(courseFields => {
return this._ngRedux.dispatch({
type: COURSEFIELDS_RECEIVED,
payload: {
courseFields
}
});
});
}
};
saveCourseFieldsSelected = (courseFieldsSelected) => {
return this._ngRedux.dispatch({
type: COURSEFIELDS_SELECTED_SAVE,
payload: {
courseFieldsSelected
}
});
};
}
import { CRITERIA_RECEIVED, CRITERIA_SAVE, CRITERIA_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
import { HelperDataService } from '../services/helper-data-service';
@Injectable()
export class CriteriaActions {
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {}
getCriteria = (reload) => {
const { criter } = this._ngRedux.getState();
//if (sectorFields.size === 0) {
if (reload === true || (reload === false && criter.size === 0)) {
return this._hds.getCriteria().then(criteria => {
return this._ngRedux.dispatch({
type: CRITERIA_RECEIVED,
payload: {
criteria
}
});
});
}
};
saveCriteria = (criter) => {
return this._ngRedux.dispatch({
type: CRITERIA_SAVE,
payload: {
criter
}
});
};
initCriteria = () => {
return this._ngRedux.dispatch({
type: CRITERIA_INIT,
payload: {
}
});
};
}
import { EPALCLASSES_SAVE } from '../constants';
import { EPALCLASSES_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
import { NgRedux } from "@angular-redux/store";
import { Injectable } from "@angular/core";
import { EPALCLASSES_SAVE } from "../constants";
import { EPALCLASSES_INIT } from "../constants";
import { IAppState } from "../store";
@Injectable()
export class EpalClassesActions {
constructor(
private _ngRedux: NgRedux<IAppState>) {}
constructor(
private _ngRedux: NgRedux<IAppState>) { }
saveEpalClassesSelected = (epalClasses) => {
return this._ngRedux.dispatch({
type: EPALCLASSES_SAVE,
payload: {
epalClasses
}
});
};
saveEpalClassesSelected = (epalClasses) => {
return this._ngRedux.dispatch({
type: EPALCLASSES_SAVE,
payload: {
epalClasses
}
});
};
initEpalClasses = () => {
return this._ngRedux.dispatch({
type: EPALCLASSES_INIT,
payload: {
}
});
};
initEpalClasses = () => {
return this._ngRedux.dispatch({
type: EPALCLASSES_INIT,
payload: {
}
});
};
}
import { CourseFieldsActions } from './coursefields.actions';
import { SectorFieldsActions } from './sectorfields.actions';
import { RegionSchoolsActions } from './regionschools.actions';
import { SectorCoursesActions } from './sectorcourses.actions';
import { StudentDataFieldsActions } from './studentdatafields.actions';
import { EpalClassesActions } from './epalclass.actions';
import { LoginInfoActions} from './logininfo.actions';
import { CriteriaActions} from './criteria.actions';
import { SectorFieldsActions } from "./sectorfields.actions";
import { RegionSchoolsActions } from "./regionschools.actions";
import { SectorCoursesActions } from "./sectorcourses.actions";
import { StudentDataFieldsActions } from "./studentdatafields.actions";
import { EpalClassesActions } from "./epalclass.actions";
import { LoginInfoActions } from "./logininfo.actions";
const ACTION_PROVIDERS = [ CourseFieldsActions, SectorFieldsActions, RegionSchoolsActions, SectorCoursesActions, StudentDataFieldsActions,
EpalClassesActions, LoginInfoActions, CriteriaActions];
const ACTION_PROVIDERS = [
SectorFieldsActions,
RegionSchoolsActions,
SectorCoursesActions,
StudentDataFieldsActions,
EpalClassesActions,
LoginInfoActions
];
export {
CourseFieldsActions,
SectorFieldsActions,
RegionSchoolsActions,
SectorCoursesActions,
StudentDataFieldsActions,
EpalClassesActions,
LoginInfoActions,
CriteriaActions,
ACTION_PROVIDERS,
SectorFieldsActions,
RegionSchoolsActions,
SectorCoursesActions,
StudentDataFieldsActions,
EpalClassesActions,
LoginInfoActions,
ACTION_PROVIDERS,
};
import { LOGININFO_SAVE, PROFILE_SAVE, LOGININFO_RECEIVED, STATEMENTAGREE_SAVE } from '../constants';
import { LOGININFO_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
import { HelperDataService } from '../services/helper-data-service';
import { NgRedux } from "@angular-redux/store";
import { Injectable } from "@angular/core";
import { LOGININFO_SAVE, PROFILE_SAVE, STATEMENTAGREE_SAVE } from "../constants";
import { LOGININFO_INIT } from "../constants";
import { HelperDataService } from "../services/helper-data-service";
import { IAppState } from "../store";
@Injectable()
export class LoginInfoActions {
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {}
getloginInfo = (loginInfo) => {
return this._hds.getCurrentUser(loginInfo.auth_token, loginInfo.auth_role).then (loginInfos => {
return this._ngRedux.dispatch({
type: LOGININFO_SAVE,
payload: {
loginInfos
}
});
});
}
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) { }
saveMinEduloginInfo = (loginInfos) => {
return this._ngRedux.dispatch({
type: LOGININFO_SAVE,
payload: {
loginInfos
getloginInfo = (loginInfo) => {
return this._hds.getCurrentUser(loginInfo.auth_token, loginInfo.auth_role).then(loginInfos => {
return this._ngRedux.dispatch({
type: LOGININFO_SAVE,
payload: {
loginInfos
}
});
});
}
});
};
saveProfile = (profile) => {
return this._ngRedux.dispatch({
type: PROFILE_SAVE,
payload: {
profile
}
});
};
saveStatementAgree = (disclaimer_checked) => {
return this._ngRedux.dispatch({
type: STATEMENTAGREE_SAVE,
payload: {
disclaimer_checked
}
});
};
initLoginInfo = () => {
return this._ngRedux.dispatch({
type: LOGININFO_INIT,
payload: {
}
});
};
saveMinEduloginInfo = (loginInfos) => {
return this._ngRedux.dispatch({
type: LOGININFO_SAVE,
payload: {
loginInfos
}
});
};
saveProfile = (profile) => {
return this._ngRedux.dispatch({
type: PROFILE_SAVE,
payload: {
profile
}
});
};
saveStatementAgree = (disclaimer_checked) => {
return this._ngRedux.dispatch({
type: STATEMENTAGREE_SAVE,
payload: {
disclaimer_checked
}
});
};
initLoginInfo = () => {
return this._ngRedux.dispatch({
type: LOGININFO_INIT,
payload: {
}
});
};
}
import { REGIONSCHOOLS_RECEIVED, REGIONSCHOOLS_SELECTED_SAVE, REGIONSCHOOLS_ORDER_SAVE, REGIONSCHOOLS_INIT } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
import { HelperDataService } from '../services/helper-data-service';
import { NgRedux } from "@angular-redux/store";
import { Injectable } from "@angular/core";
import {
REGIONSCHOOLS_INIT,
REGIONSCHOOLS_ORDER_SAVE,
REGIONSCHOOLS_RECEIVED,
REGIONSCHOOLS_SELECTED_SAVE,
} from "../constants";
import { HelperDataService } from "../services/helper-data-service";
import { IAppState } from "../store";
@Injectable()
export class RegionSchoolsActions {
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {}
constructor(
private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) { }
getRegionSchools = (classActive,courseActive, reload) => {
const { regions } = this._ngRedux.getState();
if (reload === true || (reload === false && regions.size === 0)) {
return this._hds.getRegionsWithSchools(classActive,courseActive).then(regions => {
return this._ngRedux.dispatch({
type: REGIONSCHOOLS_RECEIVED,
payload: {
regions
}
getRegionSchools = (classActive, courseActive, reload) => {
const { regions } = this._ngRedux.getState();
if (reload === true || (reload === false && regions.size === 0)) {
return this._hds.getRegionsWithSchools(classActive, courseActive).then(regions => {
return this._ngRedux.dispatch({
type: REGIONSCHOOLS_RECEIVED,
payload: {