Compare commits
No commits in common. "97baca05a7e3b341997ed350a24835000c61b510" and "3a4d3fea18d4c3cad3b6a864e8b272eb82cd561f" have entirely different histories.
97baca05a7
...
3a4d3fea18
@ -1,6 +1,10 @@
|
||||
{
|
||||
"ExpandedNodes": [
|
||||
""
|
||||
"",
|
||||
"\\src",
|
||||
"\\src\\app",
|
||||
"\\src\\app\\about",
|
||||
"\\src\\app\\boards"
|
||||
],
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
// двач лучший двач
|
||||
import { ApiChatService } from '../services/api-chat.service';
|
||||
import { ApiChatService } from '../api-chat.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-about',
|
||||
|
8
src/app/api-chat.service.ts
Normal file
8
src/app/api-chat.service.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ApiChatService {
|
||||
|
||||
}
|
@ -8,10 +8,9 @@ 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 './services/api-chat.service';
|
||||
import { ApiChatService } from './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 },
|
||||
@ -27,7 +26,6 @@ const appRoutes: Routes = [
|
||||
AboutComponent,
|
||||
BoardsComponent,
|
||||
NotFoundComponent,
|
||||
PostComponent,
|
||||
SendPostComponent
|
||||
],
|
||||
imports: [
|
||||
|
@ -1,11 +1,18 @@
|
||||
<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)="refreshPosts()">Обновить</button>
|
||||
<post-single
|
||||
*ngFor="let post of postsToShow" [post]="post"
|
||||
></post-single>
|
||||
<button (click)="refreshPosts()">Обновить</button>
|
||||
|
||||
<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>
|
||||
<br>
|
||||
<div class="hexagon">
|
||||
<div class="hexagon-inside">
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ApiChatService } from '../services/api-chat.service';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ApiChatService } from '../api-chat.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { SinglePost } from '../models/post'
|
||||
|
||||
@Component({
|
||||
selector: 'app-boards',
|
||||
@ -11,24 +10,24 @@ import { SinglePost } from '../models/post'
|
||||
export class BoardsComponent implements OnInit {
|
||||
command: string = "";
|
||||
response: any;
|
||||
postsToShow: SinglePost[] = [] //products: Iproduct[] = data
|
||||
|
||||
constructor(public apiChatService: ApiChatService) {
|
||||
constructor(private http: HttpClient) {
|
||||
console.log("Boards opened");
|
||||
|
||||
}
|
||||
|
||||
refreshPosts() {
|
||||
this.apiChatService.getPosts().subscribe(response => {
|
||||
this.postsToShow = response
|
||||
listPosts() {
|
||||
console.log("Получаю данные...");
|
||||
this.http.get('http://api.vdk2ch.ru:5000/List')
|
||||
.subscribe((response)=> {
|
||||
this.response = response;
|
||||
console.log(this.response);
|
||||
})
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.apiChatService.getPosts().subscribe(response => {
|
||||
this.postsToShow = response
|
||||
})
|
||||
this.listPosts();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
.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;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
<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>
|
@ -1,19 +0,0 @@
|
||||
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 {
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ApiChatService } from '../../services/api-chat.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-send-post',
|
||||
@ -9,11 +8,23 @@ import { ApiChatService } from '../../services/api-chat.service';
|
||||
})
|
||||
export class SendPostComponent implements OnInit {
|
||||
|
||||
constructor(public apiChatService: ApiChatService) {
|
||||
constructor(private http: HttpClient) {
|
||||
console.log("Открыто окно постинга");
|
||||
}
|
||||
|
||||
sendPost(text: string) {
|
||||
this.apiChatService.sendPostToApi(text).subscribe();
|
||||
console.log("Отправляю пост...");
|
||||
var postToSend =
|
||||
{
|
||||
Date: Date,
|
||||
Id: 0,
|
||||
Text: text
|
||||
}
|
||||
|
||||
|
||||
this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend).subscribe();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ApiChatService } from '../api-chat.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
|
@ -1,6 +0,0 @@
|
||||
export interface SinglePost {
|
||||
Date: string
|
||||
Id: number
|
||||
Text: string
|
||||
|
||||
}
|
@ -1 +1 @@
|
||||
<p>Страничка не найдена. Попробуйте внимательнее.</p>
|
||||
<p>not-found works!</p>
|
||||
|
@ -2,8 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-not-found',
|
||||
templateUrl: './not-found.component.html',
|
||||
styleUrls: ['./not-found.component.css']
|
||||
template: `<h3>Страница не найдена.<h3>`
|
||||
})
|
||||
export class NotFoundComponent implements OnInit {
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"sourceMap": true,
|
||||
@ -21,8 +21,7 @@
|
||||
"lib": [
|
||||
"es2020",
|
||||
"dom"
|
||||
],
|
||||
"strictPropertyInitialization" : false
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
|
Reference in New Issue
Block a user