Merge branch 'edge_v4' into 'develop'

Merge to develop

See merge request !255
parents 96f089d9 1cb2f0e4
<?php <?php
/** /**
* @file * @file
* Contains \Drupal\query_example\Controller\QueryExampleController. * Contains \Drupal\query_example\Controller\QueryExampleController
*/ */
namespace Drupal\epal\Controller; namespace Drupal\epal\Controller;
...@@ -20,8 +20,6 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface; ...@@ -20,8 +20,6 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\TypedData\Plugin\DataType\TimeStamp; use Drupal\Core\TypedData\Plugin\DataType\TimeStamp;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
class HelpDesk extends ControllerBase { class HelpDesk extends ControllerBase {
protected $entity_query; protected $entity_query;
...@@ -35,12 +33,11 @@ class HelpDesk extends ControllerBase { ...@@ -35,12 +33,11 @@ class HelpDesk extends ControllerBase {
Connection $connection, Connection $connection,
LoggerChannelFactoryInterface $loggerChannel LoggerChannelFactoryInterface $loggerChannel
) { ) {
$this->entityTypeManager = $entityTypeManager;
$this->entityTypeManager = $entityTypeManager; $this->entity_query = $entity_query;
$this->entity_query = $entity_query; $connection = Database::getConnection();
$connection = Database::getConnection(); $this->connection = $connection;
$this->connection = $connection; $this->logger = $loggerChannel->get('epal');
$this->logger = $loggerChannel->get('epal');
} }
public static function create(ContainerInterface $container) public static function create(ContainerInterface $container)
...@@ -53,44 +50,36 @@ class HelpDesk extends ControllerBase { ...@@ -53,44 +50,36 @@ class HelpDesk extends ControllerBase {
); );
} }
private function respondWithStatus($arr, $s) { private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr); $res = new JsonResponse($arr);
$res->setStatusCode($s); $res->setStatusCode($s);
return $res; return $res;
} }
public function sendEmail(Request $request)
public function sendEmail(Request $request)
{ {
if (!$request->isMethod('POST')) { if (!$request->isMethod('POST')) {
return $this->respondWithStatus([ return $this->respondWithStatus([
"message" => t("Method Not Allowed") "message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED); ], Response::HTTP_METHOD_NOT_ALLOWED);
} }
$postData = null; $postData = null;
if ($content = $request->getContent()) { if ($content = $request->getContent()) {
$postData = json_decode($content); $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);
}
$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) { private function sendEmailToHelpDesk($email, $name, $cont_message, $surname) {
$mailManager = \Drupal::service('plugin.manager.mail'); $mailManager = \Drupal::service('plugin.manager.mail');
...@@ -113,50 +102,26 @@ class HelpDesk extends ControllerBase { ...@@ -113,50 +102,26 @@ class HelpDesk extends ControllerBase {
return; 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'); return $this->respondWithStatus($list, Response::HTTP_OK);
$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);
} }
} }
This diff is collapsed.
...@@ -12,54 +12,51 @@ ...@@ -12,54 +12,51 @@
"typings": "rimraf typings/ && typings install" "typings": "rimraf typings/ && typings install"
}, },
"devDependencies": { "devDependencies": {
"@types/d3": "^4.8.0", "@types/redux-logger": "^3.0.0",
"@types/node": "^6.0.48",
"@types/systemjs": "^0.20.2", "@types/systemjs": "^0.20.2",
"angular2-router-loader": "^0.3.4", "angular2-router-loader": "^0.3.4",
"angular2-template-loader": "^0.6.0", "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", "babili-webpack-plugin": "^0.1.1",
"bootstrap-loader": "^2.0.0-beta.20", "bootstrap-loader": "^2.0.0-beta.20",
"css-loader": "^0.25.0",
"node-sass": "^4.5.0", "node-sass": "^4.5.0",
"redux-logger": "^2.7.4",
"resolve-url-loader": "^1.6.1", "resolve-url-loader": "^1.6.1",
"sass-loader": "^4.1.1", "sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5", "to-string-loader": "^1.1.5",
"tslint": "^3.15.1", "tslint": "^3.15.1",
"tslint-loader": "^2.1.5", "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-cleanup-plugin": "^0.5.1",
"webpack-closure-compiler": "^2.1.4",
"webpack-dashboard": "^0.2.0", "webpack-dashboard": "^0.2.0",
"webpack-dev-server": "^1.16.2" "webpack-dev-server": "^1.16.2"
}, },
"dependencies": { "dependencies": {
"@angular/common": "^2.0.0", "@angular-redux/store": "^6.5.7",
"@angular/compiler": "^2.0.0", "@angular/animations": "^4.3.1",
"@angular/core": "^2.0.0", "@angular/common": "^4.3.1",
"@angular/forms": "^2.0.0", "@angular/compiler": "^4.3.1",
"@angular/http": "^2.0.0", "@angular/compiler-cli": "^4.3.1",
"@angular/platform-browser": "^2.0.0", "@angular/core": "^4.3.1",
"@angular/platform-browser-dynamic": "^2.0.0", "@angular/forms": "^4.3.1",
"@angular/router": "^3.2.0", "@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", "@ngui/auto-complete": "^0.13.3",
"@types/d3": "^4.10.0",
"@types/file-saver": "0.0.1", "@types/file-saver": "0.0.1",
"@types/jquery": "^2.0.41", "@types/jquery": "^2.0.48",
"@types/node": "^6.0.60", "@types/node": "^6.0.85",
"@types/node-sass": "^3.10.32", "@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", "bootstrap": "^4.0.0-alpha.6",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"css-loader": "^0.25.0", "css-loader": "^0.25.0",
"d3": "^4.4.0", "d3": "^4.10.0",
"es6-promise": "^4.0.5", "es6-promise": "^4.0.5",
"es6-shim": "^0.35.0", "es6-shim": "^0.35.0",
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
...@@ -68,22 +65,25 @@ ...@@ -68,22 +65,25 @@
"fs-writefile-promise": "^2.0.0", "fs-writefile-promise": "^2.0.0",
"html-webpack-plugin": "^2.24.1", "html-webpack-plugin": "^2.24.1",
"immutable": "^3.8.1", "immutable": "^3.8.1",
"jquery": "^3.1.1", "jquery": "^3.2.1",
"mydatepicker": "^2.0.13", "mydatepicker": "^2.0.26",
"ng2-redux": "^5.1.0", "ng2-smart-table": "^1.2.1",
"ng2-smart-table": "^0.4.0-5",
"ngx-cookie": "^1.0.0", "ngx-cookie": "^1.0.0",
"ngx-uploader": "^2.2.5", "ngx-uploader": "^2.2.5",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"redux": "^3.6.0", "redux": "^3.7.2",
"redux-logger": "^3.0.6",
"reflect-metadata": "0.1.8", "reflect-metadata": "0.1.8",
"rimraf": "^2.4.3", "rimraf": "^2.4.3",
"roboto-fontface": "^0.7.0", "roboto-fontface": "^0.7.1",
"rxjs": "^5.0.0-rc.3", "rxjs": "^5.0.0-rc.3",
"style-loader": "^0.13.1", "style-loader": "^0.13.1",
"ts-loader": "^1.2.1", "ts-loader": "^1.2.1",
"typed-immutable-record": "0.0.6",
"typescript": "^2.4.2",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^1.13.3", "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 { NgRedux } from "@angular-redux/store";
import { EPALCLASSES_INIT } from '../constants'; import { Injectable } from "@angular/core";
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
import { EPALCLASSES_SAVE } from "../constants";
import { EPALCLASSES_INIT } from "../constants";
import { IAppState } from "../store";
@Injectable() @Injectable()
export class EpalClassesActions { export class EpalClassesActions {
constructor( constructor(
private _ngRedux: NgRedux<IAppState>) {} private _ngRedux: NgRedux<IAppState>) { }
saveEpalClassesSelected = (epalClasses) => {
return this._ngRedux.dispatch({
type: EPALCLASSES_SAVE,
payload: {
epalClasses
}
});
};
saveEpalClassesSelected = (epalClasses) => { initEpalClasses = () => {
return this._ngRedux.dispatch({ return this._ngRedux.dispatch({
type: EPALCLASSES_SAVE, type: EPALCLASSES_INIT,
payload: { payload: {
epalClasses }
} });
}); };
};
initEpalClasses = () => {
return this._ngRedux.dispatch({
type: EPALCLASSES_INIT,
payload: {
}
});
};
} }
import { CourseFieldsActions } from './coursefields.actions'; import { SectorFieldsActions } from "./sectorfields.actions";
import { SectorFieldsActions } from './sectorfields.actions'; import { RegionSchoolsActions } from "./regionschools.actions";
import { RegionSchoolsActions } from './regionschools.actions'; import { SectorCoursesActions } from "./sectorcourses.actions";
import { SectorCoursesActions } from './sectorcourses.actions'; import { StudentDataFieldsActions } from "./studentdatafields.actions";
import { StudentDataFieldsActions } from './studentdatafields.actions'; import { EpalClassesActions } from "./epalclass.actions";
import { EpalClassesActions } from './epalclass.actions'; import { LoginInfoActions } from "./logininfo.actions";
import { LoginInfoActions} from './logininfo.actions';
import { CriteriaActions} from './criteria.actions';
const ACTION_PROVIDERS = [ CourseFieldsActions, SectorFieldsActions, RegionSchoolsActions, SectorCoursesActions, StudentDataFieldsActions, const ACTION_PROVIDERS = [
EpalClassesActions, LoginInfoActions, CriteriaActions]; SectorFieldsActions,
RegionSchoolsActions,
SectorCoursesActions,
StudentDataFieldsActions,
EpalClassesActions,
LoginInfoActions
];
export { export {
CourseFieldsActions, SectorFieldsActions,
SectorFieldsActions, RegionSchoolsActions,
RegionSchoolsActions, SectorCoursesActions,
SectorCoursesActions, StudentDataFieldsActions,
StudentDataFieldsActions, EpalClassesActions,
EpalClassesActions, LoginInfoActions,
LoginInfoActions, ACTION_PROVIDERS,
CriteriaActions,
ACTION_PROVIDERS,
}; };
import { LOGININFO_SAVE, PROFILE_SAVE, LOGININFO_RECEIVED, STATEMENTAGREE_SAVE } from '../constants'; import { NgRedux } from "@angular-redux/store";
import { LOGININFO_INIT } from '../constants'; import { Injectable } from "@angular/core";
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux'; import { LOGININFO_SAVE, PROFILE_SAVE, STATEMENTAGREE_SAVE } from "../constants";
import { IAppState } from '../store'; import { LOGININFO_INIT } from "../constants";
import { HelperDataService } from '../services/helper-data-service'; import { HelperDataService } from "../services/helper-data-service";
import { IAppState } from "../store";
@Injectable() @Injectable()
export class LoginInfoActions { export class LoginInfoActions {
constructor( constructor(
private _ngRedux: NgRedux<IAppState>, private _ngRedux: NgRedux<IAppState>,
private _hds: HelperDataService) {} 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
}
});
});
}
saveMinEduloginInfo = (loginInfos) => {
return this._ngRedux.dispatch({ getloginInfo = (loginInfo) => {
type: LOGININFO_SAVE, return this._hds.getCurrentUser(loginInfo.auth_token, loginInfo.auth_role).then(loginInfos => {
payload: { return this._ngRedux.dispatch({
loginInfos type: LOGININFO_SAVE,
payload: {
loginInfos
}
});
});
} }
});
}; saveMinEduloginInfo = (loginInfos) => {
return this._ngRedux.dispatch({
saveProfile = (profile) => { type: LOGININFO_SAVE,
return this._ngRedux.dispatch({ payload: {
type: PROFILE_SAVE, loginInfos
payload: { }
profile });
} };
});
}; saveProfile = (profile) => {
return this._ngRedux.dispatch({
saveStatementAgree = (disclaimer_checked) => { type: PROFILE_SAVE,
return this._ngRedux.dispatch({ payload: {
type: STATEMENTAGREE_SAVE, profile
payload: { }
disclaimer_checked });
} };
});
}; saveStatementAgree = (disclaimer_checked) => {
return this._ngRedux.dispatch({
type: STATEMENTAGREE_SAVE,
initLoginInfo = () => { payload: {
return this._ngRedux.dispatch({ disclaimer_checked
type: LOGININFO_INIT, }
payload: { });
} };
});
};
initLoginInfo = () => {
return this._ngRedux.dispatch({
type: LOGININFO_INIT,
payload: {
}
});
};
} }
import { REGIONSCHOOLS_RECEIVED, REGIONSCHOOLS_SELECTED_SAVE, REGIONSCHOOLS_ORDER_SAVE, REGIONSCHOOLS_INIT } from '../constants'; import { NgRedux } from "@angular-redux/store";