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 2cd74c0 commit 045025d
Show file tree
Hide file tree
Showing 5 changed files with 60 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,35 @@
import { IController, module } from 'angular';

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

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

constructor(public trigger: IPubsubTrigger) {
constructor(public trigger: IPubsubTrigger,
pubsubSubscriptionService: PubsubSubscriptionService) {
'ngInject';

this.subscriptionsLoaded = false;
pubsubSubscriptionService.getPubsubSubscriptions()
.then(subscriptions => this.pubsubSubscriptions = subscriptions)
.catch(() => this.pubsubSubscriptions = [])
.finally(() => this.subscriptionsLoaded = true);
}
}

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,30 @@
<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" ng-if="vm.subscriptionsLoaded">
<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>
<div ng-if="!vm.subscriptionsLoaded">
<span class="fa fa-cog fa-spin"></span>
</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, IPromise } from 'angular';

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

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

public getPubsubSubscriptions(): 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 045025d

Please sign in to comment.