This commit is contained in:
parent
984c47c045
commit
44049bf900
20
src/app/const/alert.ts
Normal file
20
src/app/const/alert.ts
Normal file
@ -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}
|
@ -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}
|
||||
|
@ -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 {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
@ -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")
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user