Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Jupyter] fix gitignore add missing files (#1118)
Shan Heeb1ed75067c7
diff --git a/bindings/kepler.gl-jupyter/js/.gitignore b/bindings/kepler.gl-jupyter/js/.gitignoreindex 8e1dcff08..b5749e8e2 100644--- a/bindings/kepler.gl-jupyter/js/.gitignore+++ b/bindings/kepler.gl-jupyter/js/.gitignore@@ -1,7 +1,6 @@node_modules/dist/temp.*-keplergl/babel/yarn.lockdiff --git a/bindings/kepler.gl-jupyter/js/lib/keplergl/components/config-panel.js b/bindings/kepler.gl-jupyter/js/lib/keplergl/components/config-panel.jsnew file mode 100644index 000000000..23d1005a7--- /dev/null+++ b/bindings/kepler.gl-jupyter/js/lib/keplergl/components/config-panel.js@@ -0,0 +1,119 @@+// Copyright (c) 2020 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React, {useState} from 'react';++import {Button, Icons, TextArea, withState} from 'kepler.gl/components';+import {KeplerGlSchema} from 'kepler.gl/schemas';+import {visStateLens, mapStateLens, mapStyleLens} from 'kepler.gl/reducers';+import {CopyToClipboard} from 'react-copy-to-clipboard';+import styled from 'styled-components';++const Params = {+ true: 'True',+ false: 'False',+ null: 'None'+};++export const StyleCopyConfig = styled.div.attrs({+ className: 'copy-config'+})`+ width: 100%;+ display: flex;+ flex-direction: column;+ height: 100%;+ .copy-button {+ position: absolute;+ margin-top: -45px;+ right: 28px;+ }+ textarea {+ overflow-y: scroll;+ white-space: pre-wrap;+ width: 100%;+ height: 100%;+ resize: none;+ }+`;++// convert config from string to pything dictionary+function configStringify(config) {+ // replace true => True; false => False; null => None+ const configStr = JSON.stringify(config, null, 2);+ return configStr.replace(/: ([a-z]+)/g, function(_, key) {+ return ': ' + Params[key] || ': ' + key;+ });+}++export const CopyConfig = ({config}) => {+ const [copied, setCopy] = useState(false);+ const value = configStringify(config);+ return (+ <StyleCopyConfig>+ <CopyToClipboard text={value} onCopy={() => setCopy(true)} className="copy-button">+ <Button width="100px">+ <Icons.Clipboard height="16px" />+ {copied ? 'Copied!' : 'Copy'}+ </Button>+ </CopyToClipboard>+ <TextArea value={value} readOnly selected />+ </StyleCopyConfig>+ );+};++function CustomSidePanelsFactory() {+ const CustomPanels = ({activeSidePanel, visState, mapState, mapStyle}) => {+ const config = KeplerGlSchema.getConfigToSave({visState, mapState, mapStyle});+ if (activeSidePanel === 'config') {+ return <CopyConfig config={config} />;+ }++ return null;+ };++ CustomPanels.defaultProps = {+ panels: [+ {+ id: 'config',+ label: 'Config',+ iconComponent: Icons.CodeAlt+ }+ ]+ };++ const ConnectedCustomPanels = withState(+ [visStateLens, mapStateLens, mapStyleLens],+ state => state+ )(CustomPanels);++ ConnectedCustomPanels.defaultProps = {+ panels: [+ {+ id: 'config',+ label: 'modal.exportMap.json.configTitle',+ iconComponent: Icons.CodeAlt+ }+ ]+ };++ return ConnectedCustomPanels;+}++export default CustomSidePanelsFactory;