From 44049bf900ed7035755b43042beec027e6a2ac2f Mon Sep 17 00:00:00 2001 From: RakVhalate Date: Sat, 17 Dec 2022 20:57:29 +0500 Subject: [PATCH] Small Changes --- src/app/const/alert.ts | 20 +++++++++++++++++ src/app/const/api.ts | 22 ------------------- .../pages/BoardThreads/threads.component.ts | 5 +++++ .../pages/SingleThread/boards.component.ts | 13 ++++++----- .../pages/send-form/send-form.component.ts | 5 +++-- 5 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 src/app/const/alert.ts diff --git a/src/app/const/alert.ts b/src/app/const/alert.ts new file mode 100644 index 0000000..b3db92e --- /dev/null +++ b/src/app/const/alert.ts @@ -0,0 +1,20 @@ +const ALERT_SHOW_TIME = 5000; +const showAlert = (message:string, color:string) => { + const alertContainer = document.createElement('div'); + alertContainer.style.zIndex = '100'; + alertContainer.style.position = 'fixed'; + alertContainer.style.left = '50'; + alertContainer.style.top = '0'; + alertContainer.style.right = '0'; + alertContainer.style.padding = '30px 3px'; + alertContainer.style.fontSize = '20px'; + alertContainer.style.textAlign = 'right'; + alertContainer.style.backgroundColor = color; + alertContainer.style.border = "2px dashed #6CFFDD" + alertContainer.textContent = message; + document.body.append(alertContainer); + setTimeout(() => { + alertContainer.remove(); + }, ALERT_SHOW_TIME); +} +export {showAlert} \ No newline at end of file diff --git a/src/app/const/api.ts b/src/app/const/api.ts index 61dc6c0..0a733c9 100644 --- a/src/app/const/api.ts +++ b/src/app/const/api.ts @@ -1,24 +1,2 @@ export const api_endpoint: string = 'http://api.vdk2ch.ru:5000/'; //export const api_endpoint: string = 'http://localhost:7141/'; - - -const ALERT_SHOW_TIME = 5000; -const showAlert = (message:string, color:string) => { - const alertContainer = document.createElement('div'); - alertContainer.style.zIndex = '100'; - alertContainer.style.position = 'fixed'; - alertContainer.style.left = '50'; - alertContainer.style.top = '0'; - alertContainer.style.right = '0'; - alertContainer.style.padding = '30px 3px'; - alertContainer.style.fontSize = '20px'; - alertContainer.style.textAlign = 'right'; - alertContainer.style.backgroundColor = color; - alertContainer.style.border = "2px dashed #6CFFDD" - alertContainer.textContent = message; - document.body.append(alertContainer); - setTimeout(() => { - alertContainer.remove(); - }, ALERT_SHOW_TIME); -} -export {showAlert} diff --git a/src/app/pages/BoardThreads/threads.component.ts b/src/app/pages/BoardThreads/threads.component.ts index 9a616f2..ade5cf8 100644 --- a/src/app/pages/BoardThreads/threads.component.ts +++ b/src/app/pages/BoardThreads/threads.component.ts @@ -1,7 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import { showAlert } from 'src/app/const/alert'; import {SinglePost} from "../../models/post"; import {ApiChatService} from "../../services/api-chat.service"; + @Component({ selector: 'app-BoardThreads', templateUrl: './threads.component.html', @@ -27,6 +29,7 @@ export class ThreadsComponent implements OnInit { alert(tosend: any){ console.log("Получен эмит создания треда " + tosend.text); console.log("С картинками: " + tosend.images) + showAlert("Cкоро можно будет создавать треды" , "#ff0a36"); } ngOnInit(): void { @@ -35,3 +38,5 @@ export class ThreadsComponent implements OnInit { }) } } + + diff --git a/src/app/pages/SingleThread/boards.component.ts b/src/app/pages/SingleThread/boards.component.ts index a022df5..b26508a 100644 --- a/src/app/pages/SingleThread/boards.component.ts +++ b/src/app/pages/SingleThread/boards.component.ts @@ -2,6 +2,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { ApiChatService } from '../../services/api-chat.service'; import { SinglePost } from '../../models/post' import * as vars from "../../const/api" +import { showAlert } from 'src/app/const/alert'; import {ActivatedRoute} from "@angular/router"; @Component({ @@ -29,14 +30,16 @@ export class BoardsComponent implements OnInit { }) } - sendPost(tosend: any){ - console.log(`Получен эмит создания поста с текстом ${tosend.text}`); - console.log("С картинками: " + tosend.images) + sendPost(toSend: any){ + console.log(`Получен эмит создания поста с текстом ${toSend.text}`); + console.log("С картинками: " + toSend.images) console.log("В тред " + this.threadId) - this.apiChatService.sendPostToApi(tosend.text, tosend.images, this.threadId).subscribe( response => { + + + this.apiChatService.sendPostToApi(toSend.text, toSend.images, this.threadId).subscribe( response => { response = response.toString(); - vars.showAlert(response.toString(), "#ff0a36"); + showAlert(response.toString(), "#ff0a36"); this.getThreadPosts(); }); } diff --git a/src/app/pages/send-form/send-form.component.ts b/src/app/pages/send-form/send-form.component.ts index b9800dc..fe096d5 100644 --- a/src/app/pages/send-form/send-form.component.ts +++ b/src/app/pages/send-form/send-form.component.ts @@ -1,4 +1,5 @@ import { Component, Output, EventEmitter, Input, OnInit } from '@angular/core'; +import { showAlert } from 'src/app/const/alert'; import { ApiChatService } from 'src/app/services/api-chat.service'; import * as vars from "../../const/api" @@ -11,7 +12,7 @@ export class SendFormComponent implements OnInit { @Input() board: string; showForm:boolean = false; - inputText: string; + // inputText: string; inputImages: string[] = []; @Output() sendInfoToCreate = new EventEmitter(); @@ -36,7 +37,7 @@ export class SendFormComponent implements OnInit { response => { response = response.value.toString(); this.inputImages.push(response); - vars.showAlert(`Картинка ${response} добавлена`, "#ff0a36") + showAlert(`Картинка ${response} добавлена`, "#ff0a36") }); }