diff --git a/app/scripts/modules/core/src/index.ts b/app/scripts/modules/core/src/index.ts index f45ad180f6c..b5ff26e17d7 100644 --- a/app/scripts/modules/core/src/index.ts +++ b/app/scripts/modules/core/src/index.ts @@ -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'; diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts index c4fe3d2f085..eed675274f7 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts +++ b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsub.trigger.ts @@ -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', diff --git a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html index aa9357d31fc..299ed51e0d6 100644 --- a/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html +++ b/app/scripts/modules/core/src/pipeline/config/triggers/pubsub/pubsubTrigger.html @@ -1,25 +1,30 @@ - -
- -
- -
+
+ +
+
+
-
-
- Subscription Name -
-
- -
+
+
+ Subscription Name
- +
+ +
+
+
+ +
diff --git a/app/scripts/modules/core/src/pubsub/index.ts b/app/scripts/modules/core/src/pubsub/index.ts new file mode 100644 index 00000000000..9661b25e9ac --- /dev/null +++ b/app/scripts/modules/core/src/pubsub/index.ts @@ -0,0 +1 @@ +export * from './pubsubSubscription.service'; diff --git a/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts b/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts new file mode 100644 index 00000000000..4f19b008ec9 --- /dev/null +++ b/app/scripts/modules/core/src/pubsub/pubsubSubscription.service.ts @@ -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 { + 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);