Skip to content

Commit

Permalink
NAS-132626 / 25.04 / Fix styles for contract mentions on sys-info wid…
Browse files Browse the repository at this point in the history
…gets on the dashboard and general settings (#11272)
  • Loading branch information
RehanY147 authored Jan 20, 2025
1 parent 62bbc27 commit ddd0812
Show file tree
Hide file tree
Showing 100 changed files with 295 additions and 123 deletions.
27 changes: 26 additions & 1 deletion src/app/interfaces/system-info.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface SystemLicense {
addhw_detail: unknown[];
contract_end: ApiDate;
contract_start: ApiDate;
contract_type: string;
contract_type: ContractType;
customer_name: string;
expired: boolean;
features: LicenseFeature[];
Expand All @@ -43,3 +43,28 @@ export interface SystemLicense {
system_serial: string;
system_serial_ha: string;
}

export enum ContractType {
Gold = 'GOLD',
SilverInternational = 'SILVERINTERNATIONAL',
Legacy = 'LEGACY',
Standard = 'STANDARD',
Bronze = 'BRONZE',
Silver = 'SILVER',
FreeNasCertified = 'FREENASCERTIFIED',
FreeNasMini = 'FREENASMINI',
}

export function getLabelForContractType(contractType: ContractType): string {
const contractTypeToLabelsMap: Record<ContractType, string> = {
[ContractType.Gold]: 'Gold',
[ContractType.Legacy]: 'Legacy',
[ContractType.Standard]: 'Standard',
[ContractType.Bronze]: 'Bronze',
[ContractType.Silver]: 'Silver',
[ContractType.FreeNasCertified]: 'Free NAS Certified',
[ContractType.FreeNasMini]: 'Free NAS Mini',
[ContractType.SilverInternational]: 'Silver International',
};
return contractTypeToLabelsMap[contractType] || contractType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,24 @@ <h3>{{ 'System Information' | translate }}</h3>

@if (systemInfo()?.license) {
<mat-list-item>
<strong>{{ 'Support License' | translate }}:</strong>
<span>
{{
'{license} contract, expires {date}' | translate:
{
license: systemInfo().license.contract_type | titlecase,
date: systemInfo().license.contract_end.$value,
}
}}
</span>
<div class="license-info">
<div class="title">{{ 'Support License' | translate }}:</div>
<div class="info">
<div>
{{
'{license} Contract,' | translate:
{
license: getLabelForContractType(systemInfo().license.contract_type),
}
}}
</div>
<div>
{{
'Expires on {date}' | translate: { date: systemInfo().license.contract_end.$value }
}}
</div>
</div>
</div>
</mat-list-item>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.license-info {
display: flex;
gap: 10px;
width: 100%;

.title {
font-weight: bold;
height: 100%;
}

.info {
width: 100%;
}

div {
span {
display: inline-block;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { Codename } from 'app/enums/codename.enum';
import { ProductType } from 'app/enums/product-type.enum';
import { LoadingState } from 'app/helpers/operators/to-loading-state.helper';
import { SystemLicense, SystemInfo } from 'app/interfaces/system-info.interface';
import { SystemLicense, SystemInfo, ContractType } from 'app/interfaces/system-info.interface';
import { selectUpdateJobForActiveNode } from 'app/modules/jobs/store/job.selectors';
import { LocaleService } from 'app/modules/language/locale.service';
import { WidgetResourcesService } from 'app/pages/dashboard/services/widget-resources.service';
Expand All @@ -33,7 +33,7 @@ describe('WidgetSysInfoActiveComponent', () => {
version: 'TrueNAS-SCALE-24.10.0-MASTER-20240301-233006',
codename: Codename.ElectricEel,
license: {
contract_type: 'BEST',
contract_type: ContractType.Gold,
contract_end: {
$type: 'date',
$value: '2025-01-01',
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('WidgetSysInfoActiveComponent', () => {
expect(items).toEqual([
'Platform: TRUENAS-M40-HA',
'Version: ElectricEel-24.10.0-MASTER-20240301-233006',
'Support License: Best contract, expires 2025-01-01',
'Support License: Gold Contract, Expires on 2025-01-01',
'System Serial: AA-00001',
'Hostname: test-hostname-a',
'Uptime: 23 hours 12 minutes as of 10:34',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TitleCasePipe } from '@angular/common';
import {
Component, ChangeDetectionStrategy, input,
computed,
Expand All @@ -13,6 +12,7 @@ import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { filter, map } from 'rxjs';
import { getLabelForContractType } from 'app/interfaces/system-info.interface';
import { CopyButtonComponent } from 'app/modules/buttons/copy-button/copy-button.component';
import { iconMarker } from 'app/modules/ix-icon/icon-marker.util';
import { IxIconComponent } from 'app/modules/ix-icon/ix-icon.component';
Expand All @@ -33,7 +33,7 @@ import {
@Component({
selector: 'ix-widget-sys-info-active',
templateUrl: './widget-sys-info-active.component.html',
styleUrls: ['../common/widget-sys-info.scss'],
styleUrls: ['../common/widget-sys-info.scss', './widget-sys-info-active.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
Expand All @@ -52,7 +52,6 @@ import {
CopyButtonComponent,
TranslateModule,
UptimePipe,
TitleCasePipe,
],
})
export class WidgetSysInfoActiveComponent {
Expand All @@ -63,6 +62,7 @@ export class WidgetSysInfoActiveComponent {
isHaLicensed = toSignal(this.store$.select(selectIsHaLicensed));
hasEnclosureSupport = toSignal(this.store$.select(selectHasEnclosureSupport));
isUpdateRunning = toSignal(this.store$.select(selectUpdateJobForActiveNode));
protected readonly getLabelForContractType = getLabelForContractType;

updateAvailable = toSignal(this.resources.updateAvailable$);
systemInfo = toSignal(this.resources.systemInfo$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,24 @@ <h3>{{ 'System Information' | translate }} <small>{{ 'standby' | translate }}</s

@if (systemInfo()?.license) {
<mat-list-item>
<strong>{{ 'Support License' | translate }}:</strong>
<span>
{{
'{license} contract, expires {date}' | translate:
{
license: systemInfo().license.contract_type | titlecase,
date: systemInfo().license.contract_end.$value,
}
}}
</span>
<div class="license-info">
<div class="title">{{ 'Support License' | translate }}:</div>
<div class="info">
<div>
{{
'{license} Contract,' | translate:
{
license: getLabelForContractType(systemInfo().license.contract_type),
}
}}
</div>
<div>
{{
'Expires on {date}' | translate: { date: systemInfo().license.contract_end.$value }
}}
</div>
</div>
</div>
</mat-list-item>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.license-info {
display: flex;
gap: 10px;
width: 100%;

.title {
font-weight: bold;
height: 100%;
}

.info {
width: 100%;
}

div {
span {
display: inline-block;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { Codename } from 'app/enums/codename.enum';
import { ProductType } from 'app/enums/product-type.enum';
import { LoadingState } from 'app/helpers/operators/to-loading-state.helper';
import { SystemLicense, SystemInfo } from 'app/interfaces/system-info.interface';
import { SystemLicense, SystemInfo, ContractType } from 'app/interfaces/system-info.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { selectUpdateJobForPassiveNode } from 'app/modules/jobs/store/job.selectors';
import { LocaleService } from 'app/modules/language/locale.service';
Expand All @@ -37,7 +37,7 @@ describe('WidgetSysInfoPassiveComponent', () => {
version: 'TrueNAS-SCALE-24.10.0-MASTER-20240301-233006',
codename: Codename.ElectricEel,
license: {
contract_type: 'BEST',
contract_type: ContractType.Gold,
contract_end: {
$type: 'date',
$value: '2025-01-01',
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('WidgetSysInfoPassiveComponent', () => {
expect(items).toEqual([
'Platform: TRUENAS-M40-HA',
'Version: ElectricEel-24.10.0-MASTER-20240301-233006',
'Support License: Best contract, expires 2025-01-01',
'Support License: Gold Contract, Expires on 2025-01-01',
'System Serial: AA-00002',
'Hostname: test-hostname-b',
'Uptime: 1 minute 17 seconds as of 10:34',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TitleCasePipe } from '@angular/common';
import {
ChangeDetectionStrategy, Component, computed, effect, input,
} from '@angular/core';
Expand All @@ -18,6 +17,7 @@ import {
import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive';
import { Role } from 'app/enums/role.enum';
import { helptextSystemFailover } from 'app/helptext/system/failover';
import { getLabelForContractType } from 'app/interfaces/system-info.interface';
import { CopyButtonComponent } from 'app/modules/buttons/copy-button/copy-button.component';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { iconMarker } from 'app/modules/ix-icon/icon-marker.util';
Expand All @@ -40,7 +40,7 @@ import {
@Component({
selector: 'ix-widget-sys-info-passive',
templateUrl: './widget-sys-info-passive.component.html',
styleUrls: ['../common/widget-sys-info.scss'],
styleUrls: ['../common/widget-sys-info.scss', './widget-sys-info-passive.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
Expand All @@ -58,7 +58,6 @@ import {
CopyButtonComponent,
TranslateModule,
UptimePipe,
TitleCasePipe,
],
})
export class WidgetSysInfoPassiveComponent {
Expand All @@ -73,6 +72,7 @@ export class WidgetSysInfoPassiveComponent {
isHaEnabled = toSignal(this.store$.select(selectIsHaEnabled));
hasEnclosureSupport = toSignal(this.store$.select(selectHasEnclosureSupport));
isUpdateRunning = toSignal(this.store$.select(selectUpdateJobForPassiveNode));
protected readonly getLabelForContractType = getLabelForContractType;

updateAvailable = toSignal(this.resources.updateAvailable$);
systemInfo = toSignal(this.resources.systemInfo$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
<div class="sys-info-row">
<span class="label">{{ 'Contract Type' | translate }}:</span>
<span class="value">{{ license.contract_type }}</span>
<span class="value">{{ getLabelForContractType(license.contract_type) }}</span>
</div>
<div class="sys-info-row">
<span class="label">{{ 'Expiration Date' | translate }}:</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('SysInfoComponent', () => {
'Licensed Serials:': licenseInfo.system_serial,
'System Serial:': systemInfo.system_serial,
'Features:': licenseInfo.features.join(', '),
'Contract Type:': licenseInfo.contract_type,
'Contract Type:': 'Gold',
'Expiration Date:': `${licenseInfo.expiration_date} ( EXPIRED )`,
'Additional Hardware:': licenseInfo.add_hardware,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ChangeDetectionStrategy, Component, input,
} from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { getLabelForContractType } from 'app/interfaces/system-info.interface';
import { LicenseInfoInSupport } from 'app/pages/system/general-settings/support/license-info-in-support.interface';
import { SystemInfoInSupport } from 'app/pages/system/general-settings/support/system-info-in-support.interface';

Expand All @@ -16,4 +17,6 @@ export class SysInfoComponent {
readonly hasLicense = input<boolean>();
readonly licenseInfo = input<LicenseInfoInSupport>();
readonly systemInfo = input.required<SystemInfoInSupport>();

protected readonly getLabelForContractType = getLabelForContractType;
}
3 changes: 2 additions & 1 deletion src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@
"Experimental": "",
"Expiration Date": "",
"Expires On": "",
"Expires on {date}": "",
"Export": "",
"Export All Keys": "",
"Export As {fileType}": "",
Expand Down Expand Up @@ -5262,7 +5263,7 @@
"{hours, plural, =1 {# hour} other {# hours}}": "",
"{interfaceName} must start with \"{prefix}\" followed by an unique number": "",
"{key} Key": "",
"{license} contract, expires {date}": "",
"{license} Contract,": "",
"{minutes, plural, =1 {# minute} other {# minutes}}": "",
"{n, plural, =0 {No Errors} one {# Error} other {# Errors}}": "",
"{n, plural, =0 {No Tasks} one {# Task} other {# Tasks}} Configured": "",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@
"Experimental": "",
"Expiration Date": "",
"Expires On": "",
"Expires on {date}": "",
"Export": "",
"Export All Keys": "",
"Export As {fileType}": "",
Expand Down Expand Up @@ -5262,7 +5263,7 @@
"{hours, plural, =1 {# hour} other {# hours}}": "",
"{interfaceName} must start with \"{prefix}\" followed by an unique number": "",
"{key} Key": "",
"{license} contract, expires {date}": "",
"{license} Contract,": "",
"{minutes, plural, =1 {# minute} other {# minutes}}": "",
"{n, plural, =0 {No Errors} one {# Error} other {# Errors}}": "",
"{n, plural, =0 {No Tasks} one {# Task} other {# Tasks}} Configured": "",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@
"Experimental": "",
"Expiration Date": "",
"Expires On": "",
"Expires on {date}": "",
"Export": "",
"Export All Keys": "",
"Export As {fileType}": "",
Expand Down Expand Up @@ -5262,7 +5263,7 @@
"{hours, plural, =1 {# hour} other {# hours}}": "",
"{interfaceName} must start with \"{prefix}\" followed by an unique number": "",
"{key} Key": "",
"{license} contract, expires {date}": "",
"{license} Contract,": "",
"{minutes, plural, =1 {# minute} other {# minutes}}": "",
"{n, plural, =0 {No Errors} one {# Error} other {# Errors}}": "",
"{n, plural, =0 {No Tasks} one {# Task} other {# Tasks}} Configured": "",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@
"Experimental": "",
"Expiration Date": "",
"Expires On": "",
"Expires on {date}": "",
"Export": "",
"Export All Keys": "",
"Export As {fileType}": "",
Expand Down Expand Up @@ -5262,7 +5263,7 @@
"{hours, plural, =1 {# hour} other {# hours}}": "",
"{interfaceName} must start with \"{prefix}\" followed by an unique number": "",
"{key} Key": "",
"{license} contract, expires {date}": "",
"{license} Contract,": "",
"{minutes, plural, =1 {# minute} other {# minutes}}": "",
"{n, plural, =0 {No Errors} one {# Error} other {# Errors}}": "",
"{n, plural, =0 {No Tasks} one {# Task} other {# Tasks}} Configured": "",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@
"Experimental": "",
"Expiration Date": "",
"Expires On": "",
"Expires on {date}": "",
"Export": "",
"Export All Keys": "",
"Export As {fileType}": "",
Expand Down Expand Up @@ -5262,7 +5263,7 @@
"{hours, plural, =1 {# hour} other {# hours}}": "",
"{interfaceName} must start with \"{prefix}\" followed by an unique number": "",
"{key} Key": "",
"{license} contract, expires {date}": "",
"{license} Contract,": "",
"{minutes, plural, =1 {# minute} other {# minutes}}": "",
"{n, plural, =0 {No Errors} one {# Error} other {# Errors}}": "",
"{n, plural, =0 {No Tasks} one {# Task} other {# Tasks}} Configured": "",
Expand Down
Loading

0 comments on commit ddd0812

Please sign in to comment.