UNPKG

@spotinst/spinnaker-deck

Version:

Spinnaker-Deck service, forked with support to Spotinst

52 lines (44 loc) 1.39 kB
import { Application } from 'core/application'; import { ModalInjector } from 'core/reactShims'; import { IJob, ITaskCommand, TaskExecutor } from 'core/task/taskExecutor'; export class PagerDutyWriter { public static pageApplicationOwnerModal(app: Application): void { ModalInjector.modalService .open({ templateUrl: require('./pageApplicationOwner.html'), controller: 'PageModalCtrl as ctrl', resolve: { application: () => app, }, }) .result.catch(() => {}); } public static sendPage( applications: Application[], keys: string[], reason: string, ownerApp: Application, details?: { [key: string]: any }, ): PromiseLike<any> { const job = { type: 'pageApplicationOwner', message: reason, details, } as IJob; if (applications && applications.length > 0) { job.applications = applications.map((app) => app.name); } if (keys && keys.length > 0) { job.keys = keys; } const task = { application: ownerApp, job: [job], description: 'Send Page', } as ITaskCommand; return TaskExecutor.executeTask(task); } public static pageApplicationOwner(application: Application, reason: string, details?: string): PromiseLike<any> { return this.sendPage([application], undefined, reason, application, { details }); } }