Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$output.file("web/src/app/entities/${entity.model.var}/${entity.model.var}-list.component.ts")##
import { Component, Input, Output, OnChanges, EventEmitter, SimpleChanges, Inject } from '@angular/core';
import { Component, Input, Output, OnChanges, EventEmitter, SimpleChanges} from '@angular/core';
import { Router } from '@angular/router';
import { DataTable, LazyLoadEvent } from 'primeng/primeng';
import { PageResponse } from "../../support/paging";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$output.file("web/src/app/entities/${entity.model.var}/${entity.model.var}.service.ts")##
import { Injectable } from '@angular/core';
import { HttpClientModule, HttpClient, HttpResponse, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { HttpClient, HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { LazyLoadEvent } from 'primeng/primeng';
import { MessageService } from '../../service/message.service';
import { PageResponse, PageRequestByExample } from '../../support/paging';
Expand All @@ -12,8 +12,6 @@ import 'rxjs/add/observable/throw';
@Injectable()
export class ${entity.service.type} {

private options = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };

constructor(private http: HttpClient, private messageService : MessageService) {}

/**
Expand All @@ -31,9 +29,9 @@ export class ${entity.service.type} {
* Update the passed ${entity.model.var}.
*/
update($entity.model.var : $entity.model.type) : Observable<$entity.model.type> {
let body = JSON.stringify($entity.model.var);
let body = $entity.model.var;

return this.http.put('/api/$entity.model.vars/', body, this.options)
return this.http.put('/api/$entity.model.vars/', body)
.pipe(
map(response => new ${entity.model.type}(response)),
catchError(this.handleError)
Expand All @@ -46,14 +44,11 @@ export class ${entity.service.type} {
*/
getPage($entity.model.var : $entity.model.type, event : LazyLoadEvent) : Observable<PageResponse<$entity.model.type>> {
let req = new PageRequestByExample($entity.model.var, event);
let body = JSON.stringify(req);
let body = req;

return this.http.post('/api/$entity.model.vars/page', body, this.options)
return this.http.post<PageResponse<any>>('/api/$entity.model.vars/page', body)
.pipe(
map(response => {
let pr : any = response;
return new PageResponse<$entity.model.type>(pr.totalPages, pr.totalElements, ${entity.model.type}.toArray(pr.content));
}),
map(pr => new PageResponse<$entity.model.type>(pr.totalPages, pr.totalElements, ${entity.model.type}.toArray(pr.content))),
catchError(this.handleError)
);
}
Expand All @@ -63,8 +58,8 @@ export class ${entity.service.type} {
* Used by ${entity.model.type}CompleteComponent.
*/
complete(query : string) : Observable<${entity.model.type}[]> {
let body = JSON.stringify({'query': query, 'maxResults': 10});
return this.http.post<any[]>('/api/$entity.model.vars/complete', body, this.options)
let body = {'query': query, 'maxResults': 10};
return this.http.post<any[]>('/api/$entity.model.vars/complete', body)
.pipe(
map(response => ${entity.model.type}.toArray(response)),
catchError(this.handleError)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$output.file("web/src/app/service/auth.service.ts")##

import { Injectable } from '@angular/core'
import { HttpClientModule, HttpHeaders, HttpClient, HttpErrorResponse } from '@angular/common/http';
import { HttpParams, HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import { catchError, map } from 'rxjs/operators';
import 'rxjs/add/observable/throw';
Expand All @@ -20,9 +20,16 @@ export class AuthService {

login(j_username : string, j_password : string) : Observable<boolean> {
console.log("login for " + j_username);
let body = 'j_username=' + j_username + '&j_password=' + j_password + '&submit=Login';
const params = {
j_username: j_username,
j_password: j_password,
submit: 'Login'
};

let body = new HttpParams({fromObject: params});


return this.http.post('/api/login', body, { headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' }), observe: 'response' })
return this.http.post('/api/login', body, { observe: 'response' })
.pipe(
map(res => res.status == 200),
catchError(this.handleError)
Expand Down
31 changes: 15 additions & 16 deletions quickstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
**Prerequisites:**

* [Java Development Kit 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [Maven 3.3.3](https://maven.apache.org/download.cgi)
* [Angular cli 1.6.3 ](https://github.com/angular/angular-cli#installation) - 1.6.3 is really required to work with Angular 5.0
* [Npm 3.x.x](https://nodejs.org/en/)
* [NodeJS 6.10](https://nodejs.org/en/)
* [Maven 3.5.x](https://maven.apache.org/download.cgi)
* [Angular cli 1.6.3 ](https://github.com/angular/angular-cli#installation) - 1.0.0 is really required to work with Angular 4.0
* [Npm 5.x.x](https://nodejs.org/en/)
* [NodeJS 8.x](https://nodejs.org/en/)


### Run these commands to generate and run an Angular 5.0 web app:
Expand All @@ -31,10 +31,9 @@ Make sure you wait until spring boot starts and listen on port 8080
**Then from a second console run:**

cd celerio-angular-quickstart/quickstart/web
npm install --save @angular/material @angular/cdk
npm install --save @angular/animations
npm install --save primeng@5.0.2
npm install --save font-awesome
npm i @angular/material @angular/cdk
npm i primeng
npm i font-awesome
ng serve --proxy-config proxy.conf.json

Then open [http://localhost:4200/](http://localhost:4200/)
Expand Down Expand Up @@ -91,10 +90,10 @@ The backend listens on port 8080.

The 4 command below install some additional dependencies required by the code generated by Celerio.

npm install --save @angular/material @angular/cdk
npm install --save @angular/animations
npm install --save primeng@5.0.2
npm install --save font-awesome
npm i @angular/material @angular/cdk
npm i primeng
npm i font-awesome


Starts a node server on port 4200 using angular cli. The node server proxies the calls to /api and /img to the
spring boot backend that runs in the first console.
Expand Down Expand Up @@ -174,10 +173,10 @@ Here are the command lines (hope it is self explanatory):
rm web/src/app/app.module.ts web/src/app/app.component.* web/src/styles.css
mvn -Pdb,metadata,gen generate-sources
cd web
npm install --save @angular/material @angular/cdk
npm install --save @angular/animations
npm install --save primeng@5.0.2
npm install --save font-awesome
npm i @angular/material @angular/cdk
npm i primeng
npm i font-awesome

ng build --prod
cp dist/* ../src/main/resources/static
cd ..
Expand Down
50 changes: 9 additions & 41 deletions quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<version>1.5.9.RELEASE</version>
</parent>

<properties>
Expand All @@ -22,12 +22,7 @@
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- maven-compiler-plugin -->
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>

<hibernate.version>5.0.2.Final</hibernate.version>
<spring-security.version>4.0.4.RELEASE</spring-security.version>
<java.version>1.8</java.version>

<!-- ~~~~~~~~ -->
<!-- Database -->
Expand All @@ -39,7 +34,7 @@
<!-- H2 DATABASE SETTINGS -->
<jdbc.groupId>com.h2database</jdbc.groupId>
<jdbc.artifactId>h2</jdbc.artifactId>
<jdbc.version>1.4.187</jdbc.version>
<jdbc.version>${h2.version}</jdbc.version>

<jdbc.driver>org.h2.Driver</jdbc.driver>
<jdbc.url>jdbc:h2:${project.build.directory}/db/angulardb;MVCC=TRUE;FILE_LOCK=NO</jdbc.url>
Expand All @@ -55,7 +50,7 @@
<!-- MYSQL DATABASE SETTINGS
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.1.40</jdbc.version>
<jdbc.version>${mysql.version}</jdbc.version>

<jdbc.driver>com.mysql.jdbc.Driver</jdbc.driver>
<jdbc.url>jdbc:mysql://127.0.0.1:3306/angulardb</jdbc.url>
Expand Down Expand Up @@ -100,21 +95,17 @@
<hibernate.use.second.level.cache>false</hibernate.use.second.level.cache>
<hibernate.use.query.cache>false</hibernate.use.query.cache>

<!-- use latest versions-->
<spring-data-releasetrain.version>Hopper-SR11</spring-data-releasetrain.version>

</properties>

<dependencies>
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<version>5.0.2.Final</version>
<version>${hibernate.version}</version>
</dependency>
<!-- Celerio code completion support in velocity templates -->
<!-- See pack-angular/META-INF/velocity_implicit.vm -->
Expand All @@ -138,14 +129,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand Down Expand Up @@ -191,16 +174,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -264,7 +242,7 @@
<!-- http://maven.apache.org/plugins/maven-resources-plugin/ -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<version>3.0.2</version>
<configuration>
<delimiters>
<delimiter>@*@</delimiter>
Expand All @@ -282,7 +260,7 @@
<!-- http://mojo.codehaus.org/build-helper-maven-plugin/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<version>3.0.0</version>
<executions>
<execution>
<id>Adding generated java folder to build</id>
Expand Down Expand Up @@ -314,16 +292,6 @@
</plugin>


<!-- Compiler plugin enforces Java compatibility and activates
annotation processors -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down