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

trans

parent 59da0b72
...@@ -310,4 +310,4 @@ class CASLogin extends ControllerBase ...@@ -310,4 +310,4 @@ class CASLogin extends ControllerBase
return false; return false;
} }
} }
\ No newline at end of file
...@@ -152,4 +152,4 @@ class CASLogout extends ControllerBase ...@@ -152,4 +152,4 @@ class CASLogout extends ControllerBase
return new RedirectResponseWithCookieExt($this->redirectUrl .'&error_code=' . $errorCode, 302, []); return new RedirectResponseWithCookieExt($this->redirectUrl .'&error_code=' . $errorCode, 302, []);
} }
} }
} }
\ No newline at end of file
...@@ -70,12 +70,6 @@ epal.application_submit: ...@@ -70,12 +70,6 @@ epal.application_submit:
_controller: '\Drupal\epal\Controller\ApplicationSubmit::appSubmit' _controller: '\Drupal\epal\Controller\ApplicationSubmit::appSubmit'
requirements: requirements:
_user_is_logged_in: 'TRUE' _user_is_logged_in: 'TRUE'
epal.demo_data:
path: '/epal/demodata'
defaults:
_controller: '\Drupal\epal\Controller\CreateDemoData::createData'
requirements:
_access: 'TRUE'
epal.allocation: epal.allocation:
path: '/epal/distribution' path: '/epal/distribution'
options: options:
...@@ -212,3 +206,12 @@ findcapacity: ...@@ -212,3 +206,12 @@ findcapacity:
_controller: '\Drupal\epal\Controller\DirectorView::findCapacity' _controller: '\Drupal\epal\Controller\DirectorView::findCapacity'
requirements: requirements:
_user_is_logged_in: 'TRUE' _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 ...@@ -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) { private function respondWithStatus($arr, $s) {
$res = new JsonResponse($arr); $res = new JsonResponse($arr);
$res->setStatusCode($s); $res->setStatusCode($s);
......
...@@ -152,6 +152,8 @@ import { ...@@ -152,6 +152,8 @@ import {
public formGroup: FormGroup; public formGroup: FormGroup;
private StudentSelected$: BehaviorSubject<any>; private StudentSelected$: BehaviorSubject<any>;
private StudentSelectedSub: Subscription; private StudentSelectedSub: Subscription;
private School$: BehaviorSubject<any>;
private SchoolSub: Subscription;
private StudentInfo$: BehaviorSubject<any>; private StudentInfo$: BehaviorSubject<any>;
private StudentInfoSub: Subscription; private StudentInfoSub: Subscription;
private StudentsSize$: BehaviorSubject<any>; private StudentsSize$: BehaviorSubject<any>;
...@@ -163,7 +165,7 @@ import { ...@@ -163,7 +165,7 @@ import {
private retrievedStudent: BehaviorSubject<boolean>; private retrievedStudent: BehaviorSubject<boolean>;
private selectionBClass: BehaviorSubject<boolean>; private selectionBClass: BehaviorSubject<boolean>;
private selectionCClass: BehaviorSubject<boolean>; private selectionCClass: BehaviorSubject<boolean>;
private SchoolId = 147; private SchoolId ;
private currentclass: Number; private currentclass: Number;
private saved: Array<number> = new Array(); private saved: Array<number> = new Array();
private limitdown = 0; private limitdown = 0;
...@@ -188,6 +190,9 @@ import { ...@@ -188,6 +190,9 @@ import {
this.retrievedStudent = new BehaviorSubject(false); this.retrievedStudent = new BehaviorSubject(false);
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.formGroup = this.fb.group({ this.formGroup = this.fb.group({
tomeas: ['', []], tomeas: ['', []],
taxi: ['', []], taxi: ['', []],
...@@ -216,7 +221,22 @@ import { ...@@ -216,7 +221,22 @@ import {
ngOnInit() { 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) { verifyclass(txop) {
...@@ -360,9 +380,6 @@ import { ...@@ -360,9 +380,6 @@ import {
confirmStudent() { confirmStudent() {
this._hds.saveConfirmStudents(this.saved, this.type); this._hds.saveConfirmStudents(this.saved, this.type);
let event = new MouseEvent('click', {bubbles: true});
this.fileInput.nativeElement.dispatchEvent(event);
} }
checkcclass() { checkcclass() {
......
...@@ -76,10 +76,10 @@ export default class SchoolHome implements OnInit { ...@@ -76,10 +76,10 @@ export default class SchoolHome implements OnInit {
this.authToken = loginInfoToken.auth_token; this.authToken = loginInfoToken.auth_token;
this.authRole = loginInfoToken.auth_role; this.authRole = loginInfoToken.auth_role;
if (this.authToken && this.authToken.length > 0) if (this.authToken && this.authToken.length > 0)
if (this.authRole = 'director') if (this.authRole === 'director')
console.log("ok"); console.log("ok");
this.router.navigate(['/school/director-buttons']); this.router.navigate(['/school/director-buttons']);
if (this.authRole = 'pde') if (this.authRole === 'pde')
this.router.navigate(['/school/perfecture-view']); this.router.navigate(['/school/perfecture-view']);
return loginInfoToken; return loginInfoToken;
}, {}); }, {});
......
...@@ -13,10 +13,7 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types'; ...@@ -13,10 +13,7 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import * as html2canvas from "html2canvas" import * as html2canvas from "html2canvas"
import * as fs from "fs"
@Component({ @Component({
selector: 'submited-preview', selector: 'submited-preview',
template: ` template: `
...@@ -219,37 +216,26 @@ import * as fs from "fs" ...@@ -219,37 +216,26 @@ import * as fs from "fs"
html2canvas(document.getElementById("target")).then(function(canvas) 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" var img=new Image();
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO" img.src=canvas.toDataURL();
+ "3gAAAABJRU5ErkJggg=="; img.onload=function(){
console.log(img,"img");
var data = img.replace(/^data:image\/\w+;base64,/, ""); var doc = new jsPDF();
var buf = new Buffer(data, 'base64'); console.log(img, doc, "ok");
fs.writeFile('image.png', buf); 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"); function(error){
doc.save('applications.pdf'); console.log("i fail");
});
}
});
} }
......
...@@ -922,4 +922,31 @@ getCapacityPerSchool(taxi, tomeas, specialit, schoolid) { ...@@ -922,4 +922,31 @@ getCapacityPerSchool(taxi, tomeas, specialit, schoolid) {
.map(response => response.json()); .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