Skip to content

Commit 754c066

Browse files
committed
fix: timezone changes on an instance don't get updated when access by Federation Server
1 parent 095bb90 commit 754c066

File tree

6 files changed

+41
-31
lines changed

6 files changed

+41
-31
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
## Bugfix
33
-Fixed an issue preventing incident status updates when entering long solutions.
44
-Fixed an issue blocking incident creation from the Alerts panel.
5-
-Added Asia/Jakarta timezone to the TIMEZONES list.
5+
-Added Asia/Jakarta timezone to the TIMEZONES list.
6+
-Fixed Timezone changes on an instance don't get updated when access by Federation Server

frontend/src/app/app-management/app-management.module.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {NgxSortableModule} from 'ngx-sortable-2';
1010
import {ComplianceManagementModule} from '../compliance/compliance-management/compliance-management.module';
1111
import {NavBehavior} from '../shared/behaviors/nav.behavior';
1212
import {VersionUpdateBehavior} from '../shared/behaviors/version-update.behavior';
13-
import {TimezoneFormatService} from '../shared/services/utm-timezone.service';
1413
import {UtmSharedModule} from '../shared/utm-shared.module';
1514
import {AppConfigComponent} from './app-config/app-config.component';
1615
import {AppLogsComponent} from './app-logs/app-logs.component';
@@ -102,7 +101,7 @@ import {UtmApiDocComponent} from './utm-api-doc/utm-api-doc.component';
102101
HealthChecksComponent,
103102
],
104103
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
105-
providers: [NavBehavior, VersionUpdateBehavior, TimezoneFormatService]
104+
providers: [NavBehavior, VersionUpdateBehavior]
106105
})
107106
export class AppManagementModule {
108107
}

frontend/src/app/app.component.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {ThemeChangeBehavior} from './shared/behaviors/theme-change.behavior';
88
import {ADMIN_ROLE, USER_ROLE} from './shared/constants/global.constant';
99
import {AppThemeLocationEnum} from './shared/enums/app-theme-location.enum';
1010
import {UtmAppThemeService} from './shared/services/theme/utm-app-theme.service';
11-
import {TimezoneFormatService} from './shared/services/utm-timezone.service';
1211

1312
@Component({
1413
selector: 'app-root',
@@ -32,8 +31,7 @@ export class AppComponent implements OnInit {
3231
private themeChangeBehavior: ThemeChangeBehavior,
3332
private utmAppThemeService: UtmAppThemeService,
3433
private router: Router, private renderer: Renderer2,
35-
private apiServiceCheckerService: ApiServiceCheckerService,
36-
private timezoneFormatService: TimezoneFormatService) {
34+
private apiServiceCheckerService: ApiServiceCheckerService) {
3735

3836
this.translate.setDefaultLang('en');
3937

@@ -128,7 +126,6 @@ export class AppComponent implements OnInit {
128126
}
129127

130128
init() {
131-
this.timezoneFormatService.loadTimezoneAndFormat();
132129
this.getReportLogo();
133130
}
134131
}

frontend/src/app/app.module.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from '@angular/common/http';
2-
import {CUSTOM_ELEMENTS_SCHEMA, Injector, NgModule} from '@angular/core';
2+
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Injector, NgModule} from '@angular/core';
33
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
44
import {BrowserModule} from '@angular/platform-browser';
55
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@@ -36,6 +36,10 @@ import {TimezoneFormatService} from './shared/services/utm-timezone.service';
3636
import {UtmSharedModule} from './shared/utm-shared.module';
3737
import {AccountService} from "./core/auth/account.service";
3838

39+
export function initTimezoneFormat(timezoneService: TimezoneFormatService) {
40+
return () => timezoneService.loadTimezoneAndFormat();
41+
}
42+
3943
@NgModule({
4044
declarations: [
4145
AppComponent,
@@ -105,11 +109,16 @@ import {AccountService} from "./core/auth/account.service";
105109
useClass: ManageHttpInterceptor,
106110
multi: true,
107111
},
112+
{
113+
provide: APP_INITIALIZER,
114+
useFactory: initTimezoneFormat,
115+
deps: [TimezoneFormatService],
116+
multi: true
117+
},
108118
NewAlertBehavior,
109119
NavBehavior,
110120
AlertIncidentStatusChangeBehavior,
111-
GettingStartedBehavior,
112-
TimezoneFormatService
121+
GettingStartedBehavior
113122
],
114123
bootstrap: [AppComponent],
115124
schemas: [CUSTOM_ELEMENTS_SCHEMA],
@@ -118,6 +127,5 @@ export class AppModule {
118127
constructor(private dpConfig: NgbDatepickerConfig, private config: NgbModalConfig) {
119128
this.dpConfig.minDate = {year: moment().year() - 100, month: 1, day: 1};
120129
config.backdrop = 'static';
121-
//timezoneFormatService.loadTimezoneAndFormat();
122130
}
123131
}

frontend/src/app/shared/components/utm/config/app-config-sections/app-config-sections.component.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
TIMEZONES
1010
} from '../../../../constants/date-timezone-date.const';
1111
import {UtmConfigParamsService} from '../../../../services/config/utm-config-params.service';
12+
import {TimezoneFormatService} from "../../../../services/utm-timezone.service";
1213
import {ConfigDataTypeEnum, SectionConfigParamType} from '../../../../types/configuration/section-config-param.type';
1314
import {ApplicationConfigSectionEnum, SectionConfigType} from '../../../../types/configuration/section-config.type';
1415
import {AppConfigDeleteConfirmComponent} from '../app-config-delete-confirm/app-config-delete-confirm.component';
@@ -41,7 +42,8 @@ export class AppConfigSectionsComponent implements OnInit, OnDestroy {
4142
constructor(private utmConfigParamsService: UtmConfigParamsService,
4243
private modalService: NgbModal,
4344
private restartApiBehavior: RestartApiBehavior,
44-
private toastService: UtmToastService) {
45+
private toastService: UtmToastService,
46+
private timezoneFormatService: TimezoneFormatService) {
4547
}
4648

4749

@@ -162,19 +164,12 @@ export class AppConfigSectionsComponent implements OnInit, OnDestroy {
162164
});
163165
}
164166

165-
refreshTimeSettings() {
167+
async refreshTimeSettings() {
166168
const index = this.configToSave
167169
.findIndex(value => value.confParamShort === DATE_SETTING_TIMEZONE_SHORT
168170
|| value.confParamShort === DATE_SETTING_FORMAT_SHORT);
169171
if (index !== -1) {
170-
window.location.reload();
171-
// const timezone = this.getConfigToSaveValue(DATE_SETTING_TIMEZONE_SHORT);
172-
// const dateFormat = this.getConfigToSaveValue(DATE_SETTING_FORMAT_SHORT);
173-
// const format: DatePipeDefaultOptions = {
174-
// dateFormat: dateFormat ? dateFormat : DEFAULT_DATE_SETTING_DATE,
175-
// timezone: timezone ? timezone : DEFAULT_DATE_SETTING_TIMEZONE
176-
// };
177-
// this.timezoneFormatService.setDateFormatSubject(format);
172+
await this.timezoneFormatService.loadTimezoneAndFormat();
178173
}
179174
}
180175

frontend/src/app/shared/services/utm-timezone.service.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,26 @@ export class TimezoneFormatService {
1818
constructor(private httpClient: HttpClient) {
1919
}
2020

21-
loadTimezoneAndFormat(): void {
22-
this.httpClient.get(this.resourceUrl)
23-
.subscribe(response => {
24-
const configs = response;
25-
const timezone = this.getSettingValue(configs, DATE_SETTING_TIMEZONE_SHORT);
26-
const dateFormat = this.getSettingValue(configs, DATE_SETTING_FORMAT_SHORT);
27-
this.dateFormatSubject.next({dateFormat: dateFormat ? dateFormat : 'medium', timezone: timezone ? timezone : 'UTC'});
28-
}, error => {
29-
console.error('Unable to set default time format');
30-
});
21+
loadTimezoneAndFormat(): Promise<void> {
22+
return new Promise((resolve, reject) => {
23+
this.httpClient.get(this.resourceUrl)
24+
.subscribe(
25+
response => {
26+
const configs = response;
27+
const timezone = this.getSettingValue(configs, DATE_SETTING_TIMEZONE_SHORT);
28+
const dateFormat = this.getSettingValue(configs, DATE_SETTING_FORMAT_SHORT);
29+
this.dateFormatSubject.next({
30+
dateFormat: dateFormat ? dateFormat : 'medium',
31+
timezone: timezone ? timezone : 'UTC'
32+
});
33+
resolve();
34+
},
35+
error => {
36+
console.error('Unable to set default time format', error);
37+
reject(error);
38+
}
39+
);
40+
});
3141
}
3242

3343
getSettingValue(settings: any, key: string): string {

0 commit comments

Comments
 (0)