Skip to content

Commit 46dbfe4

Browse files
authored
Merge pull request #1746 from swisstopo/feature/viewer-1701-seismic-linien-ueber-ogc-api-einbinden
Feature 1701: Seismic-Linien über OGC-API einbinden
2 parents 4e01f17 + 60411d2 commit 46dbfe4

22 files changed

+1074
-77
lines changed

ui/locales/toolbox/toolbox.de.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"actions": {
3+
"export": "Daten exportieren"
4+
},
5+
"ogc": {
6+
"layer-selection": {
7+
"title": "Export",
8+
"confirm": "Export"
9+
},
10+
"queue": {
11+
"title": "Export Warteschlange"
12+
},
13+
"stage": {
14+
"Prepare": "Vorbereitung Download auf dem Server",
15+
"Running": "Durchführung Export",
16+
"Success": "Export wurde erfolgreich durchgeführt",
17+
"Failure": "Export ist fehlgeschlagen",
18+
"Complete": "Export Abgeschlossen"
19+
}
20+
}
21+
}

ui/locales/toolbox/toolbox.en.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"actions": {
3+
"export": ""
4+
},
5+
"ogc": {
6+
"layer-selection": {
7+
"title": "",
8+
"confirm": ""
9+
},
10+
"queue": {
11+
"title": ""
12+
},
13+
"stage": {
14+
"Prepare": "",
15+
"Running": "",
16+
"Success": "",
17+
"Failure": "",
18+
"Complete": ""
19+
}
20+
}
21+
}

ui/locales/toolbox/toolbox.fr.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"actions": {
3+
"export": ""
4+
},
5+
"ogc": {
6+
"layer-selection": {
7+
"title": "",
8+
"confirm": ""
9+
},
10+
"queue": {
11+
"title": ""
12+
},
13+
"stage": {
14+
"Prepare": "",
15+
"Running": "",
16+
"Success": "",
17+
"Failure": "",
18+
"Complete": ""
19+
}
20+
}
21+
}

ui/locales/toolbox/toolbox.it.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"actions": {
3+
"export": ""
4+
},
5+
"ogc": {
6+
"layer-selection": {
7+
"title": "",
8+
"confirm": ""
9+
},
10+
"queue": {
11+
"title": ""
12+
},
13+
"stage": {
14+
"Prepare": "",
15+
"Running": "",
16+
"Success": "",
17+
"Failure": "",
18+
"Complete": ""
19+
}
20+
}
21+
}

ui/src/context/register-context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { LayerInfoService } from 'src/features/layer/info/layer-info.service';
1818
import { LayerService } from 'src/features/layer/layer.service';
1919
import { GestureControlsService } from 'src/features/controls/gestures/gesture-controls.service';
2020
import { SessionService } from 'src/features/session/session.service';
21+
import { OgcService } from 'src/features/ogc';
2122

2223
type AppContext = ContextProvider<Context<unknown, unknown>, LitElement>;
2324
export const registerAppContext = (
@@ -50,6 +51,7 @@ export const registerAppContext = (
5051
contexts.push(makeProvider(LayerService));
5152
contexts.push(makeProvider(LayerInfoService));
5253
contexts.push(makeProvider(GestureControlsService));
54+
contexts.push(makeProvider(OgcService));
5355

5456
return contexts;
5557
};

ui/src/elements/ngm-side-bar.ts

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ import { consume } from '@lit/context';
4949
import { isSameLayer, LayerService } from 'src/features/layer/layer.service';
5050
import { LayerInfoService } from 'src/features/layer/info/layer-info.service';
5151
import { distinctUntilChanged, map, skip, take } from 'rxjs';
52-
import { run } from 'src/utils/fn.utils';
5352
import { getLayersConfig } from 'src/swisstopoImagery';
5453
import { SessionService } from 'src/features/session';
5554
import { initializeLayerHelpers } from 'src/layers/helpers';
55+
import { run } from 'src/utils/fn.utils';
5656

5757
export type SearchLayer = SearchLayerWithLayer | SearchLayerWithSource;
5858

@@ -123,7 +123,9 @@ export class SideBar extends LitElementI18n {
123123
private shareListenerAdded = false;
124124

125125
private readonly shareDownListener = (evt) => {
126-
if (!evt.composedPath().includes(this)) this.activePanel = null;
126+
if (!evt.composedPath().includes(this)) {
127+
this.closePanel();
128+
}
127129
};
128130

129131
private viewer: Viewer | null = null;
@@ -206,8 +208,9 @@ export class SideBar extends LitElementI18n {
206208
});
207209

208210
const sliceOptions = getSliceParam();
209-
if (sliceOptions?.type && sliceOptions.slicePoints)
210-
this.activePanel = 'tools';
211+
if (sliceOptions?.type && sliceOptions.slicePoints) {
212+
this.openPanel('tools');
213+
}
211214

212215
this.layerService.layerActivated$.subscribe((layer) => {
213216
this.maybeShowVisibilityHint(layer as LayerConfig);
@@ -224,18 +227,49 @@ export class SideBar extends LitElementI18n {
224227
});
225228
}
226229

227-
async togglePanel(panelName, showHeader = true) {
230+
async togglePanel(panelName: string, showHeader = true) {
231+
this.showHeader = showHeader;
232+
if (this.activePanel === panelName) {
233+
this.closePanel(panelName);
234+
} else {
235+
this.openPanel(panelName);
236+
}
237+
}
238+
239+
private openPanel(panelName: string): void {
240+
document.body.style.setProperty(
241+
'--sidebar-width',
242+
run(() => {
243+
switch (panelName) {
244+
case 'data':
245+
return '440px';
246+
case 'settings':
247+
case 'tools':
248+
return '250px';
249+
case 'dashboard':
250+
return 'min(1028px, calc(100vw - 144px))';
251+
case 'share':
252+
return '436px';
253+
default:
254+
return '';
255+
}
256+
}),
257+
);
258+
this.activePanel = panelName;
259+
}
260+
261+
private readonly handlePanelClose = () => this.closePanel();
262+
263+
private readonly closePanel = (panelName?: string): void => {
228264
if (DashboardStore.projectMode.value === 'edit') {
229265
DashboardStore.showSaveOrCancelWarning(true);
230266
return;
231267
}
232-
this.showHeader = showHeader;
233-
if (this.activePanel === panelName) {
268+
if (panelName === undefined || this.activePanel === panelName) {
269+
document.body.style.setProperty('--sidebar-width', '');
234270
this.activePanel = null;
235-
return;
236271
}
237-
this.activePanel = panelName;
238-
}
272+
};
239273

240274
async syncActiveLayers() {
241275
const flatLayers = flattenLayers(this.catalogLayers!);
@@ -570,18 +604,18 @@ export class SideBar extends LitElementI18n {
570604
<ngm-dashboard
571605
class="ngm-side-bar-panel ngm-large-panel"
572606
?hidden=${this.activePanel !== 'dashboard'}
573-
@close=${() => (this.activePanel = null)}
607+
@close=${this.handlePanelClose}
574608
></ngm-dashboard>
575609
<ngm-layer-panel
576610
?hidden="${this.activePanel !== 'data'}"
577611
.layers="${this.catalogLayers ?? []}"
578-
@close="${() => (this.activePanel = null)}"
612+
@close="${this.handlePanelClose}"
579613
></ngm-layer-panel>
580614
<div .hidden=${this.activePanel !== 'tools'} class="ngm-side-bar-panel">
581615
<ngm-tools
582616
.toolsHidden=${this.activePanel !== 'tools'}
583-
@open=${() => (this.activePanel = 'tools')}
584-
@close=${() => (this.activePanel = null)}
617+
@open=${() => this.openPanel('tools')}
618+
@close=${this.handlePanelClose}
585619
></ngm-tools>
586620
</div>
587621
<div
@@ -590,10 +624,7 @@ export class SideBar extends LitElementI18n {
590624
>
591625
<div class="ngm-panel-header">
592626
${i18next.t('lsb_share')}
593-
<div
594-
class="ngm-close-icon"
595-
@click=${() => (this.activePanel = null)}
596-
></div>
627+
<div class="ngm-close-icon" @click=${this.handlePanelClose}></div>
597628
</div>
598629
${this.activePanel !== 'share'
599630
? ''
@@ -605,10 +636,7 @@ export class SideBar extends LitElementI18n {
605636
>
606637
<div class="ngm-panel-header">
607638
${i18next.t('lsb_settings')}
608-
<div
609-
class="ngm-close-icon"
610-
@click=${() => (this.activePanel = null)}
611-
></div>
639+
<div class="ngm-close-icon" @click=${this.handlePanelClose}></div>
612640
</div>
613641
<div class="toolbar-settings">
614642
<div class="inner-toolbar-settings">

ui/src/features/core/core-checkbox.element.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export class CoreCheckbox extends LitElement {
1010
@property({ type: Boolean })
1111
accessor isIndeterminate: boolean = false;
1212

13+
@property({ type: Boolean, attribute: 'disabled', reflect: true })
14+
accessor isDisabled: boolean = false;
15+
1316
firstUpdated() {
1417
const slot = this.shadowRoot?.querySelector('slot');
1518
slot?.addEventListener('slotchange', () => {
@@ -25,6 +28,9 @@ export class CoreCheckbox extends LitElement {
2528
private handleClick(e: Event) {
2629
e.stopPropagation();
2730
e.preventDefault();
31+
if (this.isDisabled) {
32+
return;
33+
}
2834
this.dispatchEvent(
2935
new CustomEvent('update', { bubbles: true, composed: true }),
3036
);
@@ -82,6 +88,13 @@ export class CoreCheckbox extends LitElement {
8288
:host {
8389
display: flex;
8490
align-items: center;
91+
--checkbox-color: var(--color-primary);
92+
--checkbox-color--active: var(--color-primary--active);
93+
}
94+
95+
:host([disabled]) {
96+
--checkbox-color: var(--color-primary--disabled);
97+
--checkbox-color--active: var(--color-primary--disabled);
8598
}
8699
87100
label {
@@ -107,15 +120,15 @@ export class CoreCheckbox extends LitElement {
107120
width: 20px;
108121
height: 20px;
109122
border-radius: 1px;
110-
border: 2px solid var(--color-primary);
123+
border: 2px solid var(--checkbox-color);
111124
112125
${applyTransition('fade')};
113126
transition-property: background-color, border-color;
114127
}
115128
116129
label:has(input[checked]) .icon {
117-
border-color: var(--color-primary--active);
118-
background-color: var(--color-primary--active);
130+
border-color: var(--checkbox-color--active);
131+
background-color: var(--checkbox-color--active);
119132
}
120133
121134
/* checkbox highlight */

ui/src/features/core/core-modal.element.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ export class CoreModal extends LitElement {
3636
static open(props: CoreModalProps, content: TemplateResult): CoreModal {
3737
const container = document.createElement('div');
3838
container.classList.add('ngm-core-modal-container');
39-
document.body.appendChild(container);
39+
const root = document.querySelector('ngm-app-boot')!;
40+
root.appendChild(container);
4041

4142
const close = () => {
4243
render(null, container);
4344
if (container.parentElement != null) {
44-
document.body.removeChild(container);
45+
root.removeChild(container);
4546
}
4647
if (props.onClose != null) {
4748
props.onClose();

ui/src/features/layer/display/layer-display-list-item.element.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import i18next from 'i18next';
1111
import { LayerService } from 'src/features/layer/layer.service';
1212
import { consume } from '@lit/context';
1313
import { LayerTiffController } from 'src/features/layer';
14+
import { OgcService } from 'src/features/ogc';
1415

1516
@customElement('ngm-layer-display-list-item')
1617
export class LayerDisplayListItem extends CoreElement {
@@ -35,6 +36,9 @@ export class LayerDisplayListItem extends CoreElement {
3536
@consume({ context: LayerService.context() })
3637
accessor layerService!: LayerService;
3738

39+
@consume({ context: OgcService.context() })
40+
accessor ogcService!: OgcService;
41+
3842
@state()
3943
accessor isOpacityActive = false;
4044

ui/src/features/layer/info/layer-info.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export class LayerInfoService extends BaseService {
7373
const eventHandler = new ScreenSpaceEventHandler(viewer.canvas);
7474
eventHandler.setInputAction(
7575
async (event: ScreenSpaceEventHandler.PositionedEvent) => {
76+
// Don't pick while drawing.
7677
if (DrawStore.drawStateValue) {
7778
return;
7879
}

0 commit comments

Comments
 (0)