@deepkit/desktop-ui
Version:
Library for desktop UI widgets in Angular 10+
116 lines (97 loc) • 3.28 kB
text/typescript
/*
* Deepkit Framework
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* You should have received a copy of the MIT License along with this program.
*/
import { ChangeDetectorRef, Component, OnChanges, OnDestroy, input } from '@angular/core';
import { ProgressTracker } from '@deepkit/core-rxjs';
import { Subscription } from 'rxjs';
import { DecimalPipe } from '@angular/common';
import { DialogActionsComponent } from '../dialog/dialog.component';
import { ButtonComponent } from '../button/button.component';
export class IndicatorComponent {
step = input<number>(0);
}
export class ProgressIndicatorComponent implements OnChanges, OnDestroy {
title = input<string>('Progress');
description = input<string>('');
progressTracker = input<ProgressTracker>();
display = input<'horizontal' | 'vertical'>('horizontal');
step: number = 0;
sub?: Subscription;
constructor(private cd: ChangeDetectorRef) {
}
ngOnChanges(): void {
if (this.sub) this.sub.unsubscribe();
const progressTracker = this.progressTracker();
if (progressTracker) {
this.sub = progressTracker.subscribe(v => {
this.step = this.progressTracker()!.progress;
this.cd.detectChanges();
});
}
}
ngOnDestroy(): void {
if (this.sub) this.sub.unsubscribe();
}
}