From 0034b663912b30df7a826a02ee719f7a85e16da6 Mon Sep 17 00:00:00 2001 From: NyxiumYuuki Date: Sun, 30 May 2021 18:25:55 +0200 Subject: [PATCH] General renamed to message component --- .../src/app/general/general.component.html | 25 -------- .../src/app/general/general.component.scss | 0 .../src/app/general/general.component.spec.ts | 25 -------- frontend/src/app/general/general.component.ts | 61 ------------------- 4 files changed, 111 deletions(-) delete mode 100644 frontend/src/app/general/general.component.html delete mode 100644 frontend/src/app/general/general.component.scss delete mode 100644 frontend/src/app/general/general.component.spec.ts delete mode 100644 frontend/src/app/general/general.component.ts diff --git a/frontend/src/app/general/general.component.html b/frontend/src/app/general/general.component.html deleted file mode 100644 index 21f47dc..0000000 --- a/frontend/src/app/general/general.component.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - Socket.IO chat - - - - -
- -
- - diff --git a/frontend/src/app/general/general.component.scss b/frontend/src/app/general/general.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/app/general/general.component.spec.ts b/frontend/src/app/general/general.component.spec.ts deleted file mode 100644 index 99edc2f..0000000 --- a/frontend/src/app/general/general.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { GeneralComponent } from './general.component'; - -describe('GeneralComponent', () => { - let component: GeneralComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ GeneralComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(GeneralComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/general/general.component.ts b/frontend/src/app/general/general.component.ts deleted file mode 100644 index 096d68b..0000000 --- a/frontend/src/app/general/general.component.ts +++ /dev/null @@ -1,61 +0,0 @@ -import {Component, ElementRef, OnInit, ViewChild} from '@angular/core'; -import {ChatInfo, ChatService} from "../services/chat/chat.service"; -import {environment} from "../../environments/environment"; -import {DatePipe} from "@angular/common"; -import {MessageService} from "../services/message/message.service"; - -@Component({ - selector: 'app-general', - templateUrl: './general.component.html', - styleUrls: ['./general.component.scss'] -}) -export class GeneralComponent implements OnInit { - - private username = sessionStorage.getItem('login'); - private room = 'general'; - public msg = ''; - - // @ts-ignore - @ViewChild('ulMessages') ulMsg: ElementRef; - - - constructor(private chatservice: ChatService, private pipe: DatePipe, private messageservice: MessageService) {} - - ngOnInit() { - console.log('General working'); - this.messageservice.sendMessage(environment.urlCL,'getUsers', {username: this.username}).subscribe( - data => { - if (data.status !== 'ok'){ - console.log(data.data.reason); - } - else{ - console.log(data.data); - } - } - ); - this.chatservice.setUrl(environment.urlCG); - this.chatservice.setRoom(this.room); - this.chatservice.onNewMessage(this.room).subscribe((infos: ChatInfo[]) => { - for(let data of infos){ - if(data !== undefined && data.date !== undefined){ - if(data.username === 'Server'){ - this.ulMsg.nativeElement.insertAdjacentHTML('beforeend', '
  • '+data.message+'
  • '); - } - else{ - this.ulMsg.nativeElement.insertAdjacentHTML('beforeend','
  • ['+this.pipe.transform(data.date, 'dd/MM/yyyy HH:MM:ss')+'] '+data.username+' : '+data.message+'
  • '); - } - } - } - window.scrollTo(0, document.body.scrollHeight); - }); - } - - sendButtonClick(){ - console.log('Button working'); - if(this.msg && this.username){ - this.chatservice.sendMessage(this.username, this.room, this.msg); - console.log(this.username, this.room, this.msg); - this.msg = ''; - } - } -}