Added threads listing.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
RakVhalate 2022-11-24 12:54:59 +10:00
parent 592509f337
commit 28e0cfb239
21 changed files with 155 additions and 57 deletions

View File

@ -0,0 +1,12 @@
.op {
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-top: 6px;
}

View File

@ -0,0 +1,10 @@
<div class="op">
<h4>Тред номер {{op.Thread_Id}}</h4>
<p> # {{op.Id}} {{op.Timestamp}}</p>
<div>
<a *ngFor="let i of op.ImgURL" [href]="i" target="_blank">
<img [src]="i" style="height:140px">
</a>
</div>
<p>{{op.Text}}</p>
</div>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OPComponent } from './op.component';
describe('OPComponent', () => {
let component: OPComponent;
let fixture: ComponentFixture<OPComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ OPComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(OPComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,18 @@
import {Component, Input, OnInit} from '@angular/core';
import { SinglePost } from '../../models/post';
@Component({
selector: 'op-single',
templateUrl: './op.component.html',
styleUrls: ['./op.component.css']
})
export class OPComponent implements OnInit {
constructor() { }
@Input() op: SinglePost
ngOnInit(): void {
}
}

View File

@ -0,0 +1,12 @@
<h2>Вы находитесь на доске {{boardName}} </h2>
<a (click)="showGuide = !showGuide" style=" font-size: small; color: chocolate; width: 500px;"> Что это и как это работает?</a>
<br>
<div *ngIf="showGuide">
Добро пожаловать в список доступных тредов. Выберите подходящий для вас тред, затем введите его номер во вкладке "Тред" выше и нажмите "обновить" чтобы перейти в этот тред.
</div>
<br>
<button (click)="refreshOPs(boardName)">Обновить</button>
<op-single
*ngFor="let ops of opsToShow" [op]="ops"
></op-single>
<button (click)="refreshOPs(boardName)">Обновить</button>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ThreadsComponent } from './threads.component';
describe('ThreadsComponent', () => {
let component: ThreadsComponent;
let fixture: ComponentFixture<ThreadsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ThreadsComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(ThreadsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,35 @@
import { Component, OnInit } from '@angular/core';
import * as vars from "../var/api";
import {SinglePost} from "../models/post";
import {ApiChatService} from "../services/api-chat.service";
@Component({
selector: 'app-BoardThreads',
templateUrl: './threads.component.html',
styleUrls: ['./threads.component.css']
})
export class ThreadsComponent implements OnInit {
boardName:string = 'b'
command: string = "";
response: any;
opsToShow: SinglePost[] = []
displayed_thread_number = vars.displayed_thread;
showGuide: boolean = false;
constructor(public apiChatService: ApiChatService) {
}
refreshOPs(boardName: string) {
this.apiChatService.getThreads(boardName).subscribe(response => {
this.opsToShow = response
vars.setDisplayedThread(this.displayed_thread_number);
})
}
ngOnInit(): void {
this.apiChatService.getThreads(this.boardName).subscribe(response => {
this.opsToShow = response
})
}
}

View File

@ -4,7 +4,7 @@ import { SinglePost } from '../models/post'
import * as vars from '../var/api'
@Component({
selector: 'app-boards',
selector: 'app-SingleThread',
templateUrl: `./boards.component.html`,
styleUrls: [`./boards.component.css`]
})

View File

@ -7,7 +7,8 @@ import { Component } from '@angular/core';
<nav>
<a routerLink = "">Главная </a>
<a routerLink = "about">О нас </a>
<a routerLink = "boards">Борда </a>
<a routerLink = "board">Тред </a>
<a routerLink = "threads">Борда </a>
</nav>
<router-outlet></router-outlet>
</div>`

View File

@ -7,19 +7,21 @@ 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 './boards/boards.component';
import { BoardsComponent } from './SingleThread/boards.component';
import { NotFoundComponent } from './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 './boards/post/post.component'
import { MinIoService } from "./services/min-io.service.";
import { PostComponent } from './SingleThread/post/post.component'
import { ThreadsComponent } from './BoardThreads/threads.component';
import { OPComponent } from './BoardThreads/op/op.component';
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'boards', component: BoardsComponent },
{ path: 'threads', component: ThreadsComponent},
{ path: 'board', component: BoardsComponent },
{ path: 'about', component: AboutComponent },
{ path: '**', component: NotFoundComponent },
{ path: '**', component: NotFoundComponent }
]
@NgModule({
@ -30,7 +32,9 @@ const appRoutes: Routes = [
BoardsComponent,
NotFoundComponent,
PostComponent,
SendPostComponent
SendPostComponent,
ThreadsComponent,
OPComponent
],
imports: [
BrowserModule,
@ -39,8 +43,7 @@ const appRoutes: Routes = [
FormsModule
],
providers: [
ApiChatService,
MinIoService
ApiChatService
],
bootstrap: [AppComponent]
})

View File

@ -1,7 +1,5 @@
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";
@ -17,8 +15,7 @@ export class SendPostComponent implements OnInit {
filename: string[] = [];
constructor(
public apiChatService: ApiChatService,
public minIoService: MinIoService,
public apiChatService: ApiChatService
) {
}

View File

@ -36,5 +36,10 @@ export class ApiChatService {
return this.http.post(globals.api_endpoint +'UploadPic', PostPicture)
}
getThreads(boardName:string): Observable<SinglePost[]> {
//console.log("Получаю посты и картинки");
return this.http.get<SinglePost[]>(globals.api_endpoint +'Threads/', {params:{board: boardName}}) ;
}
}

View File

@ -1,25 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient } from "@angular/common/http";
import * as Minio from 'minio';
@Injectable({
providedIn: 'root'
})
export class MinIoService {
picToSend = null;
constructor(private http: HttpClient) {
}
//SendPicture(event: any): void {
//console.log(event.target.files[0].name);
//console.log('Отправляю картинку сервисом...');
//}
}

View File

@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { MinIoService } from './min-io.service.';
describe('MinIoServiceService', () => {
let service: MinIoService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(MinIoService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});