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: migrate center-map-button #2809

Merged
merged 2 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Chore 👨‍💻 👩‍💻

- Track not only changes to color metric options by slider but also by related input field [#2797](https://github.com/MaibornWolff/codecharta/pull/2797)
- Migrate center-map-button-component to Angular [#2809](https://github.com/MaibornWolff/codecharta/pull/2809)

## [1.96.0] - 2022-05-17

Expand Down
4 changes: 3 additions & 1 deletion visualization/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { MetricColorRangeSliderModule } from "./codeCharta/ui/colorSettingsPanel
import { FilePanelModule } from "./codeCharta/ui/filePanel/filePanel.module"
import { CustomConfigsModule } from "./codeCharta/ui/customConfigs/customConfigs.module"
import { ResetColorRangeEffect } from "./codeCharta/state/store/dynamicSettings/colorRange/resetColorRange.effect"
import { CenterMapButtonModule } from "./codeCharta/ui/viewCube/centerMapButton/centerMapButton.module"

@NgModule({
imports: [
Expand Down Expand Up @@ -80,7 +81,8 @@ import { ResetColorRangeEffect } from "./codeCharta/state/store/dynamicSettings/
FilePanelModule,
HeightSettingsPanelModule,
ResetSettingsButtonModule,
MetricColorRangeSliderModule
MetricColorRangeSliderModule,
CenterMapButtonModule
],
providers: [
threeSceneServiceProvider,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions visualization/app/codeCharta/ui/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "./nodePathPanel/nodePathPanel.module"
import "./edgeSettingsPanel/edgeSettingsPanel.module"
import "./edgeChooser/edgeChooser.module"
import "./presentationModeButton/presentationModeButton.module"
import "./centerMapButton/centerMapButton.module"
import "./areaSettingsPanel/areaSettingsPanel.module"
import "./codeMap/codeMap.module"
import "./colorSettingsPanel/colorSettingsPanel.module"
Expand Down Expand Up @@ -39,7 +38,6 @@ angular
"app.codeCharta.ui.edgeSettingsPanel",
"app.codeCharta.ui.edgeChooser",
"app.codeCharta.ui.presentationModeButton",
"app.codeCharta.ui.centerMapButton",
"app.codeCharta.ui.areaSettingsPanel",
"app.codeCharta.ui.codeMap",
"app.codeCharta.ui.colorSettingsPanel",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button class="cc-shadow" aria-label="Center map in View" (click)="centerMap()" title="Center map">
<i class="fa fa-compass"></i>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@use "../../../../material/theme";

cc-center-map-button {
button {
position: absolute;
right: 15px;
width: 36px;
height: 36px;
font-size: 28px;
border-radius: 100%;
color: white;
background-color: theme.$cc-primary-color;

i {
margin-top: 2px;
}

&:hover {
cursor: pointer;
color: #eee;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TestBed } from "@angular/core/testing"
import { render, screen } from "@testing-library/angular"
import userEvent from "@testing-library/user-event"
import { ThreeOrbitControlsServiceToken } from "../../../services/ajs-upgraded-providers"
import { CenterMapButtonComponent } from "./centerMapButton.component"

describe("CenterMapButtonComponent", () => {
const threeOrbitControlsService = { autoFitTo: jest.fn() }

beforeEach(() => {
threeOrbitControlsService.autoFitTo = jest.fn()
TestBed.configureTestingModule({
providers: [{ provide: ThreeOrbitControlsServiceToken, useValue: threeOrbitControlsService }]
})
})

it("should call autoFitTo of threeOrbitControlsService on click", async () => {
await render(CenterMapButtonComponent)

userEvent.click(screen.getByTitle("Center map"))

expect(threeOrbitControlsService.autoFitTo).toHaveBeenCalled()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "./centerMapButton.component.scss"
import { Component, Inject } from "@angular/core"
import { ThreeOrbitControlsServiceToken } from "../../../services/ajs-upgraded-providers"
import { ThreeOrbitControlsService } from "../../codeMap/threeViewer/threeOrbitControlsService"

@Component({
selector: "cc-center-map-button",
template: require("./centerMapButton.component.html")
})
export class CenterMapButtonComponent {
constructor(@Inject(ThreeOrbitControlsServiceToken) private threeOrbitControlsService: ThreeOrbitControlsService) {}

centerMap() {
this.threeOrbitControlsService.autoFitTo()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { NgModule } from "@angular/core"
import { CenterMapButtonComponent } from "./centerMapButton.component"

@NgModule({
declarations: [CenterMapButtonComponent],
exports: [CenterMapButtonComponent],
entryComponents: [CenterMapButtonComponent]
})
export class CenterMapButtonModule {}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<center-map-button-component></center-map-button-component>
<cc-center-map-button></cc-center-map-button>
12 changes: 0 additions & 12 deletions visualization/app/codeCharta/ui/viewCube/viewCube.component.scss

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./viewCube.component.scss"
import {
AmbientLight,
AxesHelper,
Expand Down
3 changes: 3 additions & 0 deletions visualization/app/codeCharta/ui/viewCube/viewCube.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import "../codeMap/threeViewer/threeViewer.module"
import { viewCubeComponent } from "./viewCube.component"
import { ViewCubeMouseEventsService } from "./viewCube.mouseEvents.service"
import camelCase from "lodash.camelcase"
import { downgradeComponent } from "@angular/upgrade/static"
import { CenterMapButtonComponent } from "./centerMapButton/centerMapButton.component"

angular
.module("app.codeCharta.ui.viewCube", ["app.codeCharta.ui.codeMap.threeViewer"])
.component(viewCubeComponent.selector, viewCubeComponent)
.service(camelCase(ViewCubeMouseEventsService.name), ViewCubeMouseEventsService)
.directive("ccCenterMapButton", downgradeComponent({ component: CenterMapButtonComponent }))