WIP: implementing application deletion

parent 569c2ae6
......@@ -44,6 +44,31 @@ class SubmitedApplications extends ControllerBase
);
}
public function deleteApplication(Request $request) {
$authToken = $request->headers->get('PHP_AUTH_USER');
$epalUsers = $this->entityTypeManager->getStorage('epal_users')->loadByProperties(array('authtoken' => $authToken));
$epalUser = reset($epalUsers);
if ($epalUser) {
$userid = $epalUser->id();
$epalStudents = $this->entityTypeManager->getStorage('epal_student')->loadByProperties(array('epaluser_id' => $userid));
$epalStudent = reset($epalStudents);
if ($epalStudent) {
} else {
return $this->respondWithStatus([
'message' => t('EPAL user not found'),
], Response::HTTP_FORBIDDEN);
}
} else {
return $this->respondWithStatus([
'message' => t('User not found'),
], Response::HTTP_FORBIDDEN);
}
}
public function getSubmittedApplications(Request $request)
{
$authToken = $request->headers->get('PHP_AUTH_USER');
......
......@@ -29,7 +29,8 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
<div *ngIf="(SubmitedApplic$ | async).length > 0" class="row list-group-item" style="margin: 0px 2px 0px 2px; background-color: #ccc;">
<div class="col-md-6" style="font-size: 1em; font-weight: bold;">Επώνυμο</div>
<div class="col-md-6" style="font-size: 1em; font-weight: bold;">Όνομα</div>
<div class="col-md-5" style="font-size: 1em; font-weight: bold;">Όνομα</div>
<div class="col-md-1" style="font-size: 1em; font-weight: bold;">&nbsp;</div>
</div>
<div *ngIf="(SubmitedApplic$ | async).length > 0">
......@@ -40,7 +41,8 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
[class.selectedappout]="userActive === UserData$.id"
*ngFor="let UserData$ of SubmitedApplic$ | async; let i=index; let isOdd=odd; let isEven=even" >
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{UserData$.studentsurname}}</div>
<div class="col-md-6" style="font-size: 0.8em; font-weight: bold;">{{UserData$.name}}</div>
<div class="col-md-5" style="font-size: 0.8em; font-weight: bold;">{{UserData$.name}}</div>
<div class="col-md-1" style="font-size: 1em; font-weight: bold;"><i class="fa fa-trash isclickable" (click)="deleteApplication(UserData$.id)"></i></div>
<div style="width: 100%">
<div *ngFor="let StudentDetails$ of SubmitedDetails$ | async" [hidden]="UserData$.id !== userActive" style="margin: 10px 10px 10px 10px;">
......@@ -276,4 +278,8 @@ import { BehaviorSubject, Subscription } from 'rxjs/Rx';
}
deleteApplication(appId: number) : void {
}
}
......@@ -154,6 +154,31 @@ export class HelperDataService implements OnInit, OnDestroy {
});
}
deleteApplication(appId) {
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, withCredentials: true });
let options = new RequestOptions({ headers: headers });
return new Promise((resolve, reject) => {
this.http.post(`${AppSettings.API_ENDPOINT}/epal/application/delete`, { applicationId: appId }, options)
.map(response => response.json())
.subscribe(data => {
resolve(<any>data);
},
error => {
console.log("Error Removing Application");
reject("Error Removing Application");
},
() => console.log("Removing Application"));
});
}
getCourseFields() {
this.loginInfo$.getValue().forEach(loginInfoToken => {
......
......@@ -10,7 +10,7 @@
"sourceMap": false,
"inlineSourceMap": false,
"module": "commonjs",
"target": "es6"
"target": "ES5"
},
"exclude": [
......
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