Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "HAS_SETTINGS, DRAGGABLE, RESIZABLE" into config files #102

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function fillMatrix(matrix, val, pos = [0, 0], size = [matrix[0].length,
}

// get layout for react-grid-layout
export function getLayoutConfig(chartsConfig, cols) {
export function getLayoutConfig(chartsConfig, cols, resiziable = false) {
const layout = [];
const matrix = createMatrix(cols);
// sort charts by priority
Expand Down Expand Up @@ -144,7 +144,7 @@ export function getLayoutConfig(chartsConfig, cols) {
y: pos[1],
w: size[0],
h: size[1],
isResizable: false,
isResizable: resiziable,
});
});

Expand Down
1 change: 0 additions & 1 deletion source/components/Eaglescope/Eaglescope.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function Eaglescope() {
// handle progress bar
useEffect(() => {
if (!data) return;
console.log(config)
if (filters.length > 0) {
setProgressAttrs({
now: filteredData.length,
Expand Down
14 changes: 14 additions & 0 deletions source/components/Layout/VisGridView/VisGridItem/VisGridItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,18 @@
position: relative;
display: flex;
height: 100%;
}
.place-holder {
background-color: #f1f1f1;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: row;
}
.chart-area {
color:#c4c3d1;
height: 45%;
width: 45%;
}
20 changes: 9 additions & 11 deletions source/components/Layout/VisGridView/VisGridItem/VisGridItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import VisGridItemContent from './VisGridItemContent/VisGridItemContent';
import VisGridItemHeader from './VisGridItemHeader/VisGridItemHeader';
import { DataContext } from '../../../../contexts/DataContext';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
// css class
import './VisGridItem.css';

Expand All @@ -15,26 +15,21 @@ function VisGridItem(props) {
const onMouseLeaveHandle = () => {
setHover(false);
};

const {
data, filteredData, filters, addFiltersHandler, removeFiltersHandler,
} = useContext(DataContext);

useEffect(() => {
if (props.fullScreened) setHover(true);
}, [props.fullScreened]);

/* useEffect(() => {
console.log(props.layout);
}, [props.layout]); */

useEffect(() => {}, [props.isResizing]);
return (
<div
className="vis-grid-item"
onMouseEnter={onMouseEnterHandle}
onMouseLeave={onMouseLeaveHandle}
>
<VisGridItemHeader

><VisGridItemHeader
id={props.operation.id}
title={props.operation.title}
description={props.operation.description}
Expand All @@ -45,7 +40,10 @@ function VisGridItem(props) {
filters={filters}
filterRemove={removeFiltersHandler}
/>


{props.isResizing?<div className="place-holder">
<FontAwesomeIcon icon="chart-area" className="chart-area"/>
</div>:
<VisGridItemContent
fields={props.operation.fields}
chartType={props.operation.chartType}
Expand All @@ -57,7 +55,7 @@ function VisGridItem(props) {
id={props.operation.id}
title={props.operation.title}
layout={props.layout}
/>
/>}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
font-weight: bold;
}

.draggable {
.name-header.draggable {
cursor: move;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import './VisGridItemHeader.css';

function VisGridItemHeader(props) {
const { config } = useContext(ConfigContext);
console.log("config", config)
const { THEME_COLOR: color } = config;
let dragHeader = "name-header draggable";
if (config.DISABLE_DRAGGING){
dragHeader = "name-header notDraggable";

let dragHeader = 'name-header';
if (config.DRAGGABLE) {
dragHeader = 'name-header draggable';
}
return (
<div
Expand Down
11 changes: 11 additions & 0 deletions source/components/Layout/VisGridView/VisGridView.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
flex-wrap: wrap;
width: 100%;
}

.react-grid-item > .react-resizable-handle.react-resizable-handle-se {
bottom: 0;
right: 0;
cursor: se-resize;
opacity: 0;
}
.react-grid-item:hover > .react-resizable-handle.react-resizable-handle-se {
opacity: 1;
}

/* .react-grid-item {

} */
29 changes: 22 additions & 7 deletions source/components/Layout/VisGridView/VisGridView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
const grid = config.UNIT_OF_GRID_VIEW;
const margins = config.MARGIN_OF_GRID_VIEW;
const visConfig = config.VISUALIZATION_VIEW_CONFIGURATION;
const draggableHandle = '.draggable';

const draggableHandle = config.GRAGGABLE ? '.draggable' : '';
const isDraggable = config.DRAGGABLE || false;
const isResizable = config.RESIZABLE || false;

const [isResizing, SetIsResizing] = useState(false);
const [resizingItemId, SetResizingItemId] = useState(null);
const [appLayout, setAppLayout] = useState({
width: 0,
currentCols: 0,
layout: [],
margin: 0,
grid,
});

const self = useRef();

const updateViewSize = () => {
Expand All @@ -45,7 +48,7 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
&& margins[1] === appLayout.margins[1]
) return;
const gridLayoutWidth = cols * grid[0] + (cols + 1) * margins[0];
const updatedLayout = getLayoutConfig(visConfig, cols);
const updatedLayout = getLayoutConfig(visConfig, cols, isResizable);

setAppLayout({
width: gridLayoutWidth,
Expand All @@ -58,8 +61,15 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {

const debouncedUpdateViewSize = debounce(updateViewSize, 100);

const onResizeStartHandle = (layout, oldItem) => {
SetIsResizing(true);
SetResizingItemId(oldItem.i);
};
const onResizeStopHandle = () => {
SetIsResizing(false);
SetResizingItemId(null);
};
useEffect(() => {
// if (!appLayout.currentCols) updateViewSize();
updateViewSize();
window.addEventListener('resize', debouncedUpdateViewSize);
return () => {
Expand All @@ -71,7 +81,7 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
const rect = self.current.getBoundingClientRect();
const cols = parseInt((rect.width - margins[0]) / (grid[0] + margins[0]), 10);
const gridLayoutWidth = cols * grid[0] + (cols + 1) * margins[0];
const updatedLayout = getLayoutConfig(visConfig, cols);
const updatedLayout = getLayoutConfig(visConfig, cols, isResizable);

setAppLayout({
width: gridLayoutWidth,
Expand All @@ -81,7 +91,7 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
grid,
});
}, [visConfig]);

useEffect(() => {}, [isResizing, resizingItemId]);
return (
<div className="vis-grid-view" ref={self}>
{appLayout.layout.length > 0 && (
Expand All @@ -91,7 +101,11 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
width={appLayout.width}
margin={margins}
layout={appLayout.layout}
isDraggable={isDraggable}
isResizable={isResizable}
draggableHandle={draggableHandle}
onResizeStart={onResizeStartHandle}
onResizeStop={onResizeStopHandle}
>
{appLayout.layout.map((item) => (
<div
Expand All @@ -105,6 +119,7 @@ function VisGridView({ fullVisScreenHandler, fullScreened }) {
>
{visConfig.find((vis) => vis.id === item.i) && (
<VisGridItem
isResizing={item.i === resizingItemId && isResizing}
layout={appLayout}
operation={visConfig.find((vis) => vis.id === item.i)}
toggleFullScreen={fullVisScreenHandler}
Expand Down
7 changes: 4 additions & 3 deletions source/components/Settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ function Settings() {
return (
<>
{showNewVis && <VisSettings chartConfig={newVis} show={showNewVis} setShow={setShowNewVis} />}
<Button

{config.HAS_SETTINGS&&(<Button
size="lg"
style={{
display: 'none',
background: 'none',
border: 'none',
}}
Expand All @@ -102,7 +102,8 @@ function Settings() {
<span>
<FontAwesomeIcon size="1x" icon="fa-solid fa-bars" />
</span>
</Button>
</Button>)}

<Offcanvas
show={show}
onHide={handleClose}
Expand Down
11 changes: 6 additions & 5 deletions source/components/partials/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ function createTooltip(mount, addLabel, offset) {
const tooltip = d3
.select(mount)
.append('div')
.style('opacity', 0)
.style('opacity', 1)
.attr('class', 'tooltip')
.style('display', 'none')
.style('background-color', 'white')
.style('border', 'solid')
.style('border-width', '2px')
Expand All @@ -25,13 +26,13 @@ function createTooltip(mount, addLabel, offset) {
const mousemove = function move(d) {
tooltip
.html(addLabel(d))
.style('opacity', 0.9)
.style('left', `${offset.x + d3.mouse(mount)[0]}px`)
.style('top', `${offset.y + d3.mouse(mount)[1]}px`);
.style('display', '')
.style('left', `${offset.x + d3.mouse(this)[0]}px`)
.style('top', `${offset.y + d3.mouse(this)[1]}px`);
};

const mouseleave = function leave() {
tooltip.style('opacity', 0);
tooltip.style('display', 'none');
};

return { mousemove, mouseleave };
Expand Down
Loading