Skip to content

Commit b891b9b

Browse files
Made panels use tab , fixe them to the edge of the map.
1 parent 4489a76 commit b891b9b

File tree

14 files changed

+250
-158
lines changed

14 files changed

+250
-158
lines changed

packages/base/src/mainview/mainView.tsx

Lines changed: 29 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import { IStateDB } from '@jupyterlab/statedb';
21
import { MapChange } from '@jupyter/ydoc';
32
import {
43
IAnnotation,
4+
IAnnotationModel,
55
IDict,
66
IGeoTiffSource,
77
IHeatmapLayer,
88
IHillshadeLayer,
99
IImageLayer,
1010
IImageSource,
1111
IJGISFilterItem,
12+
IJGISFormSchemaRegistry,
1213
IJGISLayer,
1314
IJGISLayerDocChange,
1415
IJGISLayerTreeDocChange,
@@ -34,9 +35,10 @@ import {
3435
import { showErrorMessage } from '@jupyterlab/apputils';
3536
import { IObservableMap, ObservableMap } from '@jupyterlab/observables';
3637
import { User } from '@jupyterlab/services';
38+
import { IStateDB } from '@jupyterlab/statedb';
3739
import { CommandRegistry } from '@lumino/commands';
3840
import { JSONValue, UUID } from '@lumino/coreutils';
39-
import { ContextMenu, Widget } from '@lumino/widgets';
41+
import { ContextMenu } from '@lumino/widgets';
4042
import { Collection, MapBrowserEvent, Map as OlMap, View, getUid } from 'ol';
4143
import Feature, { FeatureLike } from 'ol/Feature';
4244
import { FullScreen, ScaleLine } from 'ol/control';
@@ -80,19 +82,17 @@ import StacLayer from 'ol-stac';
8082
import proj4 from 'proj4';
8183
import proj4list from 'proj4-list';
8284
import * as React from 'react';
83-
import { Rnd } from 'react-rnd';
8485

8586
import AnnotationFloater from '@/src/annotations/components/AnnotationFloater';
8687
import { CommandIDs } from '@/src/constants';
8788
import { LoadingOverlay } from '@/src/shared/components/loading';
8889
import StatusBar from '@/src/statusbar/StatusBar';
89-
import { isLightTheme, loadFile, throttle } from '@/src/tools';
90-
import Lumino from '../Lumino';
90+
import { debounce, isLightTheme, loadFile, throttle } from '@/src/tools';
9191
import CollaboratorPointers, { ClientPointer } from './CollaboratorPointers';
9292
import { FollowIndicator } from './FollowIndicator';
9393
import TemporalSlider from './TemporalSlider';
9494
import { MainViewModel } from './mainviewmodel';
95-
import { LeftPanelComponent } from '../panelview';
95+
import { LeftPanelComponent, RightPanelComponent } from '../panelview';
9696

9797
type OlLayerTypes =
9898
| TileLayer
@@ -106,7 +106,8 @@ type OlLayerTypes =
106106
interface IProps {
107107
viewModel: MainViewModel;
108108
state?: IStateDB;
109-
rightPanel?: Widget;
109+
formSchemaRegistry?: IJGISFormSchemaRegistry;
110+
annotationModel?: IAnnotationModel;
110111
}
111112

112113
interface IStates {
@@ -128,9 +129,12 @@ interface IStates {
128129
export class MainView extends React.Component<IProps, IStates> {
129130
constructor(props: IProps) {
130131
super(props);
131-
132132
this._state = props.state;
133133

134+
this._formSchemaRegistry = props.formSchemaRegistry;
135+
136+
this._annotationModel = props.annotationModel;
137+
134138
// Enforce the map to take the full available width in the case of Jupyter Notebook viewer
135139
const el = document.getElementById('main-panel');
136140

@@ -160,7 +164,6 @@ export class MainView extends React.Component<IProps, IStates> {
160164
resizeObserver.observe(el);
161165
}
162166

163-
this._rightPanel = props.rightPanel;
164167
this._mainViewModel = this.props.viewModel;
165168
this._mainViewModel.viewSettingChanged.connect(this._onViewChanged, this);
166169

@@ -225,6 +228,7 @@ export class MainView extends React.Component<IProps, IStates> {
225228
this._contextMenu = new ContextMenu({
226229
commands: this._commands,
227230
});
231+
this._updateCenter = debounce(this.updateCenter, 100);
228232
}
229233

230234
async componentDidMount(): Promise<void> {
@@ -2205,51 +2209,20 @@ export class MainView extends React.Component<IProps, IStates> {
22052209
scale={this.state.scale}
22062210
/>
22072211
</div>
2208-
{this._state &&
2209-
<Rnd
2210-
default={{
2211-
x: 400,
2212-
y: 0,
2213-
width: 200,
2214-
height: 600,
2215-
}}
2216-
bounds="window"
2217-
minWidth={100}
2218-
minHeight={100}
2219-
>
2220-
<LeftPanelComponent model={this._model} commands={this._commands} state={this._state}></LeftPanelComponent>
2221-
</Rnd>
2222-
}
2223-
{/* {this._leftPanel && (
2224-
<Rnd
2225-
default={{
2226-
x: 0,
2227-
y: 0,
2228-
width: 200,
2229-
height: 600,
2230-
}}
2231-
bounds="window"
2232-
minWidth={100}
2233-
minHeight={100}
2234-
>
2235-
<Lumino>{this._leftPanel}</Lumino>
2236-
</Rnd>
2237-
)} */}
2238-
2239-
{this._rightPanel && (
2240-
<Rnd
2241-
default={{
2242-
x: 400,
2243-
y: 0,
2244-
width: 200,
2245-
height: 600,
2246-
}}
2247-
bounds="window"
2248-
minWidth={100}
2249-
minHeight={100}
2250-
>
2251-
<Lumino>{this._rightPanel}</Lumino>
2252-
</Rnd>
2212+
2213+
{this._state && (
2214+
<LeftPanelComponent
2215+
model={this._model}
2216+
commands={this._commands}
2217+
state={this._state}
2218+
></LeftPanelComponent>
2219+
)}
2220+
{this._formSchemaRegistry && this._annotationModel && (
2221+
<RightPanelComponent
2222+
model={this._model}
2223+
formSchemaRegistry={this._formSchemaRegistry}
2224+
annotationModel={this._annotationModel}
2225+
></RightPanelComponent>
22532226
)}
22542227
</>
22552228
);
@@ -2272,5 +2245,6 @@ export class MainView extends React.Component<IProps, IStates> {
22722245
private _highlightLayer: VectorLayer<VectorSource>;
22732246
private _updateCenter: CallableFunction;
22742247
private _state?: IStateDB;
2275-
private _rightPanel?: Widget;
2248+
private _formSchemaRegistry?: IJGISFormSchemaRegistry;
2249+
private _annotationModel?: IAnnotationModel;
22762250
}
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
import { IStateDB } from '@jupyterlab/statedb';
1+
import { IAnnotationModel, IJGISFormSchemaRegistry } from '@jupytergis/schema';
22
import { ReactWidget } from '@jupyterlab/apputils';
3-
import { Widget } from '@lumino/widgets';
3+
import { IStateDB } from '@jupyterlab/statedb';
44
import * as React from 'react';
55

66
import { MainView } from './mainView';
77
import { MainViewModel } from './mainviewmodel';
88

9+
export interface IOptions {
10+
mainViewModel: MainViewModel;
11+
state?: IStateDB;
12+
formSchemaRegistry?: IJGISFormSchemaRegistry;
13+
annotationModel?: IAnnotationModel;
14+
}
15+
916
export class JupyterGISMainViewPanel extends ReactWidget {
1017
/**
1118
* Construct a `JupyterGISPanel`.
1219
*/
13-
constructor(
14-
options: { mainViewModel: MainViewModel, state?: IStateDB },
15-
rightPanel?: Widget,
16-
) {
20+
constructor(options: IOptions) {
1721
super();
18-
this._mainViewModel = options.mainViewModel;
1922
this._state = options.state;
2023
this.addClass('jp-jupytergis-panel');
21-
this._rightPanel = rightPanel;
24+
this._options = options;
2225
}
2326

2427
render(): JSX.Element {
2528
return (
2629
<MainView
2730
state={this._state}
28-
rightPanel={this._rightPanel}
29-
viewModel={this._mainViewModel}
31+
viewModel={this._options.mainViewModel}
32+
formSchemaRegistry={this._options.formSchemaRegistry}
33+
annotationModel={this._options.annotationModel}
3034
/>
3135
);
3236
}
3337

3438
private _state?: IStateDB;
35-
private _mainViewModel: MainViewModel;
36-
private _rightPanel?: Widget;
39+
private _options: IOptions;
3740
}

packages/base/src/panelview/annotationPanel.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,17 @@ export class AnnotationsPanel extends Component<IAnnotationPanelProps> {
1313
constructor(props: IAnnotationPanelProps) {
1414
super(props);
1515

16+
console.log(props.annotationModel);
17+
1618
const updateCallback = () => {
1719
this.forceUpdate();
1820
};
1921

2022
this._annotationModel = props.annotationModel;
2123
this._rightPanelModel = props.rightPanelModel;
2224

23-
this._annotationModel.modelChanged.connect(async () => {
24-
// await this._annotationModel?.context?.ready;
25-
26-
this._annotationModel?.model?.sharedMetadataChanged.disconnect(
27-
updateCallback,
28-
);
29-
this._annotationModel = props.annotationModel;
30-
this._annotationModel?.model?.sharedMetadataChanged.connect(
31-
updateCallback,
32-
);
33-
this.forceUpdate();
34-
});
25+
this._annotationModel?.model?.sharedMetadataChanged.connect(updateCallback);
26+
this.forceUpdate();
3527
}
3628

3729
render(): JSX.Element {

packages/base/src/panelview/components/filter-panel/Filter.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ const FilterComponent: React.FC<IFilterComponentProps> = props => {
285285
</div>
286286
</div>
287287
)}
288+
{!shouldDisplay && (
289+
<div style={{ textAlign: 'center' }}>No layer selected</div>
290+
)}
288291
</>
289292
);
290293
};

packages/base/src/panelview/components/identify-panel/IdentifyPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface IIdentifyComponentProps {
3838
model: IJupyterGISModel;
3939
}
4040

41-
const IdentifyPanelComponent = (options: IIdentifyComponentProps) => {
41+
export const IdentifyPanelComponent = (options: IIdentifyComponentProps) => {
4242
const [features, setFeatures] = useState<IDict<any>>();
4343
const [visibleFeatures, setVisibleFeatures] = useState<IDict<any>>({
4444
0: true,

packages/base/src/panelview/components/layers.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ import {
88
} from '@jupytergis/schema';
99
import { DOMUtils } from '@jupyterlab/apputils';
1010
import { IStateDB } from '@jupyterlab/statedb';
11-
import {
12-
Button,
13-
LabIcon,
14-
caretDownIcon,
15-
} from '@jupyterlab/ui-components';
11+
import { Button, LabIcon, caretDownIcon } from '@jupyterlab/ui-components';
12+
import { CommandRegistry } from '@lumino/commands';
1613
import { ReadonlyPartialJSONObject, UUID } from '@lumino/coreutils';
1714
import React, {
1815
MouseEvent as ReactMouseEvent,
@@ -22,10 +19,7 @@ import React, {
2219

2320
import { CommandIDs, icons } from '@/src/constants';
2421
import { nonVisibilityIcon, visibilityIcon } from '@/src/icons';
25-
import {
26-
ILeftPanelClickHandlerParams,
27-
} from '@/src/panelview/leftpanel';
28-
import { CommandRegistry } from '@lumino/commands';
22+
import { ILeftPanelClickHandlerParams } from '@/src/panelview/leftpanel';
2923

3024
// const LAYERS_PANEL_CLASS = 'jp-gis-layerPanel';
3125
const LAYER_GROUP_CLASS = 'jp-gis-layerGroup';
@@ -37,7 +31,6 @@ const LAYER_TITLE_CLASS = 'jp-gis-layerTitle';
3731
const LAYER_ICON_CLASS = 'jp-gis-layerIcon';
3832
const LAYER_TEXT_CLASS = 'jp-gis-layerText data-jgis-keybinding';
3933

40-
4134
// /**
4235
// * The layers panel widget.
4336
// */
@@ -156,7 +149,7 @@ export function LayersBodyComponent(props: IBodyProps): JSX.Element {
156149
// Notify commands that need updating
157150
props.commands.notifyCommandChanged(CommandIDs.identify);
158151
props.commands.notifyCommandChanged(CommandIDs.temporalController);
159-
}
152+
};
160153

161154
const onSelect = ({
162155
type,
@@ -219,7 +212,11 @@ export function LayersBodyComponent(props: IBodyProps): JSX.Element {
219212
}
220213
};
221214

222-
const resetSelected = (type: SelectionType, nodeId?: string, item?: string) => {
215+
const resetSelected = (
216+
type: SelectionType,
217+
nodeId?: string,
218+
item?: string,
219+
) => {
223220
const selection: { [key: string]: ISelection } = {};
224221
if (item && nodeId) {
225222
selection[item] = {
@@ -230,7 +227,7 @@ export function LayersBodyComponent(props: IBodyProps): JSX.Element {
230227
props.model.syncSelected(selection, id);
231228

232229
notifyCommands();
233-
}
230+
};
234231

235232
/**
236233
* Propagate the layer selection.

0 commit comments

Comments
 (0)