Browse Source

UI: Added show timezone Abbr in timewindow component

pull/4259/head
Vladyslav_Prykhodko 6 years ago
parent
commit
098f42040b
  1. 2
      ui-ngx/src/app/shared/components/time/timewindow.component.html
  2. 4
      ui-ngx/src/app/shared/components/time/timewindow.component.scss
  3. 9
      ui-ngx/src/app/shared/components/time/timewindow.component.ts
  4. 5
      ui-ngx/src/app/shared/models/time/time.models.ts

2
ui-ngx/src/app/shared/components/time/timewindow.component.html

@ -34,7 +34,7 @@
(click)="openEditMode()" (click)="openEditMode()"
matTooltip="{{ 'timewindow.edit' | translate }}" matTooltip="{{ 'timewindow.edit' | translate }}"
[matTooltipPosition]="tooltipPosition"> [matTooltipPosition]="tooltipPosition">
{{innerValue?.displayValue}} {{innerValue?.displayValue}} <span [fxShow]="innerValue?.displayTimezoneAbbr !== ''">| <span class="timezone-abbr">{{innerValue.displayTimezoneAbbr}}</span></span>
</span> </span>
<button *ngIf="direction === 'right'" [disabled]="timewindowDisabled" mat-icon-button class="tb-mat-32" <button *ngIf="direction === 'right'" [disabled]="timewindowDisabled" mat-icon-button class="tb-mat-32"
type="button" type="button"

4
ui-ngx/src/app/shared/components/time/timewindow.component.scss

@ -27,5 +27,9 @@
pointer-events: all; pointer-events: all;
cursor: pointer; cursor: pointer;
} }
.timezone-abbr {
font-weight: 500;
}
} }
} }

9
ui-ngx/src/app/shared/components/time/timewindow.component.ts

@ -31,6 +31,7 @@ import { TranslateService } from '@ngx-translate/core';
import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-string.pipe'; import { MillisecondsToTimeStringPipe } from '@shared/pipe/milliseconds-to-time-string.pipe';
import { import {
cloneSelectedTimewindow, cloneSelectedTimewindow,
getTimezoneInfo,
HistoryWindowType, HistoryWindowType,
initModelFromDefaultTimewindow, initModelFromDefaultTimewindow,
QuickTimeIntervalTranslationMap, QuickTimeIntervalTranslationMap,
@ -51,7 +52,7 @@ import { BreakpointObserver } from '@angular/cdk/layout';
import { WINDOW } from '@core/services/window.service'; import { WINDOW } from '@core/services/window.service';
import { TimeService } from '@core/services/time.service'; import { TimeService } from '@core/services/time.service';
import { TooltipPosition } from '@angular/material/tooltip'; import { TooltipPosition } from '@angular/material/tooltip';
import { deepClone } from '@core/utils'; import { deepClone, isDefinedAndNotNull } from '@core/utils';
import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { coerceBooleanProperty } from '@angular/cdk/coercion';
// @dynamic // @dynamic
@ -306,6 +307,12 @@ export class TimewindowComponent implements OnInit, OnDestroy, ControlValueAcces
this.innerValue.displayValue += this.translate.instant('timewindow.period', {startTime: startString, endTime: endString}); this.innerValue.displayValue += this.translate.instant('timewindow.period', {startTime: startString, endTime: endString});
} }
} }
if (isDefinedAndNotNull(this.innerValue.timezone) && this.innerValue.timezone !== '') {
this.innerValue.displayValue += ' ';
this.innerValue.displayTimezoneAbbr = getTimezoneInfo(this.innerValue.timezone).abbr;
} else {
this.innerValue.displayTimezoneAbbr = '';
}
} }
hideLabel() { hideLabel() {

5
ui-ngx/src/app/shared/models/time/time.models.ts

@ -92,6 +92,7 @@ export interface Aggregation {
export interface Timewindow { export interface Timewindow {
displayValue?: string; displayValue?: string;
displayTimezoneAbbr?: string;
hideInterval?: boolean; hideInterval?: boolean;
hideAggregation?: boolean; hideAggregation?: boolean;
hideAggInterval?: boolean; hideAggInterval?: boolean;
@ -731,6 +732,7 @@ export interface TimezoneInfo {
name: string; name: string;
offset: string; offset: string;
nOffset: number; nOffset: number;
abbr: string;
} }
let timezones: TimezoneInfo[] = null; let timezones: TimezoneInfo[] = null;
@ -744,7 +746,8 @@ export function getTimezones(): TimezoneInfo[] {
id: zoneName, id: zoneName,
name: zoneName.replace(/_/g, ' '), name: zoneName.replace(/_/g, ' '),
offset: `UTC${tz.format('Z')}`, offset: `UTC${tz.format('Z')}`,
nOffset: tz.utcOffset() nOffset: tz.utcOffset(),
abbr: tz.zoneAbbr()
}; };
}); });
} }

Loading…
Cancel
Save