-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map control dialog and layer control for scenario results (#1527)
* add scenario result layer control and dialog
- Loading branch information
1 parent
aa0a99b
commit cd4db3b
Showing
10 changed files
with
314 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,3 +180,4 @@ pyrightconfig.json | |
|
||
Session.vim | ||
|
||
cypress/screenshots/* |
37 changes: 37 additions & 0 deletions
37
src/interface/src/app/plan/map-layer-select-dialog/map-layer-select-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<section class="header"> | ||
<h4>Map Controls</h4> | ||
<button mat-icon-button (click)="cancel()" aria-label="close"> | ||
<mat-icon class="close-btn">close</mat-icon> | ||
</button> | ||
</section> | ||
<section class="radio-row"> | ||
<div class="radio-group-label">Base Map</div> | ||
|
||
<mat-radio-group | ||
name="dialog-select" | ||
aria-label="Select an option" | ||
class="layer-radio-group" | ||
[(ngModel)]="currentLayer" | ||
color="primary"> | ||
<div | ||
class="layer-control-container" | ||
*ngFor="let baseLayerType of baseLayerTypes"> | ||
<mat-radio-button | ||
aria-label="baseLayerType" | ||
[value]="baseLayerType" | ||
checked="{{ baseLayerType === currentLayer }}"> | ||
{{ BaseLayerType[baseLayerType] }} | ||
</mat-radio-button> | ||
</div> | ||
</mat-radio-group> | ||
</section> | ||
<section class="footer"> | ||
<button | ||
class="action" | ||
mat-flat-button | ||
type="button" | ||
color="primary" | ||
(click)="confirm()"> | ||
DONE | ||
</button> | ||
</section> |
70 changes: 70 additions & 0 deletions
70
src/interface/src/app/plan/map-layer-select-dialog/map-layer-select-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
@import 'colors'; | ||
@import 'mixins'; | ||
|
||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
width: 400px; | ||
} | ||
|
||
.header { | ||
display: flex; | ||
align-items: center; | ||
padding: 16px; | ||
padding-bottom: 10px; | ||
padding-top: 10px; | ||
border-bottom: 1px solid $color-soft-gray; | ||
justify-content: space-between; | ||
align-items: center; | ||
height: 64px; | ||
|
||
button { | ||
background: none; | ||
border: none; | ||
padding: 0; | ||
margin: 0; | ||
line-height: 0; | ||
cursor: pointer; | ||
height: auto; | ||
width: auto; | ||
} | ||
|
||
} | ||
|
||
h4 { | ||
@include h4(); | ||
height: 1em; | ||
line-height: 32px; | ||
} | ||
|
||
.radio-row { | ||
padding: 1em; | ||
justify-content: space-between; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
mat-radio-group { | ||
height: 128px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-evenly; | ||
color: $color-dark-gray; | ||
|
||
} | ||
.radio-group-label { | ||
@include xs-label(); | ||
color:black; | ||
} | ||
|
||
.footer { | ||
border-top: 1px solid $color-soft-gray; | ||
padding: 16px; | ||
height: 64px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-end; | ||
gap: 16px; | ||
|
||
|
||
} |
60 changes: 60 additions & 0 deletions
60
src/interface/src/app/plan/map-layer-select-dialog/map-layer-select-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { MapLayerSelectDialogComponent } from './map-layer-select-dialog.component'; | ||
import { | ||
MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, | ||
MatLegacyDialog as MatDialog, | ||
MatLegacyDialogRef as MatDialogRef, | ||
} from '@angular/material/legacy-dialog'; | ||
|
||
describe('MapLayerSelectDialogComponent', () => { | ||
let component: MapLayerSelectDialogComponent; | ||
let fixture: ComponentFixture<MapLayerSelectDialogComponent>; | ||
|
||
beforeEach(async () => { | ||
const fakeData = { | ||
user: { | ||
email: '[email protected]', | ||
}, | ||
}; | ||
const fakeDialog = jasmine.createSpyObj( | ||
'MatDialog', | ||
{ | ||
open: undefined, | ||
}, | ||
{} | ||
); | ||
const fakeDialogRef = jasmine.createSpyObj( | ||
'MatDialogRef', | ||
{ | ||
close: undefined, | ||
}, | ||
{} | ||
); | ||
await TestBed.configureTestingModule({ | ||
// imports: [MapLayerSelectDialogComponent], | ||
declarations: [MapLayerSelectDialogComponent], | ||
providers: [ | ||
{ | ||
provide: MAT_DIALOG_DATA, | ||
useValue: fakeData, | ||
}, | ||
{ | ||
provide: MatDialog, | ||
useValue: fakeDialog, | ||
}, | ||
{ | ||
provide: MatDialogRef<MapLayerSelectDialogComponent>, | ||
useValue: fakeDialogRef, | ||
}, | ||
], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MapLayerSelectDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
src/interface/src/app/plan/map-layer-select-dialog/map-layer-select-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Component, Inject } from '@angular/core'; | ||
import { | ||
MatLegacyDialogRef as MatDialogRef, | ||
MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA, | ||
} from '@angular/material/legacy-dialog'; | ||
import { BaseLayerType } from '@types'; | ||
|
||
@Component({ | ||
selector: 'app-map-layer-select-dialog', | ||
templateUrl: './map-layer-select-dialog.component.html', | ||
styleUrl: './map-layer-select-dialog.component.scss', | ||
}) | ||
export class MapLayerSelectDialogComponent { | ||
disableDeleteButton = false; | ||
constructor( | ||
@Inject(MatDialogRef) | ||
private dialogRef: MatDialogRef<MapLayerSelectDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) | ||
public data: { | ||
selectedLayer: number; | ||
} | ||
) {} | ||
givenLayer = this.data.selectedLayer; | ||
currentLayer = this.givenLayer; | ||
baseLayerTypes: number[] = [ | ||
BaseLayerType.Road, | ||
BaseLayerType.Terrain, | ||
BaseLayerType.Satellite, | ||
]; | ||
readonly BaseLayerType = BaseLayerType; | ||
cancel(): void { | ||
this.dialogRef.close(undefined); | ||
} | ||
|
||
confirm(): void { | ||
this.dialogRef.close(this.currentLayer); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/interface/src/app/plan/plan-map/map-layer-control/map-layer-control-component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Component, EventEmitter, Output } from '@angular/core'; | ||
import * as L from 'leaflet'; | ||
|
||
@Component({ | ||
template: '<div></div>', | ||
}) | ||
export class MapLayerControlComponent extends L.Control { | ||
constructor() { | ||
super({ position: 'topleft' }); // Set the position (optional) | ||
} | ||
@Output() layerClicked = new EventEmitter<void>(); | ||
|
||
override onAdd(map: L.Map) { | ||
const container = L.DomUtil.create('div', 'base-layer-control'); | ||
const icon = L.DomUtil.create( | ||
'span', | ||
'material-symbols-outlined layer-icon' | ||
); | ||
icon.textContent = 'layers'; | ||
container.append(icon); | ||
container.addEventListener('click', () => this.handleClick()); | ||
return container; | ||
} | ||
|
||
handleClick() { | ||
this.layerClicked.emit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.