diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index bcc2c20..6bbd04a 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -3,8 +3,9 @@ "", "\\src", "\\src\\app", - "\\src\\app\\boards", + "\\src\\app\\send-post", "\\src\\app\\services" ], + "SelectedNode": "\\src\\app\\services\\api-chat.service.ts", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 00ba346..6bc0bea 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/src/app/boards/post/post.component.html b/src/app/boards/post/post.component.html index 7181ce5..30589a8 100644 --- a/src/app/boards/post/post.component.html +++ b/src/app/boards/post/post.component.html @@ -1,5 +1,5 @@
- anonpls # {{post.Id}} + anonpls # {{post.Id}}

{{post.Timestamp}}

{{post.Text}}

diff --git a/src/app/models/post.ts b/src/app/models/post.ts index fce1055..5a7cf0b 100644 --- a/src/app/models/post.ts +++ b/src/app/models/post.ts @@ -2,5 +2,5 @@ export interface SinglePost { Timestamp: string Id: number Text: string - + ImgURL: string } diff --git a/src/app/send-post/send-post.component.html b/src/app/send-post/send-post.component.html index d518dcf..d62918f 100644 --- a/src/app/send-post/send-post.component.html +++ b/src/app/send-post/send-post.component.html @@ -5,5 +5,7 @@

Загрузить картинку:

- + + +

{{filename}} : {{progress}}

diff --git a/src/app/send-post/send-post.component.ts b/src/app/send-post/send-post.component.ts index 9f9d36c..682466f 100644 --- a/src/app/send-post/send-post.component.ts +++ b/src/app/send-post/send-post.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { ApiChatService } from '../services/api-chat.service'; import { MinIoService } from '../services/min-io.service.' @@ -9,15 +9,22 @@ import { MinIoService } from '../services/min-io.service.' }) export class SendPostComponent implements OnInit { + progress: number; + message: string; + filename = ''; + constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) { } + sendPost(text: string) { this.apiChatService.sendPostToApi(text).subscribe(); } sendPic(event: any) { - this.minIoService.SendPicture(event); + this.filename = event.target.files[0].name; + //console.log(event.target.files[0]); + this.apiChatService.sendpic(event.target.files[0]).subscribe(); } ngOnInit(): void { diff --git a/src/app/services/api-chat.service.ts b/src/app/services/api-chat.service.ts index f51b005..dcb8d37 100644 --- a/src/app/services/api-chat.service.ts +++ b/src/app/services/api-chat.service.ts @@ -11,20 +11,29 @@ export class ApiChatService { } getPosts(): Observable { - console.log("Получаю данные из сервиса"); + console.log("Получаю посты"); return this.http.get('http://api.vdk2ch.ru:5000/List/'); //return this.http.get('http://localhost:7141/List/'); } - sendPostToApi(text: string) { + sendPostToApi(text: string) { console.log("Отправляю пост..."); var postToSend = { Timestamp: text, Id: 0, - Text: text + Text: text, + Picture: text } - return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend) - //return this.http.post('http://localhost:7141/PostTo', postToSend) + //return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend) + return this.http.post('http://localhost:7141/PostTo', postToSend) + } -} + sendpic(picToSend: File) { + const formData = new FormData(); + formData.append('file', picToSend, picToSend.name); + return this.http.post('http://localhost:7141/UploadPic', formData) + } + + } +