Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/2734/migrate custom configs list #2760

Merged
merged 55 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a3d227e
Add new Angular component
Hall-Ma Mar 22, 2022
9ea7ba7
Move download functions to new component
Hall-Ma Mar 22, 2022
454d16e
Implement prototype selector for downloadable custom configs
Hall-Ma Mar 22, 2022
ae73d88
Improve selector for downloadable custom configs
Hall-Ma Mar 22, 2022
7c66e9c
Remove FileStateConnector from component and remove unused state call
Hall-Ma Mar 22, 2022
dd87560
Combine observables to get downloadableConfigs when file state or loc…
Hall-Ma Mar 24, 2022
3aeed42
Remove unused download button in custom configs component
Hall-Ma Mar 24, 2022
7369403
Adjust style for download button
Hall-Ma Mar 24, 2022
e63d3d8
Adjust disabled button style for download custom config button
Hall-Ma Mar 25, 2022
3c250dc
Implement service for get downloadable configs
Hall-Ma Mar 25, 2022
e190db3
Fix bug notified from sonar + do some renaming + refactoring
Hall-Ma Mar 25, 2022
885e5c4
Add new test with mocked service -> WIP
Hall-Ma Mar 25, 2022
aed1902
Introduce new module for downloading custom configs + refactor downlo…
Hall-Ma Mar 28, 2022
3ba6998
Change function signature of getDownloadableCustomConfigs$
Hall-Ma Mar 28, 2022
64d4d19
Add tests
Hall-Ma Mar 28, 2022
04cb432
Remove getter function because observable is already read only
Hall-Ma Mar 28, 2022
c69312d
Delete unused tests and function in custom config component
Hall-Ma Mar 28, 2022
7a07bbe
Merge remote-tracking branch 'origin/main' into refactor/2734/migrate…
Hall-Ma Mar 28, 2022
b62a8e8
Add tests for get downloadable custom configs
Hall-Ma Mar 28, 2022
745cf22
WIP Add new Angular component for custom config list
Hall-Ma Mar 29, 2022
dced61c
Try to implement new component for custom config item group but doesn…
Hall-Ma Mar 29, 2022
40207bc
Angular component for custom config item group is working now
Hall-Ma Mar 29, 2022
7251881
Implement showing custom config items when a custom group is selected
Hall-Ma Mar 30, 2022
15610c9
Implement new interface for getting custom config item groups (it's n…
Hall-Ma Apr 8, 2022
c840768
Implement new button to open custom configs list dialog (work around …
Hall-Ma Apr 8, 2022
14fcfdd
Implement showing custom configs list of applicable configs
Hall-Ma Apr 8, 2022
d691aae
Merge remote-tracking branch 'origin/main' into refactor/2734/migrate…
Hall-Ma Apr 8, 2022
813abfa
Add css style to download and add custom config button (lost by mergi…
Hall-Ma Apr 8, 2022
8e78f21
Implement expand and hide function for non-applicable custom configs
Hall-Ma Apr 8, 2022
4821819
Implement expand and hide function for non-applicable custom configs
Hall-Ma Apr 8, 2022
f91e2b1
Merge remote-tracking branch 'origin/refactor/2734/migrate-custom-con…
Hall-Ma Apr 8, 2022
0e180a2
Try to implement custom configs button in dialog, but doesn't work.
Hall-Ma Apr 8, 2022
a8a541d
fix: add selector
shaman-apprentice Apr 8, 2022
b5d03e9
Add expansion panel to show custom configs and add css style to it, s…
Hall-Ma Apr 9, 2022
41f5241
Implement apply custom config function, still WIP
Hall-Ma Apr 10, 2022
934b86b
Introduce new selector for collecting file checksums and map selectio…
Hall-Ma Apr 10, 2022
761ddd1
Remove work around for showing custom configs list, adjust css style …
Hall-Ma Apr 10, 2022
4c9c4dd
Adjust css style for mat-dialog
Hall-Ma Apr 10, 2022
17c98ac
Implement angularJS services used for applying custom configs
Hall-Ma Apr 11, 2022
deac0cf
Merge branch 'main' into refactor/2734/migrate-custom-configs-list
Hall-Ma May 1, 2022
86835f6
Add padding to custom config list items
Hall-Ma May 2, 2022
5740dd8
Outsource mapCheckSumsByMapSelectionMode function for better testing
Hall-Ma May 9, 2022
b28e974
Add tests and test description, adjust data mocks, delete unused code
Hall-Ma May 9, 2022
7d37a36
Add tests for custom config group items
Hall-Ma May 9, 2022
2f45b8a
Remove input if custom config is applicable or not
Hall-Ma May 9, 2022
ddb2e87
Merge branch 'main' into refactor/2734/migrate-custom-configs-list
Hall-Ma May 9, 2022
9137234
Remove unused functions and move interface to extracted method
Hall-Ma May 9, 2022
d85a403
Remove subscripton, use observable in template instead
Hall-Ma May 9, 2022
c3ae17f
Remove unused entryComponent
Hall-Ma May 9, 2022
97b98fb
Add Eventemitter to mat extension panel (now, panel does not close wh…
Hall-Ma May 9, 2022
544528c
add observable to get custom config item groups to template
Hall-Ma May 9, 2022
a2f3267
Optimize css style
Hall-Ma May 11, 2022
6a84eae
Add changelog entry
Hall-Ma May 11, 2022
c96dd88
Adjust naming of css selector
Hall-Ma May 11, 2022
d0554df
Adjust import statement for a test
Hall-Ma May 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 15 additions & 10 deletions visualization/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import { UnfocusNodesOnLoadingMapEffect } from "./codeCharta/state/effects/unfoc
import { TrackEventUsageDataEffect } from "./codeCharta/state/effects/trackEventUsageData/trackEventUsageData.effect"
import { AddBlacklistItemsIfNotResultsInEmptyMapEffect } from "./codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect"
import { dialogs } from "./codeCharta/ui/dialogs/dialogs"
import { threeSceneServiceProvider, codeChartaServiceProvider } from "./codeCharta/services/ajs-upgraded-providers"
import {
threeSceneServiceProvider,
codeChartaServiceProvider,
threeOrbitControlsServiceProvider,
threeCameraServiceProvider
} from "./codeCharta/services/ajs-upgraded-providers"
import { NodeContextMenuCardModule } from "./codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.module"
import { OpenNodeContextMenuEffect } from "./codeCharta/state/effects/nodeContextMenu/openNodeContextMenu.effect"
import { InvertAreaOptionComponent } from "./codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component"
import { AddCustomConfigButtonComponent } from "./codeCharta/ui/customConfigs/addCustomConfigButton/addCustomConfigButton.component"
import { AddCustomConfigButtonModule } from "./codeCharta/ui/customConfigs/addCustomConfigButton/addCustomConfigButton.module"
import { RemoveFileButtonComponent } from "./codeCharta/ui/filePanel/filePanelFileSelector/removeFileButton/removeFileButton.component"
import { FocusButtonsComponent } from "./codeCharta/state/effects/nodeContextMenu/focusButtons/focusButtons.component"
import { IdToBuildingService } from "./codeCharta/services/idToBuilding/idToBuilding.service"
Expand All @@ -40,14 +43,13 @@ import { BlacklistSearchPatternEffect } from "./codeCharta/ui/searchPanel/search
import { EdgeMetricToggleComponent } from "./codeCharta/ui/edgeSettingsPanel/edgeMetricToggle/edgeMetricToggle.component"
import { SearchPanelComponent } from "./codeCharta/ui/searchPanel/searchPanel.component"
import { SearchPanelModule } from "./codeCharta/ui/searchPanel/searchPanel.module"
import { DownloadCustomConfigButtonModule } from "./codeCharta/ui/customConfigs/downloadCustomConfigsButton/downloadCustomConfigButton.module"
import { MetricValueHoveredModule } from "./codeCharta/ui/metricChooser/metricValueHovered/metricValueHovered.module"
import { UploadCustomConfigButtonModule } from "./codeCharta/ui/customConfigs/uploadCustomConfigButton/uploadCustomConfigButton.module"
import { UploadFilesButtonComponent } from "./codeCharta/ui/toolBar/uploadFilesButton/uploadFilesButton.component"
import { MetricTypeHoveredModule } from "./codeCharta/ui/metricChooser/metricTypeHovered/metricTypeHovered.module"
import { SliderModule } from "./codeCharta/ui/slider/slider.module"
import { HeightSettingsPanelModule } from "./codeCharta/ui/ribbonBar/heightSettingsPanel/heightSettingsPanel.module"
import { ResetSettingsButtonModule } from "./codeCharta/ui/resetSettingsButton/resetSettingsButton.module"
import { CustomConfigsModule } from "./codeCharta/ui/customConfigs/customConfigs.module"

@NgModule({
imports: [
Expand All @@ -68,19 +70,23 @@ import { ResetSettingsButtonModule } from "./codeCharta/ui/resetSettingsButton/r
LegendPanelModule,
ColorPickerForMapColorModule,
NodeContextMenuCardModule,
AddCustomConfigButtonModule,
ReactiveFormsModule,
LoadingFileProgressSpinnerModule,
LoadingMapProgressSpinnerModule,
SearchPanelModule,
MetricTypeHoveredModule,
DownloadCustomConfigButtonModule,
MetricValueHoveredModule,
UploadCustomConfigButtonModule,
CustomConfigsModule,
HeightSettingsPanelModule,
ResetSettingsButtonModule
],
providers: [threeSceneServiceProvider, codeChartaServiceProvider, IdToBuildingService],
providers: [
threeSceneServiceProvider,
codeChartaServiceProvider,
IdToBuildingService,
threeCameraServiceProvider,
threeOrbitControlsServiceProvider
],
declarations: [
FilePanelFileSelectorComponent,
FilePanelStateButtonsComponent,
Expand All @@ -101,7 +107,6 @@ import { ResetSettingsButtonModule } from "./codeCharta/ui/resetSettingsButton/r
FilePanelStateButtonsComponent,
FilePanelDeltaSelectorComponent,
InvertAreaOptionComponent,
AddCustomConfigButtonComponent,
FocusButtonsComponent,
RemoveFileButtonComponent,
LoadingFileProgressSpinnerComponent,
Expand Down
18 changes: 18 additions & 0 deletions visualization/app/codeCharta/services/ajs-upgraded-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,21 @@ export const codeChartaServiceProvider = {
},
deps: ["$injector"]
}

export const ThreeCameraServiceToken = new InjectionToken("ThreeCameraService")
export const threeCameraServiceProvider = {
provide: ThreeCameraServiceToken,
useFactory: function ThreeCameraServiceFactory(injector: Injector) {
return injector.get("threeCameraService")
},
deps: ["$injector"]
}

export const ThreeOrbitControlsServiceToken = new InjectionToken("ThreeOrbitControlsService")
export const threeOrbitControlsServiceProvider = {
provide: ThreeOrbitControlsServiceToken,
useFactory: function ThreeOrbitControlsServiceFactory(injector: Injector) {
return injector.get("threeOrbitControlsService")
},
deps: ["$injector"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { combineLatest, map } from "rxjs"
import { visibleFileStatesSelector } from "../../state/selectors/visibleFileStates.selector"
import { CustomConfigHelper } from "../../util/customConfigHelper"
import { getDownloadableCustomConfigs } from "./downloadCustomConfigsButton/getDownloadableCustomConfigs"
import { Inject, Injectable } from "@angular/core"
import { Store } from "../../state/angular-redux/store"
import { getCustomConfigItemGroups } from "./customConfigList/getCustomConfigItemGroups"
import { fileMapCheckSumsSelector } from "./customConfigList/fileMapCheckSums.selector"

@Injectable()
export class CustomConfigHelperService {
readonly downloadableCustomConfigs$ = combineLatest([
this.store.select(visibleFileStatesSelector),
CustomConfigHelper.customConfigChange$
]).pipe(map(([visibleFileStates]) => getDownloadableCustomConfigs(visibleFileStates)))

readonly customConfigItemGroups$ = combineLatest([
this.store.select(fileMapCheckSumsSelector),
CustomConfigHelper.customConfigChange$
]).pipe(map(([fileMapCheckSumsByMapSelectionMode]) => getCustomConfigItemGroups(fileMapCheckSumsByMapSelectionMode)))

constructor(@Inject(Store) private store: Store) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<mat-expansion-panel *ngFor="let customConfigItemGroup of customConfigItemGroups | keyvalue">
<mat-expansion-panel-header>
<mat-panel-title>
Custom View(s) in
<span class="highlight-mode"> {{ customConfigItemGroup.value.mapSelectionMode | lowercase }} </span>
mode for
{{ customConfigItemGroup.value.mapNames }}
</mat-panel-title>
</mat-expansion-panel-header>
<mat-list *ngFor="let customConfig of customConfigItemGroup.value.customConfigItems">
<mat-list-item
title="{{
customConfig.isApplicable
? 'Apply Custom Config'
: 'This one is applicable for map(s) ' + customConfig.mapNames + ' in ' + customConfig.mapSelectionMode + ' mode only.'
}}"
>
<button mat-dialog-close [disabled]="!customConfig.isApplicable" (click)="applyCustomConfig(customConfig.id)">
{{ customConfig.name }}
</button>
<button class="remove-button" title="Remove Custom Config" (click)="removeCustomConfig(customConfig.id)">
<i class="fa fa-minus-square"></i>
</button>
</mat-list-item>
</mat-list>
</mat-expansion-panel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { TestBed } from "@angular/core/testing"
import { CustomConfigsModule } from "../customConfigs.module"
import { MatDialog, MatDialogRef } from "@angular/material/dialog"
import { ThreeCameraServiceToken, ThreeOrbitControlsServiceToken } from "../../../services/ajs-upgraded-providers"
import { fireEvent, render, screen } from "@testing-library/angular"
import { CustomConfigItemGroupComponent } from "./customConfigItemGroup.component"
import { CUSTOM_CONFIG_ITEM_GROUPS } from "../../../util/dataMocks"
import { CustomConfigHelper } from "../../../util/customConfigHelper"

describe("customConfigItemGroupComponent", () => {
let mockedDialog = { open: jest.fn() }
let mockedDialogReference = { close: jest.fn() }

beforeEach(() => {
mockedDialog = { open: jest.fn() }
mockedDialogReference = { close: jest.fn() }

TestBed.configureTestingModule({
imports: [CustomConfigsModule],
providers: [
{ provide: MatDialogRef, useValue: mockedDialogReference },
{ provide: MatDialog, useValue: mockedDialog },
{ provide: ThreeCameraServiceToken, useValue: {} },
{ provide: ThreeOrbitControlsServiceToken, useValue: {} }
]
})
})

it("should apply a custom Config and close custom config dialog", async () => {
CustomConfigHelper.applyCustomConfig = jest.fn()
const customConfigItemGroups = new Map([["fileAfileBMultiple", CUSTOM_CONFIG_ITEM_GROUPS.get("fileAfileBMultiple")]])
await render(CustomConfigItemGroupComponent, {
excludeComponentDeclaration: true,
componentProperties: { customConfigItemGroups }
})

fireEvent.click(screen.getByText("SampleMap View #1"))

expect(CustomConfigHelper.applyCustomConfig).toHaveBeenCalledTimes(1)
expect(mockedDialogReference.close).toHaveBeenCalledTimes(1)
})

it("should remove a custom Config and not close custom config dialog", async () => {
CustomConfigHelper.deleteCustomConfig = jest.fn()
const customConfigItemGroups = new Map([["fileAfileBMultiple", CUSTOM_CONFIG_ITEM_GROUPS.get("fileAfileBMultiple")]])
await render(CustomConfigItemGroupComponent, {
excludeComponentDeclaration: true,
componentProperties: { customConfigItemGroups }
})

fireEvent.click(screen.getAllByTitle("Remove Custom Config")[0])

expect(CustomConfigHelper.deleteCustomConfig).toHaveBeenCalledTimes(1)
expect(CustomConfigHelper.deleteCustomConfig).toHaveBeenCalledWith("MULTIPLEfileCSampleMap View #1")
expect(mockedDialogReference.close).toHaveBeenCalledTimes(0)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Component, Inject, Input } from "@angular/core"
import { CustomConfigHelper } from "../../../util/customConfigHelper"
import { CustomConfigItemGroup } from "../customConfigs.component"
import { Store } from "../../../state/angular-redux/store"
import { ThreeCameraServiceToken, ThreeOrbitControlsServiceToken } from "../../../services/ajs-upgraded-providers"
import { ThreeCameraService } from "../../codeMap/threeViewer/threeCameraService"
import { ThreeOrbitControlsService } from "../../codeMap/threeViewer/threeOrbitControlsService"

@Component({
selector: "cc-custom-config-item-group",
template: require("./customConfigItemGroup.component.html")
Hall-Ma marked this conversation as resolved.
Show resolved Hide resolved
})
export class CustomConfigItemGroupComponent {
@Input() customConfigItemGroups: Map<string, CustomConfigItemGroup>
isCollapsed = false

constructor(
@Inject(Store) private store: Store,
@Inject(ThreeCameraServiceToken) private threeCameraService: ThreeCameraService,
@Inject(ThreeOrbitControlsServiceToken) private threeOrbitControlsService: ThreeOrbitControlsService
) {}

applyCustomConfig(configId: string) {
CustomConfigHelper.applyCustomConfig(configId, this.store, this.threeCameraService, this.threeOrbitControlsService)
}

removeCustomConfig(configId: string) {
CustomConfigHelper.deleteCustomConfig(configId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<mat-dialog-content class="content">
<div class="row">
<div class="title">
<h3>Custom Views</h3>
</div>
<div class="action-buttons">
<cc-upload-custom-config-button></cc-upload-custom-config-button>
<cc-download-custom-configs-button></cc-download-custom-configs-button>
<cc-add-custom-config-button class="custom-configs-button-in-custom-views"></cc-add-custom-config-button>
</div>
</div>
<mat-divider></mat-divider>
<div
class="no-custom-configs-box"
*ngIf="dropDownCustomConfigItemGroups.applicableItems.size === 0 && dropDownCustomConfigItemGroups.nonApplicableItems.size === 0"
>
<span>It is time to add your first Custom View!</span>
</div>
<mat-accordion class="custom-config-container" [multi]="true">
<cc-custom-config-item-group
[customConfigItemGroups]="dropDownCustomConfigItemGroups.applicableItems"
></cc-custom-config-item-group>
<cc-custom-config-item-group
*ngIf="!isCollapsed"
class="non-applicable-group"
Hall-Ma marked this conversation as resolved.
Show resolved Hide resolved
[customConfigItemGroups]="dropDownCustomConfigItemGroups.nonApplicableItems"
></cc-custom-config-item-group>
<button
class="toggle-non-applicable-configs-button"
*ngIf="dropDownCustomConfigItemGroups.nonApplicableItems.size > 0"
(click)="toggleNonApplicableCustomConfigsList()"
>
{{ isCollapsed ? "Show non-applicable Custom Views" : "Hide non-applicable Custom Views" }}
<i [ngClass]="isCollapsed ? 'fa fa-angle-down' : 'fa fa-angle-up'"></i>
</button>
</mat-accordion>
</mat-dialog-content>