Skip to content

Commit

Permalink
chore: Set some injected services to readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-huehn-mw authored and IhsenBouallegue committed Jan 17, 2025
1 parent e3047a4 commit 83311e0
Show file tree
Hide file tree
Showing 25 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Injectable } from "@angular/core"
export class IsAttributeSideBarVisibleService {
isOpen = false

constructor(private threeSceneService: ThreeSceneService) {
constructor(private readonly threeSceneService: ThreeSceneService) {
this.threeSceneService.subscribe("onBuildingSelected", () => {
this.isOpen = true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export class LoadInitialFileService {
private urlUtils = new UrlExtractor(this.httpClient)

constructor(
private store: Store,
private state: State<CcState>,
private dialog: MatDialog,
private loadFileService: LoadFileService,
private httpClient: HttpClient
private readonly store: Store,
private readonly state: State<CcState>,
private readonly dialog: MatDialog,
private readonly loadFileService: LoadFileService,
private readonly httpClient: HttpClient
) {}

async loadFilesOrSampleFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { compareVersion } from "./utils/compareVersion"
export class VersionService {
readonly version = packageJson.version

constructor(private dialog: MatDialog) {}
constructor(private readonly dialog: MatDialog) {}

synchronizeLocalCodeChartaVersion() {
const savedPreviousVersion = localStorage.getItem("codeChartaVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { RenderCodeMapEffect } from "../renderCodeMapEffect/renderCodeMap.effect
@Injectable()
export class AutoFitCodeMapEffect {
constructor(
private store: Store<CcState>,
private renderCodeMapEffect: RenderCodeMapEffect,
private threeMapControlsService: ThreeMapControlsService,
private actions$: Actions
private readonly store: Store<CcState>,
private readonly renderCodeMapEffect: RenderCodeMapEffect,
private readonly threeMapControlsService: ThreeMapControlsService,
private readonly actions$: Actions
) {}

autoFitTo$ = createEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { MatButton } from "@angular/material/button"
export class ExcludeButtonComponent {
@Input() codeMapNode: Pick<CodeMapNode, "path" | "type">

constructor(private store: Store) {}
constructor(private readonly store: Store) {}

excludeNode() {
this.store.dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { MatButton } from "@angular/material/button"
export class FlattenButtonsComponent {
@Input() codeMapNode: Pick<CodeMapNode, "path" | "type" | "isFlattened">

constructor(private store: Store) {}
constructor(private readonly store: Store) {}

flattenNode() {
this.store.dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class FocusButtonsComponent {
currentFocusedNodePath$ = this.store.select(currentFocusedNodePathSelector)
hasPreviousFocusedNodePath$ = this.store.select(focusedNodePathSelector).pipe(map(focusedNodePaths => focusedNodePaths.length > 1))

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

handleFocusNodeClicked() {
this.store.dispatch(focusNode({ value: this.codeMapNode.path }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class MarkFolderRowComponent {
markFolderItems$ = this.store.select(markFolderItemsSelector)
codeMapNode$ = this.store.select(rightClickedCodeMapNodeSelector)

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

markFolder(path: string, color: string) {
this.store.dispatch(markPackages({ packages: [{ path, color }] }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { LastPartOfNodePathPipe } from "./lastPartOfNodePath.pipe"
export class NodeContextMenuCardComponent implements OnInit {
codeMapNode$: Observable<CodeMapNode>

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

ngOnInit(): void {
this.codeMapNode$ = this.store.select(rightClickedCodeMapNodeSelector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const maxFPS = 1000 / 60
@Injectable()
export class RenderCodeMapEffect {
constructor(
private store: Store<CcState>,
private actions$: Actions,
private uploadFilesService: UploadFilesService,
private threeRendererService: ThreeRendererService,
private codeMapRenderService: CodeMapRenderService
private readonly store: Store<CcState>,
private readonly actions$: Actions,
private readonly uploadFilesService: UploadFilesService,
private readonly threeRendererService: ThreeRendererService,
private readonly codeMapRenderService: CodeMapRenderService
) {}

private actionsRequiringRender$ = this.actions$.pipe(ofType(...actionsRequiringRerender))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { defaultNMetrics, isAnyMetricAvailable, preselectCombination } from "./u

@Injectable()
export class ResetChosenMetricsEffect {
constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

resetChosenDistributionMetric$ = createEffect(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { edgeMetricSelector } from "../../store/dynamicSettings/edgeMetric/edgeM

@Injectable()
export class ResetSelectedEdgeMetricWhenItDoesntExistAnymoreEffect {
constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

resetSelectedEdgeMetricWhenItDoesntExistAnymore$ = createEffect(() =>
this.store.select(metricDataSelector).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CcState } from "../../../codeCharta.model"

@Injectable()
export class UnfocusNodesEffect {
constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

unfocusNodes$ = createEffect(() => this.store.select(visibleFileStatesSelector).pipe(map(() => unfocusAllNodes())))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CcState } from "../../../codeCharta.model"

@Injectable()
export class UpdateEdgePreviewsEffect {
constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

resetIsEdgeMetricVisible$ = createEffect(() =>
this.store.select(edgeMetricSelector).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class AttributeSideBarHeaderSectionComponent {
@Input() node: Pick<CodeMapNode, "children" | "name" | "link" | "path">
@Input() fileName: string

constructor(private isAttributeSideBarVisibleService: IsAttributeSideBarVisibleService) {}
constructor(private readonly isAttributeSideBarVisibleService: IsAttributeSideBarVisibleService) {}

closeSideBar() {
this.isAttributeSideBarVisibleService.isOpen = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class AttributeSideBarPrimaryMetricsComponent {
showAttributeTypeSelector$: Observable<boolean>
attributeDescriptors$: Observable<AttributeDescriptors>

constructor(private store: Store<CcState>) {
constructor(private readonly store: Store<CcState>) {
this.primaryMetrics$ = this.store.select(primaryMetricsSelector)
this.showAttributeTypeSelector$ = this.store.select(showAttributeTypeSelectorSelector)
this.attributeDescriptors$ = this.store.select(attributeDescriptorsSelector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AttributeSideBarSecondaryMetricsComponent {
showDeltaValue$: Observable<boolean>
attributeDescriptors$: Observable<AttributeDescriptors>

constructor(private store: Store<CcState>) {
constructor(private readonly store: Store<CcState>) {
this.secondaryMetrics$ = this.store.select(secondaryMetricsSelector)
this.showAttributeTypeSelector$ = this.store.select(showAttributeTypeSelectorSelector)
this.showDeltaValue$ = this.store.select(showDeltaValueSelector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AttributeTypeSelectorComponent {

attributeTypes$ = this.store.select(attributeTypesSelector)

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

setToAbsolute() {
this.setAttributeType(AttributeTypeValue.absolute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class MetricDeltaSelectedComponent implements OnInit {
selectedNode$: Observable<CodeMapNode>
mapColors$: Observable<MapColors>

constructor(private store: Store<CcState>) {}
constructor(private readonly store: Store<CcState>) {}

ngOnInit(): void {
this.selectedNode$ = this.store.select(selectedNodeSelector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export class CodeMapArrowService implements OnDestroy {
.subscribe()

constructor(
private store: Store<CcState>,
private state: State<CcState>,
private readonly store: Store<CcState>,
private readonly state: State<CcState>,
private threeSceneService: ThreeSceneService,
private idToBuildingService: IdToBuildingService
private readonly idToBuildingService: IdToBuildingService
) {
this.threeSceneService.subscribe("onBuildingSelected", this.onBuildingSelected)
this.threeSceneService.subscribe("onBuildingDeselected", this.onBuildingDeselected)
Expand Down
8 changes: 4 additions & 4 deletions visualization/app/codeCharta/ui/codeMap/codeMap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class CodeMapComponent implements AfterViewInit, OnDestroy {

constructor(
public isAttributeSideBarVisibleService: IsAttributeSideBarVisibleService,
private store: Store<CcState>,
private threeViewerService: ThreeViewerService,
private codeMapMouseEventService: CodeMapMouseEventService,
private elementReference: ElementRef
private readonly store: Store<CcState>,
private readonly threeViewerService: ThreeViewerService,
private readonly codeMapMouseEventService: CodeMapMouseEventService,
private readonly elementReference: ElementRef
) {}

ngAfterViewInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export class CodeMapLabelService {
private nodeHeight = 0

constructor(
private state: State<CcState>,
private threeCameraService: ThreeCameraService,
private readonly state: State<CcState>,
private readonly threeCameraService: ThreeCameraService,
private threeSceneService: ThreeSceneService,
private threeMapControlsService: ThreeMapControlsService
private readonly threeMapControlsService: ThreeMapControlsService
) {
this.labels = new Array<InternalLabel>()
this.threeMapControlsService.subscribe("onCameraChanged", () => this.onCameraChanged())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ export class CodeMapMouseEventService implements OnDestroy {
private threeCameraService: ThreeCameraService,
private threeRendererService: ThreeRendererService,
private threeSceneService: ThreeSceneService,
private store: Store<CcState>,
private state: State<CcState>,
private codeMapLabelService: CodeMapLabelService,
private viewCubeMouseEvents: ViewCubeMouseEventsService,
private threeViewerService: ThreeViewerService,
private idToBuilding: IdToBuildingService
private readonly store: Store<CcState>,
private readonly state: State<CcState>,
private readonly codeMapLabelService: CodeMapLabelService,
private readonly viewCubeMouseEvents: ViewCubeMouseEventsService,
private readonly threeViewerService: ThreeViewerService,
private readonly idToBuilding: IdToBuildingService
) {}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class CodeMapRenderService implements OnDestroy {
private subscription: Subscription

constructor(
private store: Store<CcState>,
private state: State<CcState>,
private readonly store: Store<CcState>,
private readonly state: State<CcState>,
private threeSceneService: ThreeSceneService,
private codeMapLabelService: CodeMapLabelService,
private codeMapArrowService: CodeMapArrowService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class ThreeMapControlsService {
zoomPercentage$ = new BehaviorSubject<number>(100)

constructor(
private threeCameraService: ThreeCameraService,
private threeSceneService: ThreeSceneService,
private threeRendererService: ThreeRendererService
private readonly threeCameraService: ThreeCameraService,
private readonly threeSceneService: ThreeSceneService,
private readonly threeRendererService: ThreeRendererService
) {}

setControlTarget(cameraTarget: Vector3) {
Expand Down

0 comments on commit 83311e0

Please sign in to comment.