Commit 187d5a4d authored by Vitali Stupin's avatar Vitali Stupin

Creating component for displaying messages

parent 54518e68
......@@ -13,6 +13,7 @@ import { SubsystemComponent } from './subsystem/subsystem.component';
import { HeaderComponent } from './header/header.component';
import { APP_INITIALIZER } from '@angular/core';
import { AppConfig } from './app.config';
import { MessagesComponent } from './messages/messages.component';
@NgModule({
declarations: [
......@@ -21,7 +22,8 @@ import { AppConfig } from './app.config';
SearchComponent,
SubsystemItemComponent,
SubsystemComponent,
HeaderComponent
HeaderComponent,
MessagesComponent
],
imports: [
BrowserModule,
......
<div class="alert alert-warning" role="alert" *ngIf="message">
{{message | translate:{"subsystem": subsystemId} }}
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { HttpClientModule } from '@angular/common/http';
import { MessagesComponent } from './messages.component';
describe('MessagesComponent', () => {
let component: MessagesComponent;
let fixture: ComponentFixture<MessagesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
MessagesComponent
],
imports: [
TranslateModule.forRoot(),
HttpClientModule
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MessagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-messages',
templateUrl: './messages.component.html'
})
export class MessagesComponent implements OnInit {
@Input() message: '';
@Input() subsystemId: '';
constructor() { }
ngOnInit() {
}
}
......@@ -7,9 +7,7 @@
<p [innerHTML]="'subsystemList.intro.p4' | translate:{'jsonUrl': getApiUrl()}"></p>
<p [innerHTML]="'subsystemList.intro.p5' | translate"></p>
<div class="alert alert-warning" role="alert" *ngIf="message">
{{message | translate}}
</div>
<app-messages [message]="message"></app-messages>
<div class="btn-group" role="group" [attr.aria-label]="'subsystemList.selectInstance' | translate">
<button *ngFor="let instance of getInstances()"
......
......@@ -13,6 +13,10 @@ import { AppConfig } from 'src/app/app.config';
@Component({selector: 'app-header', template: ''})
class HeaderStubComponent {}
@Component({selector: 'app-messages', template: ''})
class MessagesStubComponent {
@Input() message: string;
}
@Component({selector: 'app-search', template: ''})
class SearchStubComponent {}
@Component({selector: 'app-subsystem-item', template: ''})
......@@ -32,6 +36,7 @@ describe('SubsystemListComponent', () => {
declarations: [
SubsystemListComponent,
HeaderStubComponent,
MessagesStubComponent,
SearchStubComponent,
SubsystemItemStubComponent
],
......
......@@ -3,9 +3,7 @@
<h3>{{'subsystem.heading' | translate:{"subsystem": subsystemId, "instance": getInstance() === "" ? paramsInstance : getInstance()} }}</h3>
<p [innerHTML]="'subsystem.intro.p1' | translate"></p>
<div class="alert alert-warning" role="alert" *ngIf="message">
{{message | translate:{"subsystem": subsystemId} }}
</div>
<app-messages [message]="message" [subsystemId]="subsystemId"></app-messages>
<button type="button" class="btn btn-secondary" (click)="goToList()">{{'subsystem.allSystemsBtn' | translate}}</button>
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { Component, EventEmitter } from '@angular/core';
import { Component, Input } from '@angular/core';
import { SubsystemComponent } from './subsystem.component';
import { HttpClientModule } from '@angular/common/http';
import { Router, ActivatedRoute, Scroll } from '@angular/router';
......@@ -12,6 +12,11 @@ import { AppConfig } from 'src/app/app.config';
@Component({selector: 'app-header', template: ''})
class HeaderStubComponent {}
@Component({selector: 'app-messages', template: ''})
class MessagesStubComponent {
@Input() message: string;
@Input() subsystemId: string;
}
describe('SubsystemComponent', () => {
let component: SubsystemComponent;
......@@ -24,7 +29,8 @@ describe('SubsystemComponent', () => {
TestBed.configureTestingModule({
declarations: [
SubsystemComponent,
HeaderStubComponent
HeaderStubComponent,
MessagesStubComponent
],
imports: [
TranslateModule.forRoot(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment