diff --git a/src/app/SingleThread/boards.component.html b/src/app/SingleThread/boards.component.html deleted file mode 100644 index 6002101..0000000 --- a/src/app/SingleThread/boards.component.html +++ /dev/null @@ -1,28 +0,0 @@ -
-свiня -, -

Вы находитесь на доске {{boardName}}

-

в треде номер {{displayed_thread_number}}

- Что это и как это работает? -
-
- Добро пожаловать на эту небольшую борду. Сейчас тут только три треда и одна доска, но скоро будет больше. - Чтобы выбрать тред воспользуйтесь полем ниже, после выбора нажмите кнопку "Обновить" дабы перейти в этот тред. - Вы можете отправлять сообщения в открытый тред и прикреплять к сообщению картинки. - Ведите себя хорошо. -
- -
- - - -
-
-
-
-
-
-
-
diff --git a/src/app/SingleThread/boards.component.ts b/src/app/SingleThread/boards.component.ts deleted file mode 100644 index 2e62cea..0000000 --- a/src/app/SingleThread/boards.component.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { ApiChatService } from '../services/api-chat.service'; -import { SinglePost } from '../models/post' -import * as vars from '../var/api' -import {ActivatedRoute} from "@angular/router"; -import {setDisplayedThread} from "../var/api"; - -@Component({ - selector: 'app-SingleThread', - templateUrl: `./boards.component.html`, - styleUrls: [`./boards.component.css`] -}) -export class BoardsComponent implements OnInit { - command: string = ""; - response: any; - postsToShow: SinglePost[] = [] - boardName:string = 'b'; - displayed_thread_number = vars.displayed_thread; - showGuide: boolean = false; - - constructor( - public apiChatService: ApiChatService, - private activatedRoute:ActivatedRoute - ){ - - } - refreshPosts(boardName: string , threadId:number) { - this.apiChatService.getPosts(boardName, threadId).subscribe(response => { - this.postsToShow = response - vars.setDisplayedThread(this.displayed_thread_number); - }) - } - - ngOnInit(): void { - var threadId = this.activatedRoute.snapshot.queryParamMap.get('thread'); - if(threadId != null) - { - this.displayed_thread_number = parseInt(threadId); - vars.setDisplayedThread(this.displayed_thread_number); - } - this.apiChatService.getPosts('postgres', this.displayed_thread_number).subscribe(response => { - this.postsToShow = response - }) - } - - -} - diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5272f87..c9f72e8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -5,16 +5,16 @@ import { HttpClientModule } from '@angular/common/http'; import { AppComponent } from './app.component'; -import { HomeComponent } from './home/home.component'; -import { AboutComponent } from './about/about.component'; -import { BoardsComponent } from './SingleThread/boards.component'; -import { NotFoundComponent } from './not-found/not-found.component'; +import { HomeComponent } from './pages/home/home.component'; +import { AboutComponent } from './pages/about/about.component'; +import { BoardsComponent } from './pages/SingleThread/boards.component'; +import { NotFoundComponent } from './pages/not-found/not-found.component'; import { ApiChatService } from './services/api-chat.service'; import { FormsModule } from '@angular/forms'; -import { SendPostComponent } from './send-post/send-post.component'; -import { PostComponent } from './SingleThread/post/post.component' -import { ThreadsComponent } from './BoardThreads/threads.component'; -import { OPComponent } from './BoardThreads/op/op.component'; +import { SendPostComponent } from './pages/send-post/send-post.component'; +import { PostComponent } from './pages/SingleThread/post/post.component' +import { ThreadsComponent } from './pages/BoardThreads/threads.component'; +import { OPComponent } from './pages/BoardThreads/op/op.component'; const appRoutes: Routes = [ { path: '', component: HomeComponent }, diff --git a/src/app/var/api.ts b/src/app/const/api.ts similarity index 87% rename from src/app/var/api.ts rename to src/app/const/api.ts index dbbd11c..61dc6c0 100644 --- a/src/app/var/api.ts +++ b/src/app/const/api.ts @@ -1,9 +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; -export function setDisplayedThread(toset:number){ - displayed_thread = toset; -}; + const ALERT_SHOW_TIME = 5000; const showAlert = (message:string, color:string) => { diff --git a/src/app/BoardThreads/op/op.component.css b/src/app/pages/BoardThreads/op/op.component.css similarity index 100% rename from src/app/BoardThreads/op/op.component.css rename to src/app/pages/BoardThreads/op/op.component.css diff --git a/src/app/BoardThreads/op/op.component.html b/src/app/pages/BoardThreads/op/op.component.html similarity index 100% rename from src/app/BoardThreads/op/op.component.html rename to src/app/pages/BoardThreads/op/op.component.html diff --git a/src/app/BoardThreads/op/op.component.spec.ts b/src/app/pages/BoardThreads/op/op.component.spec.ts similarity index 100% rename from src/app/BoardThreads/op/op.component.spec.ts rename to src/app/pages/BoardThreads/op/op.component.spec.ts diff --git a/src/app/BoardThreads/op/op.component.ts b/src/app/pages/BoardThreads/op/op.component.ts similarity index 85% rename from src/app/BoardThreads/op/op.component.ts rename to src/app/pages/BoardThreads/op/op.component.ts index ca61e2b..ec0cbc1 100644 --- a/src/app/BoardThreads/op/op.component.ts +++ b/src/app/pages/BoardThreads/op/op.component.ts @@ -1,5 +1,5 @@ import {Component, Input, OnInit} from '@angular/core'; -import { SinglePost } from '../../models/post'; +import { SinglePost } from '../../../models/post'; @Component({ selector: 'op-single', diff --git a/src/app/BoardThreads/threads.component.css b/src/app/pages/BoardThreads/threads.component.css similarity index 100% rename from src/app/BoardThreads/threads.component.css rename to src/app/pages/BoardThreads/threads.component.css diff --git a/src/app/BoardThreads/threads.component.html b/src/app/pages/BoardThreads/threads.component.html similarity index 100% rename from src/app/BoardThreads/threads.component.html rename to src/app/pages/BoardThreads/threads.component.html diff --git a/src/app/BoardThreads/threads.component.spec.ts b/src/app/pages/BoardThreads/threads.component.spec.ts similarity index 100% rename from src/app/BoardThreads/threads.component.spec.ts rename to src/app/pages/BoardThreads/threads.component.spec.ts diff --git a/src/app/BoardThreads/threads.component.ts b/src/app/pages/BoardThreads/threads.component.ts similarity index 73% rename from src/app/BoardThreads/threads.component.ts rename to src/app/pages/BoardThreads/threads.component.ts index d0701d9..f1e2751 100644 --- a/src/app/BoardThreads/threads.component.ts +++ b/src/app/pages/BoardThreads/threads.component.ts @@ -1,7 +1,6 @@ import { Component, OnInit } from '@angular/core'; -import * as vars from "../var/api"; -import {SinglePost} from "../models/post"; -import {ApiChatService} from "../services/api-chat.service"; +import {SinglePost} from "../../models/post"; +import {ApiChatService} from "../../services/api-chat.service"; @Component({ selector: 'app-BoardThreads', @@ -14,7 +13,6 @@ export class ThreadsComponent implements OnInit { command: string = ""; response: any; opsToShow: SinglePost[] = [] - displayed_thread_number = vars.displayed_thread; showGuide: boolean = false; constructor(public apiChatService: ApiChatService) { @@ -23,7 +21,6 @@ export class ThreadsComponent implements OnInit { refreshOPs(boardName: string) { this.apiChatService.getThreads(boardName).subscribe(response => { this.opsToShow = response - vars.setDisplayedThread(this.displayed_thread_number); }) } diff --git a/src/app/SingleThread/boards.component.css b/src/app/pages/SingleThread/boards.component.css similarity index 100% rename from src/app/SingleThread/boards.component.css rename to src/app/pages/SingleThread/boards.component.css diff --git a/src/app/pages/SingleThread/boards.component.html b/src/app/pages/SingleThread/boards.component.html new file mode 100644 index 0000000..a09a066 --- /dev/null +++ b/src/app/pages/SingleThread/boards.component.html @@ -0,0 +1,21 @@ +
+свiня +, +

Вы находитесь на доске {{boardName}}

+

в треде номер {{threadId}}

+ Что это и как это работает? +
+
+ + + +
+
+
+
+
+
+
+
diff --git a/src/app/SingleThread/boards.component.spec.ts b/src/app/pages/SingleThread/boards.component.spec.ts similarity index 100% rename from src/app/SingleThread/boards.component.spec.ts rename to src/app/pages/SingleThread/boards.component.spec.ts diff --git a/src/app/pages/SingleThread/boards.component.ts b/src/app/pages/SingleThread/boards.component.ts new file mode 100644 index 0000000..1d2887d --- /dev/null +++ b/src/app/pages/SingleThread/boards.component.ts @@ -0,0 +1,37 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { ApiChatService } from '../../services/api-chat.service'; +import { SinglePost } from '../../models/post' +import {ActivatedRoute} from "@angular/router"; + +@Component({ + selector: 'app-SingleThread', + templateUrl: `./boards.component.html`, + styleUrls: [`./boards.component.css`] +}) +export class BoardsComponent implements OnInit { + command: string = ""; + response: any; + postsToShow: SinglePost[] = [] + boardName:string = 'b'; + showGuide: boolean = false; + threadId: number; + + constructor( + public apiChatService: ApiChatService, + private activatedRoute:ActivatedRoute + ){ + + } + refreshPosts(boardName: string , threadId:number) { + this.apiChatService.getPosts(boardName, this.threadId).subscribe(response => { + this.postsToShow = response + }) + } + + ngOnInit(): void { + this.threadId = parseInt(this.activatedRoute.snapshot.queryParamMap.get('thread')); + this.apiChatService.getPosts('postgres', this.threadId).subscribe(response => { + this.postsToShow = response + }) + } +} diff --git a/src/app/SingleThread/post/post.component.css b/src/app/pages/SingleThread/post/post.component.css similarity index 100% rename from src/app/SingleThread/post/post.component.css rename to src/app/pages/SingleThread/post/post.component.css diff --git a/src/app/SingleThread/post/post.component.html b/src/app/pages/SingleThread/post/post.component.html similarity index 100% rename from src/app/SingleThread/post/post.component.html rename to src/app/pages/SingleThread/post/post.component.html diff --git a/src/app/SingleThread/post/post.component.ts b/src/app/pages/SingleThread/post/post.component.ts similarity index 84% rename from src/app/SingleThread/post/post.component.ts rename to src/app/pages/SingleThread/post/post.component.ts index 4bff470..7c1b1c8 100644 --- a/src/app/SingleThread/post/post.component.ts +++ b/src/app/pages/SingleThread/post/post.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input } from '@angular/core'; -import { SinglePost } from '../../models/post'; +import { SinglePost } from '../../../models/post'; diff --git a/src/app/about/about.component.css b/src/app/pages/about/about.component.css similarity index 100% rename from src/app/about/about.component.css rename to src/app/pages/about/about.component.css diff --git a/src/app/about/about.component.html b/src/app/pages/about/about.component.html similarity index 100% rename from src/app/about/about.component.html rename to src/app/pages/about/about.component.html diff --git a/src/app/about/about.component.spec.ts b/src/app/pages/about/about.component.spec.ts similarity index 100% rename from src/app/about/about.component.spec.ts rename to src/app/pages/about/about.component.spec.ts diff --git a/src/app/about/about.component.ts b/src/app/pages/about/about.component.ts similarity index 86% rename from src/app/about/about.component.ts rename to src/app/pages/about/about.component.ts index 593a846..de35370 100644 --- a/src/app/about/about.component.ts +++ b/src/app/pages/about/about.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; // двач лучший двач -import { ApiChatService } from '../services/api-chat.service'; +import { ApiChatService } from '../../services/api-chat.service'; @Component({ selector: 'app-about', diff --git a/src/app/home/home.component.css b/src/app/pages/home/home.component.css similarity index 100% rename from src/app/home/home.component.css rename to src/app/pages/home/home.component.css diff --git a/src/app/home/home.component.html b/src/app/pages/home/home.component.html similarity index 100% rename from src/app/home/home.component.html rename to src/app/pages/home/home.component.html diff --git a/src/app/home/home.component.spec.ts b/src/app/pages/home/home.component.spec.ts similarity index 100% rename from src/app/home/home.component.spec.ts rename to src/app/pages/home/home.component.spec.ts diff --git a/src/app/home/home.component.ts b/src/app/pages/home/home.component.ts similarity index 100% rename from src/app/home/home.component.ts rename to src/app/pages/home/home.component.ts diff --git a/src/app/not-found/not-found.component.css b/src/app/pages/not-found/not-found.component.css similarity index 100% rename from src/app/not-found/not-found.component.css rename to src/app/pages/not-found/not-found.component.css diff --git a/src/app/not-found/not-found.component.html b/src/app/pages/not-found/not-found.component.html similarity index 100% rename from src/app/not-found/not-found.component.html rename to src/app/pages/not-found/not-found.component.html diff --git a/src/app/not-found/not-found.component.spec.ts b/src/app/pages/not-found/not-found.component.spec.ts similarity index 100% rename from src/app/not-found/not-found.component.spec.ts rename to src/app/pages/not-found/not-found.component.spec.ts diff --git a/src/app/not-found/not-found.component.ts b/src/app/pages/not-found/not-found.component.ts similarity index 100% rename from src/app/not-found/not-found.component.ts rename to src/app/pages/not-found/not-found.component.ts diff --git a/src/app/send-post/send-post.component.css b/src/app/pages/send-post/send-post.component.css similarity index 100% rename from src/app/send-post/send-post.component.css rename to src/app/pages/send-post/send-post.component.css diff --git a/src/app/send-post/send-post.component.html b/src/app/pages/send-post/send-post.component.html similarity index 100% rename from src/app/send-post/send-post.component.html rename to src/app/pages/send-post/send-post.component.html diff --git a/src/app/send-post/send-post.component.spec.ts b/src/app/pages/send-post/send-post.component.spec.ts similarity index 100% rename from src/app/send-post/send-post.component.spec.ts rename to src/app/pages/send-post/send-post.component.spec.ts diff --git a/src/app/send-post/send-post.component.ts b/src/app/pages/send-post/send-post.component.ts similarity index 60% rename from src/app/send-post/send-post.component.ts rename to src/app/pages/send-post/send-post.component.ts index b5794ca..c504ee9 100644 --- a/src/app/send-post/send-post.component.ts +++ b/src/app/pages/send-post/send-post.component.ts @@ -1,7 +1,8 @@ -import { Component, EventEmitter, OnInit, Output } from '@angular/core'; -import { ApiChatService } from '../services/api-chat.service'; -import {BoardsComponent} from "../SingleThread/boards.component"; -import * as vars from "../var/api"; +import { Component, OnInit, } from '@angular/core'; +import { ApiChatService } from '../../services/api-chat.service'; +import { BoardsComponent } from "../SingleThread/boards.component"; +import * as vars from "../../const/api"; +import {ActivatedRoute} from "@angular/router"; @Component({ @@ -14,10 +15,12 @@ export class SendPostComponent implements OnInit { progress: number; message: string = ''; filename: string[] = []; + threadId: number; constructor( public apiChatService: ApiChatService, - private boards: BoardsComponent + private boards: BoardsComponent, + private activatedRoute:ActivatedRoute ) { } @@ -25,8 +28,8 @@ export class SendPostComponent implements OnInit { sendPost(text: string) { - var threadId = vars.displayed_thread; - this.apiChatService.sendPostToApi(text, this.filename, threadId).subscribe( response => { + this.threadId = parseInt(this.activatedRoute.snapshot.queryParamMap.get('thread')); + this.apiChatService.sendPostToApi(text, this.filename, this.threadId).subscribe( response => { response = response.toString(); vars.showAlert(response.toString(), "#ff0a36"); this.refreshDisplayedThread(); @@ -46,7 +49,7 @@ export class SendPostComponent implements OnInit { } refreshDisplayedThread(){ - this.boards.refreshPosts("b", vars.displayed_thread) + this.boards.refreshPosts("b", this.threadId) } ngOnInit(): void { diff --git a/src/app/services/api-chat.service.ts b/src/app/services/api-chat.service.ts index 4ea180f..010ac5a 100644 --- a/src/app/services/api-chat.service.ts +++ b/src/app/services/api-chat.service.ts @@ -2,7 +2,7 @@ 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'; +import * as globals from '../const/api'; @Injectable({