import { Injector } from '@angular/core' ; import { TranslateService } from '@ngx-translate/core' ; import { Observable } from 'rxjs/Rx' ; import { SubscriptionQuotaIds , LogCategories } from '../../../shared/models/constants' ; import { PortalResources } from '../../../shared/models/portal-resources' ; import { ServerFarm } from './../../../shared/models/server-farm' ; import { ArmObj } from '../../../shared/models/arm/arm-obj' ; import { BillingService } from './../../../shared/services/billing.service' ; import { LogService } from '../../../shared/services/log.service' ; import { SpecResourceSet } from './billing-models' ; import { PriceSpecDetail } from './price-spec-detail' ; import { SpecPickerInput , PlanSpecPickerData } from './plan-price-spec-manager' ; export interface PlanDetailsForPriceSpecInput { plan : ArmObj < ServerFarm > ; containsJbossSite : boolean ; } export interface PriceSpecInput { specPickerInput : SpecPickerInput < PlanSpecPickerData > ; subscriptionId : string ; planDetails ? : PlanDetailsForPriceSpecInput ; } export abstract class PriceSpec { abstract skuCode : string ; abstract tier : string ; abstract legacySkuName : string ; abstract topLevelFeatures : string [ ] ; abstract featureItems : PriceSpecDetail [ ] ; abstract hardwareItems : PriceSpecDetail [ ] ; abstract specResourceSet : SpecResourceSet ; abstract meterFriendlyName : string ; billingSkuCode ? : string ; cssClass = 'spec' ; allowZeroCost = false ; state : 'enabled' | 'disabled' | 'hidden' = 'enabled' ; upsellEnabled = false ; disabledMessage : string ; disabledInfoLink : string ; priceString : string ; price : number ; priceIsBaseline = false ; skuAvailabilityCheckFailed = false ; jbossMultiplier = 0 ; protected _billingService : BillingService ; protected _logService : LogService ; protected _ts : TranslateService ; constructor ( injector ) { this . _billingService = injector . get ( BillingService ) ; this . _logService = injector . get ( LogService ) ; this . _ts = injector . get ( TranslateService ) ; } initialize ( input ) { this . _logService . debug ( LogCategories . specPicker , `Call runInitialize for ${ this . skuCode }` ) ; return this . runInitialization ( input ) . do ( r => { this . _logService . debug ( LogCategories . specPicker , `Completed runInitialize for ${ this . skuCode }` ) ; } ) ; } abstract runInitialization ( input ) ; protected checkIfDreamspark ( subscriptionId ) { if ( this . state !== 'hidden' ) { return this . _billingService . checkIfSubscriptionHasQuotaId ( subscriptionId , SubscriptionQuotaIds . dreamSparkQuotaId ) . do ( isDreamspark => { if ( isDreamspark ) { this . state = 'disabled' ; this . disabledMessage = this . _ts . instant ( PortalResources . pricing_subscriptionNotAllowed ) ; this . disabledInfoLink = `https://account.windowsazure.com/Subscriptions/Statement?subscriptionId=${ subscriptionId }&isRdfeId=true&launchOption=upgrade` ; } } ) ; } return Observable . of ( null ) ; } public getUpsellSpecSkuCode ( ) { return null ; } public updateUpsellBanner ( ) { } }