Skip to content

Commit 4c05acb

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

File tree

13 files changed

+4370
-3572
lines changed

13 files changed

+4370
-3572
lines changed

packages/base/src/mainview/mainView.tsx

Lines changed: 2622 additions & 2221 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
import { IStateDB } from '@jupyterlab/statedb';
22
import { ReactWidget } from '@jupyterlab/apputils';
3-
import { Widget } from '@lumino/widgets';
43
import * as React from 'react';
54

65
import { MainView } from './mainView';
76
import { MainViewModel } from './mainviewmodel';
7+
import { IAnnotationModel, IJGISFormSchemaRegistry } from '@jupytergis/schema';
8+
9+
export interface IOptions {
10+
mainViewModel: MainViewModel;
11+
state?: IStateDB;
12+
formSchemaRegistry?: IJGISFormSchemaRegistry;
13+
annotationModel?: IAnnotationModel;
14+
}
815

916
export class JupyterGISMainViewPanel extends ReactWidget {
10-
/**
11-
* Construct a `JupyterGISPanel`.
12-
*/
13-
constructor(
14-
options: { mainViewModel: MainViewModel, state?: IStateDB },
15-
rightPanel?: Widget,
16-
) {
17-
super();
18-
this._mainViewModel = options.mainViewModel;
19-
this._state = options.state;
20-
this.addClass('jp-jupytergis-panel');
21-
this._rightPanel = rightPanel;
22-
}
17+
/**
18+
* Construct a `JupyterGISPanel`.
19+
*/
20+
constructor(options: IOptions) {
21+
super();
22+
this._state = options.state;
23+
this.addClass('jp-jupytergis-panel');
24+
this._options = options;
25+
}
2326

24-
render(): JSX.Element {
25-
return (
26-
<MainView
27-
state={this._state}
28-
rightPanel={this._rightPanel}
29-
viewModel={this._mainViewModel}
30-
/>
31-
);
32-
}
27+
render(): JSX.Element {
28+
return (
29+
<MainView
30+
state={this._state}
31+
viewModel={this._options.mainViewModel}
32+
formSchemaRegistry={
33+
this._options.formSchemaRegistry
34+
}
35+
annotationModel={this._options.annotationModel}
36+
/>
37+
);
38+
}
3339

34-
private _state?: IStateDB;
35-
private _mainViewModel: MainViewModel;
36-
private _rightPanel?: Widget;
40+
private _state?: IStateDB;
41+
private _options: IOptions;
3742
}

packages/base/src/panelview/annotationPanel.tsx

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,90 +5,88 @@ import React, { Component } from 'react';
55
import Annotation from '@/src/annotations/components/Annotation';
66

77
interface IAnnotationPanelProps {
8-
annotationModel: IAnnotationModel;
9-
rightPanelModel: IJupyterGISModel;
8+
annotationModel: IAnnotationModel;
9+
rightPanelModel: IJupyterGISModel;
1010
}
1111

1212
export class AnnotationsPanel extends Component<IAnnotationPanelProps> {
13-
constructor(props: IAnnotationPanelProps) {
14-
super(props);
15-
16-
const updateCallback = () => {
17-
this.forceUpdate();
18-
};
19-
20-
this._annotationModel = props.annotationModel;
21-
this._rightPanelModel = props.rightPanelModel;
22-
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-
});
35-
}
36-
37-
render(): JSX.Element {
38-
const annotationIds = this._annotationModel?.getAnnotationIds();
39-
40-
if (!annotationIds || !this._annotationModel) {
41-
return <div></div>;
42-
}
43-
44-
const annotations = annotationIds.map((id: string) => {
45-
return (
46-
<div>
47-
<Annotation
48-
rightPanelModel={this._rightPanelModel}
49-
annotationModel={this._annotationModel}
50-
itemId={id}
51-
/>
52-
<hr className="jGIS-Annotations-Separator"></hr>
53-
</div>
54-
);
55-
});
56-
57-
return <div className="jgis-scrollable">{annotations}</div>;
58-
}
59-
60-
private _annotationModel: IAnnotationModel;
61-
private _rightPanelModel: IJupyterGISModel;
13+
constructor(props: IAnnotationPanelProps) {
14+
super(props);
15+
16+
console.log(props.annotationModel);
17+
18+
const updateCallback = () => {
19+
this.forceUpdate();
20+
};
21+
22+
this._annotationModel = props.annotationModel;
23+
this._rightPanelModel = props.rightPanelModel;
24+
25+
this._annotationModel?.model?.sharedMetadataChanged.connect(
26+
updateCallback,
27+
);
28+
this.forceUpdate();
29+
}
30+
31+
render(): JSX.Element {
32+
const annotationIds = this._annotationModel?.getAnnotationIds();
33+
34+
if (!annotationIds || !this._annotationModel) {
35+
return <div></div>;
36+
}
37+
38+
const annotations = annotationIds.map((id: string) => {
39+
return (
40+
<div>
41+
<Annotation
42+
rightPanelModel={
43+
this._rightPanelModel
44+
}
45+
annotationModel={
46+
this._annotationModel
47+
}
48+
itemId={id}
49+
/>
50+
<hr className="jGIS-Annotations-Separator"></hr>
51+
</div>
52+
);
53+
});
54+
55+
return <div className="jgis-scrollable">{annotations}</div>;
56+
}
57+
58+
private _annotationModel: IAnnotationModel;
59+
private _rightPanelModel: IJupyterGISModel;
6260
}
6361

6462
export class Annotations extends PanelWithToolbar {
65-
constructor(options: Annotations.IOptions) {
66-
super({});
63+
constructor(options: Annotations.IOptions) {
64+
super({});
6765

68-
this.title.label = 'Annotations';
69-
this.addClass('jgis-scrollable');
66+
this.title.label = 'Annotations';
67+
this.addClass('jgis-scrollable');
7068

71-
this._annotationModel = options.annotationModel;
72-
this._rightPanelModel = options.rightPanelModel;
69+
this._annotationModel = options.annotationModel;
70+
this._rightPanelModel = options.rightPanelModel;
7371

74-
this._widget = ReactWidget.create(
75-
<AnnotationsPanel
76-
rightPanelModel={this._rightPanelModel}
77-
annotationModel={this._annotationModel}
78-
/>,
79-
);
72+
this._widget = ReactWidget.create(
73+
<AnnotationsPanel
74+
rightPanelModel={this._rightPanelModel}
75+
annotationModel={this._annotationModel}
76+
/>,
77+
);
8078

81-
this.addWidget(this._widget);
82-
}
79+
this.addWidget(this._widget);
80+
}
8381

84-
private _widget: ReactWidget;
85-
private _annotationModel: IAnnotationModel;
86-
private _rightPanelModel: IJupyterGISModel;
82+
private _widget: ReactWidget;
83+
private _annotationModel: IAnnotationModel;
84+
private _rightPanelModel: IJupyterGISModel;
8785
}
8886

8987
export namespace Annotations {
90-
export interface IOptions {
91-
annotationModel: IAnnotationModel;
92-
rightPanelModel: IJupyterGISModel;
93-
}
88+
export interface IOptions {
89+
annotationModel: IAnnotationModel;
90+
rightPanelModel: IJupyterGISModel;
91+
}
9492
}

0 commit comments

Comments
 (0)