Commit 33d58717 authored by Open Source Developer's avatar Open Source Developer

trans

parent 59da0b72
......@@ -310,4 +310,4 @@ class CASLogin extends ControllerBase
return false;
}
}
}
\ No newline at end of file
......@@ -152,4 +152,4 @@ class CASLogout extends ControllerBase
return new RedirectResponseWithCookieExt($this->redirectUrl .'&error_code=' . $errorCode, 302, []);
}
}
}
}
\ No newline at end of file
......@@ -70,12 +70,6 @@ epal.application_submit:
_controller: '\Drupal\epal\Controller\ApplicationSubmit::appSubmit'
requirements:
_user_is_logged_in: 'TRUE'
epal.demo_data:
path: '/epal/demodata'
defaults:
_controller: '\Drupal\epal\Controller\CreateDemoData::createData'
requirements:
_access: 'TRUE'
epal.allocation:
path: '/epal/distribution'
options:
......@@ -212,3 +206,12 @@ findcapacity:
_controller: '\Drupal\epal\Controller\DirectorView::findCapacity'
requirements:
_user_is_logged_in: 'TRUE'
findschoolid:
path: '/epal/getschool'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\epal\Controller\DirectorView::getSchoolID'
requirements:
_user_is_logged_in: 'TRUE'
......@@ -687,6 +687,48 @@ public function findCapacity(Request $request,$taxi,$tomeas,$specialit,$schoolid
}
public function getSchoolID(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
$users = $this->entityTypeManager->getStorage('user')->loadByProperties(array('name' => $authToken));
$user = reset($users);
if ($user) {
$schid = intval($user -> init -> value );
$list = array();
$list[] = array(
'id' => $schid
);
$i++;
return $this->respondWithStatus(
$list
, Response::HTTP_OK);
} else {
return $this->respondWithStatus([
'message' => t("User not found!"),
], Response::HTTP_FORBIDDEN);
}
}
private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr);
$res->setStatusCode($s);
......
......@@ -152,6 +152,8 @@ import {
public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private StudentInfo$: BehaviorSubject<any>;
private StudentInfoSub: Subscription;
private StudentsSize$: BehaviorSubject<any>;
......@@ -163,7 +165,7 @@ import {
private retrievedStudent: BehaviorSubject<boolean>;
private selectionBClass: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>;
private SchoolId = 147;
private SchoolId ;
private currentclass: Number;
private saved: Array<number> = new Array();
private limitdown = 0;
......@@ -188,6 +190,9 @@ import {
this.retrievedStudent = new BehaviorSubject(false);
this.selectionBClass = new BehaviorSubject(false);
this.selectionCClass = new BehaviorSubject(false);
this.School$ = new BehaviorSubject([{}]);
this.formGroup = this.fb.group({
tomeas: ['', []],
taxi: ['', []],
......@@ -216,7 +221,22 @@ import {
ngOnInit() {
}
this.SchoolSub = this._hds.getSchoolId().subscribe(x => {
this.School$.next(x);
console.log(x[0].id, "schoolid!");
this.SchoolId = x[0].id;
console.log(this.SchoolId,"schoolid");
},
error => {
this.School$.next([{}]);
console.log("Error Getting School");
},
() => console.log("Getting School "));
}
verifyclass(txop) {
......@@ -360,9 +380,6 @@ import {
confirmStudent() {
this._hds.saveConfirmStudents(this.saved, this.type);
let event = new MouseEvent('click', {bubbles: true});
this.fileInput.nativeElement.dispatchEvent(event);
}
checkcclass() {
......
......@@ -76,10 +76,10 @@ export default class SchoolHome implements OnInit {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0)
if (this.authRole = 'director')
if (this.authRole === 'director')
console.log("ok");
this.router.navigate(['/school/director-buttons']);
if (this.authRole = 'pde')
if (this.authRole === 'pde')
this.router.navigate(['/school/perfecture-view']);
return loginInfoToken;
}, {});
......
......@@ -13,10 +13,7 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import * as html2canvas from "html2canvas"
import * as fs from "fs"
@Component({
selector: 'submited-preview',
template: `
......@@ -219,37 +216,26 @@ import * as fs from "fs"
html2canvas(document.getElementById("target")).then(function(canvas)
{
console.log("i am !");
if(document.readyState === "complete") {
console.log("mphka");
var img = canvas.toDataURL();
var fs = require('fs');
var sys = require('sys');
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0"
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO"
+ "3gAAAABJRU5ErkJggg==";
var data = img.replace(/^data:image\/\w+;base64,/, "");
var buf = new Buffer(data, 'base64');
fs.writeFile('image.png', buf);
var img=new Image();
img.src=canvas.toDataURL();
img.onload=function(){
console.log(img,"img");
var doc = new jsPDF();
console.log(img, doc, "ok");
doc.addImage(img, 'PNG',0, 0, 210, 297);
console.log(img, doc, "ok2");
doc.save('applications.pdf');
}
var doc = new jsPDF();
console.log("mphkaneo");
doc.addImage(img, 'PNG',0, 0, 1000, 1000);
console.log("mphkaneoneo");
doc.save('applications.pdf');
}
});
},
function(error){
console.log("i fail");
});
}
......
......@@ -922,4 +922,31 @@ getCapacityPerSchool(taxi, tomeas, specialit, schoolid) {
.map(response => response.json());
}
getSchoolId() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role;
});
let headers = new Headers({
"Content-Type": "application/json",
});
this.createAuthorizationHeader(headers);
let options = new RequestOptions({ headers: headers });
return this.http.get(`${AppSettings.API_ENDPOINT}/epal/getschool/`, 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