import { Component , Injector , OnInit } from '@angular/core' ; import { ComboboxItemDto , CommonLookupServiceProxy , HostSettingsEditDto , HostSettingsServiceProxy , SendTestEmailInput , SettingScopes } from '@shared/service-proxies/service-proxies' ; import { AppComponentBase } from '@shared/common/app-component-base' ; @ Component ( { templateUrl : './host-settings.component.html' , } ) export class HostSettingsComponent extends AppComponentBase implements OnInit { hostSettings : HostSettingsEditDto = undefined ; editions : ComboboxItemDto [ ] = undefined ; testEmailAddress : string = undefined ; showTimezoneSelection = abp . clock . provider . supportsMultipleTimezone ; defaultTimezoneScope : SettingScopes = SettingScopes . Application ; usingDefaultTimeZone = false ; initialTimeZone : string = undefined ; selectedEditionId = '' ; constructor ( injector , private _hostSettingService , private _commonLookupService ) { super ( injector ) ; } loadHostSettings ( ) { const self = this ; self . _hostSettingService . getAllSettings ( ) . subscribe ( setting => { self . hostSettings = setting ; self . initialTimeZone = setting . general . timezone ; self . usingDefaultTimeZone = setting . general . timezoneForComparison === self . setting . get ( 'Abp.Timing.TimeZone' ) ; if ( self . hostSettings . tenantManagement . defaultEditionId ) { self . selectedEditionId = self . hostSettings . tenantManagement . defaultEditionId + '' ; } } ) ; } loadEditions ( ) { const self = this ; self . _commonLookupService . getEditionsForCombobox ( false ) . subscribe ( ( result ) => { self . editions = result . items ; const notAssignedEdition = new ComboboxItemDto ( ) ; notAssignedEdition . value = '' ; notAssignedEdition . displayText = self . l ( 'NotAssigned' ) ; self . editions . unshift ( notAssignedEdition ) ; } ) ; } init ( ) { const self = this ; self . testEmailAddress = self . appSession . user . emailAddress ; self . showTimezoneSelection = abp . clock . provider . supportsMultipleTimezone ; self . loadHostSettings ( ) ; self . loadEditions ( ) ; } ngOnInit ( ) { const self = this ; self . init ( ) ; } sendTestEmail ( ) { const self = this ; const input = new SendTestEmailInput ( ) ; input . emailAddress = self . testEmailAddress ; self . _hostSettingService . sendTestEmail ( input ) . subscribe ( result => { self . notify . info ( self . l ( 'TestEmailSentSuccessfully' ) ) ; } ) ; } saveAll ( ) { const self = this ; self . hostSettings . tenantManagement . defaultEditionId = parseInt ( self . selectedEditionId ) ; self . _hostSettingService . updateAllSettings ( self . hostSettings ) . subscribe ( result => { self . notify . info ( self . l ( 'SavedSuccessfully' ) ) ; if ( abp . clock . provider . supportsMultipleTimezone && self . usingDefaultTimeZone && self . initialTimeZone !== self . hostSettings . general . timezone ) { self . message . info ( self . l ( 'TimeZoneSettingChangedRefreshPageNotification' ) ) . then ( ( ) => { window . location . reload ( ) ; } ) ; } } ) ; } }