some fixes, one alert

parent ad86f7bb
{"version":3,"sources":["webpack:///./source/components/lazy-load/lazy-load.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qCAA0C;AAC1C,qCAAyC;AACzC,wCAAuD;AAMvD,KAAM,sBAAsB;KAA5B;KAA8B,CAAC;KAAD,6BAAC;AAAD,EAAC;AAAzB,uBAAsB;KAH3B,gBAAS,CAAC;SACT,QAAQ,EAAE,oCAAoC;MAC/C,CAAC;;IACI,sBAAsB,CAAG;AAE/B,KAAM,MAAM,GAAW;KACrB,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE;EACrD,CAAC;AAMF,KAAa,gBAAgB;KAA7B;KAAgC,CAAC;KAAD,uBAAC;AAAD,EAAC;AAApB,iBAAgB;KAJ5B,eAAQ,CAAC;SACR,OAAO,EAAE,CAAG,qBAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAE;SAC3C,YAAY,EAAE,CAAE,sBAAsB,CAAE;MACzC,CAAC;;IACW,gBAAgB,CAAI;AAApB,6CAAgB","file":"1.chunk.js","sourcesContent":["import { Component } from '@angular/core';\nimport { NgModule } from '@angular/core';\nimport { Routes, RouterModule } from '@angular/router';\n\n\n@Component({\n template: `<H1>Lazy Loaded Component One</H1>`\n})\nclass LazyLoadedComponentOne {}\n\nconst routes: Routes = [\n { path: 'lazy1', component: LazyLoadedComponentOne },\n];\n\n@NgModule({\n imports: [ RouterModule.forChild(routes) ],\n declarations: [ LazyLoadedComponentOne ]\n})\nexport class LazyLoadedModule { }\n\n\n\n// WEBPACK FOOTER //\n// ./~/angular2-router-loader/src!./~/tslint-loader!./source/components/lazy-load/lazy-load.ts"],"sourceRoot":""}
\ No newline at end of file
{"version":3,"sources":["webpack:///./source/components/lazy-load/lazy-load.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qCAA0C;AAC1C,qCAAyC;AACzC,wCAAuD;AAMvD,KAAM,sBAAsB;KAA5B;KAA8B,CAAC;KAAD,6BAAC;AAAD,EAAC;AAAzB,uBAAsB;KAH3B,gBAAS,CAAC;SACT,QAAQ,EAAE,oCAAoC;MAC/C,CAAC;;IACI,sBAAsB,CAAG;AAE/B,KAAM,MAAM,GAAW;KACrB,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE;EACrD,CAAC;AAMF,KAAa,gBAAgB;KAA7B;KAAgC,CAAC;KAAD,uBAAC;AAAD,EAAC;AAApB,iBAAgB;KAJ5B,eAAQ,CAAC;SACR,OAAO,EAAE,CAAG,qBAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAE;SAC3C,YAAY,EAAE,CAAE,sBAAsB,CAAE;MACzC,CAAC;;IACW,gBAAgB,CAAI;AAApB,6CAAgB","file":"1.chunk.js","sourcesContent":["import { Component } from '@angular/core';\nimport { NgModule } from '@angular/core';\nimport { Routes, RouterModule } from '@angular/router';\n\n\n@Component({\n template: `<H1>Lazy Loaded Component One</H1>`\n})\nclass LazyLoadedComponentOne {}\n\nconst routes: Routes = [\n { path: 'lazy1', component: LazyLoadedComponentOne },\n];\n\n@NgModule({\n imports: [ RouterModule.forChild(routes) ],\n declarations: [ LazyLoadedComponentOne ]\n})\nexport class LazyLoadedModule { }\n\n\n\n// WEBPACK FOOTER //\n// ./~/angular2-router-loader/src!./~/tslint-loader!./source/components/lazy-load/lazy-load.ts"],"sourceRoot":""}
\ No newline at end of file
webpackJsonp([1],{
/***/ 471:
/***/ function(module, exports, __webpack_require__) {
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = __webpack_require__(1);
var core_2 = __webpack_require__(1);
var router_1 = __webpack_require__(25);
var LazyLoadedComponentOne = (function () {
function LazyLoadedComponentOne() {
}
return LazyLoadedComponentOne;
}());
LazyLoadedComponentOne = __decorate([
core_1.Component({
template: "<H1>Lazy Loaded Component One</H1>"
}),
__metadata("design:paramtypes", [])
], LazyLoadedComponentOne);
var routes = [
{ path: 'lazy1', component: LazyLoadedComponentOne },
];
var LazyLoadedModule = (function () {
function LazyLoadedModule() {
}
return LazyLoadedModule;
}());
LazyLoadedModule = __decorate([
core_2.NgModule({
imports: [router_1.RouterModule.forChild(routes)],
declarations: [LazyLoadedComponentOne]
}),
__metadata("design:paramtypes", [])
], LazyLoadedModule);
exports.LazyLoadedModule = LazyLoadedModule;
/***/ }
});
//# sourceMappingURL=1.5d424ee89dc353107fad.bundle.js.map
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!doctype html>
<html lang="en" data-framework="angular2">
<head>
<meta charset="utf-8">
<title>Angular 2 με Drupal backend RESTful server</title>
<link rel="stylesheet" href="https://bootswatch.com/paper/bootstrap.min.css">
</head>
<body>
<h3 class="text-center">Angular 2 με Drupal backend RESTful server</h3>
<hr/>
<div class="container-fluid">
<kitchen-sink></kitchen-sink>
</div>
<script type="text/javascript" src="vendor.5d424ee89dc353107fad.bundle.js"></script><script type="text/javascript" src="app.5d424ee89dc353107fad.bundle.js"></script></body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import {Component} from '@angular/core';
import { Http, Response } from '@angular/http';
import { Http, Response, RequestOptions, Headers } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Student } from '../students/student';
import {
FormControl,
FormGroup
FormControl,
FormGroup
} from '@angular/forms';
@Component({
selector: 'form3',
template: `
selector: 'form3',
template: `
<div>
<form #studentform="ngForm" (submit)="onSubmit(studentform)" class="col-sm-8">
<div class="form-group">
......@@ -39,104 +39,30 @@ import {
`
})
export default class Form3 {
public student;
public student;
constructor(private http: Http) {
this.student = new Student(0,'','','','','1');
}
constructor(private http: Http) {
this.student = new Student(0, '', '', '', '', 1);
}
onSubmit(studentform: any) {
// console.log(studentform);
// console.log(studentform.surname + "..." + studentform.name + "..." + studentform.address+ "..." + studentform.birthdate);
this.student.type = [{"target_id": "student"}];
this.student._links = {
"self":{"href":"http:\/\/eepal.dev\/drupal\/admin\/structure\/student\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/student\/student"},
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/user_id":[
{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json","lang":"en"}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/studentclass_id":[
{"href":"http:\/\/eepal.dev\/drupal\/admin\/structure\/student_class\/1?_format=hal_json","lang":"en"}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/revision_uid":[
{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json"}
]
};
this.student.langcode = [
{"value":"en","lang":"en"}
];
this.student.embedded = {
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/user_id":[
{
"_links":{
"self":{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/user\/user"}
},
"uuid":[
{"value":"1291f55b-3258-400f-8a0a-634252e13552"}
],
"lang":"en"
}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/studentclass_id":[
{
"_links":{
"self":{"href":"http:\/\/eepal.dev\/drupal\/admin\/structure\/student_class\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/student_class\/student_class"}
},
"uuid":[
{"value":"eaf42da6-290a-49c0-8d86-551bca2023fa"}
],
"lang":"en"
}
],
"http:\/\/eepal.dev\/drupal\/rest\/relation\/student\/student\/revision_uid":[
{
"_links":{
"self":{"href":"http:\/\/eepal.dev\/drupal\/user\/1?_format=hal_json"},
"type":{"href":"http:\/\/eepal.dev\/drupal\/rest\/type\/user\/user"}
},
"uuid":[
{"value":"1291f55b-3258-400f-8a0a-634252e13552"}
]
}
]
};
this.student.name = [
{
"value":"Haris"
}
];
this.student.surname = [
{
"value":"Papadopoulos"
}
];
this.student.address = [
{
"value":"Kimonos Voga 36"
}
];
this.student.birthdate = [
{
"value":"2001-10-01"
}
];
onSubmit(studentform: any) {
let headers = new Headers({
"Authorization": "Basic cmVzdHVzZXI6czNjckV0MFAwdWwwJA==", // encoded user:pass
"Accept": "*/*",
"Access-Control-Allow-Credentials": "true",
"Content-Type": "application/json",
// "Content-Type": "text/plain", // try to skip preflight
"X-CSRF-Token": "hVtACDJjFRSyE4bgGJENHbXY0B9yNhF71Fw-cYHSDNY"
});
let options = new RequestOptions({ headers: headers, withCredentials: true });
console.log(this.student);
let headers = {
"Authorization": "Basic cmVzdHVzZXI6czNjcjN0b3BvdWxvcw==", // encoded user/pass - this is admin/123qwe
"Accept": "application/hal+json",
"Content-Type": "application/hal+json",
"X-CSRF-Token": "N2tI55qa9gUDWJ_KXuZC1YL2Xb9Dt3pdGr2KkYGHKv0"
};
console.log(this.student);
this.http.post('http://eepal.dev/drupal/entity/student',this.student,headers)
// Call map on the response observable to get the parsed people object
.map((res: Response) => res.json())
.subscribe(success => console.log("success post"), // put the data returned from the server in our variable
error => console.log("Error HTTP GET Service"), // in case of failure show this message
() => console.log("write this message anyway"));//run this code in all cases);
}
this.http.post('http://eepal.dev/drupal/entity/student', this.student, options)
// Call map on the response observable to get the parsed people object
.map((res: Response) => res.json())
.subscribe(success => {alert("Η εγγραφή έγινε με επιτυχία"); console.log("success post")}, // put the data returned from the server in our variable
error => console.log("Error HTTP GET Service"), // in case of failure show this message
() => console.log("write this message anyway"));//run this code in all cases);
}
}
......@@ -5,6 +5,6 @@ export class Student {
public surname: string,
public address: string,
public birthdate: string,
public studentclass_id:string
public studentclass_id:number
){}
}
......@@ -8,8 +8,8 @@ import { ServerDataSource } from '../../../node_modules/ng2-smart-table/build/sr
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
@Component({
selector: 'students-list',
template: `
selector: 'students-list',
template: `
<div>
<ng2-smart-table [settings]="settings" [source]="data"></ng2-smart-table>
</div>
......@@ -17,51 +17,46 @@ import 'rxjs/add/operator/toPromise';
})
@Injectable() export default class StudentsList implements OnInit {
public students: Student[];
public data;
public settings = {
columns: {
id: {
title: 'ID'
},
name: {
title: 'Ονοματεπώνυμο'
},
surname: {
title: 'Επώνυμο'
},
address: {
title: 'Διεύθυνση'
},
studentclass_id: {
title: 'Τμήμα'
}
}
};
constructor(private http: Http) {
}
ngOnInit(){
this.data = [];
this.students = [];
this.getStudents(this.http);//called after the constructor and called after the first ngOnChanges()
}
getStudents(http: Http) {
// this.http.get('http://eduslim2.minedu.gov.gr/drupal/students/list')
this.data = new ServerDataSource(http, {endPoint: 'http://eepal.dev/drupal/students/list'});
// this.data = new ServerDataSource(http, {endPoint: 'http://eduslim2.minedu.gov.gr/drupal/students/list'});
/* this.http.get('http://eepal.dev/drupal/students/list')
// Call map on the response observable to get the parsed people object
.map(response => <Student[]>response.json())
.subscribe(data => DataSource.load(this.data = data), // put the data returned from the server in our variable
error => console.log("Error HTTP GET Service"), // in case of failure show this message
() => console.log(this.data));//run this code in all cases); */
}
public students: Student[];
public data;
public settings = {
columns: {
id: {
title: 'ID'
},
name: {
title: 'Ονοματεπώνυμο'
},
surname: {
title: 'Επώνυμο'
},
address: {
title: 'Διεύθυνση'
},
studentclass_id: {
title: 'Τμήμα'
}
}
};
constructor(private http: Http) {
}
ngOnInit() {
this.data = [];
this.students = [];
this.getStudents(this.http);//called after the constructor and called after the first ngOnChanges()
}
getStudents(http: Http) {
// this.http.get('http://eduslim2.minedu.gov.gr/drupal/students/list')
this.data = new ServerDataSource(http, { endPoint: 'http://eepal.dev/drupal/students/list' });
// this.data = new ServerDataSource(http, {endPoint: 'http://eduslim2.minedu.gov.gr/drupal/students/list'});
/* this.http.get('http://eepal.dev/drupal/students/list')
// Call map on the response observable to get the parsed people object
.map(response => <Student[]>response.json())
.subscribe(data => DataSource.load(this.data = data), // put the data returned from the server in our variable
error => console.log("Error HTTP GET Service"), // in case of failure show this message
() => console.log(this.data));//run this code in all cases); */
}
}
/* * * ./app/comments/services/comment.service.ts * * */
// Imports
// import { Http, Response, Headers, RequestOptions } from '@angular/http';
// import { Student } from './student';
// import {Observable} from 'rxjs/Rx';
// Import RxJs required methods
// import 'rxjs/add/operator/map';
// import 'rxjs/add/operator/catch';
export class StudentsListService {
// Resolve HTTP using the constructor
constructor () {}
// private instance variable to hold base url
private studentsListUrl = 'http://eepal.dev/drupal/students/list';
// Fetch all existing comments
/* getStudents() : Observable<Student[]> {
console.log("hello from service");
// ...using get request
return this.http.get(this.studentsListUrl)
// ...and calling .json() on the response to return data
.map((res:Response) => res.json())
//...errors if any
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}*/
}
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