src.app.modules.scenarios.components.edition.edition-info.edition-info.component.ts Maven / Gradle / Ivy
The newest version!
/*
* SPDX-FileCopyrightText: 2017-2024 Enedis
*
* SPDX-License-Identifier: Apache-2.0
*
*/
import { Component, HostListener, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
import { EditionService } from '@core/services';
import { TestCaseEdition } from '@model';
@Component({
selector: 'chutney-edition-info',
templateUrl: './edition-info.component.html',
styleUrls: ['./edition-info.component.scss']
})
export class EditionInfoComponent implements OnChanges, OnDestroy {
@Input() testCase;
edition: TestCaseEdition;
editions: Array = [];
constructor(private editionService: EditionService) {
}
ngOnChanges(changes: SimpleChanges) {
if (this.testCase && this.testCase.id) {
const id = this.testCase.id;
this.editionService.editTestCase(id).subscribe(
edition => {
this.edition = edition;
this.editionService.findAllTestCaseEditions(id).subscribe(
editions => { this.editions = editions.filter(e => e.editionUser != edition.editionUser); }
);
},
error => {
console.log(error);
}
);
}
}
@HostListener('window:beforeunload')
async ngOnDestroy() {
if (this.testCase.id != null) {
await this.editionService.endTestCaseEdition(this.testCase.id)
.toPromise();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy