Skip to content
Open
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
17,253 changes: 17,224 additions & 29 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AppComponent {
static readonly api = {
user: {
retrieve: `${environment.backend}/user/retrieve?size=1000`,
create: `${environment.backend}/user/create`
},
};
}
30 changes: 16 additions & 14 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {CoreModule} from "./core/core.module";
import {SharedModule} from "./shared/shared.module";
import {HttpClient, HttpClientModule} from "@angular/common/http";
import {FormsModule} from "@angular/forms";

@NgModule({
declarations: [
Expand All @@ -18,20 +19,21 @@ import {HttpClient, HttpClientModule} from "@angular/common/http";
UserFormComponent,
UserSearchComponent,
],
imports: [
BrowserAnimationsModule,
BrowserModule,
CoreModule,
HttpClientModule,
RouterModule.forRoot([
{path: 'user', redirectTo: 'user/search', pathMatch: 'full' },
{path: 'user/form', component: UserFormComponent },
{path: 'user/search', component: UserSearchComponent },
{path: '', component: HomeComponent },
{path: '**', redirectTo: '', pathMatch: 'full' },
]),
SharedModule,
],
imports: [
BrowserAnimationsModule,
BrowserModule,
CoreModule,
HttpClientModule,
RouterModule.forRoot([
{path: 'user', redirectTo: 'user/search', pathMatch: 'full'},
{path: 'user/form', component: UserFormComponent},
{path: 'user/search', component: UserSearchComponent},
{path: '', component: HomeComponent},
{path: '**', redirectTo: '', pathMatch: 'full'},
]),
SharedModule,
FormsModule,
],
providers: [HttpClient],
bootstrap: [AppComponent]
})
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/service/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class UserService {
constructor(private httpClient: HttpClient) {}

retrieve(): Observable<User[]> {
return this.httpClient.post<User[]>(AppComponent.api.user.retrieve, {});
const resposne = this.httpClient.get<User[]>(AppComponent.api.user.retrieve, {});
console.log(resposne);
return resposne;
}
}
10 changes: 7 additions & 3 deletions src/app/core/store/user/user.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ export interface UserState {
}

export interface User {
id: string;
name: string;
updated: string;
firstName: string;
middleName: string;
lastName: string;
phoneNumber: string;
email: string;
password: string;
role: string;
}

export const initialUserState: UserState = {
Expand Down
58 changes: 38 additions & 20 deletions src/app/user/user-form/user-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,42 @@
User Form
</div>
<div class="form-container">
<mat-form-field appearance="fill">
<mat-label>First Name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Middle Name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Last Name</mat-label>
<input matInput>
</mat-form-field>
<div class="button-container">
<button mat-raised-button color="primary">
Save
</button>
<button routerLink="/user" mat-raised-button color="accent">
Back
</button>
</div>
<form #loginForm=ngForm (ngSubmit)="submit(loginForm)">
<mat-form-field appearance="fill">
<mat-label>First Name</mat-label>
<input matInput ngModel name="firstName" >
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Middle Name</mat-label>
<input matInput ngModel name="middleName">
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Last Name</mat-label>
<input matInput ngModel name="lastName">
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Phone Number</mat-label>
<input matInput ngModel name="phoneNumber">
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Email</mat-label>
<input matInput ngModel name="email">
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Password</mat-label>
<input matInput ngModel name="password">
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Role</mat-label>
<input matInput ngModel name="role">
</mat-form-field>
<div class="button-container">
<button mat-raised-button color="primary">
Save
</button>
<button routerLink="/user" mat-raised-button color="accent">
Back
</button>
</div>
</form>
</div>
28 changes: 27 additions & 1 deletion src/app/user/user-form/user-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
import { Component, OnInit } from '@angular/core';
import {NgForm} from "@angular/forms";
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {AppComponent} from "../../app.component";
import {throwError} from "rxjs";
import {catchError} from "rxjs/operators";

@Component({
templateUrl: './user-form.component.html',
styleUrls: ['./user-form.component.scss']
})
export class UserFormComponent implements OnInit {

constructor() { }
constructor(private httpClient: HttpClient) {

}

ngOnInit(): void {

}

private handleError(errorRes: HttpErrorResponse) {
return throwError(errorRes.error.error.message);
}

submit(loginForm: NgForm) {
const data = loginForm.value;
console.log("button clicked " + data.firstName + " " + data.lastName + ' ' + AppComponent.api.user.create);
return this.httpClient.post(AppComponent.api.user.create, {
firstName: data.firstName,
middleName: data.middleName,
lastName: data.lastName,
phoneNumber: data.phoneNumber,
email: data.email,
password: data.password,
role: data.role
}).subscribe();
}

}
9 changes: 9 additions & 0 deletions src/app/user/user-search/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface User {
firstName: string;
middleName: string;
lastName: string;
phoneNumber: string;
email: string;
password: string;
role: string;
}
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

export const environment = {
backend: "https://java.bravolt.dev",
backend: "http://localhost:9999",
production: true
};
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

export const environment = {
backend: "https://java.bravolt.dev",
backend: "http://localhost:9999",
production: false,
};