mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 23:43:01 +00:00
initial i18n messages for loading and error components
This commit is contained in:
@@ -8,7 +8,8 @@ span {
|
||||
}
|
||||
|
||||
span[class*="l-"] {
|
||||
height: 4px; width: 4px;
|
||||
height: 4px;
|
||||
width: 4px;
|
||||
background: #000;
|
||||
display: inline-block;
|
||||
margin: 12px 2px;
|
||||
|
@@ -2,6 +2,10 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { MockTranslateLoader } from '../testing/mock-translate-loader';
|
||||
|
||||
import { LoadingComponent } from './loading.component';
|
||||
|
||||
describe('LoadingComponent (inline template)', () => {
|
||||
@@ -13,7 +17,16 @@ describe('LoadingComponent (inline template)', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: MockTranslateLoader
|
||||
}
|
||||
}),
|
||||
],
|
||||
declarations: [ LoadingComponent ], // declare the test component
|
||||
providers: [ TranslateService ]
|
||||
}).compileComponents(); // compile template and css
|
||||
}));
|
||||
|
||||
|
@@ -1,12 +1,36 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-loading',
|
||||
styleUrls: ['./loading.component.scss'],
|
||||
templateUrl: './loading.component.html'
|
||||
})
|
||||
export class LoadingComponent {
|
||||
export class LoadingComponent implements OnDestroy, OnInit {
|
||||
|
||||
@Input() message = 'Loading...';
|
||||
@Input() message: string;
|
||||
|
||||
private subscription: Subscription;
|
||||
|
||||
constructor(private translate: TranslateService) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.message === undefined) {
|
||||
this.subscription = this.translate.get('loading.default').subscribe((message: string) => {
|
||||
this.message = message;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.subscription !== undefined) {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user