Skip to content

Commit

Permalink
Merge branch 'master' of github.com:truenas/webui into NAS-131691
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/app/pages/apps/apps.module.ts
  • Loading branch information
undsoft committed Oct 10, 2024
2 parents 93e7fd1 + 07149af commit 9110f16
Show file tree
Hide file tree
Showing 124 changed files with 1,555 additions and 355 deletions.
2 changes: 1 addition & 1 deletion .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
node-version: '20'
cache: 'yarn'
- name: Cache Jest cache
uses: actions/cache@v3
uses: actions/cache@v4
id: jest-cache
with:
path: .jest/cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker_internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
37 changes: 31 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,45 @@ jobs:
test:
name: Run tests
needs: [install]
strategy:
fail-fast: false
matrix:
shard: [1, 2]
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
uses: ./.github/actions/prepare
- name: Run tests
run: yarn test:pr
- if: ${{ env.CODECOV_TOKEN }}
name: Upload coverage to codecov
uses: codecov/codecov-action@v3
run: yarn test:pr --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Save shard coverage
run: mv coverage/webui/coverage-final.json coverage/${{matrix.shard}}.json && rm -rf coverage/webui
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.shard }}
path: coverage/${{matrix.shard}}.json

report-coverage:
name: Collect coverage
runs-on: ubuntu-latest
needs: [test]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Collect coverage from shards
uses: actions/download-artifact@v4
with:
pattern: 'coverage-*'
path: coverage
merge-multiple: true
- name: Merge Code Coverage
run: npx -y nyc merge coverage/ coverage/merged-coverage.json
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
name: webui
token: ${{ env.CODECOV_TOKEN }}
file: coverage/merged-coverage.json
fail_ci_if_error: true
11 changes: 10 additions & 1 deletion src/app/enums/docker-config.interface.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { DockerStatus } from 'app/enums/docker-status.enum';

export interface DockerConfig {
id: number;
pool: string;
dataset: string;
id: number;
enable_image_updates: boolean;
nvidia: boolean;
address_pools: DockerAddressPool[];
}

export interface DockerAddressPool {
base: string;
size: number;
}

export interface DockerConfigUpdate {
pool?: string;
nvidia?: boolean;
address_pools?: DockerAddressPool[];
enable_image_updates?: boolean;
}

export interface DockerStatusData {
Expand Down
11 changes: 10 additions & 1 deletion src/app/helpers/json-to-yaml.helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { marker as T } from '@biesbjerg/ngx-translate-extract-marker';
import { dump } from 'js-yaml';
import { dump, load } from 'js-yaml';

export function jsonToYaml(jsonData: unknown): string {
try {
Expand All @@ -18,3 +18,12 @@ export function jsonToYaml(jsonData: unknown): string {
return T('Error occurred');
}
}

export function yamlToJson(value: string): unknown {
try {
return load(value);
} catch (error) {
console.error(error);
return T('Error occurred');
}
}
4 changes: 4 additions & 0 deletions src/app/helptext/apps/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export const helptextApps = {
advanced: T('Advanced Settings'),
unset_pool: T('Unset Pool'),

dockerSettings: {
addressPoolsSize: T('Network size of each docker network which will be cut off from base subnet.'),
},

bulkActions: {
title: T('Bulk actions'),
finished: T('Requested action performed for selected Applications'),
Expand Down
8 changes: 3 additions & 5 deletions src/app/interfaces/api/api-call-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
UpdateBootenvParams,
} from 'app/interfaces/bootenv.interface';
import {
Catalog, CatalogApp,
CatalogConfig, CatalogApp,
CatalogUpdate, GetItemDetailsParams,
} from 'app/interfaces/catalog.interface';
import {
Expand Down Expand Up @@ -77,7 +77,6 @@ import {
CloudSyncCredentialVerify, CloudSyncCredentialVerifyResult,
} from 'app/interfaces/cloudsync-credential.interface';
import { CloudSyncProvider, CloudSyncRestoreParams } from 'app/interfaces/cloudsync-provider.interface';
import { ContainerConfig } from 'app/interfaces/container-config.interface';
import {
ContainerImage, DeleteContainerImageParams,
} from 'app/interfaces/container-image.interface';
Expand Down Expand Up @@ -356,8 +355,8 @@ export interface ApiCallDirectory {
// Catalog
'catalog.get_app_details': { params: [name: string, params: GetItemDetailsParams]; response: CatalogApp };
'catalog.trains': { params: void; response: string[] };
'catalog.update': { params: [CatalogUpdate]; response: Catalog };
'catalog.config': { params: void; response: Catalog };
'catalog.update': { params: [CatalogUpdate]; response: CatalogConfig };
'catalog.config': { params: void; response: CatalogConfig };

// Certificate
'certificate.acme_server_choices': { params: void; response: Choices };
Expand Down Expand Up @@ -410,7 +409,6 @@ export interface ApiCallDirectory {
'cloudsync.update': { params: [id: number, task: CloudSyncTaskUpdate]; response: CloudSyncTask };

// Container
'container.config': { params: void; response: ContainerConfig };
'app.image.delete': { params: DeleteContainerImageParams; response: boolean };
'app.image.dockerhub_rate_limit': { params: void; response: DockerHubRateLimit };
'app.image.query': { params: QueryParams<ContainerImage>; response: ContainerImage[] };
Expand Down
14 changes: 13 additions & 1 deletion src/app/interfaces/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface App {
portals: Record<string, string>;
version: string;
migrated: boolean;
custom_app: boolean;
/**
* Present with `retrieve_config` query param.
*/
Expand Down Expand Up @@ -132,7 +133,18 @@ export interface AppCreate {
}

export interface AppUpdate {
values: Record<string, ChartFormValue>;
/**
* Required when `custom_app = false`
*/
values?: Record<string, ChartFormValue>;
/**
* Required attr when `custom_app = true`
*/
custom_compose_config?: Record<string, unknown>;
/**
* Optional attr when `custom_app = true`
*/
custom_compose_config_string?: string;
}

export interface AppUpgrade {
Expand Down
4 changes: 1 addition & 3 deletions src/app/interfaces/catalog.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
} from 'app/interfaces/app.interface';
import { AppMaintainer } from 'app/interfaces/available-app.interface';

export interface Catalog {
export interface CatalogConfig {
id: string;
label: string;
location: string;
Expand All @@ -15,8 +15,6 @@ export interface CatalogUpdate {
nvidia?: boolean;
}

export type CatalogTrain = Record<string, CatalogApp>;

export interface CatalogApp {
app_readme: string;
app_metadata: AppMetadata;
Expand Down
2 changes: 1 addition & 1 deletion src/app/interfaces/cloud-backup.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface CloudBackup {
credentials: CloudCredential;
job: Job | null;
locked: boolean;
bwlimit?: BwLimit[];
keep_last?: number;
bwlimit?: BwLimit[];
}

export interface CloudBackupUpdate extends Omit<CloudBackup, 'id' | 'job' | 'locked' | 'bwlimit' | 'credentials'> {
Expand Down
4 changes: 0 additions & 4 deletions src/app/interfaces/container-config.interface.ts

This file was deleted.

12 changes: 10 additions & 2 deletions src/app/pages/apps/apps.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import { IxChipsComponent } from 'app/modules/forms/ix-forms/components/ix-chips
import { IxCodeEditorComponent } from 'app/modules/forms/ix-forms/components/ix-code-editor/ix-code-editor.component';
import { IxFieldsetComponent } from 'app/modules/forms/ix-forms/components/ix-fieldset/ix-fieldset.component';
import { IxInputComponent } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.component';
import {
IxIpInputWithNetmaskComponent,
} from 'app/modules/forms/ix-forms/components/ix-ip-input-with-netmask/ix-ip-input-with-netmask.component';
import { IxListItemComponent } from 'app/modules/forms/ix-forms/components/ix-list/ix-list-item/ix-list-item.component';
import { IxListComponent } from 'app/modules/forms/ix-forms/components/ix-list/ix-list.component';
import { IxSelectComponent } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.component';
import {
IxModalHeaderComponent,
Expand Down Expand Up @@ -70,7 +75,7 @@ import {
import { AppJsonDetailsCardComponent } from 'app/pages/apps/components/app-detail-view/app-json-details-card/app-json-details-card.component';
import { AppWizardComponent } from 'app/pages/apps/components/app-wizard/app-wizard.component';
import { AppsScopeWrapperComponent } from 'app/pages/apps/components/apps-scope-wrapper.component';
import { CatalogSettingsComponent } from 'app/pages/apps/components/catalog-settings/catalog-settings.component';
import { AppsSettingsComponent } from 'app/pages/apps/components/catalog-settings/apps-settings.component';
import { CustomAppFormComponent } from 'app/pages/apps/components/custom-app-form/custom-app-form.component';
import { DockerImageDeleteDialogComponent } from 'app/pages/apps/components/docker-images/docker-image-delete-dialog/docker-image-delete-dialog.component';
import { DockerImagesListComponent } from 'app/pages/apps/components/docker-images/docker-images-list/docker-images-list.component';
Expand Down Expand Up @@ -145,7 +150,7 @@ import { InstalledAppsComponent } from './components/installed-apps/installed-ap
CategoryViewComponent,
CustomAppButtonComponent,
DockerStatusComponent,
CatalogSettingsComponent,
AppsSettingsComponent,
DockerImagesListComponent,
DockerImageDeleteDialogComponent,
PullImageFormComponent,
Expand Down Expand Up @@ -221,6 +226,9 @@ import { InstalledAppsComponent } from './components/installed-apps/installed-ap
PageHeaderComponent,
TerminalComponent,
FilterSelectListComponent,
IxIpInputWithNetmaskComponent,
IxListComponent,
IxListItemComponent,
],
})
export class AppsModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService } from '@ngx-translate/core';
import { isArray, isPlainObject, unset } from 'lodash-es';
import {
isArray, isPlainObject, unset,
} from 'lodash-es';
import {
BehaviorSubject, Observable, of, Subject, Subscription, timer,
} from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<ix-modal-header
[title]="'Settings' | translate"
[loading]="isFormLoading()"
[requiredRoles]="requiredRoles"
></ix-modal-header>

<mat-card>
<mat-card-content>
<form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
<ix-fieldset class="trains">
<ix-checkbox-list
formControlName="preferred_trains"
[label]="'Preferred Trains' | translate"
[tooltip]="tooltips.preferred_trains | translate"
[options]="allTrains$"
[inlineFields]="true"
></ix-checkbox-list>

<ix-list
formArrayName="address_pools"
class="address-pools"
[empty]="form.controls.address_pools.controls.length === 0"
[label]="'Address Pools' | translate"
[formArray]="form.get('address_pools')"
(add)="addAddressPool()"
>
@for (network of form.controls.address_pools.controls; track network; let i = $index) {
<ix-list-item
[formGroupName]="i"
[label]="'Address Pool' | translate"
(delete)="removeAddressPool(i)"
>
<div class="address-pool">
<ix-ip-input-with-netmask
class="base"
formControlName="base"
[label]="'Base' | translate"
[required]="true"
></ix-ip-input-with-netmask>

<ix-input
formControlName="size"
type="number"
class="size"
[required]="true"
[label]="'Size' | translate"
[tooltip]="helptext.dockerSettings.addressPoolsSize | translate"
></ix-input>
</div>
</ix-list-item>
}
</ix-list>

@if (showNvidiaCheckbox()) {
<ix-checkbox
formControlName="nvidia"
[label]="'Install NVIDIA Drivers' | translate"
[tooltip]="tooltips.install_nvidia_driver| translate"
></ix-checkbox>
}

<ix-checkbox
formControlName="enable_image_updates"
[label]="'Check for docker image updates' | translate"
></ix-checkbox>
</ix-fieldset>

<div class="actions">
<ix-form-actions>
<button
*ixRequiresRoles="requiredRoles"
mat-button
type="submit"
color="primary"
ixTest="save"
[disabled]="form.invalid || isFormLoading()"
>
{{ 'Save' | translate }}
</button>
</ix-form-actions>
</div>
</form>
</mat-card-content>
</mat-card>
Loading

0 comments on commit 9110f16

Please sign in to comment.