Skip to content

Commit

Permalink
argoproj#48: Moved the setter functions to ngOnChange (argoproj#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixApplatix authored and wokeGit committed Nov 22, 2017
1 parent 5440ab8 commit f292dd9
Showing 1 changed file with 20 additions and 15 deletions.
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

0 comments on commit f292dd9

Please sign in to comment.