From 37d73b2f24c9ab262b6a15f46a0dcfb2552a6805 Mon Sep 17 00:00:00 2001 From: Cathy Hu Date: Mon, 24 Aug 2020 18:21:30 +0200 Subject: [PATCH] [frontend] Add backend connection for GET trigger/badwords --- .../app/dashboard/board/board.component.ts | 2 +- .../badwords/badwords.component.html | 38 ++++++++++++++++-- .../badwords/badwords.component.scss | 20 ++++++++++ .../badwords/badwords.component.ts | 4 +- .../hoodsettings/hoodsettings.component.html | 23 +++++------ .../hoodsettings/hoodsettings.component.scss | 6 +-- .../trigger/trigger.component.html | 39 +++++++++++++++++-- .../trigger/trigger.component.scss | 20 ++++++++++ .../hoodsettings/trigger/trigger.component.ts | 13 +++++-- .../app/shared/material/material.module.ts | 3 ++ .../option-card/option-card.component.html | 12 ------ .../option-card/option-card.component.scss | 0 .../option-card/option-card.component.spec.ts | 24 ------------ .../option-card/option-card.component.ts | 14 ------- .../src/app/shared/shared.module.ts | 10 +---- 15 files changed, 138 insertions(+), 90 deletions(-) delete mode 100644 kibicara-frontend/src/app/shared/option-card/option-card.component.html delete mode 100644 kibicara-frontend/src/app/shared/option-card/option-card.component.scss delete mode 100644 kibicara-frontend/src/app/shared/option-card/option-card.component.spec.ts delete mode 100644 kibicara-frontend/src/app/shared/option-card/option-card.component.ts diff --git a/kibicara-frontend/src/app/dashboard/board/board.component.ts b/kibicara-frontend/src/app/dashboard/board/board.component.ts index c1a75b3..6dbddf5 100644 --- a/kibicara-frontend/src/app/dashboard/board/board.component.ts +++ b/kibicara-frontend/src/app/dashboard/board/board.component.ts @@ -11,7 +11,7 @@ import { Observable } from 'rxjs'; }) export class BoardComponent implements OnInit { hoodId: number; - hood$: Observable; + hood$: Observable; constructor( private route: ActivatedRoute, diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.html b/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.html index bc3af20..9055002 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.html +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.html @@ -1,11 +1,41 @@ Badwords Lorem ipsum dolor sit amet, consectetur adipiscing elit.Discards an incoming message that matches the pattern (spam-protection, insult-filtering) -
- -
+ + + +
+
+ {{ badword.pattern }} +
+ + +
+ +
+
+
+ +
+ No badwords configured yet. +
+
diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.scss b/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.scss index e69de29..cb2e043 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.scss +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.scss @@ -0,0 +1,20 @@ +.entry { + display: grid; + grid-template-columns: 4fr 50px 50px; + width: 100%; +} + +.regex { + margin: 5px; + margin-top: 10px; + font-size: medium; +} + +.button { + align-self: stretch; +} + +.error-msg { + display: flex; + font-style: italic; +} \ No newline at end of file diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.ts b/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.ts index 6c997ee..00b5af9 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.ts +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/badwords/badwords.component.ts @@ -9,11 +9,11 @@ import { Observable } from 'rxjs'; }) export class BadwordsComponent implements OnInit { @Input() hoodId; - badwords$: Observable; + badwords$: Observable>; constructor(private badwordService: BadwordsService) {} ngOnInit(): void { - //this.badwords$ = this.badwordService.getBadwords(this.hoodId); + this.badwords$ = this.badwordService.getBadwords(this.hoodId); } } diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.html b/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.html index 9224fce..1f67654 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.html +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.html @@ -11,25 +11,20 @@

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nisi - enim, semper at metus dapibus, mattis rutrum risus. Nam sit amet - venenatis ipsum. Nulla accumsan blandit est, vel dignissim nisl - consectetur in. Phasellus pretium vulputate lorem, ornare lobortis est - euismod ut. Nullam sit amet malesuada diam. Sed condimentum felis eu - scelerisque fringilla. Mauris vel sapien et nisl faucibus rutrum. Ut - dictum erat nec mattis tristique. Suspendisse ultrices tempus - facilisis. Fusce ac quam tempus sapien commodo vehicula. Suspendisse - viverra accumsan nunc, lacinia sagittis augue porttitor non. Cras - auctor, lorem sed convallis bibendum, odio sapien blandit nisl, sed - pulvinar augue risus a ligula. In dui massa, fringilla eu dolor eu, - volutpat varius lorem. Vivamus et molestie eros. + To avoid misuse of the service, some safety mechanisms are in place. + For a message to be shared, it needs to contain + at least one trigger word. Additionally, no badwords + may occur in the message. Therefore triggers are words that only + appear in legitimate messages. Badwords on the other hand, are words + that completely discard the message, even if the remaining message is + legitimate. For example insults or spam words like "blockchain".

- - + +
diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.scss b/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.scss index 4d8663b..8874fba 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.scss +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/hoodsettings.component.scss @@ -2,15 +2,13 @@ display: grid; grid-template-columns: 1fr 1fr; gap: 10px; + align-items: stretch; + justify-items: stretch; @media (max-width: 600px) { grid-template-columns: 1fr; } } -.container-item { - align-items: center; -} - .settings { margin: 1%; } diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.html b/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.html index cfc32f2..ccb857a 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.html +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.html @@ -1,11 +1,42 @@ Triggers Lorem ipsum dolor sit amet, consectetur adipiscing elit.Only shares an incoming message if it matches a pattern (topic-setting).
+ Add at least one trigger! -
- -
+ + + +
+
+ {{ trigger.pattern }} +
+ + +
+ +
+
+
+ +
+ No triggers configured yet. +
+
diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.scss b/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.scss index e69de29..cb2e043 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.scss +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.scss @@ -0,0 +1,20 @@ +.entry { + display: grid; + grid-template-columns: 4fr 50px 50px; + width: 100%; +} + +.regex { + margin: 5px; + margin-top: 10px; + font-size: medium; +} + +.button { + align-self: stretch; +} + +.error-msg { + display: flex; + font-style: italic; +} \ No newline at end of file diff --git a/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.ts b/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.ts index 9a1772a..009fb24 100644 --- a/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.ts +++ b/kibicara-frontend/src/app/dashboard/board/hoodsettings/trigger/trigger.component.ts @@ -1,4 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; +import { TriggersService, BodyTrigger } from 'src/app/core/api'; +import { Observable } from 'rxjs'; @Component({ selector: 'app-trigger', @@ -6,7 +8,12 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./trigger.component.scss'], }) export class TriggerComponent implements OnInit { - constructor() {} + @Input() hoodId: number; + triggers$: Observable>; - ngOnInit(): void {} + constructor(private triggersService: TriggersService) {} + + ngOnInit(): void { + this.triggers$ = this.triggersService.getTriggers(this.hoodId); + } } diff --git a/kibicara-frontend/src/app/shared/material/material.module.ts b/kibicara-frontend/src/app/shared/material/material.module.ts index 219ca7f..061ca61 100644 --- a/kibicara-frontend/src/app/shared/material/material.module.ts +++ b/kibicara-frontend/src/app/shared/material/material.module.ts @@ -6,6 +6,7 @@ import { MatMenuModule } from '@angular/material/menu'; import { MatTabsModule } from '@angular/material/tabs'; import { MatCardModule } from '@angular/material/card'; import { MatExpansionModule } from '@angular/material/expansion'; +import { MatListModule } from '@angular/material/list'; @NgModule({ declarations: [], @@ -17,6 +18,7 @@ import { MatExpansionModule } from '@angular/material/expansion'; MatTabsModule, MatCardModule, MatExpansionModule, + MatListModule, ], exports: [ MatButtonModule, @@ -26,6 +28,7 @@ import { MatExpansionModule } from '@angular/material/expansion'; MatTabsModule, MatCardModule, MatExpansionModule, + MatListModule, ], }) export class MaterialModule {} diff --git a/kibicara-frontend/src/app/shared/option-card/option-card.component.html b/kibicara-frontend/src/app/shared/option-card/option-card.component.html deleted file mode 100644 index c1b64b7..0000000 --- a/kibicara-frontend/src/app/shared/option-card/option-card.component.html +++ /dev/null @@ -1,12 +0,0 @@ -

option-card works!

- - - test - - - - diff --git a/kibicara-frontend/src/app/shared/option-card/option-card.component.scss b/kibicara-frontend/src/app/shared/option-card/option-card.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/kibicara-frontend/src/app/shared/option-card/option-card.component.spec.ts b/kibicara-frontend/src/app/shared/option-card/option-card.component.spec.ts deleted file mode 100644 index 5b7c47a..0000000 --- a/kibicara-frontend/src/app/shared/option-card/option-card.component.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { OptionCardComponent } from './option-card.component'; - -describe('OptionCardComponent', () => { - let component: OptionCardComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [OptionCardComponent], - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(OptionCardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/kibicara-frontend/src/app/shared/option-card/option-card.component.ts b/kibicara-frontend/src/app/shared/option-card/option-card.component.ts deleted file mode 100644 index 83bd287..0000000 --- a/kibicara-frontend/src/app/shared/option-card/option-card.component.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Component, OnInit, Input } from '@angular/core'; - -@Component({ - selector: 'app-option-card', - templateUrl: './option-card.component.html', - styleUrls: ['./option-card.component.scss'], -}) -export class OptionCardComponent implements OnInit { - @Input() option; - - constructor() {} - - ngOnInit(): void {} -} diff --git a/kibicara-frontend/src/app/shared/shared.module.ts b/kibicara-frontend/src/app/shared/shared.module.ts index 1169524..163d34b 100644 --- a/kibicara-frontend/src/app/shared/shared.module.ts +++ b/kibicara-frontend/src/app/shared/shared.module.ts @@ -2,16 +2,10 @@ import { NgModule } from '@angular/core'; import { ToolbarComponent } from './toolbar/toolbar.component'; import { MaterialModule } from './material/material.module'; import { NotFoundComponent } from './not-found/not-found.component'; -import { OptionCardComponent } from './option-card/option-card.component'; @NgModule({ - declarations: [ToolbarComponent, NotFoundComponent, OptionCardComponent], + declarations: [ToolbarComponent, NotFoundComponent], imports: [MaterialModule], - exports: [ - ToolbarComponent, - NotFoundComponent, - OptionCardComponent, - MaterialModule, - ], + exports: [ToolbarComponent, NotFoundComponent, MaterialModule], }) export class SharedModule {}