From 57ef20f293325ae8a8467c290121d1d5834b01c6 Mon Sep 17 00:00:00 2001 From: RakVhalate Date: Fri, 18 Nov 2022 14:45:51 +1000 Subject: [PATCH] Redesign --- src/app/boards/boards.component.html | 6 ++++-- src/app/boards/boards.component.ts | 11 +++++++---- src/app/boards/post/post.component.css | 5 ++--- src/app/boards/post/post.component.html | 9 +++++---- src/app/models/post.ts | 4 +++- src/app/send-post/send-post.component.html | 1 + src/app/send-post/send-post.component.ts | 16 +++++++-------- src/app/services/api-chat.service.ts | 23 +++++++++++----------- src/app/var/api.ts | 6 ++++++ 9 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 src/app/var/api.ts diff --git a/src/app/boards/boards.component.html b/src/app/boards/boards.component.html index 2ea1a1b..a3d0f57 100644 --- a/src/app/boards/boards.component.html +++ b/src/app/boards/boards.component.html @@ -2,11 +2,13 @@ свiня ,

{{boardName}}

- +

{{displayed_thread_number}}

+ + - +
diff --git a/src/app/boards/boards.component.ts b/src/app/boards/boards.component.ts index 102f6ce..d3a764e 100644 --- a/src/app/boards/boards.component.ts +++ b/src/app/boards/boards.component.ts @@ -2,6 +2,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { ApiChatService } from '../services/api-chat.service'; import { HttpClient } from '@angular/common/http'; import { SinglePost } from '../models/post' +import * as vars from '../var/api' @Component({ selector: 'app-boards', @@ -12,20 +13,22 @@ export class BoardsComponent implements OnInit { command: string = ""; response: any; postsToShow: SinglePost[] = [] - boardName:string = 'postgres'; + boardName:string = 'b'; + displayed_thread_number = vars.displayed_thread; constructor(public apiChatService: ApiChatService) { } - refreshPosts(boardName: string) { - this.apiChatService.getPosts(boardName).subscribe(response => { + refreshPosts(boardName: string , threadId:number) { + this.apiChatService.getPosts(boardName, threadId).subscribe(response => { this.postsToShow = response + vars.setDisplayedThread(this.displayed_thread_number); }) } ngOnInit(): void { - this.apiChatService.getPosts('postgres').subscribe(response => { + this.apiChatService.getPosts('postgres', vars.displayed_thread).subscribe(response => { this.postsToShow = response }) } diff --git a/src/app/boards/post/post.component.css b/src/app/boards/post/post.component.css index 2dbaa49..36be19e 100644 --- a/src/app/boards/post/post.component.css +++ b/src/app/boards/post/post.component.css @@ -1,13 +1,12 @@ .post { - border-width: 1; + border-width: 1px; border-color: rgb(190,190,190); border-style: solid; background-color: #F0D0B6; border-radius: 5px; + padding:20px; width: 500px; word-break: break-word; word-wrap: break-word; - margin-left: auto; - margin-right: auto; margin-top: 6px; } diff --git a/src/app/boards/post/post.component.html b/src/app/boards/post/post.component.html index d3d7ad4..c92f0d8 100644 --- a/src/app/boards/post/post.component.html +++ b/src/app/boards/post/post.component.html @@ -1,8 +1,9 @@

# {{post.Id}} {{post.Timestamp}}

- - anonpls - - pic +
+ + + +

{{post.Text}}

diff --git a/src/app/models/post.ts b/src/app/models/post.ts index 5a7cf0b..459776a 100644 --- a/src/app/models/post.ts +++ b/src/app/models/post.ts @@ -2,5 +2,7 @@ export interface SinglePost { Timestamp: string Id: number Text: string - ImgURL: string + ImgURL: string[] + Thread_Id: number + Is_OP: boolean } diff --git a/src/app/send-post/send-post.component.html b/src/app/send-post/send-post.component.html index 7ec9cbb..1e3bbe4 100644 --- a/src/app/send-post/send-post.component.html +++ b/src/app/send-post/send-post.component.html @@ -1,5 +1,6 @@

Поведай миру что-нибудь хорошее.

+

diff --git a/src/app/send-post/send-post.component.ts b/src/app/send-post/send-post.component.ts index 71b7d48..ee007f1 100644 --- a/src/app/send-post/send-post.component.ts +++ b/src/app/send-post/send-post.component.ts @@ -2,6 +2,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"; +import * as vars from "../var/api"; @Component({ selector: 'app-send-post', @@ -12,28 +13,25 @@ export class SendPostComponent implements OnInit { progress: number; message: string; - filename = '0'; - - picResponse: IPicresponse - + filename: string[] = []; constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) { } - sendPost(text: string) { - this.apiChatService.sendPostToApi(text, this.filename).subscribe(); + var threadId = vars.displayed_thread; + this.apiChatService.sendPostToApi(text, this.filename, threadId).subscribe(); this.message = '0'; - this.filename = '0'; + this.filename = []; alert("Сообщение отправлено."); } sendPic(event: any) { this.apiChatService.sendpic(event.target.files[0]).subscribe( response => { - this.filename = response.value.toString() + response = response.value.toString(); + this.filename.push(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 1dd1f57..33d1b66 100644 --- a/src/app/services/api-chat.service.ts +++ b/src/app/services/api-chat.service.ts @@ -2,6 +2,8 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { SinglePost } from '../models/post'; +import * as globals from '../var/api'; + @Injectable({ providedIn: 'root' @@ -10,31 +12,28 @@ export class ApiChatService { constructor(private http: HttpClient) { } - getPosts(boardName:string): Observable { + getPosts(boardName:string, threadID: number): Observable { //console.log("Получаю посты и картинки"); - return this.http.get('http://api.vdk2ch.ru:5000/List/?board=' + boardName); - //return this.http.get('http://localhost:7141/List/?board=' + boardName); + return this.http.get(globals.api_endpoint +'List/', {params:{board: boardName , thread: threadID}}) ; } - sendPostToApi(text: string, imgUrl: string) { + sendPostToApi(text: string, imgUrl: string[], threadId: number,) { //console.log("Отправляю пост..."); var postToSend = { - Timestamp: text, + Timestamp: "time", Id: 0, Text: text, - ImgURL: imgUrl + ImgURL: imgUrl, + Thread_Id: threadId } - //console.log(postToSend) - return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend) - //return this.http.post('http://localhost:7141/PostTo', postToSend) - + return this.http.post( globals.api_endpoint +'PostTo', postToSend) } + 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(globals.api_endpoint +'UploadPic', PostPicture) } } diff --git a/src/app/var/api.ts b/src/app/var/api.ts new file mode 100644 index 0000000..8c2b568 --- /dev/null +++ b/src/app/var/api.ts @@ -0,0 +1,6 @@ +//export const api_endpoint: string = 'http://api.vdk2ch.ru:5000/'; +export const api_endpoint: string = 'http://localhost:7141/'; +export var displayed_thread: number = 2; +export function setDisplayedThread(toset:number){ + displayed_thread = toset; +};