-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-132261 / 25.04 / Setup Truenas Connect integration (#11355)
- Loading branch information
Showing
113 changed files
with
2,843 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { marker as T } from '@biesbjerg/ngx-translate-extract-marker'; | ||
|
||
export enum TruenasConnectStatus { | ||
Disabled = 'DISABLED', | ||
ClaimTokenMissing = 'CLAIM_TOKEN_MISSING', | ||
RegistrationFinalizationWaiting = 'REGISTRATION_FINALIZATION_WAITING', | ||
RegistrationFinalizationFailed = 'REGISTRATION_FINALIZATION_FAILED', | ||
RegistrationFinalizationTimeout = 'REGISTRATION_FINALIZATION_TIMEOUT', | ||
RegistrationFinalizationSuccess = 'REGISTRATION_FINALIZATION_SUCCESS', | ||
CertGenerationInProgress = 'CERT_GENERATION_IN_PROGRESS', | ||
CertGenerationFailed = 'CERT_GENERATION_FAILED', | ||
CertGenerationSuccess = 'CERT_GENERATION_SUCCESS', | ||
CertConfigurationFailure = 'CERT_CONFIGURATION_FAILURE', | ||
CertRenewalInProgress = 'CERT_RENEWAL_IN_PROGRESS', | ||
CertRenewalFailure = 'CERT_RENEWAL_FAILURE', | ||
CertRenewalSuccess = 'CERT_RENEWAL_SUCCESS', | ||
Configured = 'CONFIGURED', | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export const TruenasConnectStatusReason: Record<TruenasConnectStatus, string> = { | ||
[TruenasConnectStatus.Disabled]: T('TrueNAS Connect is disabled'), | ||
[TruenasConnectStatus.ClaimTokenMissing]: T('Waiting for claim token to be generated'), | ||
[TruenasConnectStatus.RegistrationFinalizationWaiting]: T('Waiting for registration with TrueNAS Connect to complete'), | ||
[TruenasConnectStatus.RegistrationFinalizationFailed]: T('Registration finalization failed'), | ||
[TruenasConnectStatus.RegistrationFinalizationTimeout]: T('Registration finalization timed out'), | ||
[TruenasConnectStatus.RegistrationFinalizationSuccess]: T('Registration finalization successful'), | ||
[TruenasConnectStatus.CertGenerationInProgress]: T('Certificate generation is in progress'), | ||
[TruenasConnectStatus.CertGenerationFailed]: T('Certificate generation failed'), | ||
[TruenasConnectStatus.CertGenerationSuccess]: T('Certificate generation was successful'), | ||
[TruenasConnectStatus.CertConfigurationFailure]: T('Failed to configure certificate in system UI'), | ||
[TruenasConnectStatus.CertRenewalInProgress]: T('Certificate renewal is in progress'), | ||
[TruenasConnectStatus.CertRenewalFailure]: T('Failed to renew certificate'), | ||
[TruenasConnectStatus.CertRenewalSuccess]: T('Certificate renewal was successful'), | ||
[TruenasConnectStatus.Configured]: T('TrueNAS Connect is configured'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { TruenasConnectStatus, TruenasConnectStatusReason } from 'app/enums/truenas-connect-status.enum'; | ||
|
||
export interface TruenasConnectConfig extends TruenasConnectUpdate { | ||
id: number; | ||
registration_details: { | ||
scopes: string[]; | ||
account_id: string; | ||
system_id: string; | ||
account_name: string; | ||
exp: number; | ||
iat: number; | ||
iss: string; | ||
}; | ||
status: TruenasConnectStatus; | ||
status_reason: typeof TruenasConnectStatusReason; | ||
certificate: number; | ||
} | ||
|
||
export interface TruenasConnectUpdate { | ||
enabled: boolean; | ||
ips: string[]; | ||
tnc_base_url: string; | ||
account_service_base_url: string; | ||
leca_service_base_url: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { EnclosureModel } from 'app/enums/enclosure-model.enum'; | ||
|
||
export interface TruenasConnectRegistration { | ||
version: string; | ||
model: EnclosureModel; | ||
token: string; | ||
system_id: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...les/truenas-connect/components/truenas-connect-modal/truenas-connect-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<h1 mat-dialog-title class="title"> | ||
<ix-icon name="ix-truenas-connect-logo-color"></ix-icon> | ||
<span class="truenas">TrueNAS </span> | ||
<span>CONNECT</span> | ||
</h1> | ||
|
||
<mat-dialog-content> | ||
@if(tnc.config().status !== TruenasConnectStatus.Disabled) { | ||
<span class="warning">{{ | ||
'In order to update the form, you need to disable the service first' | ||
| translate | ||
}}</span> | ||
} | ||
<form [formGroup]="form"> | ||
<ix-input | ||
formControlName="tnc_base_url" | ||
[label]="'TNC Base Url' | translate" | ||
[tooltip]="tooltips.tnc_base_url | translate" | ||
[required]="true" | ||
></ix-input> | ||
<ix-input | ||
formControlName="account_service_base_url" | ||
[label]="'Account Service Base Url' | translate" | ||
[tooltip]="tooltips.account_service_base_url | translate" | ||
[required]="true" | ||
></ix-input> | ||
<ix-input | ||
formControlName="leca_service_base_url" | ||
[label]="'Leca Service Base Url' | translate" | ||
[tooltip]="tooltips.leca_service_base_url | translate" | ||
[required]="true" | ||
></ix-input> | ||
</form> | ||
</mat-dialog-content> | ||
|
||
<mat-dialog-actions> | ||
<div> | ||
@if(tnc.config().status !== TruenasConnectStatus.Disabled) { | ||
<button | ||
mat-button | ||
color="warn" | ||
ixTest="tnc-disable" | ||
(click)="disableService()" | ||
> | ||
{{ 'Disable Service' | translate }} | ||
</button> | ||
} @else { | ||
<button | ||
mat-button | ||
ixTest="tnc-enable" | ||
[disabled]="hasChange()" | ||
(click)="enableService()" | ||
> | ||
{{ 'Enable Service' | translate }} | ||
</button> | ||
} | ||
</div> | ||
|
||
<div> | ||
@if(tnc.config().status === TruenasConnectStatus.ClaimTokenMissing) { | ||
<button ixTest="tnc-generate-token" mat-button (click)="generateToken()"> | ||
{{ 'Generate Token' | translate }} | ||
</button> | ||
} | ||
<button mat-button ixTest="tnc-form-cancel" (click)="cancel()"> | ||
{{ 'Cancel' | translate }} | ||
</button> | ||
|
||
@if (tnc.config().status === | ||
TruenasConnectStatus.RegistrationFinalizationWaiting) { | ||
<button ixTest="tnc-connect" mat-button color="primary" (click)="connect()"> | ||
{{ 'Connect' | translate }} | ||
</button> | ||
} @else { | ||
<button | ||
mat-button | ||
ixTest="tnc-connect" | ||
color="primary" | ||
[disabled]="!hasChange() || form.invalid" | ||
(click)="save()" | ||
> | ||
{{ 'Save' | translate }} | ||
</button> | ||
} | ||
</div> | ||
</mat-dialog-actions> |
33 changes: 33 additions & 0 deletions
33
...les/truenas-connect/components/truenas-connect-modal/truenas-connect-modal.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
:host ::ng-deep { | ||
mat-dialog-actions { | ||
display: flex; | ||
justify-content: space-between !important; | ||
} | ||
} | ||
|
||
.title { | ||
font-size: 32px; | ||
justify-content: center; | ||
|
||
ix-icon { | ||
height: 56px; | ||
margin-right: 8px; | ||
width: 56px; | ||
} | ||
|
||
.truenas { | ||
color: var(--primary); | ||
} | ||
} | ||
|
||
mat-dialog-content { | ||
text-align: center; | ||
|
||
h3 { | ||
padding-bottom: 8px; | ||
} | ||
} | ||
|
||
.warning { | ||
color: var(--red); | ||
} |
Oops, something went wrong.