From db122ce20618ae91f44e363849d8b93c0bef6955 Mon Sep 17 00:00:00 2001 From: AndiMajore <andi.majore@googlemail.com> Date: Mon, 28 Nov 2022 15:55:14 +0100 Subject: [PATCH] added missing components for config error handling --- .../group-warning.component.html | 4 ++ .../group-warning.component.scss | 13 ++++++ .../group-warning.component.spec.ts | 25 ++++++++++++ .../group-warning/group-warning.component.ts | 31 ++++++++++++++ .../parser-warning.component.html | 4 ++ .../parser-warning.component.scss | 13 ++++++ .../parser-warning.component.spec.ts | 25 ++++++++++++ .../parser-warning.component.ts | 40 +++++++++++++++++++ 8 files changed, 155 insertions(+) create mode 100644 src/app/components/group-warning/group-warning.component.html create mode 100644 src/app/components/group-warning/group-warning.component.scss create mode 100644 src/app/components/group-warning/group-warning.component.spec.ts create mode 100644 src/app/components/group-warning/group-warning.component.ts create mode 100644 src/app/components/parser-warning/parser-warning.component.html create mode 100644 src/app/components/parser-warning/parser-warning.component.scss create mode 100644 src/app/components/parser-warning/parser-warning.component.spec.ts create mode 100644 src/app/components/parser-warning/parser-warning.component.ts diff --git a/src/app/components/group-warning/group-warning.component.html b/src/app/components/group-warning/group-warning.component.html new file mode 100644 index 00000000..1b0fd942 --- /dev/null +++ b/src/app/components/group-warning/group-warning.component.html @@ -0,0 +1,4 @@ +<div id="parser-issue-banner" *ngIf="!getClosedState()" class="center notification" style="background-color: rgba(255,41,41,0.6);"> + <button class="delete" (click)="close()"></button> + <span class="px-6">Missing network groups: {{getGroupString()}} .Please contact the page developer to get this issue resolved or check the browser console.</span> +</div> diff --git a/src/app/components/group-warning/group-warning.component.scss b/src/app/components/group-warning/group-warning.component.scss new file mode 100644 index 00000000..87cf4e79 --- /dev/null +++ b/src/app/components/group-warning/group-warning.component.scss @@ -0,0 +1,13 @@ +@import "src/stylesheets/variables"; + +#parser-issue-banner{ + position: absolute; + bottom: 0; + z-index: $parser-issue-banner-z; + width: 100%; + padding-left: 0; + padding-right: 0; + &.disabled { + display: none; + } +} diff --git a/src/app/components/group-warning/group-warning.component.spec.ts b/src/app/components/group-warning/group-warning.component.spec.ts new file mode 100644 index 00000000..1d346aca --- /dev/null +++ b/src/app/components/group-warning/group-warning.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GroupWarningComponent } from './group-warning.component'; + +describe('GroupWarningComponent', () => { + let component: GroupWarningComponent; + let fixture: ComponentFixture<GroupWarningComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ GroupWarningComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(GroupWarningComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/group-warning/group-warning.component.ts b/src/app/components/group-warning/group-warning.component.ts new file mode 100644 index 00000000..947a4601 --- /dev/null +++ b/src/app/components/group-warning/group-warning.component.ts @@ -0,0 +1,31 @@ +import {Component, OnInit} from '@angular/core'; +import {DrugstoneConfigService} from '../../services/drugstone-config/drugstone-config.service'; + +@Component({ + selector: 'app-group-warning', + templateUrl: './group-warning.component.html', + styleUrls: ['./group-warning.component.scss'] +}) +export class GroupWarningComponent implements OnInit { + + constructor(public drugstoneConfig: DrugstoneConfigService) { + } + + ngOnInit(): void { + + } + + getClosedState() { + return !this.drugstoneConfig.groupIssue; + } + + getGroupString() { + let str = ''; + this.drugstoneConfig.groupIssueList.forEach(g => str += (g + ', ')); + return str.substring(0, str.length - 2); + } + + close() { + this.drugstoneConfig.groupIssue = false; + } +} diff --git a/src/app/components/parser-warning/parser-warning.component.html b/src/app/components/parser-warning/parser-warning.component.html new file mode 100644 index 00000000..a632d5c5 --- /dev/null +++ b/src/app/components/parser-warning/parser-warning.component.html @@ -0,0 +1,4 @@ +<div id="parser-issue-banner" *ngIf="!getClosedState()" class="center notification" style="background-color: rgba(255,41,41,0.6);"> + <button *ngIf="!drugstoneConfig.parsingIssueNetwork" class="delete" (click)="close()"></button> + <span class="px-6">Issue while parsing JSON: {{getConfigs()}}. Please contact the page developer to get this issue resolved or check the browser console.</span> +</div> diff --git a/src/app/components/parser-warning/parser-warning.component.scss b/src/app/components/parser-warning/parser-warning.component.scss new file mode 100644 index 00000000..87cf4e79 --- /dev/null +++ b/src/app/components/parser-warning/parser-warning.component.scss @@ -0,0 +1,13 @@ +@import "src/stylesheets/variables"; + +#parser-issue-banner{ + position: absolute; + bottom: 0; + z-index: $parser-issue-banner-z; + width: 100%; + padding-left: 0; + padding-right: 0; + &.disabled { + display: none; + } +} diff --git a/src/app/components/parser-warning/parser-warning.component.spec.ts b/src/app/components/parser-warning/parser-warning.component.spec.ts new file mode 100644 index 00000000..1181ba99 --- /dev/null +++ b/src/app/components/parser-warning/parser-warning.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ParserWarningComponent } from './parser-warning.component'; + +describe('ParserWarningComponent', () => { + let component: ParserWarningComponent; + let fixture: ComponentFixture<ParserWarningComponent>; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ParserWarningComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ParserWarningComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/parser-warning/parser-warning.component.ts b/src/app/components/parser-warning/parser-warning.component.ts new file mode 100644 index 00000000..4dbec436 --- /dev/null +++ b/src/app/components/parser-warning/parser-warning.component.ts @@ -0,0 +1,40 @@ +import {Component, OnInit} from '@angular/core'; +import {DrugstoneConfigService} from '../../services/drugstone-config/drugstone-config.service'; + +@Component({ + selector: 'app-parser-warning', + templateUrl: './parser-warning.component.html', + styleUrls: ['./parser-warning.component.scss'] +}) +export class ParserWarningComponent implements OnInit { + constructor(public drugstoneConfig: DrugstoneConfigService) { + } + + ngOnInit(): void { + + } + + getClosedState() { + return this.drugstoneConfig.groupIssue || !(this.drugstoneConfig.parsingIssueGroups || this.drugstoneConfig.parsingIssueConfig || this.drugstoneConfig.parsingIssueNetwork); + } + + getConfigs() { + let out = ''; + if (this.drugstoneConfig.parsingIssueNetwork) { + out += 'network, '; + } + if (this.drugstoneConfig.parsingIssueConfig) { + out += 'config, '; + } + if (this.drugstoneConfig.parsingIssueGroups) { + out += 'groups, '; + } + return out.substring(0, out.length - 2); + } + + close() { + this.drugstoneConfig.parsingIssueConfig = false; + this.drugstoneConfig.parsingIssueGroups = false; + } + +} -- GitLab