added Timestamp Feature

This commit is contained in:
2022-10-22 22:45:51 +10:00
parent 4f8765840a
commit 5d93130970
13 changed files with 2112 additions and 87 deletions

View File

@@ -3,6 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
import { Routes, RouterModule } from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
@@ -12,6 +13,7 @@ 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.";
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
@@ -36,7 +38,10 @@ const appRoutes: Routes = [
HttpClientModule,
FormsModule
],
providers: [ApiChatService],
providers: [
ApiChatService,
MinIoService
],
bootstrap: [AppComponent]
})
export class AppModule { }

View File

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

View File

@@ -12,8 +12,8 @@ import { SinglePost } from '../../models/post';
export class PostComponent implements OnInit {
@Input() post: SinglePost
@Input() post: SinglePost
ngOnInit(): void {
}
}

View File

@@ -1,5 +1,5 @@
export interface SinglePost {
Date: string
Timestamp: string
Id: number
Text: string

View File

@@ -1,7 +1,9 @@
<div class="send_post">
<h4>Поведай миру что-нибудь хорошее.</h4>
<input type="text" size="60" placeholder="Печатать сюда" #textToPost>
<textarea type="text" rows="8" cols="45" placeholder="Печатать сюда" #textToPost> </textarea>
<p>
<button (click)="sendPost(textToPost.value)">Отправить</button>
</p>
<h1>Загрузить картинку:</h1>
<input type="file" (change)="sendPic($event)">
</div>

View File

@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ApiChatService } from '../services/api-chat.service';
import { MinIoService } from '../services/min-io.service.'
@Component({
selector: 'app-send-post',
@@ -8,13 +9,16 @@ import { ApiChatService } from '../services/api-chat.service';
})
export class SendPostComponent implements OnInit {
constructor(public apiChatService: ApiChatService) {
constructor(public apiChatService: ApiChatService, public minIoService: MinIoService) {
}
sendPost(text: string) {
this.apiChatService.sendPostToApi(text).subscribe();
}
sendPic(event: any) {
this.minIoService.SendPicture(event);
}
ngOnInit(): void {
}

View File

@@ -12,17 +12,19 @@ export class ApiChatService {
getPosts(): Observable<SinglePost[]> {
console.log("Получаю данные из сервиса");
return this.http.get<SinglePost[]>('http://api.vdk2ch.ru:5000/List/');
//return this.http.get<SinglePost[]>('http://api.vdk2ch.ru:5000/List/');
return this.http.get<SinglePost[]>('http://localhost:7141/List/');
}
sendPostToApi(text: string) {
console.log("Отправляю пост...");
var postToSend =
{
Date: Date,
Timestamp: text,
Id: 0,
Text: text
}
return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend)
//return this.http.post('http://api.vdk2ch.ru:5000/PostTo', postToSend)
return this.http.post('http://localhost:7141/PostTo', postToSend)
}
}

View File

@@ -0,0 +1,25 @@
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

@@ -0,0 +1,16 @@
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();
});
});