Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#47: Moved the setter functions to ngOnChange #110

Merged
merged 1 commit into from
Aug 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions saas/axops/src/ui/src/app/common/artifacts/artifacts.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, Output, EventEmitter, OnDestroy, ViewChildren, QueryList, ElementRef } from '@angular/core';
import { Component, Input, Output, EventEmitter, OnChanges, OnDestroy, SimpleChanges, ViewChildren, QueryList, ElementRef } from '@angular/core';
import { URLSearchParams } from '@angular/http';
import { Subscription } from 'rxjs';

Expand All @@ -22,7 +22,7 @@ class ArtifactGroup {
templateUrl: './artifacts.html',
styles: [ require('./artifacts.scss') ],
})
export class ArtifactsComponent implements OnDestroy {
export class ArtifactsComponent implements OnChanges, OnDestroy {
protected readonly artifactTypeFilter: string[] = [
ARTIFACT_TYPES.USER_LOG, ARTIFACT_TYPES.INTERNAL, ARTIFACT_TYPES.EXPORTED, ARTIFACT_TYPES.AX_LOG, ARTIFACT_TYPES.AX_LOG_EXTERNAL
];
Expand All @@ -31,19 +31,7 @@ export class ArtifactsComponent implements OnDestroy {
public allowSelecting: boolean = false;

@Input()
public set task(val: Task) {
if (val && val.id) {
if (val.id === val.task_id) {
this.loadArtifacts(val.id, null);
} else {
this.loadArtifacts(null, val.id);
}
this.flatMapOfSteps = JobTreeNode.createFromTask(val).getFlattenNodes().map(item => ({
id: item.value.id,
isRunning: item.value.status === TaskStatus.Running,
}));
}
}
public task: Task;

@Input()
public set deployment(val: Deployment) {
Expand Down Expand Up @@ -79,6 +67,23 @@ export class ArtifactsComponent implements OnDestroy {
this.artifactSubscriptionsCleanup();
}

public ngOnChanges(changes: SimpleChanges) {
if (changes.task) {
let val = changes.task.currentValue;
if (val && val.id) {
if (val.id === val.task_id) {
this.loadArtifacts(val.id, null);
} else {
this.loadArtifacts(null, val.id);
}
this.flatMapOfSteps = JobTreeNode.createFromTask(val).getFlattenNodes().map(item => ({
id: item.value.id,
isRunning: item.value.status === TaskStatus.Running,
}));
}
}
}

private loadArtifacts(workflowId: string, serviceInstanceId: string): void {
this.artifactGroups = [
{
Expand Down