Commit 2cc27bf9 authored by Open Source Developer's avatar Open Source Developer

Student Amka

parent ccf76590
import { AMKAFILL_SAVE } from '../constants';
import { Injectable } from '@angular/core';
import { NgRedux } from 'ng2-redux';
import { IAppState } from '../store';
@Injectable()
export class AmkaFillsActions {
constructor(
private _ngRedux: NgRedux<IAppState>) {}
saveAmkaFills = (amkaFills) => {
return this._ngRedux.dispatch({
type: AMKAFILL_SAVE,
payload: {
amkaFills
}
});
};
}
\ No newline at end of file
......@@ -4,7 +4,8 @@ import { RegionSchoolsActions } from './regionschools.actions';
import { SectorCoursesActions } from './sectorcourses.actions';
import { StudentDataFieldsActions } from './studentdatafields.actions';
import { EpalClassesActions } from './epalclass.actions';
const ACTION_PROVIDERS = [ CourseFieldsActions, SectorFieldsActions, RegionSchoolsActions, SectorCoursesActions, StudentDataFieldsActions, EpalClassesActions ];
import { AmkaFillsActions} from './amkafill.actions';
const ACTION_PROVIDERS = [ CourseFieldsActions, SectorFieldsActions, RegionSchoolsActions, SectorCoursesActions, StudentDataFieldsActions, EpalClassesActions, AmkaFillsActions ];
export {
CourseFieldsActions,
......@@ -13,5 +14,6 @@ export {
SectorCoursesActions,
StudentDataFieldsActions,
EpalClassesActions,
AmkaFillsActions,
ACTION_PROVIDERS,
};
......@@ -27,6 +27,8 @@ import { APP_ROUTER_PROVIDERS, APP_DECLARATIONS } from './app.routes';
/* Here we import services */
import {HelperDataService} from './services/helper-data-service';
import {UserDataService} from './services/user-data-service';
import {AmkaCheckService} from './services/amkacheck-service';
import { ACTION_PROVIDERS } from './actions';
import Home from './components/home';
......@@ -75,6 +77,7 @@ class MyLocalization extends NgLocalization {
// Service1, again services here
HelperDataService,
UserDataService,
AmkaCheckService,
]
})
class AppModule {}
......
......@@ -12,11 +12,13 @@
<li class="nav-item" [ngClass]="{active: path=='application-preview'}">
<a class="nav-link" [routerLink]="['/application-preview']" [routerLinkActive]="['active']">Προεπισκόπηση</a>
</li>
<li class="nav-item" [ngClass]="{active: path=='pal-class-select'}">
<li class="nav-item" [ngClass]="{active: path=='epal-class-select'}">
<a class="nav-link" [routerLink]="['/epal-class-select']" [routerLinkActive]="['active']">Τάξη</a>
</li>
<li class="nav-item" [ngClass]="{active: path=='amka-fill'}">
<a class="nav-link" [routerLink]="['/amka-fill']" [routerLinkActive]="['active']">ΑΜΚΑ ΜΑΘΗΤΗ</a>
</li>
<li class="nav-item" [ngClass]="{active: path=='sector-fields-select'}">
<a class="nav-link" [routerLink]="['/sector-fields-select']" [routerLinkActive]="['active']">Τομεας</a>
......
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { Injectable } from "@angular/core";
import { AmkaFillsActions } from '../../actions/amkafill.actions';
import { NgRedux, select } from 'ng2-redux';
import { IAmkaFills } from '../../store/amkafill/amkafills.types';
import { IAppState } from '../../store/store';
import { AmkaCheckService} from '../../services/amkacheck-service';
import {
FormBuilder,
FormGroup,
FormControl,
FormArray
} from '@angular/forms';
import {AppSettings} from '../../app.settings';
@Component({
selector: 'amka-fill',
template: `
<form [formGroup]="formGroup">
<div *ngFor="let amkafill$ of amkafills$ | async;"> </div>
<div class="form-group">
<label for="studentAmka">ΑΜΚΑ μαθητή</label><input class="form-control" type="text" formControlName="name">
</div>
<div class="row">
<div class="col-md-2 col-md-offset-5">
<button type="button" class="btn-primary btn-lg pull-center" (click)="saveSelected()">
Συνέχεια<span class="glyphicon glyphicon-menu-right"></span>
</button>
</div>
</div>
</form>
`
})
@Injectable() export default class AmkaFill implements OnInit {
private amkafills$: Observable<IAmkaFills>;
public formGroup: FormGroup;
private respond: any;
constructor(private fb: FormBuilder,
private _cas: AmkaCheckService,
private _cfa: AmkaFillsActions,
private _ngRedux: NgRedux<IAppState>,
private router: Router) {
this.formGroup = this.fb.group({
name: []
});
};
ngOnInit() {
// this._cfa.getEpalClasses()
console.log(this.formGroup.value);
this.amkafills$ = this._ngRedux.select(state => {
if (state.amkafills.size > 0) {
state.amkafills.reduce(({}, amkafill) => {
this.formGroup.setValue(amkafill);
return amkafill;
}, {});
}
return state.amkafills;
});
}
saveSelected() {
this._cas.checkstudentamka(this.formGroup.value)
.subscribe(res =>this.respond = res);
console.log(this.respond);
this._cfa.saveAmkaFills(this.formGroup.value);
this.router.navigate(['/epal-class-select']);
}
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ import SectorFieldsSelect from '../components/student-application-form/sector.fi
import RegionSchoolsSelect from '../components/student-application-form/region.schools.select';
import SectorCoursesSelect from '../components/student-application-form/sector.courses.select';
import ApplicationPreview from '../components/student-application-form/application.preview';
import AmkaFill from '../components/student-application-form/amka-fill';
export const MainRoutes: Routes = [
{ path: '', component: Home },
......@@ -25,7 +26,8 @@ export const MainRoutes: Routes = [
{ path: 'sector-fields-select', component: SectorFieldsSelect },
{ path: 'region-schools-select', component: RegionSchoolsSelect },
{ path: 'sectorcourses-fields-select', component: SectorCoursesSelect },
{ path: 'application-preview', component: ApplicationPreview }
{ path: 'application-preview', component: ApplicationPreview },
{ path: 'amka-fill', component: AmkaFill }
];
export const MainDeclarations = [
......@@ -39,5 +41,6 @@ export const MainDeclarations = [
RegionSchoolsSelect,
SectorCoursesSelect,
StudentApplicationMain,
ApplicationPreview
ApplicationPreview,
AmkaFill
];
import {Http,Response, RequestOptions, Headers} from '@angular/http';
import {Injectable} from '@angular/core';
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/map';
@Injectable()
export class AmkaCheckService {
private _url = "https://wso2.minedu.gov.gr/amka/v1.1/" ;
constructor(private _http: Http) {
};
checkstudentamka(amka: any) {
let authToken = '7bed3fc5-f9f5-3613-abcd-3b08bab0f625';
let headers = new Headers({ 'Accept': 'application/json' });
headers.append('Authorization', `Bearer ${authToken}`);
let options = new RequestOptions({headers : headers});
let parameter1 = 'ksdhkshf' ;
return this._http.get(this._url+ amka.name +'/'+ parameter1 ,options)
.map(response => response.json() );
}
}
\ No newline at end of file
import { List } from 'immutable';
import { IAmkaFill} from './amkafills.types';
export const INITIAL_STATE = List<IAmkaFill>();
import { IAmkaFills, IAmkaFill } from './amkafills.types';
import { INITIAL_STATE } from './amkafills.initial-state';
import { Seq } from 'immutable';
import { AMKAFILL_SAVE} from '../../constants';
export function amkafillReducer(state: IAmkaFills = INITIAL_STATE, action): IAmkaFills {
switch (action.type) {
case AMKAFILL_SAVE:
let selectedAmkaFills = Array<IAmkaFill>();
selectedAmkaFills.push(<IAmkaFill>{ name: action.payload.amkaFills.name});
return Seq(selectedAmkaFills).map(n => n).toList();
default: return state;
}
};
import { IAmkaFills, IAmkaFill } from './amkafills.types';
export function deimmutifyAmkaFills(state: IAmkaFills): IAmkaFill[] {
let fetchedAmkaFills = new Array();
state.forEach(amkafill => {
fetchedAmkaFills.push(<IAmkaFill>{name: amkafill.name});
});
return fetchedAmkaFills;
};
import { List } from 'immutable';
export interface IAmkaFill {
// id: number;
name: number;
}
export type IAmkaFills = List<IAmkaFill>;
"use strict";
const classfields_reducer_1 = require("./classfields.reducer");
exports.classFieldsReducer = classfields_reducer_1.classFieldsReducer;
const classfields_transformers_1 = require("./classfields.transformers");
exports.deimmutifyClassFields = classfields_transformers_1.deimmutifyClassFields;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsK0RBQTJEO0FBTXpELHNFQUFrQjtBQUxwQix5RUFBbUU7QUFNakUsaUZBQXFCIn0=
\ No newline at end of file
import { IAmkaFill, IAmkaFills } from './amkafills.types';
import { amkafillReducer } from './amkafills.reducer';
import { deimmutifyAmkaFills } from './amkafills.transformers';
export {
IAmkaFill,
IAmkaFills,
amkafillReducer,
deimmutifyAmkaFills,
};
......@@ -5,6 +5,7 @@ import * as regions from './regionschools';
import * as sectors from './sectorcourses';
import * as studentDataFields from './studentdatafields';
import * as epalclasses from './epalclasses';
import * as amkafills from './amkafill';
/*
* This is where we 'assemble' the full store out of its modules.
......@@ -17,6 +18,7 @@ export interface IAppState {
sectors?: sectors.ISectors;
studentDataFields?: studentDataFields.IStudentDataFields;
epalclasses?: epalclasses.IEpalClasses;
amkafills?: amkafills.IAmkaFills;
};
export const rootReducer = combineReducers<IAppState>({
......@@ -26,6 +28,7 @@ export const rootReducer = combineReducers<IAppState>({
sectors: sectors.sectorCoursesReducer,
studentDataFields: studentDataFields.studentDataFieldsReducer,
epalclasses: epalclasses.epalclassesReducer,
amkafills: amkafills.amkafillReducer,
});
export function deimmutify(state: IAppState): Object {
......@@ -36,5 +39,6 @@ export function deimmutify(state: IAppState): Object {
sectors: sectors.deimmutifySectorCourses(state.sectors),
studentdataFields: studentDataFields.deimmutifyStudentDataFields(state.studentDataFields),
epalclasses: epalclasses.deimmutifyEpalClasses(state.epalclasses),
amkafills: amkafills.deimmutifyAmkaFills(state.amkafills),
};
}
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