import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
-import { AlertModule, TabsModule } from 'ngx-bootstrap';
+import { TabsModule } from 'ngx-bootstrap';
import { ComponentsModule } from '../../shared/components/components.module';
import { PipesModule } from '../../shared/pipes/pipes.module';
CommonModule,
FormsModule,
TabsModule.forRoot(),
- AlertModule.forRoot(),
SharedModule,
ComponentsModule,
PipesModule
<ol class="breadcrumb">
<li class="breadcrumb-item">Block</li>
<li class="breadcrumb-item">Pools</li>
- <li class="breadcrumb-item active" aria-current="page">{{ name }}</li>
+ <li class="breadcrumb-item active"
+ aria-current="page">{{ name }}</li>
</ol>
</nav>
-<legend>
- Images
- <small>
- <i class="fa fa-spinner fa-spin fa-fw"
- aria-hidden="true"
- *ngIf="images === null && retries <= maxRetries"></i>
- </small>
-</legend>
-
-<alert type="warning" *ngIf="images === null && retries > 0 && retries <= maxRetries">
- Still working, please wait{{ retries | ellipsis }}
-</alert>
-
-<alert type="danger" *ngIf="images === null && retries > maxRetries">
- Cannot load images within {{ name }}.
-</alert>
-
-<div *ngIf="images !== null && images.length === 0">
- There are no images within {{ name }} pool.
-</div>
+<cd-view-cache [status]="viewCacheStatus"></cd-view-cache>
<cd-table [data]="images"
[columns]="columns"
- (fetchData)="loadImages()"
- *ngIf="images !== null && images.length > 0">
+ (fetchData)="loadImages()">
</cd-table>
import { ActivatedRoute } from '@angular/router';
import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum';
+import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe';
import { DimlessPipe } from '../../../shared/pipes/dimless.pipe';
import { FormatterService } from '../../../shared/services/formatter.service';
styleUrls: ['./pool-detail.component.scss']
})
export class PoolDetailComponent implements OnInit, OnDestroy {
-
name: string;
images: any;
- columns: any;
+ columns: CdTableColumn[];
retries: number;
maxRetries = 5;
routeParamsSubscribe: any;
+ viewCacheStatus: ViewCacheStatus;
+ interval: any;
- constructor(private route: ActivatedRoute,
- private poolService: PoolService,
- dimlessBinaryPipe: DimlessBinaryPipe,
- dimlessPipe: DimlessPipe) {
+ constructor(
+ private route: ActivatedRoute,
+ private poolService: PoolService,
+ dimlessBinaryPipe: DimlessBinaryPipe,
+ dimlessPipe: DimlessPipe
+ ) {
this.columns = [
{
name: 'Name',
{
name: 'Features',
prop: 'features_name',
- width: 150},
+ width: 150
+ },
{
name: 'Parent',
prop: 'parent',
ngOnInit() {
this.routeParamsSubscribe = this.route.params.subscribe((params: { name: string }) => {
this.name = params.name;
- this.images = null;
+ this.images = [];
this.retries = 0;
- this.loadImages();
});
+
+ this.interval = setInterval(() => {
+ this.loadImages();
+ }, 5000);
}
ngOnDestroy() {
this.routeParamsSubscribe.unsubscribe();
+ clearInterval(this.interval);
}
loadImages() {
- this.poolService.rbdPoolImages(this.name).then((resp) => {
- if (resp.status === ViewCacheStatus.ValueNone) {
- setTimeout(() => {
- this.retries++;
- if (this.retries <= this.maxRetries) {
- this.loadImages();
- }
- }, 1000);
- } else {
- this.retries = 0;
+ this.poolService.rbdPoolImages(this.name).then(
+ resp => {
+ this.viewCacheStatus = resp.status;
this.images = resp.value;
+ },
+ () => {
+ this.viewCacheStatus = ViewCacheStatus.ValueException;
}
- });
+ );
}
}
+++ /dev/null
-import { EllipsisPipe } from './ellipsis.pipe';
-
-describe('EllipsisPipe', () => {
- it('create an instance', () => {
- const pipe = new EllipsisPipe();
- expect(pipe).toBeTruthy();
- });
-});
+++ /dev/null
-import { Pipe, PipeTransform } from '@angular/core';
-
-@Pipe({
- name: 'ellipsis'
-})
-export class EllipsisPipe implements PipeTransform {
-
- transform(value: any, args?: any): any {
- let result = '';
- for (let i = 0; i < value; i++) {
- result += '...';
- }
- return result;
- }
-
-}
import { CephShortVersionPipe } from './ceph-short-version.pipe';
import { DimlessBinaryPipe } from './dimless-binary.pipe';
import { DimlessPipe } from './dimless.pipe';
-import { EllipsisPipe } from './ellipsis.pipe';
import { HealthColorPipe } from './health-color.pipe';
@NgModule({
DimlessBinaryPipe,
HealthColorPipe,
DimlessPipe,
- CephShortVersionPipe,
- EllipsisPipe
+ CephShortVersionPipe
],
exports: [
DimlessBinaryPipe,
HealthColorPipe,
DimlessPipe,
- CephShortVersionPipe,
- EllipsisPipe
+ CephShortVersionPipe
],
providers: [
CephShortVersionPipe,