Skip to content

Commit

Permalink
Merge pull request #86 from enjalot/full-screen-merge
Browse files Browse the repository at this point in the history
Full screen explore redesign
  • Loading branch information
enjalot authored Dec 1, 2024
2 parents fc03f6a + 1680b43 commit a157b67
Show file tree
Hide file tree
Showing 25 changed files with 1,540 additions and 462 deletions.
1 change: 0 additions & 1 deletion latentscope/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ def query():
# only send back the first per_page rows
# per_page = 100
# rows_json = rows_json[:per_page]
# print("ROWS JSON", rows_json)

# send back the rows as json
return jsonify({
Expand Down
3 changes: 2 additions & 1 deletion web/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Home from './components/Home';
import Settings from './pages/Settings';
import Explore from './pages/Explore';
import FullScreenExplore from './pages/FullScreenExplore';
import Compare from './pages/Compare';
import Setup from './pages/Setup';
import Jobs from './pages/Jobs';
Expand Down Expand Up @@ -38,7 +39,7 @@ function App() {
<Routes>
<Route path="/" element={<Home />} />
<Route path="/settings" element={<Settings />} />
<Route path="/datasets/:dataset/explore/:scope" element={<Explore />} />
<Route path="/datasets/:dataset/explore/:scope" element={<FullScreenExplore />} />
<Route path="/datasets/:dataset/compare/" element={<Compare />} />
<Route path="/datasets/:dataset/export" element={<Export />} />
<Route path="/datasets/:dataset/export/:scope" element={<Export />} />
Expand Down
137 changes: 55 additions & 82 deletions web/src/components/Explore/ClusterFilter.jsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,61 @@
import React from 'react';

export default function ClusterFilter({
clusterLabels,
slide,
slideAnnotations,
setSlide,
clusterLabel,
setClusterLabel,
handleLabelUpdate,
newClusterLabel,
setNewClusterLabel,
handleNewCluster
setFilteredIndices,
clusterLabels,
cluster,
clusterIndices,
setCluster,
}) {
const handleSlideChange = (e) => {
if (e.target.value === "-1") {
setSlide(null);
return;
}
const cl = clusterLabels.find((cluster) => cluster.cluster === +e.target.value);
if (cl) setSlide(cl);
};
const handleClusterChange = (e) => {
if (e.target.value === '-1') {
setCluster(null);
return;
}
const cl = clusterLabels.find((cluster) => cluster.cluster === +e.target.value);
if (cl) setCluster(cl);
};

const handleUpdateLabelSubmit = (e) => {
e.preventDefault();
handleLabelUpdate(slide.cluster, clusterLabel);
};

const handleNewLabelSubmit = (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const newLabel = formData.get("new-label");
console.log("new label", newLabel);
handleNewCluster(newLabel);
};

return (
<div className={`clusters-select filter-row ${slideAnnotations.length ? "active" : ""}`}>
<div className="filter-cell left">
<select onChange={handleSlideChange} value={slide?.cluster >= 0 ? slide.cluster : -1}>
<option value="-1">Filter by cluster</option>
{clusterLabels?.map((cluster, index) => (
<option key={index} value={cluster.cluster}>
{cluster.cluster}: {cluster.label}
</option>
))}
</select>
</div>
<div className="filter-cell middle">
{slideAnnotations.length ? (
<span>
{slideAnnotations.length} rows
<button className="deselect" onClick={() => setSlide(null)}>
X
</button>
</span>
) : null}
</div>
<div className="filter-cell right">
{slide ? (
<form onSubmit={handleUpdateLabelSubmit}>
<input
className="update-cluster-label"
type="text"
id="update-label"
value={clusterLabel}
onChange={(e) => setClusterLabel(e.target.value)}
/>
<button type="submit">✍️</button>
</form>
) : (
<form onSubmit={handleNewLabelSubmit}>
<input
type="text"
id="new-label"
name="new-label"
className="new-cluster-label"
value={newClusterLabel}
onChange={(e) => setNewClusterLabel(e.target.value)}
placeholder="New Cluster"
/>
<button type="submit">➕️ Cluster</button>
</form>
)}
</div>
</div>
);
return (
<div className={`clusters-select filter-row ${clusterIndices?.length ? 'active' : ''}`}>
<div className="filter-cell left">
<select onChange={handleClusterChange} value={cluster?.cluster >= 0 ? cluster.cluster : -1}>
<option value="-1">Filter by cluster</option>
{clusterLabels?.map((cluster, index) => (
<option key={index} value={cluster.cluster}>
{cluster.cluster}: {cluster.label}
</option>
))}
</select>
</div>
<div className="filter-cell middle">
{clusterIndices?.length ? (
<span>
{clusterIndices.length} rows
<button
className="deselect"
onClick={() => {
setCluster(null);
setFilteredIndices([]);
}}
>
X
</button>
</span>
) : (
<span>
0 rows
<button
style={{ visibility: 'hidden' }}
className="deselect"
disabled
onClick={() => setCluster(null)}
>
X
</button>
</span>
)}
</div>
</div>
);
}
4 changes: 3 additions & 1 deletion web/src/components/Explore/ColumnFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ const ColumnFilter = ({
columnFiltersActive,
setColumnFiltersActive,
setColumnIndices,
setFilteredIndices,
}) => {
return columnFilters?.length ? (
<div className={`filter-row column-filter ${columnIndices?.length ? 'active' : ''}`}>
<div className="filter-cell">
{columnFilters.map((column) => (
<span key={column.column}>
<span key={column.column} style={{ marginRight: 8 }}>
{column.column}:
<select
onChange={(e) => {
Expand Down Expand Up @@ -39,6 +40,7 @@ const ColumnFilter = ({
onClick={() => {
setColumnFiltersActive({});
setColumnIndices([]);
setFilteredIndices([]);
}}
>
X
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/Explore/ConfigurationPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const ConfigurationPanel = ({
className={styles.closeButton}
variant="outline"
onClick={onClose}
aria-label="Close configuration panel"
icon={'x'}
aria-label="Minimize configuration panel"
icon="minus"
/>
</div>

Expand Down Expand Up @@ -64,6 +64,7 @@ const ConfigurationPanel = ({
<Switch
value={showClusterOutlines}
onChange={toggleShowClusterOutlines}
defaultState={showClusterOutlines}
color="secondary"
label="Show Cluster Outlines"
/>
Expand Down
11 changes: 9 additions & 2 deletions web/src/components/Explore/ConfigurationPanel.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
padding: 2px !important;
font-size: 12px !important;
border-radius: 4px !important;
border: 1px solid #5e5d5d !important;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
border: 0px solid #5e5d5d !important;
// box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);


&:hover {
Expand Down Expand Up @@ -112,4 +112,11 @@
background: #f9f9f9;
border: 1px solid #5e5d5d;
}
}

@media (prefers-color-scheme: dark) {
.panel {
background: lightsalmon;
border: 1px solid #5e5d5d;
}
}
47 changes: 47 additions & 0 deletions web/src/components/Explore/FilterActions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.filter-actions-container {
display: flex;
flex-direction: row;
gap: .5rem;
}

.filter-actions-row {
display: flex;
flex-direction: row;
gap: 0.5rem;
margin-top: 0.5rem;
}

.filter-actions-button {
border-radius: 4px !important;
padding: 0.25rem 0.5rem !important;
font-size: 0.875rem !important;
}

.filter-actions-button.active {
background-color: var(--interactions---primary-color-interaction-primary) !important;
color: white !important;
}

.filter-actions-button:focus {
outline: none !important;
}

.filter-actions-button.not-active {
background-color: transparent !important;
color: var(--text-color-text-primary) !important;
opacity: 0.75;
}

.filter-actions-button:hover {
background-color: var(--interactions---primary-color-interaction-primary-hover) !important;
}

.filter-actions-button.active {
background-color: var(--interactions---primary-color-interaction-primary-active);
}

@media (prefers-color-scheme: dark) {
.filter-actions-button {
border: .5px solid var(--neutrals-color-neutral-3) !important;
}
}
Loading

0 comments on commit a157b67

Please sign in to comment.