Skip to content

Commit

Permalink
argoproj#46 Job notifications connected to multiple service launch pa…
Browse files Browse the repository at this point in the history
…nel.
  • Loading branch information
wokeGit committed Oct 11, 2017
1 parent 61efb9b commit 2fcc2b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export class MultipleServiceLaunchPanelComponent {
observableList.push(this.taskService.launchTask({
template_id: this.templatesToSubmit[index].id,
arguments: this.listParameters(this.allForms.controls[index.toString()]['controls']),
notifications: notifications
}));
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as _ from 'lodash';
import { Component, OnInit } from '@angular/core';

import { FilterMultiSelect } from 'argo-ui-lib/src/components';
Expand Down Expand Up @@ -177,7 +178,7 @@ export class SetupJobNotificationsComponent implements OnInit {
}
}

public getNotifications() {
public getNotifications(): PolicyNotification[] {
let isAnyError = false;
this.notificationsList.forEach(notification => {
if (!notification.rules.when.length) {
Expand Down Expand Up @@ -209,14 +210,14 @@ export class SetupJobNotificationsComponent implements OnInit {
return notification.rules;
});

return this.rules;
return _.uniqBy(this.rules, v => [v.whom, v.when].join());
}

private addDefaultNotificationRule() {
let notification = JSON.parse(JSON.stringify(this.notification));
notification.rules = {
whom: [this.authenticationService.getUsername()],
when: ['on_success', 'on_failure']
when: ['on_failure', 'on_success']
};
notification.isArgoUsersAndGroupsVisible = true;

Expand Down
4 changes: 3 additions & 1 deletion saas/axops/src/ui/src/app/services/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class TaskService {
}

public launchTask(args: TaskCreationArgs, runPartial = false) {
args = Object.assign({}, args, { notifications: DEFAULT_NOTIFICATIONS });
if (!args.hasOwnProperty('notifications') && !args.notifications) {
args = Object.assign({}, args, { notifications: DEFAULT_NOTIFICATIONS });
}
return this.http.post(`v1/services?run_partial=${runPartial}`, JSON.stringify(args))
.map(res => res.json());
}
Expand Down

0 comments on commit 2fcc2b8

Please sign in to comment.