Skip to content

Commit

Permalink
Merge pull request #1210 from aneoconsulting/chore/external-services-…
Browse files Browse the repository at this point in the history
…ux-improvements

chore: external services ux improvements
  • Loading branch information
ngruelaneo authored Sep 9, 2024
2 parents b7b7ea8 + 2b70828 commit d3eef69
Show file tree
Hide file tree
Showing 24 changed files with 346 additions and 616 deletions.
14 changes: 6 additions & 8 deletions src/app/components/icon-picker-dialog.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
@if(icon) {
<button mat-icon-button (click)="$event.preventDefault();" [matMenuTriggerFor]="menu">
<button mat-icon-button (click)="$event.preventDefault();" [matMenuTriggerFor]="menu" i18n-matTooltip matTooltip="Change the Icon">
@if(icon) {
<mat-icon [fontIcon]="getIcon(icon)" />
</button>
} @else {
<button mat-button (click)="$event.preventDefault();" [matMenuTriggerFor]="menu">
<span i18n="Button to open the icon picker">Icon</span>
</button>
}
} @else {
<mat-icon [fontIcon]="getIcon('icon')" />
}
</button>
<mat-menu #menu="matMenu" yPosition="below">
<mat-form-field style="width: 100%;" subscriptSizing="dynamic" (click)="$event.stopPropagation();" (keydown.enter)="selectFirst()">
<mat-label i18n="Input label">Icon</mat-label>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/icon-picker-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ article {
export class IconPickerDialogComponent {
readonly iconsService = inject(IconsService);

@Input({ required: true }) icon: string = '';
@Input({ required: true }) icon: string | null | undefined = '';
@Output() iconChange = new EventEmitter<string>();

icons: string[] = this.iconsService.getAllIcons();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions src/app/components/navigation/external-services.component.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<button mat-button class="external-services" [matMenuTriggerFor]="external_services" matTooltip="Access to external services">
<mat-icon matListItemIcon aria-hidden="true" [fontIcon]="getIcon('arrow-down')"/>
<span i18n="Button to view external services">
External Services
</span>
</button>
<mat-menu #external_services="matMenu">
@for (service of externalServices; track service.url) {
<a mat-menu-item [href]="service.url" target="_blank" rel="noopener noreferrer">
@if (service.icon) {
<mat-icon matListItemIcon aria-hidden="true" [fontIcon]="getIcon(service.icon)"/>
}
<span>{{ service.name }}</span>
</a>
}
@if (externalServices.length) {
<mat-divider/>
}
<button mat-menu-item (click)="manageExternalServices()">
<mat-icon matListItemIcon aria-hidden="true" [fontIcon]="getIcon('tune')"/>
<span i18n="Button">Manage services</span>
</button>
</mat-menu>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { URL } from 'url';
import { TestBed } from '@angular/core/testing';
import { MatDialog } from '@angular/material/dialog';
import { of } from 'rxjs';
Expand Down Expand Up @@ -51,15 +50,6 @@ describe('ExternalServicesComponent', () => {
it('should retrieve saved services', () => {
expect(component.externalServices).toEqual(savedServices);
});

it('should check if it has a service', () => {
expect(component.hasService).toBeTruthy();
});
});

it('should check if there is no service', () => {
component.externalServices = [];
expect(component.hasService).toBeFalsy();
});

it('should get icon', () => {
Expand All @@ -78,26 +68,13 @@ describe('ExternalServicesComponent', () => {
expect(component.externalServices).toEqual(newServices);
});

it('should update "hasServices"', () => {
expect(component.hasService).toBeTruthy();
});

it('should save services', () => {
expect(mockNavigationService.saveExternalServices).toHaveBeenCalled();
});
});

test('saveServices should save local services', () => {
component.saveServices();
expect(mockNavigationService.saveExternalServices).toHaveBeenCalled();
});

it('should allow to navigate to an url', () => {
const windowSpy = jest.spyOn(window, 'open');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
windowSpy.mockImplementationOnce((url?: string | URL | null, target?: string | null, features?: string | undefined) => null);
const url = 'https://url';
component.navigate(url);
expect(windowSpy).toHaveBeenCalledWith(url, '_blank');
expect(mockNavigationService.saveExternalServices).toHaveBeenCalledWith(component.externalServices);
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, OnInit, inject } from '@angular/core';
import { MatButtonModule, MatIconButton } from '@angular/material/button';
import { ChangeDetectionStrategy, Component, OnInit, inject, signal } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatDialog } from '@angular/material/dialog';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { MatTooltipModule } from '@angular/material/tooltip';
import { ExternalService } from '@app/types/external-service';
import { IconsService } from '@services/icons.service';
Expand All @@ -14,44 +15,34 @@ import { ManageExternalServicesDialogComponent } from './manage-external-service
templateUrl: 'external-services.component.html',
imports: [
MatIconModule,
MatIconButton,
MatTooltipModule,
MatButtonModule,
MatDividerModule,
MatMenuModule,
MatTooltipModule,
],
providers: [
IconsService,
NavigationService
],
standalone: true,
styles: [`
article {
display: flex;
}
mat-divider {
margin-left: 0.75rem;
margin-right: 0.75rem;
}
`]
styleUrl: 'external-services.css',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ExternalServicesComponent implements OnInit {
readonly navigationService = inject(NavigationService);
readonly iconsService = inject(IconsService);
readonly dialog = inject(MatDialog);

hasService: boolean = false;
private _externalServices: ExternalService[] = [];
private _externalServices = signal<ExternalService[]>([]);

set externalServices(entries: ExternalService[] | undefined) {
if (entries) {
this._externalServices = entries;
this.hasService = entries.length > 0;
this._externalServices.set(entries);
}
}

get externalServices(): ExternalService[] {
return this._externalServices;
return this._externalServices();
}

ngOnInit(): void {
Expand Down Expand Up @@ -80,8 +71,4 @@ export class ExternalServicesComponent implements OnInit {
saveServices() {
this.navigationService.saveExternalServices(this.externalServices);
}

navigate(url: string) {
window.open(url, '_blank');
}
}
Loading

1 comment on commit d3eef69

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 100%
99.97% (4548/4549) 100% (861/861) 99.91% (1219/1220)

JUnit

Tests Skipped Failures Errors Time
1715 0 💤 0 ❌ 0 🔥 1m 15s ⏱️
Files coverage (100%)
File% Stmts% Branch% Funcs% LinesUncovered Line #s
All files99.9710099.91100 
applications100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
applications/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
applications/services100100100100 
   applications-filters.service.ts100100100100 
   applications-grpc.service.ts100100100100 
   applications-index.service.ts100100100100 
components100100100100 
   actions-toolbar-group.component.ts100100100100 
   actions-toolbar.component.ts100100100100 
   auto-complete.component.html100100100100 
   auto-complete.component.ts100100100100 
   auto-refresh-button.component.html100100100100 
   auto-refresh-button.component.ts100100100100 
   auto-refresh-dialog.component.html100100100100 
   auto-refresh-dialog.component.ts100100100100 
   columns-button.component.ts100100100100 
   columns-modify-dialog.component.html100100100100 
   columns-modify-dialog.component.ts100100100100 
   count-tasks-by-status.component.ts100100100100 
   icon-picker-dialog.component.html100100100100 
   icon-picker-dialog.component.ts100100100100 
   inspect-list.component.html100100100100 
   inspect-list.component.ts100100100100 
   inspection-header.component.html100100100100 
   inspection-header.component.ts100100100100 
   inspection-toolbar.component.html100100100100 
   inspection-toolbar.component.ts100100100100 
   manage-custom-dialog.component.html100100100100 
   manage-custom-dialog.component.ts100100100100 
   page-header.component.html100100100100 
   page-header.component.ts100100100100 
   page-section-header.component.ts100100100100 
   page-section.component.ts100100100100 
   refresh-button.component.ts100100100100 
   share-url.component.ts100100100100 
   show-action-area.component.html100100100100 
   show-action-area.component.ts100100100100 
   show-actions.component.html100100100100 
   show-actions.component.ts100100100100 
   show-card-content.component.html100100100100 
   show-card-content.component.ts100100100100 
   show-card.component.html100100100100 
   show-card.component.ts100100100100 
   show-page.component.html100100100100 
   show-page.component.ts100100100100 
   spinner.component.ts100100100100 
   table-actions-toolbar.component.html100100100100 
   table-actions-toolbar.component.ts100100100100 
   table-container.component.ts100100100100 
   table-dashboard-actions-toolbar.component.html100100100100 
   table-dashboard-actions-toolbar.component.ts100100100100 
   table-index-actions-toolbar.component.html100100100100 
   table-index-actions-toolbar.component.ts100100100100 
   view-tasks-by-status.component.ts100100100100 
components/filters100100100100 
   filters-chips.component.html100100100100 
   filters-chips.component.ts100100100100 
   filters-dialog-and.component.html100100100100 
   filters-dialog-and.component.ts100100100100 
   filters-dialog-filter-field.component.html100100100100 
   filters-dialog-filter-field.component.ts100100100100 
   filters-dialog-input.component.html100100100100 
   filters-dialog-input.component.ts100100100100 
   filters-dialog-or.component.html100100100100 
   filters-dialog-or.component.ts100100100100 
   filters-dialog.component.html100100100100 
   filters-dialog.component.ts100100100100 
   filters-toolbar.component.html100100100100 
   filters-toolbar.component.ts100100100100 
components/inspection100100100100 
   field-content.component.html100100100100 
   field-content.component.ts100100100100 
   inspection-card.component.html100100100100 
   inspection-card.component.ts100100100100 
   inspection-json.component.html100100100100 
   inspection-json.component.ts100100100100 
   inspection-list-grid.component.html100100100100 
   inspection-list-grid.component.ts100100100100 
   inspection-object.component.html100100100100 
   inspection-object.component.ts100100100100 
   inspection.component.html100100100100 
   inspection.component.ts100100100100 
   json.component.html100100100100 
   json.component.ts100100100100 
components/navigation100100100100 
   change-language-button.component.html100100100100 
   change-language-button.component.ts100100100100 
   navigation.component.html100100100100 
   navigation.component.ts100100100100 
   theme-selector.component.html100100100100 
   theme-selector.component.ts100100100100 
components/navigation/external-services100100100100 
   external-services.component.html100100100100 
   external-services.component.ts100100100100 
   form-external-service.component.html100100100100 
   form-external-service.component.ts100100100100 
   manage-external-services-dialog.component.html100100100100 
   manage-external-services-dialog.component.ts100100100100 
components/statuses100100100100 
   add-statuses-group-dialog.component.ts100100100100 
   edit-status-group-dialog.component.ts100100100100 
   form-statuses-group.component.html100100100100 
   form-statuses-group.component.ts100100100100 
   manage-groups-dialog.component.html100100100100 
   manage-groups-dialog.component.ts100100100100 
components/table100100100100 
   table-actions.component.html100100100100 
   table-actions.component.ts100100100100 
   table-cell.component.html100100100100 
   table-cell.component.ts100100100100 
   table-column-header.component.html100100100100 
   table-column-header.component.ts100100100100 
   table-empty-data.component.ts100100100100 
   table-inspect-object-dialog.component.html100100100100 
   table-inspect-object-dialog.component.ts100100100100 
   table-inspect-object.component.html100100100100 
   table-inspect-object.component.ts100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
dashboard100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
dashboard/components100100100100 
   add-line-dialog.component.html100100100100 
   add-line-dialog.component.ts100100100100 
   edit-name-line-dialog.component.html100100100100 
   edit-name-line-dialog.component.ts100100100100 
   reorganize-lines-dialog.component.html100100100100 
   reorganize-lines-dialog.component.ts100100100100 
   split-lines-dialog.component.ts100100100100 
   statuses-group-card.component.html100100100100 
   statuses-group-card.component.ts100100100100 
dashboard/components/lines100100100100 
   applications-line.component.html100100100100 
   applications-line.component.ts100100100100 
   partitions-line.component.html100100100100 
   partitions-line.component.ts100100100100 
   results-line.component.html100100100100 
   results-line.component.ts100100100100 
   sessions-line.component.html100100100100 
   sessions-line.component.ts100100100100 
   task-by-status-line.component.html100100100100 
   task-by-status-line.component.ts100100100100 
   tasks-line.component.html100100100100 
   tasks-line.component.ts100100100100 
dashboard/services100100100100 
   dashboard-index.service.ts100100100100 
   dashboard-storage.service.ts100100100100 
healthcheck100100100100 
   healthcheck.component.html100100100100 
   healthcheck.component.ts100100100100 
healthcheck/services100100100100 
   healthcheck-grpc.service.ts100100100100 
partitions100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.html100100100100 
   show.component.ts100100100100 
partitions/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
partitions/services100100100100 
   partitions-filters.service.ts100100100100 
   partitions-grpc.service.ts100100100100 
   partitions-index.service.ts100100100100 
   partitions-inspection.service.ts100100100100 
pipes100100100100 
   duration.pipe.ts100100100100 
   empty-cell.pipe.ts100100100100 
   pretty.pipe.ts100100100100 
profile100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   types.ts100100100100 
results100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.html100100100100 
   show.component.ts100100100100 
results/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
results/services100100100100 
   results-filters.service.ts100100100100 
   results-grpc.service.ts100100100100 
   results-index.service.ts100100100100 
   results-inspection.service.ts100100100100 
   results-statuses.service.ts100100100100 
services100100100100 
   auto-refresh.service.ts100100100100 
   cache.service.ts100100100100 
   default-config.service.ts100100100100 
   environment.service.ts100100100100 
   filters.service.ts100100100100 
   grpc-build-request.service.ts100100100100 
   grpc-sort-field.service.ts100100100100 
   icons.service.ts100100100100 
   navigation.service.ts100100100100 
   notification.service.ts100100100100 
   query-params.service.ts100100100100 
   share-url.service.ts100100100100 
   storage.service.ts100100100100 
   table-storage.service.ts100100100100 
   table-url.service.ts100100100100 
   table.service.ts100100100100 
   tasks-by-status.service.ts100100100100 
   user-grpc.service.ts100100100100 
   user.service.ts100100100100 
   utils.service.ts100100100100 
   versions-grpc.service.ts100100100100 
   versions.service.ts100100100100 
sessions100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.html100100100100 
   show.component.ts100100100100 
sessions/components100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
sessions/services100100100100 
   sessions-filters.service.ts100100100100 
   sessions-grpc.service.ts100100100100 
   sessions-index.service.ts100100100100 
   sessions-inspection.service.ts100100100100 
   sessions-statuses.service.ts100100100100 
settings100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
settings/component100100100100 
   clear-all-dialog.component.html100100100100 
   clear-all-dialog.component.ts100100100100 
tasks100100100100 
   index.component.html100100100100 
   index.component.ts100100100100 
   show.component.html100100100100 
   show.component.ts100100100100 
tasks/components100100100100 
   manage-view-in-logs-dialog.component.html100100100100 
   manage-view-in-logs-dialog.component.ts100100100100 
   table.component.html100100100100 
   table.component.ts100100100100 
tasks/services100100100100 
   tasks-filters.service.ts100100100100 
   tasks-grpc.service.ts100100100100 
   tasks-index.service.ts100100100100 
   tasks-inspection.service.ts100100100100 
   tasks-statuses.service.ts100100100100 
tokens100100100100 
   filters.token.ts100100100100 
types100100100100 
   navigation.ts100100100100 
types/components99.7110099.13100 
   dashboard-line-table.ts100100100100 
   index.ts99.1510097.29100 
   show.ts100100100100 
   table.ts100100100100 
types/services100100100100 
   grpcService.ts100100100100 
   inspectionService.ts100100100100 

Please sign in to comment.