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": [ "ExpandedNodes": [
"", ""
"\\src",
"\\src\\app",
"\\src\\app\\about",
"\\src\\app\\boards"
], ],
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }

Binary file not shown.

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
// двач лучший двач // двач лучший двач
import { ApiChatService } from '../api-chat.service'; import { ApiChatService } from '../services/api-chat.service';
@Component({ @Component({
selector: 'app-about', 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 { AboutComponent } from './about/about.component';
import { BoardsComponent } from './boards/boards.component'; import { BoardsComponent } from './boards/boards.component';
import { NotFoundComponent } from './not-found/not-found.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 { FormsModule } from '@angular/forms';
import { SendPostComponent } from './boards/send-post/send-post.component'; import { SendPostComponent } from './boards/send-post/send-post.component';
import { PostComponent } from './boards/post/post.component'
const appRoutes: Routes = [ const appRoutes: Routes = [
{ path: '', component: HomeComponent }, { path: '', component: HomeComponent },
@ -26,6 +27,7 @@ const appRoutes: Routes = [
AboutComponent, AboutComponent,
BoardsComponent, BoardsComponent,
NotFoundComponent, NotFoundComponent,
PostComponent,
SendPostComponent SendPostComponent
], ],
imports: [ imports: [

View File

@ -1,23 +1,16 @@
<div class="wrappe"> <div class="wrappe">
<img src="http://static.vdk2ch.ru:15555/test-public/16657431265390.png" alt="свiня" width="150"> <img src="http://static.vdk2ch.ru:15555/test-public/16657431265390.png" alt="свiня" width="150">
<app-send-post></app-send-post>, <app-send-post></app-send-post>,
<button (click)="refreshPosts()">Обновить</button>
<button (click)="listPosts()">Обновить</button> <post-single
<div *ngIf="response"> *ngFor="let post of postsToShow" [post]="post"
<div class="singlePost" *ngFor="let post of response"> ></post-single>
<a href="#{{post.Id}}"></a> <button (click)="refreshPosts()">Обновить</button>
<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>
<br> <br>
<div class="hexagon"> <div class="hexagon">
<div class="hexagon-inside"> <div class="hexagon-inside">
<div class="hexagon-image"> <div class="hexagon-image">
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { ApiChatService } from '../api-chat.service'; import { ApiChatService } from '../services/api-chat.service';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { SinglePost } from '../models/post'
@Component({ @Component({
selector: 'app-boards', selector: 'app-boards',
@ -10,24 +11,24 @@ import { HttpClient } from '@angular/common/http';
export class BoardsComponent implements OnInit { export class BoardsComponent implements OnInit {
command: string = ""; command: string = "";
response: any; response: any;
postsToShow: SinglePost[] = [] //products: Iproduct[] = data
constructor(private http: HttpClient) { constructor(public apiChatService: ApiChatService) {
console.log("Boards opened");
} }
listPosts() { refreshPosts() {
console.log("Получаю данные..."); this.apiChatService.getPosts().subscribe(response => {
this.http.get('http://api.vdk2ch.ru:5000/List') this.postsToShow = response
.subscribe((response)=> { })
this.response = response;
console.log(this.response);
})
} }
ngOnInit(): void { 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 { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ApiChatService } from '../../services/api-chat.service';
@Component({ @Component({
selector: 'app-send-post', selector: 'app-send-post',
@ -8,23 +9,11 @@ import { HttpClient } from '@angular/common/http';
}) })
export class SendPostComponent implements OnInit { export class SendPostComponent implements OnInit {
constructor(private http: HttpClient) { constructor(public apiChatService: ApiChatService) {
console.log("Открыто окно постинга");
} }
sendPost(text: string) { sendPost(text: string) {
console.log("Отправляю пост..."); this.apiChatService.sendPostToApi(text).subscribe();
var postToSend =
{
Date: Date,
Id: 0,
Text: text
}
this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend).subscribe();
} }

View File

@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ApiChatService } from '../api-chat.service';
@Component({ @Component({
selector: 'app-home', 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({ @Component({
selector: 'app-not-found', selector: 'app-not-found',
template: `<h3>Страница не найдена.<h3>` templateUrl: './not-found.component.html',
styleUrls: ['./not-found.component.css']
}) })
export class NotFoundComponent implements OnInit { 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, "forceConsistentCasingInFileNames": true,
"strict": true, "strict": true,
"noImplicitOverride": true, "noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true, "noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true, "noImplicitReturns": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"sourceMap": true, "sourceMap": true,
@ -21,7 +21,8 @@
"lib": [ "lib": [
"es2020", "es2020",
"dom" "dom"
] ],
"strictPropertyInitialization" : false
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false, "enableI18nLegacyMessageIdFormat": false,