Compare commits

...

3 Commits

Author SHA1 Message Date
97baca05a7 new structire
All checks were successful
continuous-integration/drone/push Build is passing
2022-10-22 15:56:19 +10:00
c71f3e1011 new structure 2022-10-22 15:50:52 +10:00
56cbf7b140 new structure 2022-10-22 15:20:59 +10:00
18 changed files with 104 additions and 62 deletions

View File

@ -1,10 +1,6 @@
{
"ExpandedNodes": [
"",
"\\src",
"\\src\\app",
"\\src\\app\\about",
"\\src\\app\\boards"
""
],
"PreviewInSolutionExplorer": false
}

Binary file not shown.

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
// двач лучший двач
import { ApiChatService } from '../api-chat.service';
import { ApiChatService } from '../services/api-chat.service';
@Component({
selector: 'app-about',

View File

@ -1,8 +0,0 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ApiChatService {
}

View File

@ -8,9 +8,10 @@ import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { BoardsComponent } from './boards/boards.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { ApiChatService } from './api-chat.service';
import { ApiChatService } from './services/api-chat.service';
import { FormsModule } from '@angular/forms';
import { SendPostComponent } from './boards/send-post/send-post.component';
import { PostComponent } from './boards/post/post.component'
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
@ -26,6 +27,7 @@ const appRoutes: Routes = [
AboutComponent,
BoardsComponent,
NotFoundComponent,
PostComponent,
SendPostComponent
],
imports: [

View File

@ -1,18 +1,11 @@
<div class="wrappe">
<img src="http://static.vdk2ch.ru:15555/test-public/16657431265390.png" alt="свiня" width="150">
<app-send-post></app-send-post>,
<button (click)="listPosts()">Обновить</button>
<div *ngIf="response">
<div class="singlePost" *ngFor="let post of response">
<a href="#{{post.Id}}"></a>
<img src="http://static.vdk2ch.ru:15555/test-public/оладий.jpg" alt="anonpls" width="140">
<p> >>{{post.Id}} {{post.Date}}</p>
<p>{{post.Text}}</p>
</div>
</div>
<button (click)="refreshPosts()">Обновить</button>
<post-single
*ngFor="let post of postsToShow" [post]="post"
></post-single>
<button (click)="refreshPosts()">Обновить</button>
<br>
<div class="hexagon">
<div class="hexagon-inside">

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ApiChatService } from '../api-chat.service';
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'
@Component({
selector: 'app-boards',
@ -10,24 +11,24 @@ import { HttpClient } from '@angular/common/http';
export class BoardsComponent implements OnInit {
command: string = "";
response: any;
postsToShow: SinglePost[] = [] //products: Iproduct[] = data
constructor(private http: HttpClient) {
console.log("Boards opened");
constructor(public apiChatService: ApiChatService) {
}
listPosts() {
console.log("Получаю данные...");
this.http.get('http://api.vdk2ch.ru:5000/List')
.subscribe((response)=> {
this.response = response;
console.log(this.response);
refreshPosts() {
this.apiChatService.getPosts().subscribe(response => {
this.postsToShow = response
})
}
ngOnInit(): void {
this.listPosts();
this.apiChatService.getPosts().subscribe(response => {
this.postsToShow = response
})
}
}

View File

@ -0,0 +1,10 @@
.post {
border-width: 1;
border-color: rgb(190,190,190);
border-style: solid;
background-color: #F0D0B6;
border-radius: 5px;
width: 500px;
word-break: break-word;
word-wrap: break-word;
}

View File

@ -0,0 +1,5 @@
<div class="post">
<img src="http://static.vdk2ch.ru:15555/test-public/оладий.jpg" alt="anonpls" width="140"> # {{post.Id}}
<h3>{{post.Date}}</h3>
<h2>{{post.Text}}</h2>
</div>

View File

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

View File

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ApiChatService } from '../../services/api-chat.service';
@Component({
selector: 'app-send-post',
@ -8,23 +9,11 @@ import { HttpClient } from '@angular/common/http';
})
export class SendPostComponent implements OnInit {
constructor(private http: HttpClient) {
console.log("Открыто окно постинга");
constructor(public apiChatService: ApiChatService) {
}
sendPost(text: string) {
console.log("Отправляю пост...");
var postToSend =
{
Date: Date,
Id: 0,
Text: text
}
this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend).subscribe();
this.apiChatService.sendPostToApi(text).subscribe();
}

View File

@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { ApiChatService } from '../api-chat.service';
@Component({
selector: 'app-home',

6
src/app/models/post.ts Normal file
View File

@ -0,0 +1,6 @@
export interface SinglePost {
Date: string
Id: number
Text: string
}

View File

@ -1 +1 @@
<p>not-found works!</p>
<p>Страничка не найдена. Попробуйте внимательнее.</p>

View File

@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-not-found',
template: `<h3>Страница не найдена.<h3>`
templateUrl: './not-found.component.html',
styleUrls: ['./not-found.component.css']
})
export class NotFoundComponent implements OnInit {

View File

@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { SinglePost } from '../models/post';
@Injectable({
providedIn: 'root'
})
export class ApiChatService {
constructor(private http: HttpClient) {
}
getPosts(): Observable<SinglePost[]> {
console.log("Получаю данные из сервиса");
return this.http.get<SinglePost[]>('http://api.vdk2ch.ru:5000/List/');
}
sendPostToApi(text: string) {
console.log("Отправляю пост...");
var postToSend =
{
Date: Date,
Id: 0,
Text: text
}
return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend)
}
}

View File

@ -7,7 +7,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
@ -21,7 +21,8 @@
"lib": [
"es2020",
"dom"
]
],
"strictPropertyInitialization" : false
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,