diff --git a/src/app/models/picResponse.ts b/src/app/models/picResponse.ts new file mode 100644 index 0000000..cf90229 --- /dev/null +++ b/src/app/models/picResponse.ts @@ -0,0 +1,6 @@ +export interface IPicresponse { + contentType: null + serializerSettings: null + statusCode: null + value: string +} diff --git a/src/app/send-post/send-post.component.html b/src/app/send-post/send-post.component.html index d62918f..6908954 100644 --- a/src/app/send-post/send-post.component.html +++ b/src/app/send-post/send-post.component.html @@ -7,5 +7,5 @@

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

-

{{filename}} : {{progress}}

+

Картинка в статике: {{filename}}

diff --git a/src/app/send-post/send-post.component.ts b/src/app/send-post/send-post.component.ts index 682466f..eaf252d 100644 --- a/src/app/send-post/send-post.component.ts +++ b/src/app/send-post/send-post.component.ts @@ -1,6 +1,7 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { ApiChatService } from '../services/api-chat.service'; import { MinIoService } from '../services/min-io.service.' +import {IPicresponse} from "../models/picResponse"; @Component({ selector: 'app-send-post', @@ -11,20 +12,25 @@ export class SendPostComponent implements OnInit { progress: number; message: string; - filename = ''; + filename = '0'; + + picResponse: IPicresponse + constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) { } sendPost(text: string) { - this.apiChatService.sendPostToApi(text).subscribe(); + this.apiChatService.sendPostToApi(text, this.filename).subscribe(); } - sendPic(event: any) { - this.filename = event.target.files[0].name; - //console.log(event.target.files[0]); - this.apiChatService.sendpic(event.target.files[0]).subscribe(); + sendPic(event: any) { + this.apiChatService.sendpic(event.target.files[0]).subscribe( + response => { + this.picResponse = response + }); + this.filename = this.picResponse.value.toString() } ngOnInit(): void { diff --git a/src/app/services/api-chat.service.ts b/src/app/services/api-chat.service.ts index b75064c..7fb58f4 100644 --- a/src/app/services/api-chat.service.ts +++ b/src/app/services/api-chat.service.ts @@ -12,28 +12,29 @@ export class ApiChatService { getPosts(): Observable { console.log("Получаю посты и картинки"); - return this.http.get('http://api.vdk2ch.ru:5000/List/'); - //return this.http.get('http://localhost:7141/List/'); + //return this.http.get('http://api.vdk2ch.ru:5000/List/'); + return this.http.get('http://localhost:7141/List/'); } - sendPostToApi(text: string) { + sendPostToApi(text: string, imgUrl: string) { console.log("Отправляю пост..."); var postToSend = { Timestamp: text, Id: 0, Text: text, - ImgURL: "0" + ImgURL: imgUrl } - return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend) - //return this.http.post('http://localhost:7141/PostTo', postToSend) + console.log(postToSend) + //return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend) + return this.http.post('http://localhost:7141/PostTo', postToSend) } - sendpic(picToSend: File) { + sendpic(picToSend: File):Observable { const PostPicture = new FormData(); PostPicture.append('PostPicture', picToSend); - //return this.http.post('http://localhost:7141/UploadPic', PostPicture) - return this.http.post('http://api.vdk2ch.ru:5000/UploadPic', PostPicture) + return this.http.post('http://localhost:7141/UploadPic', PostPicture) + //return this.http.post('http://api.vdk2ch.ru:5000/UploadPic', PostPicture) } }