@jupytergis/base 0.4.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/annotations/components/Annotation.d.ts +2 -2
- package/lib/annotations/components/Annotation.js +3 -3
- package/lib/annotations/components/AnnotationFloater.d.ts +1 -1
- package/lib/annotations/components/AnnotationFloater.js +2 -2
- package/lib/annotations/components/Message.d.ts +2 -1
- package/lib/annotations/components/Message.js +3 -3
- package/lib/annotations/model.js +5 -5
- package/lib/commands/BaseCommandIDs.d.ts +32 -0
- package/lib/commands/BaseCommandIDs.js +43 -0
- package/lib/{commands.d.ts → commands/index.d.ts} +1 -1
- package/lib/{commands.js → commands/index.js} +76 -319
- package/lib/console/consoleview.d.ts +3 -3
- package/lib/console/consoleview.js +5 -5
- package/lib/constants.d.ts +2 -51
- package/lib/constants.js +6 -65
- package/lib/dialogs/ProcessingFormDialog.d.ts +4 -4
- package/lib/dialogs/ProcessingFormDialog.js +9 -11
- package/lib/dialogs/layerBrowserDialog.d.ts +1 -1
- package/lib/dialogs/layerBrowserDialog.js +7 -7
- package/lib/dialogs/layerCreationFormDialog.d.ts +4 -4
- package/lib/dialogs/layerCreationFormDialog.js +6 -6
- package/lib/dialogs/symbology/components/color_ramp/CanvasSelectComponent.d.ts +1 -1
- package/lib/dialogs/symbology/components/color_ramp/CanvasSelectComponent.js +3 -3
- package/lib/dialogs/symbology/components/color_ramp/ColorRamp.d.ts +3 -2
- package/lib/dialogs/symbology/components/color_ramp/ColorRamp.js +6 -7
- package/lib/dialogs/symbology/components/color_ramp/ColorRampEntry.d.ts +1 -1
- package/lib/dialogs/symbology/components/color_ramp/ColorRampEntry.js +1 -1
- package/lib/dialogs/symbology/components/color_ramp/ModeSelectRow.d.ts +1 -1
- package/lib/dialogs/symbology/components/color_ramp/ModeSelectRow.js +1 -1
- package/lib/dialogs/symbology/components/color_stops/StopContainer.d.ts +2 -2
- package/lib/dialogs/symbology/components/color_stops/StopContainer.js +4 -4
- package/lib/dialogs/symbology/components/color_stops/StopRow.d.ts +3 -3
- package/lib/dialogs/symbology/components/color_stops/StopRow.js +2 -2
- package/lib/dialogs/symbology/hooks/useGetBandInfo.js +5 -5
- package/lib/dialogs/symbology/hooks/useGetProperties.d.ts +1 -1
- package/lib/dialogs/symbology/hooks/useGetProperties.js +4 -4
- package/lib/dialogs/symbology/symbologyDialog.d.ts +8 -0
- package/lib/dialogs/symbology/symbologyDialog.js +1 -1
- package/lib/dialogs/symbology/symbologyUtils.js +38 -31
- package/lib/dialogs/symbology/tiff_layer/TiffRendering.d.ts +2 -2
- package/lib/dialogs/symbology/tiff_layer/TiffRendering.js +2 -2
- package/lib/dialogs/symbology/tiff_layer/components/BandRow.d.ts +2 -2
- package/lib/dialogs/symbology/tiff_layer/components/BandRow.js +4 -4
- package/lib/dialogs/symbology/tiff_layer/types/MultibandColor.d.ts +2 -2
- package/lib/dialogs/symbology/tiff_layer/types/MultibandColor.js +30 -20
- package/lib/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.d.ts +2 -2
- package/lib/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.js +23 -21
- package/lib/dialogs/symbology/vector_layer/VectorRendering.d.ts +2 -2
- package/lib/dialogs/symbology/vector_layer/VectorRendering.js +81 -39
- package/lib/dialogs/symbology/vector_layer/components/ValueSelect.d.ts +1 -1
- package/lib/dialogs/symbology/vector_layer/components/ValueSelect.js +1 -1
- package/lib/dialogs/symbology/vector_layer/types/Canonical.d.ts +4 -0
- package/lib/dialogs/symbology/vector_layer/types/Canonical.js +66 -0
- package/lib/dialogs/symbology/vector_layer/types/Categorized.d.ts +2 -2
- package/lib/dialogs/symbology/vector_layer/types/Categorized.js +142 -47
- package/lib/dialogs/symbology/vector_layer/types/Graduated.d.ts +2 -2
- package/lib/dialogs/symbology/vector_layer/types/Graduated.js +193 -99
- package/lib/dialogs/symbology/vector_layer/types/Heatmap.d.ts +2 -2
- package/lib/dialogs/symbology/vector_layer/types/Heatmap.js +7 -6
- package/lib/dialogs/symbology/vector_layer/types/SimpleSymbol.d.ts +2 -2
- package/lib/dialogs/symbology/vector_layer/types/SimpleSymbol.js +33 -30
- package/lib/formbuilder/creationform.js +3 -3
- package/lib/formbuilder/editform.js +3 -3
- package/lib/formbuilder/formselectors.d.ts +1 -1
- package/lib/formbuilder/formselectors.js +2 -2
- package/lib/formbuilder/objectform/baseform.d.ts +5 -4
- package/lib/formbuilder/objectform/baseform.js +16 -14
- package/lib/formbuilder/objectform/fileselectorwidget.d.ts +1 -1
- package/lib/formbuilder/objectform/fileselectorwidget.js +5 -5
- package/lib/formbuilder/objectform/layer/heatmapLayerForm.js +2 -2
- package/lib/formbuilder/objectform/layer/hillshadeLayerForm.js +1 -1
- package/lib/formbuilder/objectform/layer/layerform.d.ts +1 -1
- package/lib/formbuilder/objectform/layer/layerform.js +3 -2
- package/lib/formbuilder/objectform/process/dissolveProcessForm.d.ts +1 -1
- package/lib/formbuilder/objectform/process/dissolveProcessForm.js +5 -5
- package/lib/formbuilder/objectform/source/geojsonsource.js +4 -4
- package/lib/formbuilder/objectform/source/geotiffsource.js +4 -4
- package/lib/formbuilder/objectform/source/pathbasedsource.js +6 -6
- package/lib/formbuilder/objectform/source/sourceform.d.ts +1 -1
- package/lib/formbuilder/objectform/source/sourceform.js +1 -1
- package/lib/formbuilder/objectform/source/tilesourceform.js +3 -3
- package/lib/gdal.js +2 -2
- package/lib/icons.js +29 -29
- package/lib/index.d.ts +4 -2
- package/lib/index.js +4 -2
- package/lib/mainview/CollaboratorPointers.d.ts +1 -1
- package/lib/mainview/CollaboratorPointers.js +5 -5
- package/lib/mainview/FollowIndicator.d.ts +2 -2
- package/lib/mainview/FollowIndicator.js +3 -3
- package/lib/mainview/TemporalSlider.d.ts +1 -1
- package/lib/mainview/TemporalSlider.js +7 -7
- package/lib/mainview/mainView.d.ts +4 -2
- package/lib/mainview/mainView.js +232 -137
- package/lib/menus.d.ts +4 -0
- package/lib/menus.js +45 -0
- package/lib/panelview/annotationPanel.d.ts +2 -2
- package/lib/panelview/annotationPanel.js +1 -1
- package/lib/panelview/components/filter-panel/Filter.d.ts +2 -2
- package/lib/panelview/components/filter-panel/Filter.js +5 -5
- package/lib/panelview/components/filter-panel/FilterRow.d.ts +2 -2
- package/lib/panelview/components/identify-panel/IdentifyPanel.d.ts +1 -1
- package/lib/panelview/components/identify-panel/IdentifyPanel.js +5 -5
- package/lib/panelview/components/layers.d.ts +1 -1
- package/lib/panelview/components/layers.js +12 -12
- package/lib/panelview/leftpanel.d.ts +4 -2
- package/lib/panelview/leftpanel.js +24 -14
- package/lib/panelview/model.d.ts +1 -1
- package/lib/panelview/objectproperties.d.ts +1 -1
- package/lib/panelview/objectproperties.js +3 -3
- package/lib/panelview/rightpanel.d.ts +2 -1
- package/lib/panelview/rightpanel.js +13 -5
- package/lib/{processing.d.ts → processing/index.d.ts} +4 -4
- package/lib/{processing.js → processing/index.js} +19 -24
- package/lib/processing/processingCommands.d.ts +6 -0
- package/lib/processing/processingCommands.js +47 -0
- package/lib/processing/processingFormToParam.d.ts +2 -0
- package/lib/processing/processingFormToParam.js +15 -0
- package/lib/shared/components/Badge.d.ts +7 -0
- package/lib/shared/components/Badge.js +19 -0
- package/lib/shared/components/Button.d.ts +9 -0
- package/lib/shared/components/Button.js +20 -0
- package/lib/shared/components/Calendar.d.ts +47 -0
- package/lib/shared/components/Calendar.js +184 -0
- package/lib/shared/components/Checkbox.d.ts +4 -0
- package/lib/shared/components/Checkbox.js +25 -0
- package/lib/shared/components/DropdownMenu.d.ts +27 -0
- package/lib/shared/components/DropdownMenu.js +92 -0
- package/lib/shared/components/Pagination.d.ts +25 -0
- package/lib/shared/components/Pagination.js +68 -0
- package/lib/shared/components/Popover.d.ts +7 -0
- package/lib/shared/components/Popover.js +32 -0
- package/lib/shared/components/Tabs.d.ts +7 -0
- package/lib/shared/components/Tabs.js +31 -0
- package/lib/shared/components/ToggleGroup.d.ts +12 -0
- package/lib/shared/components/ToggleGroup.js +52 -0
- package/lib/shared/components/loading.d.ts +12 -0
- package/lib/shared/components/loading.js +6 -0
- package/lib/shared/components/utils.d.ts +2 -0
- package/lib/shared/components/utils.js +4 -0
- package/lib/shared/hooks/useIsFirstRender.d.ts +2 -0
- package/lib/shared/hooks/useIsFirstRender.js +10 -0
- package/lib/stacBrowser/StacBrowser.d.ts +7 -0
- package/lib/stacBrowser/StacBrowser.js +16 -0
- package/lib/stacBrowser/StacPanel.d.ts +14 -0
- package/lib/stacBrowser/StacPanel.js +16 -0
- package/lib/stacBrowser/components/StacFilterSection.d.ts +23 -0
- package/lib/stacBrowser/components/StacFilterSection.js +49 -0
- package/lib/stacBrowser/components/StacPanelFilters.d.ts +14 -0
- package/lib/stacBrowser/components/StacPanelFilters.js +65 -0
- package/lib/stacBrowser/components/StacPanelResults.d.ts +13 -0
- package/lib/stacBrowser/components/StacPanelResults.js +48 -0
- package/lib/stacBrowser/components/StacPanelView.d.ts +7 -0
- package/lib/stacBrowser/components/StacPanelView.js +20 -0
- package/lib/stacBrowser/constants.d.ts +25 -0
- package/lib/stacBrowser/constants.js +197 -0
- package/lib/stacBrowser/hooks/useStacSearch.d.ts +30 -0
- package/lib/stacBrowser/hooks/useStacSearch.js +221 -0
- package/lib/stacBrowser/index.d.ts +1 -0
- package/lib/stacBrowser/index.js +1 -0
- package/lib/stacBrowser/types/types.d.ts +124 -0
- package/lib/stacBrowser/types/types.js +1 -0
- package/lib/statusbar/StatusBar.d.ts +1 -1
- package/lib/statusbar/StatusBar.js +3 -3
- package/lib/toolbar/index.d.ts +0 -1
- package/lib/toolbar/index.js +0 -1
- package/lib/toolbar/widget.js +28 -64
- package/lib/tools.d.ts +30 -5
- package/lib/tools.js +82 -69
- package/lib/types.d.ts +2 -0
- package/lib/widget.d.ts +2 -1
- package/lib/widget.js +8 -5
- package/package.json +22 -8
- package/style/base.css +26 -0
- package/style/layerBrowser.css +10 -0
- package/style/leftPanel.css +0 -1
- package/style/shared/badge.css +61 -0
- package/style/shared/button.css +164 -0
- package/style/shared/calendar.css +274 -0
- package/style/shared/checkbox.css +28 -0
- package/style/shared/dropdownMenu.css +240 -0
- package/style/shared/pagination.css +167 -0
- package/style/shared/popover.css +53 -0
- package/style/shared/tabs.css +57 -0
- package/style/shared/toggle.css +85 -0
- package/style/stacBrowser.css +74 -0
- package/style/symbologyDialog.css +0 -7
- package/lib/mainview/spinner.d.ts +0 -6
- package/lib/mainview/spinner.js +0 -5
- package/lib/panelview/components/sources.d.ts +0 -10
- package/lib/panelview/components/sources.js +0 -147
- package/lib/toolbar/usertoolbaritem.d.ts +0 -19
- package/lib/toolbar/usertoolbaritem.js +0 -59
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { DOMUtils } from '@jupyterlab/apputils';
|
|
2
|
-
import { LabIcon, ReactWidget } from '@jupyterlab/ui-components';
|
|
3
|
-
import { Panel } from '@lumino/widgets';
|
|
4
|
-
import React, { useEffect, useState } from 'react';
|
|
5
|
-
import { icons } from '../../constants';
|
|
6
|
-
const SOURCES_PANEL_CLASS = 'jp-gis-sourcePanel';
|
|
7
|
-
const SOURCE_CLASS = 'jp-gis-source';
|
|
8
|
-
const SOURCE_TITLE_CLASS = 'jp-gis-sourceTitle';
|
|
9
|
-
const SOURCE_ICON_CLASS = 'jp-gis-sourceIcon';
|
|
10
|
-
const SOURCE_TEXT_CLASS = 'jp-gis-sourceText';
|
|
11
|
-
const SOURCE_UNUSED = 'jp-gis-sourceUnused';
|
|
12
|
-
const SOURCE_INFO = 'jp-gis-sourceInfo';
|
|
13
|
-
/**
|
|
14
|
-
* The sources panel widget.
|
|
15
|
-
*/
|
|
16
|
-
export class SourcesPanel extends Panel {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
super();
|
|
19
|
-
this._model = options.model;
|
|
20
|
-
this._onSelect = options.onSelect;
|
|
21
|
-
this.id = 'jupytergis::sourcesPanel';
|
|
22
|
-
this.addClass(SOURCES_PANEL_CLASS);
|
|
23
|
-
this.addWidget(ReactWidget.create(React.createElement(SourcesBodyComponent, { model: this._model, onSelect: this._onSelect })));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The body component of the panel.
|
|
28
|
-
*/
|
|
29
|
-
function SourcesBodyComponent(props) {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
const [model, setModel] = useState((_a = props.model) === null || _a === void 0 ? void 0 : _a.jGISModel);
|
|
32
|
-
const [sourceIds, setSourceIds] = useState(Private.sortedSourceIds(model));
|
|
33
|
-
/**
|
|
34
|
-
* Propagate the source selection.
|
|
35
|
-
*/
|
|
36
|
-
const onItemClick = ({ type, item, nodeId, event }) => {
|
|
37
|
-
props.onSelect({ type, item, nodeId, event });
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Listen to the sources and changes.
|
|
41
|
-
*/
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const updateSources = () => {
|
|
44
|
-
setSourceIds([...Private.sortedSourceIds(model)]);
|
|
45
|
-
};
|
|
46
|
-
model === null || model === void 0 ? void 0 : model.sharedModel.sourcesChanged.connect(updateSources);
|
|
47
|
-
model === null || model === void 0 ? void 0 : model.clientStateChanged.connect(updateSources);
|
|
48
|
-
updateSources();
|
|
49
|
-
return () => {
|
|
50
|
-
model === null || model === void 0 ? void 0 : model.sharedModel.sourcesChanged.disconnect(updateSources);
|
|
51
|
-
model === null || model === void 0 ? void 0 : model.clientStateChanged.disconnect(updateSources);
|
|
52
|
-
};
|
|
53
|
-
}, [model]);
|
|
54
|
-
/**
|
|
55
|
-
* Update the model when it changes.
|
|
56
|
-
*/
|
|
57
|
-
(_b = props.model) === null || _b === void 0 ? void 0 : _b.documentChanged.connect((_, widget) => {
|
|
58
|
-
setModel(widget === null || widget === void 0 ? void 0 : widget.model);
|
|
59
|
-
});
|
|
60
|
-
return (React.createElement("div", { id: "jp-gis-sources" }, sourceIds.map(sourceId => {
|
|
61
|
-
return (React.createElement(SourceComponent, { key: `source-${sourceId}`, gisModel: model, sourceId: sourceId, onClick: onItemClick }));
|
|
62
|
-
})));
|
|
63
|
-
}
|
|
64
|
-
function isSelected(sourceId, model) {
|
|
65
|
-
var _a, _b, _c, _d;
|
|
66
|
-
return ((((_b = (_a = model === null || model === void 0 ? void 0 : model.localState) === null || _a === void 0 ? void 0 : _a.selected) === null || _b === void 0 ? void 0 : _b.value) &&
|
|
67
|
-
Object.keys((_d = (_c = model === null || model === void 0 ? void 0 : model.localState) === null || _c === void 0 ? void 0 : _c.selected) === null || _d === void 0 ? void 0 : _d.value).includes(sourceId)) ||
|
|
68
|
-
false);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* The component to display a single source.
|
|
72
|
-
*/
|
|
73
|
-
function SourceComponent(props) {
|
|
74
|
-
const { sourceId, gisModel, onClick } = props;
|
|
75
|
-
const source = gisModel === null || gisModel === void 0 ? void 0 : gisModel.getSource(sourceId);
|
|
76
|
-
if (source === undefined) {
|
|
77
|
-
return React.createElement(React.Fragment, null);
|
|
78
|
-
}
|
|
79
|
-
const [id, setId] = useState('');
|
|
80
|
-
const [selected, setSelected] = useState(
|
|
81
|
-
// TODO Support multi-selection as `model?.jGISModel?.localState?.selected.value` does
|
|
82
|
-
isSelected(sourceId, gisModel));
|
|
83
|
-
const [unused, setUnused] = useState(false);
|
|
84
|
-
const name = source.name;
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
setId(DOMUtils.createDomID());
|
|
87
|
-
}, []);
|
|
88
|
-
/**
|
|
89
|
-
* Check if the source is used by a layer.
|
|
90
|
-
*/
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
const checkUsage = () => {
|
|
93
|
-
const sources = gisModel === null || gisModel === void 0 ? void 0 : gisModel.getLayersBySource(sourceId);
|
|
94
|
-
setUnused(sources ? sources.length === 0 : true);
|
|
95
|
-
};
|
|
96
|
-
gisModel === null || gisModel === void 0 ? void 0 : gisModel.sharedLayersChanged.connect(checkUsage);
|
|
97
|
-
checkUsage();
|
|
98
|
-
return () => {
|
|
99
|
-
gisModel === null || gisModel === void 0 ? void 0 : gisModel.sharedLayersChanged.disconnect(checkUsage);
|
|
100
|
-
};
|
|
101
|
-
}, [gisModel]);
|
|
102
|
-
/**
|
|
103
|
-
* Listen to the changes on the current source.
|
|
104
|
-
*/
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
const onClientSharedStateChanged = (sender, clients) => {
|
|
107
|
-
// TODO Support follow mode and remoteUser state
|
|
108
|
-
setSelected(isSelected(sourceId, gisModel));
|
|
109
|
-
};
|
|
110
|
-
gisModel === null || gisModel === void 0 ? void 0 : gisModel.clientStateChanged.connect(onClientSharedStateChanged);
|
|
111
|
-
return () => {
|
|
112
|
-
gisModel === null || gisModel === void 0 ? void 0 : gisModel.clientStateChanged.disconnect(onClientSharedStateChanged);
|
|
113
|
-
};
|
|
114
|
-
}, [gisModel]);
|
|
115
|
-
const setSelection = (event) => {
|
|
116
|
-
var _a;
|
|
117
|
-
const childId = (_a = event.currentTarget.children.namedItem(id)) === null || _a === void 0 ? void 0 : _a.id;
|
|
118
|
-
onClick({ type: 'source', item: sourceId, nodeId: childId, event });
|
|
119
|
-
};
|
|
120
|
-
let mainClasses = SOURCE_CLASS;
|
|
121
|
-
if (selected) {
|
|
122
|
-
mainClasses = mainClasses.concat(' jp-mod-selected');
|
|
123
|
-
}
|
|
124
|
-
if (unused) {
|
|
125
|
-
mainClasses = mainClasses.concat(` ${SOURCE_UNUSED}`);
|
|
126
|
-
}
|
|
127
|
-
return (React.createElement("div", { className: mainClasses },
|
|
128
|
-
React.createElement("div", { className: SOURCE_TITLE_CLASS, onClick: setSelection, onContextMenu: setSelection },
|
|
129
|
-
icons.has(source.type) && (React.createElement(LabIcon.resolveReact, Object.assign({}, icons.get(source.type), { className: SOURCE_ICON_CLASS }))),
|
|
130
|
-
React.createElement("span", { id: id, className: SOURCE_TEXT_CLASS }, name),
|
|
131
|
-
unused && React.createElement("span", { className: SOURCE_INFO }, "(unused)"))));
|
|
132
|
-
}
|
|
133
|
-
var Private;
|
|
134
|
-
(function (Private) {
|
|
135
|
-
function sortedSourceIds(model) {
|
|
136
|
-
const sources = model === null || model === void 0 ? void 0 : model.getSources();
|
|
137
|
-
if (sources === undefined) {
|
|
138
|
-
return [];
|
|
139
|
-
}
|
|
140
|
-
return Object.keys(sources).sort((id1, id2) => {
|
|
141
|
-
const name1 = sources[id1].name.toLowerCase();
|
|
142
|
-
const name2 = sources[id2].name.toLowerCase();
|
|
143
|
-
return name1 < name2 ? -1 : name1 > name2 ? 1 : 0;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
Private.sortedSourceIds = sortedSourceIds;
|
|
147
|
-
})(Private || (Private = {}));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IUserData, JupyterGISModel } from '@jupytergis/schema';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
interface IProps {
|
|
4
|
-
model: JupyterGISModel;
|
|
5
|
-
}
|
|
6
|
-
interface IState {
|
|
7
|
-
usersList: IUserData[];
|
|
8
|
-
selectedUser?: IUserData;
|
|
9
|
-
}
|
|
10
|
-
export declare class UsersItem extends React.Component<IProps, IState> {
|
|
11
|
-
constructor(props: IProps);
|
|
12
|
-
componentDidMount(): void;
|
|
13
|
-
selectUser: (user: IUserData) => void;
|
|
14
|
-
private createUserIcon;
|
|
15
|
-
private filterDuplicated;
|
|
16
|
-
render(): React.ReactNode;
|
|
17
|
-
private _model;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export class UsersItem extends React.Component {
|
|
3
|
-
constructor(props) {
|
|
4
|
-
super(props);
|
|
5
|
-
this.selectUser = (user) => {
|
|
6
|
-
var _a;
|
|
7
|
-
let selected = undefined;
|
|
8
|
-
if (user.userId !== ((_a = this.state.selectedUser) === null || _a === void 0 ? void 0 : _a.userId)) {
|
|
9
|
-
selected = user;
|
|
10
|
-
}
|
|
11
|
-
this.setState(old => (Object.assign(Object.assign({}, old), { selectedUser: selected })), () => {
|
|
12
|
-
this._model.setUserToFollow(selected === null || selected === void 0 ? void 0 : selected.userId);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
this._model = props.model;
|
|
16
|
-
this.state = { usersList: [] };
|
|
17
|
-
}
|
|
18
|
-
componentDidMount() {
|
|
19
|
-
this.setState(old => (Object.assign(Object.assign({}, old), { usersList: this._model.users })));
|
|
20
|
-
this._model.userChanged.connect((_, usersList) => {
|
|
21
|
-
this.setState(old => (Object.assign(Object.assign({}, old), { usersList: usersList })));
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
createUserIcon(options) {
|
|
25
|
-
var _a;
|
|
26
|
-
let el;
|
|
27
|
-
const { userId, userData } = options;
|
|
28
|
-
const selected = `${userId === ((_a = this.state.selectedUser) === null || _a === void 0 ? void 0 : _a.userId) ? 'selected' : ''}`;
|
|
29
|
-
if (userData.avatar_url) {
|
|
30
|
-
el = (React.createElement("div", { key: userId, title: userData.display_name, className: `lm-MenuBar-itemIcon jp-MenuBar-imageIcon ${selected}`, onClick: () => this.selectUser(options) },
|
|
31
|
-
React.createElement("img", { src: userData.avatar_url, alt: "" })));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
el = (React.createElement("div", { key: userId, title: userData.display_name, className: `lm-MenuBar-itemIcon jp-MenuBar-anonymousIcon ${selected}`, style: { backgroundColor: userData.color }, onClick: () => this.selectUser(options) },
|
|
35
|
-
React.createElement("span", null, userData.initials)));
|
|
36
|
-
}
|
|
37
|
-
return el;
|
|
38
|
-
}
|
|
39
|
-
filterDuplicated(usersList) {
|
|
40
|
-
var _a;
|
|
41
|
-
const newList = [];
|
|
42
|
-
const selected = new Set();
|
|
43
|
-
for (const element of usersList) {
|
|
44
|
-
if (((_a = element === null || element === void 0 ? void 0 : element.userData) === null || _a === void 0 ? void 0 : _a.username) &&
|
|
45
|
-
!selected.has(element.userData.username)) {
|
|
46
|
-
selected.add(element.userData.username);
|
|
47
|
-
newList.push(element);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return newList;
|
|
51
|
-
}
|
|
52
|
-
render() {
|
|
53
|
-
return (React.createElement("div", { className: "jGIS-toolbar-usertoolbar" }, this.filterDuplicated(this.state.usersList).map(item => {
|
|
54
|
-
if (item.userId !== this._model.currentUserId) {
|
|
55
|
-
return this.createUserIcon(item);
|
|
56
|
-
}
|
|
57
|
-
})));
|
|
58
|
-
}
|
|
59
|
-
}
|