Skip to content

Commit 7d6712b

Browse files
committed
updated url and spring consul gateway ->url change
1 parent 06a6f16 commit 7d6712b

File tree

6 files changed

+127
-99
lines changed

6 files changed

+127
-99
lines changed

src/app/diary/diary.service.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ import { Observable } from 'rxjs';
44
import { Diary } from './diary';
55

66
@Injectable({
7-
providedIn: 'root'
7+
providedIn: 'root',
88
})
99
export class DiaryService {
10-
11-
baseUrl = 'http://127.0.0.1:1700/diary';
12-
constructor(private http: HttpClient) { }
13-
10+
baseUrl = 'http://127.0.0.1:9000/diary';
11+
constructor(private http: HttpClient) {}
1412

1513
getDiary(): Observable<Diary[]> {
1614
return this.http.get<Diary[]>(this.baseUrl).pipe();
1715
}
1816
addDiary(diary: Diary): Observable<any> {
19-
return this.http.post(this.baseUrl, diary,{responseType:'text'}).pipe();
17+
return this.http.post(this.baseUrl, diary, { responseType: 'text' }).pipe();
2018
}
2119
editDiary(diary: Diary): Observable<any> {
22-
return this.http.put(this.baseUrl, diary,{responseType:'text'}).pipe();
20+
return this.http.put(this.baseUrl, diary, { responseType: 'text' }).pipe();
2321
}
2422
deleteDiary(diaryId): Observable<any> {
25-
return this.http.delete(this.baseUrl + "/" + diaryId,{responseType:'text'}).pipe();
23+
return this.http
24+
.delete(this.baseUrl + '/' + diaryId, { responseType: 'text' })
25+
.pipe();
2626
}
2727
}

src/app/idea/idea.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Idea } from './idea';
88
})
99
export class IdeaService {
1010

11-
baseUrl = 'http://127.0.0.1:1800/idea';
11+
baseUrl = 'http://127.0.0.1:9000/idea';
1212
constructor(private http: HttpClient) { }
1313

1414

src/app/story/story.component.html

+113-85
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,122 @@
1-
<div style="min-height:82vh;">
2-
<div class="container">
3-
4-
5-
<div *ngIf="listing" class="my-5">
6-
7-
8-
<div class="row">
9-
<span class="fs-3 ">Your Stories
10-
<button class="btn btn-secondary float-end" (click)="openCreateForm()">Add
11-
New</button></span>
12-
</div>
13-
<div class="mx-5 py-3" *ngFor="
14-
let story of stories | sortByDate
1+
<div style="min-height: 82vh">
2+
<div class="container">
3+
<div *ngIf="listing" class="my-5">
4+
<div class="row">
5+
<span class="fs-3"
6+
>Your Stories
7+
<button
8+
class="btn btn-secondary float-end"
9+
(click)="openCreateForm()"
10+
>
11+
Add New
12+
</button></span
13+
>
14+
</div>
15+
<div
16+
class="mx-5 py-3"
17+
*ngFor="
18+
let story of stories
19+
| sortByDate
1520
| paginate
16-
: {
17-
itemsPerPage: tableSize,
18-
currentPage: page,
19-
totalItems: count
20-
};
21-
let i = index
22-
23-
">
24-
25-
<div class="row pb-2">
26-
<div>
27-
<span class="float-start fs-3"> {{story.title}}</span>
28-
<span class="float-end text-primary"> Date :- {{story.created_at | date:'mediumDate'}}</span>
29-
30-
</div>
31-
</div>
32-
33-
34-
<div [innerHTML]="story.content | safeHtml" class="p-2"></div>
35-
36-
<button class="btn btn-outline-secondary me-2" (click)="openEditForm(story.id)">Edit</button>
37-
<button class="btn btn-outline-danger" (click)="deleteStory(story.id)">Delete</button>
38-
</div>
39-
<div style="min-height: 60vh;" class="text-center m-auto" *ngIf="stories.length==0">
40-
No story found
41-
</div>
42-
<div class="d-flex justify-content-center">
43-
<pagination-controls previousLabel="Prev" nextLabel="Next" (pageChange)="onTableDataChange($event)">
44-
</pagination-controls>
45-
</div>
21+
: {
22+
itemsPerPage: tableSize,
23+
currentPage: page,
24+
totalItems: count
25+
};
26+
let i = index
27+
"
28+
>
29+
<div class="row pb-2">
30+
<div>
31+
<span class="float-start fs-3"> {{ story.title }}</span>
32+
<span class="float-end text-primary">
33+
Date :- {{ story.createdAt | date: "medium" }}</span
34+
>
35+
</div>
4636
</div>
47-
<div *ngIf="openForm" class="mx-5 my-4">
48-
<p class="fs-3 text-center">
49-
<button class="btn btn-warning float-start" (click)="listing=true;openForm=false;">Go Back</button>
50-
Add Your Story
51-
</p>
5237

53-
<form [formGroup]="storyForm" (ngSubmit)="editButton==false?addStory():editStoryFun()">
54-
<div class="mb-3">
55-
<label class="form-label">Title</label>
56-
<input type="text" class="form-control" formControlName="title">
57-
<p *ngIf="(
58-
storyForm.controls['title'].dirty ||
59-
storyForm.controls['title'].touched ||
60-
storyForm.controls['title'].pristine) &&
61-
storyForm.controls['title'].errors
62-
" class="alert alert-danger">This Field is Required</p>
63-
</div>
64-
<div class="mb-3">
65-
<label class="form-label">Content</label>
66-
<ckeditor #editor formControlName="content">
67-
</ckeditor>
68-
<p *ngIf="(
69-
storyForm.controls['content'].dirty ||
70-
storyForm.controls['content'].touched ||
71-
storyForm.controls['content'].pristine) &&
72-
storyForm.controls['content'].errors
73-
" class="alert alert-danger">This Field is Required</p>
74-
</div>
75-
<div class="mb-3">
76-
<label class="form-label">Created At</label>
77-
<input type="datetime-local" class="form-control"
78-
formControlName="created_at">
79-
<p *ngIf="(
80-
storyForm.controls['created_at'].dirty ||
81-
storyForm.controls['created_at'].touched ||
82-
storyForm.controls['created_at'].pristine) &&
83-
storyForm.controls['created_at'].errors
84-
" class="alert alert-danger">This Field is Required</p>
85-
</div>
38+
<div [innerHTML]="story.content | safeHtml" class="p-2"></div>
8639

87-
<button type="submit" class="btn btn-primary" [disabled]="!storyForm.valid">Submit
88-
</button>
40+
<button
41+
class="btn btn-outline-secondary me-2"
42+
(click)="openEditForm(story.id)"
43+
>
44+
Edit
45+
</button>
46+
<button class="btn btn-outline-danger" (click)="deleteStory(story.id)">
47+
Delete
48+
</button>
49+
</div>
50+
<div
51+
style="min-height: 60vh"
52+
class="text-center m-auto"
53+
*ngIf="stories.length == 0"
54+
>
55+
No story found
56+
</div>
57+
<div class="d-flex justify-content-center">
58+
<pagination-controls
59+
previousLabel="Prev"
60+
nextLabel="Next"
61+
(pageChange)="onTableDataChange($event)"
62+
>
63+
</pagination-controls>
64+
</div>
65+
</div>
66+
<div *ngIf="openForm" class="mx-5 my-4">
67+
<p class="fs-3 text-center">
68+
<button
69+
class="btn btn-warning float-start"
70+
(click)="listing = true; openForm = false"
71+
>
72+
Go Back
73+
</button>
74+
Add Your Story
75+
</p>
8976

90-
</form>
77+
<form
78+
[formGroup]="storyForm"
79+
(ngSubmit)="editButton == false ? addStory() : editStoryFun()"
80+
>
81+
<div class="mb-3">
82+
<label class="form-label">Title</label>
83+
<input type="text" class="form-control" formControlName="title" />
84+
<p
85+
*ngIf="
86+
(storyForm.controls['title'].dirty ||
87+
storyForm.controls['title'].touched ||
88+
storyForm.controls['title'].pristine) &&
89+
storyForm.controls['title'].errors
90+
"
91+
class="alert alert-danger"
92+
>
93+
This Field is Required
94+
</p>
95+
</div>
96+
<div class="mb-3">
97+
<label class="form-label">Content</label>
98+
<ckeditor #editor formControlName="content"> </ckeditor>
99+
<p
100+
*ngIf="
101+
(storyForm.controls['content'].dirty ||
102+
storyForm.controls['content'].touched ||
103+
storyForm.controls['content'].pristine) &&
104+
storyForm.controls['content'].errors
105+
"
106+
class="alert alert-danger"
107+
>
108+
This Field is Required
109+
</p>
91110
</div>
92111

112+
<button
113+
type="submit"
114+
class="btn btn-primary"
115+
[disabled]="!storyForm.valid"
116+
>
117+
Submit
118+
</button>
119+
</form>
93120
</div>
121+
</div>
94122
</div>

src/app/story/story.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class StoryComponent implements OnInit {
4444
next: (stories) => {
4545

4646
this.toastr.success("Data inserted successfully !!")
47-
this.stories.push(story);
47+
this.getStories();
4848
},
4949
error: errror => console.log(errror),
5050
});
@@ -103,7 +103,7 @@ export class StoryComponent implements OnInit {
103103
this.storyForm = this.formbuilder.group({
104104
title: ['', [Validators.required, Validators.maxLength(255)]],
105105
content: ['', Validators.required],
106-
created_at: ['', [Validators.required]],
106+
107107
});
108108
this.listing = false; this.openForm = true;
109109
}
@@ -116,7 +116,7 @@ export class StoryComponent implements OnInit {
116116
id: [story[0]['id']],
117117
title: [story[0]['title'], [Validators.required, Validators.maxLength(255)]],
118118
content: [story[0]['content'], Validators.required],
119-
created_at: [story[0]['created_at'], [Validators.required]],
119+
120120
});
121121
this.listing = false; this.openForm = true;
122122
}

src/app/story/story.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { HttpClient } from '@angular/common/http';
77
providedIn: 'root'
88
})
99
export class StoryService {
10-
baseUrl = 'http://127.0.0.1:1900/story';
10+
baseUrl = 'http://127.0.0.1:9000/story';
1111
constructor(private http: HttpClient) { }
1212

1313

src/app/story/story.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export class Story {
22
id!: Number;
33
title!: String;
44
content!: String;
5-
created_at!: Date;
5+
createdAt!: Date;
66
}

0 commit comments

Comments
 (0)