diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index fc703346bb9a708f21289258a2cb438c12d9bc9e..fb29b9167c4d5cdd2f077f9fba26de35f258c19a 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -5,6 +5,7 @@ import { HttpClientModule } from '@angular/common/http'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { PostModule } from './posts/post.module'; +import { SharedModule } from './shared/shared.module'; @NgModule({ declarations: [ @@ -14,6 +15,7 @@ import { PostModule } from './posts/post.module'; BrowserModule, AppRoutingModule, PostModule, + SharedModule, HttpClientModule ], providers: [], diff --git a/client/src/app/posts/post-form/post-form.component.html b/client/src/app/posts/post-form/post-form.component.html index d3731fb6946e0fab0e839a60a9814a0203f329c0..51f1e969366c895a3d55bcd1efb690e64ba43cc8 100644 --- a/client/src/app/posts/post-form/post-form.component.html +++ b/client/src/app/posts/post-form/post-form.component.html @@ -3,4 +3,6 @@ <p>Title: {{displayPost.getTitle}}</p> <p>Description: {{displayPost.getDescription}}</p> <p>Timestamp: {{displayPost.getTimestamp}}</p> -<p>Owner: {{displayPost.getOwner}}</p> \ No newline at end of file +<p>Owner: {{displayPost.getOwner}}</p> + +<app-text-input></app-text-input> \ No newline at end of file diff --git a/client/src/app/posts/post-form/post-form.component.spec.ts b/client/src/app/posts/post-form/post-form.component.spec.ts index ed44eee9d000622f422581b64a4989f6c907bbdb..e648ca926cdbca23c95b78f296a8133436097447 100644 --- a/client/src/app/posts/post-form/post-form.component.spec.ts +++ b/client/src/app/posts/post-form/post-form.component.spec.ts @@ -36,6 +36,6 @@ describe('PostFormComponent', () => { }) it('should deserialize Post', () => { - expect(component.deserializedPost.getUser).toEqual("Admin"); + expect(component.deserializedPost.getOwner).toEqual("Admin"); }) }); diff --git a/client/src/app/posts/post-form/post-form.component.ts b/client/src/app/posts/post-form/post-form.component.ts index c56ea19dd9be1ad36b4e3902aaae688edbaab0d6..212b51520480b55a7c2f19d93214c5794c156297 100644 --- a/client/src/app/posts/post-form/post-form.component.ts +++ b/client/src/app/posts/post-form/post-form.component.ts @@ -21,14 +21,14 @@ export class PostFormComponent implements OnInit { title: "TestAnnonse", description: "Beskrivelse", timestamp: 1612952332000, - user: "Admin", + owner: "Admin", imageUrl: "url" }); this.serializedPost = post.serialize(); this.deserializedPost.deserialize(post.serialize()); - this.postService.getPost(0) + this.postService.getPost(1) .then((gettedPost: Post) => { this.displayPost = gettedPost; }).catch((err: any) => { diff --git a/client/src/app/posts/post.module.ts b/client/src/app/posts/post.module.ts index 80a6a344243bbd98e2a125dca6b7815ca61c5a2c..6abbc81cc20a80c6df90eaba7924a90e2a98a5a8 100644 --- a/client/src/app/posts/post.module.ts +++ b/client/src/app/posts/post.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { PostFormComponent } from './post-form/post-form.component'; +import { SharedModule } from '../shared/shared.module'; @@ -9,7 +10,8 @@ import { PostFormComponent } from './post-form/post-form.component'; PostFormComponent ], imports: [ - CommonModule + CommonModule, + SharedModule ] }) export class PostModule { } diff --git a/client/src/app/posts/post.service.ts b/client/src/app/posts/post.service.ts index 2314d5d6fc7638cb0b46c74b47fe8b689e85c083..312369b1e0206f5371f19eb025996f8e2ebcdeaa 100644 --- a/client/src/app/posts/post.service.ts +++ b/client/src/app/posts/post.service.ts @@ -30,7 +30,7 @@ export class PostService { ); } - get_post(id: number) { + private get_post(id: number) { return this.http.get(this.postUrl + id); } @@ -48,7 +48,7 @@ export class PostService { ); } - add_post(post: Post) { + private add_post(post: Post) { return this.http.post(this.postUrl, post.serialize()); } } diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..cfbb9dbe6b4e5a43e9a0a7f0754cc0d3a68b71ea --- /dev/null +++ b/client/src/app/shared/shared.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { TextInputComponent } from './text-input/text-input.component'; + + + +@NgModule({ + declarations: [TextInputComponent], + exports: [TextInputComponent], + imports: [ + CommonModule + ] +}) +export class SharedModule { } diff --git a/client/src/app/shared/text-input/text-input.component.html b/client/src/app/shared/text-input/text-input.component.html new file mode 100644 index 0000000000000000000000000000000000000000..45be20b34d0a55ef106cc8623b220f2ad47d0ebd --- /dev/null +++ b/client/src/app/shared/text-input/text-input.component.html @@ -0,0 +1 @@ +<input type="text" id="textField"> \ No newline at end of file diff --git a/client/src/app/shared/text-input/text-input.component.scss b/client/src/app/shared/text-input/text-input.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..e8b11aacb8b616c3ad2b1a8ddb323ed57dc144e8 --- /dev/null +++ b/client/src/app/shared/text-input/text-input.component.scss @@ -0,0 +1,3 @@ +#textField{ + padding: 5px; +} \ No newline at end of file diff --git a/client/src/app/shared/text-input/text-input.component.spec.ts b/client/src/app/shared/text-input/text-input.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..f895776fe5022ace055990ea6f39868f964b89ec --- /dev/null +++ b/client/src/app/shared/text-input/text-input.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TextInputComponent } from './text-input.component'; + +describe('TextInputComponent', () => { + let component: TextInputComponent; + let fixture: ComponentFixture<TextInputComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ TextInputComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(TextInputComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/shared/text-input/text-input.component.ts b/client/src/app/shared/text-input/text-input.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..a739874a9e6ca425286c6d81a5b94618adb19898 --- /dev/null +++ b/client/src/app/shared/text-input/text-input.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-text-input', + templateUrl: './text-input.component.html', + styleUrls: ['./text-input.component.scss'] +}) +export class TextInputComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/server/package.json b/server/package.json index 6a225ce1ca349e18f1607c8c01dba5472d815cbc..d3e68d2c3d4ec28b509b1549a945dcc45fbe6ab5 100644 --- a/server/package.json +++ b/server/package.json @@ -4,7 +4,7 @@ "description": "REST API with MySQL", "main": "src/index.ts", "scripts": { - "start": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", + "start": "nodemon --watch 'src/**/*.ts' --exec \"ts-node\" src/index.ts", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "",