From 7d3eec6f3492d11750f035f6d4097347cfb1b761 Mon Sep 17 00:00:00 2001 From: Vladimir Shakhov Date: Tue, 30 Oct 2018 12:04:32 +0700 Subject: [PATCH] fix(dialogs): formatting and layout (#1373) * fix(dialogs): fix vm creation and volume creation dialogs * rename translation keys * add default precision * storage precision = 1 --- .../service-offering-dialog.component.html | 4 ++-- .../disk-offering-dialog.component.html | 11 +++++----- .../disk-offering-dialog.component.scss | 12 ++++++----- .../vm-statistics/vm-statistics.component.ts | 20 +++++++++++-------- .../shared/services/utils/utils.service.ts | 6 ++++-- .../template-creation.component.html | 4 ++-- src/i18n/en.json | 8 ++++---- src/i18n/ru.json | 8 ++++---- 8 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/app/service-offering/service-offering-dialog/service-offering-dialog.component.html b/src/app/service-offering/service-offering-dialog/service-offering-dialog.component.html index cd83d505c2..ef6011bc0e 100644 --- a/src/app/service-offering/service-offering-dialog/service-offering-dialog.component.html +++ b/src/app/service-offering/service-offering-dialog/service-offering-dialog.component.html @@ -35,8 +35,8 @@

diff --git a/src/app/shared/components/disk-offering/disk-offering-dialog/disk-offering-dialog.component.html b/src/app/shared/components/disk-offering/disk-offering-dialog/disk-offering-dialog.component.html index 506a991dcb..aafc8d43ac 100644 --- a/src/app/shared/components/disk-offering/disk-offering-dialog/disk-offering-dialog.component.html +++ b/src/app/shared/components/disk-offering/disk-offering-dialog/disk-offering-dialog.component.html @@ -12,11 +12,12 @@

- {{ offering.name }} + [value]="offering" + [checked]="offering.id === selectedDiskOffering?.id" + (click)="selectOffering(offering); preventTriggerExpansionPanel($event)" + > + {{ offering.name }} +
{ if (max !== Infinity) { return this.getStatsStringWithRestrictions(value, max, units, precision); @@ -179,10 +179,14 @@ export class VmStatisticsComponent implements OnInit, OnChanges { return this.getStatsStringWithNoRestrictions(value, units, precision); } - public getStatsStringFor(resource: keyof ResourcesData, units?: string): Observable { + public getStatsStringFor( + resource: keyof ResourcesData, + units?: string, + precision: number = Utils.defaultPrecision, + ): Observable { const consumed = this.resourceUsage[this.getModeKey()][resource]; const max = this.resourceUsage.max[resource]; - return this.getStatsString(consumed, max, units); + return this.getStatsString(consumed, max, units, precision); } public get memory(): Observable { @@ -197,13 +201,13 @@ export class VmStatisticsComponent implements OnInit, OnChanges { public get primaryStorage(): Observable { return this.translateService .get('UNITS.GB') - .pipe(switchMap(gb => this.getStatsStringFor('primaryStorage', gb))); + .pipe(switchMap(gb => this.getStatsStringFor('primaryStorage', gb, 1))); } public get secondaryStorage(): Observable { return this.translateService .get('UNITS.GB') - .pipe(switchMap(gb => this.getStatsStringFor('secondaryStorage', gb))); + .pipe(switchMap(gb => this.getStatsStringFor('secondaryStorage', gb, 1))); } public progressFor(resource: keyof ResourcesData): number { @@ -247,8 +251,8 @@ export class VmStatisticsComponent implements OnInit, OnChanges { precision?: number, ): Observable { const percents = this.getPercents(value, max); - const val = precision ? value.toFixed(precision) : value; - const m = precision ? max.toFixed(precision) : max; + const val = precision != null ? value.toFixed(precision) : value; + const m = precision != null ? max.toFixed(precision) : max; return of(`${val}/${m} ${units || ''} (${percents}%)`); } @@ -263,7 +267,7 @@ export class VmStatisticsComponent implements OnInit, OnChanges { } if (this.mode === StatsMode.Used) { - const val = precision ? value.toFixed(precision) : value; + const val = precision != null ? value.toFixed(precision) : value; return of(`${val} ${units || ''}`); } } diff --git a/src/app/shared/services/utils/utils.service.ts b/src/app/shared/services/utils/utils.service.ts index 435ecb6ee3..41203bad5f 100644 --- a/src/app/shared/services/utils/utils.service.ts +++ b/src/app/shared/services/utils/utils.service.ts @@ -2,6 +2,8 @@ import { RouterState } from '@angular/router'; import * as uuid from 'uuid'; export class Utils { + public static defaultPrecision = 0; + public static getUniqueId(): string { return uuid.v4(); } @@ -10,12 +12,12 @@ export class Utils { enumerator: number, denominator: number, denominatorExponent?: number, - precision?: number, + precision: number = Utils.defaultPrecision, ): number { const calculatedExponent = denominatorExponent != null ? denominatorExponent : 1; const calculatedDenominator = Math.pow(denominator, calculatedExponent); - if (precision) { + if (precision != null) { return +(enumerator / calculatedDenominator).toFixed(precision); } return enumerator / calculatedDenominator; diff --git a/src/app/template/template-creation/template-creation.component.html b/src/app/template/template-creation/template-creation.component.html index f58147d530..0e4ab962e7 100644 --- a/src/app/template/template-creation/template-creation.component.html +++ b/src/app/template/template-creation/template-creation.component.html @@ -135,8 +135,8 @@

{{ modeTranslationToken | translate }}

diff --git a/src/i18n/en.json b/src/i18n/en.json index 5653c6c74e..853839a33c 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -735,8 +735,8 @@ "IS_ROUTING": "Routing", "REQUIRES_HVM": "Requires HVM", "BOOTABLE": "Bootable", - "SHOW_ADDITIONAL": "Show additional fields", - "HIDE_ADDITIONAL": "Hide additional fields" + "SHOW_DETAILS": "Show details", + "HIDE_DETAILS": "Hide details" } }, "SNAPSHOT_PAGE": { @@ -1552,8 +1552,8 @@ "NO_AVAILABLE_OFFERINGS": "No available offerings", "CPU_MHZ": "{{ count }}x{{ speed }} MHz", "VM_WILL_BE_RESTARTED": "Virtual machine will be restarted", - "SHOW_ADDITIONAL_FIELDS": "Show additional fields", - "HIDE_ADDITIONAL_FIELDS": "Hide additional fields", + "SHOW_DETAILS": "Show details", + "HIDE_DETAILS": "Hide details", "CUSTOM_SERVICE_OFFERING": { "TITLE": "Custom offering", "CPU_NUMBER": "CPU cores", diff --git a/src/i18n/ru.json b/src/i18n/ru.json index ffa6d1af67..21f840a930 100644 --- a/src/i18n/ru.json +++ b/src/i18n/ru.json @@ -735,8 +735,8 @@ "IS_ROUTING": "Маршрутизация", "REQUIRES_HVM": "HVM", "BOOTABLE": "Загружаемый", - "SHOW_ADDITIONAL": "Показать дополнительные параметры", - "HIDE_ADDITIONAL": "Скрыть дополнительные параметры" + "SHOW_DETAILS": "Показать дополнительные параметры", + "HIDE_DETAILS": "Скрыть дополнительные параметры" } }, "SNAPSHOT_PAGE": { @@ -1548,8 +1548,8 @@ "NO_AVAILABLE_OFFERINGS": "Нет доступных предложений", "CPU_MHZ": "{{ count }}x{{ speed }} МГц", "VM_WILL_BE_RESTARTED": "Машина будет перезагружена", - "SHOW_ADDITIONAL_FIELDS": "Показать дополнительные параметры", - "HIDE_ADDITIONAL_FIELDS": "Скрыть дополнительные параметры", + "SHOW_DETAILS": "Показать дополнительные параметры", + "HIDE_DETAILS": "Скрыть дополнительные параметры", "CUSTOM_SERVICE_OFFERING": { "TITLE": "Настраиваемое предложение", "CPU_NUMBER": "Ядра CPU",