All files / app/codeCharta/ui/ribbonBar/edgeSettingsPanel edgeSettingsPanel.component.ts

90% Statements 27/30
100% Branches 0/0
40% Functions 2/5
89.65% Lines 26/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 583x 3x 3x 3x   3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x                             3x 2x 2x     2x     2x 2x 2x   2x   2x       2x                
import { Component } from "@angular/core"
import { MatCheckboxChange, MatCheckbox } from "@angular/material/checkbox"
import { Store } from "@ngrx/store"
import { map } from "rxjs"
import { CcState } from "../../../codeCharta.model"
import { setAmountOfEdgePreviews } from "../../../state/store/appSettings/amountOfEdgePreviews/amountOfEdgePreviews.actions"
import { amountOfEdgePreviewsSelector } from "../../../state/store/appSettings/amountOfEdgePreviews/amountOfEdgePreviews.selector"
import { setEdgeHeight } from "../../../state/store/appSettings/edgeHeight/edgeHeight.actions"
import { edgeHeightSelector } from "../../../state/store/appSettings/edgeHeight/edgeHeight.selector"
import { setShowOnlyBuildingsWithEdges } from "../../../state/store/appSettings/showOnlyBuildingsWithEdges/showOnlyBuildingsWithEdges.actions"
import { showOnlyBuildingsWithEdgesSelector } from "../../../state/store/appSettings/showOnlyBuildingsWithEdges/showOnlyBuildingsWithEdges.selector"
import { amountOfBuildingsWithSelectedEdgeMetricSelector } from "./selectors/amountOfBuildingsWithSelectedEdgeMetric.selector"
import { SliderComponent } from "../../slider/slider.component"
import { ColorPickerForMapColorComponent } from "../../colorPickerForMapColor/colorPickerForMapColor.component"
import { EdgeMetricToggleComponent } from "./edgeMetricToggle/edgeMetricToggle.component"
import { ResetSettingsButtonComponent } from "../../resetSettingsButton/resetSettingsButton.component"
import { AsyncPipe } from "@angular/common"
 
@Component({
    selector: "cc-edge-settings-panel",
    templateUrl: "./edgeSettingsPanel.component.html",
    standalone: true,
    imports: [
        SliderComponent,
        ColorPickerForMapColorComponent,
        MatCheckbox,
        EdgeMetricToggleComponent,
        ResetSettingsButtonComponent,
        AsyncPipe
    ]
})
export class EdgeSettingsPanelComponent {
    amountOfBuildingsWithSelectedEdgeMetric$ = this.store.select(amountOfBuildingsWithSelectedEdgeMetricSelector)
    edgePreviewLabel$ = this.amountOfBuildingsWithSelectedEdgeMetric$.pipe(
        map(
            amountOfBuildingsWithSelectedEdge =>
                `Preview the edges of up to ${amountOfBuildingsWithSelectedEdge} buildings with the highest amount of incoming and outgoing edges`
        )
    )
    amountOfEdgePreviews$ = this.store.select(amountOfEdgePreviewsSelector)
    edgeHeight$ = this.store.select(edgeHeightSelector)
    showOnlyBuildingsWithEdges$ = this.store.select(showOnlyBuildingsWithEdgesSelector)
 
    constructor(private store: Store<CcState>) {}
 
    applySettingsAmountOfEdgePreviews = (value: number) => {
        this.store.dispatch(setAmountOfEdgePreviews({ value }))
    }
 
    applySettingsEdgeHeight = (value: number) => {
        this.store.dispatch(setEdgeHeight({ value }))
    }
 
    applyShowOnlyBuildingsWithEdges(event: MatCheckboxChange) {
        this.store.dispatch(setShowOnlyBuildingsWithEdges({ value: event.checked }))
    }
}