Skip to content

Commit

Permalink
feat(trigger/pubsub): Suggest subscriptions from echo configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtk54 committed Oct 25, 2017
1 parent c957208 commit 0c504d8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
1 change: 1 addition & 0 deletions app/scripts/modules/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export * from './overrideRegistry';
export * from './pageTitle';
export * from './pipeline';
export * from './presentation';
export * from './pubsub';

export * from './reactShims';
export * from './retry';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { IController, module } from 'angular';

import { PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from 'core/pipeline/config/pipelineConfigProvider';
import { IPubsubTrigger } from '@spinnaker/core';
import {
IPubsubTrigger,
PUBSUB_SUBSCRIPTION_SERVICE,
PubsubSubscriptionService,
} from '@spinnaker/core';

class PubsubTriggerController implements IController {
public pubsubSystems = ['kafka', 'google'];
public pubsubSubscriptions: string[];

constructor(public trigger: IPubsubTrigger) {
constructor(public trigger: IPubsubTrigger,
public pubsubSubscriptionService: PubsubSubscriptionService) {
'ngInject';
pubsubSubscriptionService.getPubsubSubscriptions().then(subscriptions => {
this.pubsubSubscriptions = subscriptions;
});
}
}

export const PUBSUB_TRIGGER = 'spinnaker.core.pipeline.trigger.pubsub';
module(PUBSUB_TRIGGER, [
PIPELINE_CONFIG_PROVIDER,
PUBSUB_SUBSCRIPTION_SERVICE,
]).config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerTrigger({
label: 'Pub/Sub',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<ng-form name="pubsubTriggerForm">

<div class="form-group">
<label class="col-md-3 sm-label-right">
Pub/Sub System Type
</label>
<div class="col-md-6">
<select class="form-control input-sm"
ng-options="pubsubSystem for pubsubSystem in vm.pubsubSystems"
ng-model="vm.trigger.pubsubSystem">
<option value="">Select Pub/Sub System</option>
</select>
</div>
<div class="form-group">
<label class="col-md-3 sm-label-right">
Pub/Sub System Type
</label>
<div class="col-md-6">
<select class="form-control input-sm"
ng-options="pubsubSystem for pubsubSystem in vm.pubsubSystems"
ng-model="vm.trigger.pubsubSystem">
<option value="">Select Pub/Sub System</option>
</select>
</div>
</div>

<div class="form-group">
<div class="col-md-3 sm-label-right">
Subscription Name
</div>
<div class="col-md-9">
<input type="text" class="form-control input-sm" ng-model="vm.trigger.subscriptionName"/>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right">
Subscription Name
</div>

<div class="col-md-6">
<select class="form-control input-sm"
ng-options="pubsubSystem for pubsubSystem in vm.pubsubSubscriptions"
ng-model="vm.trigger.subscriptionName">
<option value="">Select Pub/Sub Subscription</option>
</select>
</div>
</div>
</ng-form>
1 change: 1 addition & 0 deletions app/scripts/modules/core/src/pubsub/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './pubsubSubscription.service';
15 changes: 15 additions & 0 deletions app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { module } from 'angular';

import { API_SERVICE, Api } from 'core/api/api.service';

export class PubsubSubscriptionService {
constructor(private API: Api) { 'ngInject'; }

public getPubsubSubscriptions(): ng.IPromise<string[]> {
return this.API.one('pubsub').one('subscriptions').get();
}
}

export const PUBSUB_SUBSCRIPTION_SERVICE = 'spinnaker.core.pubsubSubscription.service';
module(PUBSUB_SUBSCRIPTION_SERVICE, [API_SERVICE])
.service('pubsubSubscriptionService', PubsubSubscriptionService);

0 comments on commit 0c504d8

Please sign in to comment.