Skip to content
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
2 changes: 1 addition & 1 deletion applications/virtual-fly-brain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ RUN mkdir -p /var/log && touch /var/log/vfb_cache_cleanup.log
WORKDIR /usr/src/app/virtual_fly_brain

EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh", "gunicorn", "--log-level=info", "--preload", "--bind=0.0.0.0:8080", "--timeout=120", "--graceful-timeout=30", "--keep-alive=5", "virtual_fly_brain.__main__:app"]
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh", "gunicorn", "--log-level=info", "--preload", "--bind=0.0.0.0:8080", "--timeout=240", "--graceful-timeout=30", "--keep-alive=5", "virtual_fly_brain.__main__:app"]
5 changes: 5 additions & 0 deletions applications/virtual-fly-brain/deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ harness:
build:
- cloudharness-base-debian
- cloudharness-flask
ingress:
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
5 changes: 5 additions & 0 deletions applications/virtual-fly-brain/deploy/values-local.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
harness:
database:
size: 10Gi
ingress:
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
5 changes: 5 additions & 0 deletions applications/virtual-fly-brain/deploy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ harness:
build:
- cloudharness-base-debian
- cloudharness-flask
ingress:
annotations:
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,12 @@ const rgbToHex = (color) => {
},

callObjects: function () {
// Prevent duplicate calls within 100ms
const now = Date.now();
if (this._lastCallObjectsTime && (now - this._lastCallObjectsTime) < 100) {
return;
}
this._lastCallObjectsTime = now;

var j, result;
var that = this;
Expand Down Expand Up @@ -1289,13 +1295,20 @@ const rgbToHex = (color) => {
this.props.setExtent({ stackX: this.stack.position.x, stackY: this.stack.position.y });
this.createImages();
this.state.buffer[-1].text = '';

// Set flag to prevent duplicate click event
this._justFinishedDrag = true;
setTimeout(() => {
this._justFinishedDrag = false;
}, 10);
}
this.state.dragging = false;
},

onStackClick: function (event) {
// Backup click handler for when drag doesn't register as a click
if (!this.state.dragging) {
// But prevent duplicate calls if we just finished a drag operation
if (!this.state.dragging && !this._justFinishedDrag) {
var clickPosition;
if (event.data && typeof event.data.getLocalPosition === "function") {
clickPosition = event.data.getLocalPosition(this.stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const initialStateInstancesReducer = {
selectedInstancesCount: 1,
loadingInstances: 0,
finishedLoadedInstances: 0,
bulkLoadingCount: 0,
isBulkLoading: false,
};

const getMappedCanvasData = (loadedInstances) => {
Expand Down Expand Up @@ -120,6 +122,9 @@ const InstancesReducer = (state = initialStateInstancesReducer, response) => {
});
}

const newFinishedCount = state.finishedLoadedInstances + 1;
const isAllBulkInstancesLoaded = state.isBulkLoading && newFinishedCount >= state.bulkLoadingCount;

return Object.assign({}, state, {
allLoadedInstances: loadedInstances,
launchTemplate: launchTemplate,
Expand All @@ -130,10 +135,13 @@ const InstancesReducer = (state = initialStateInstancesReducer, response) => {
id: response.payload.Id,
trigger: Date.now(),
},
isLoading: false,
isLoading: state.isBulkLoading ? !isAllBulkInstancesLoaded : false,
error: false,
errorMessage: undefined,
finishedLoadedInstances: state.finishedLoadedInstances + 1,
finishedLoadedInstances: newFinishedCount,
// Reset bulk loading state when all instances are loaded
isBulkLoading: state.isBulkLoading && !isAllBulkInstancesLoaded,
bulkLoadingCount: isAllBulkInstancesLoaded ? 0 : state.bulkLoadingCount,
});
}
case getInstancesTypes.GET_INSTANCES_FAILURE: {
Expand All @@ -143,6 +151,9 @@ const InstancesReducer = (state = initialStateInstancesReducer, response) => {
loadingInstances: 0,
finishedLoadedInstances: 0,
isLoading: false,
// Reset bulk loading state on failure
isBulkLoading: false,
bulkLoadingCount: 0,
});
}
case getInstancesTypes.REMOVE_INSTANCES_SUCCESS: {
Expand Down Expand Up @@ -727,6 +738,23 @@ const InstancesReducer = (state = initialStateInstancesReducer, response) => {
errorMessage: undefined,
});
}
case getInstancesTypes.SET_BULK_LOADING_COUNT: {
return Object.assign({}, state, {
bulkLoadingCount: response.payload.count,
isBulkLoading: true,
loadingInstances: 0,
finishedLoadedInstances: 0,
});
}
case getInstancesTypes.RESET_BULK_LOADING: {
return Object.assign({}, state, {
bulkLoadingCount: 0,
isBulkLoading: false,
loadingInstances: 0,
finishedLoadedInstances: 0,
isLoading: false,
});
}
default:
return state;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ export const resetLoadingState = () => ({
type: getInstancesTypes.RESET_LOADING_STATE
});

export const setBulkLoadingCount = (count) => ({
type: getInstancesTypes.SET_BULK_LOADING_COUNT,
payload: { count }
});

export const resetBulkLoading = () => ({
type: getInstancesTypes.RESET_BULK_LOADING
});

export const triggerInstanceFailure = (error) => {
store.dispatch(getInstancesFailure(error));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ export const getInstancesTypes = Object.freeze({
UPDATE_SKELETON : "UPDATE_SKELETON",
LAUNCH_TEMPLATE : "LAUNCH_TEMPLATE",
UPDATE_INSTANCES : "UPDATE_INSTANCES",
RESET_LOADING_STATE : "RESET_LOADING_STATE"
RESET_LOADING_STATE : "RESET_LOADING_STATE",
SET_BULK_LOADING_COUNT : "SET_BULK_LOADING_COUNT",
RESET_BULK_LOADING : "RESET_BULK_LOADING"
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getQueriesFailure } from '../actions/queries';
import { getQueriesTypes } from '../actions/types/getQueriesTypes';
import { getInstancesTypes } from '../actions/types/getInstancesTypes';
import { setFirstIDLoaded, setAlignTemplates, setTemplateID } from '../actions/globals';
import { getInstanceByID, get3DMesh, triggerInstanceFailure } from '../actions/instances';
import { getInstanceByID, get3DMesh, triggerInstanceFailure, setBulkLoadingCount } from '../actions/instances';
import * as GeppettoActions from '@metacell/geppetto-meta-client/common/actions';

function updateUrlParameterWithCurrentUrl(param, value, reset) {
Expand Down Expand Up @@ -43,7 +43,7 @@ function updateUrlWithInstancesAndSelectedId(selectedId) {
const DEFAULT_ID = "VFB_00101567";
const APP_LOADED_FLAG_KEY = "CURRENT_LOADED_URL";

const isFirstTimeLoad = (allLoadedInstances) => {
const isFirstTimeLoad = (allLoadedInstances, store) => {
const appLoadedUrl = localStorage.getItem(APP_LOADED_FLAG_KEY);
const currentUrl = window.location.href;
if (currentUrl != appLoadedUrl) {
Expand Down Expand Up @@ -71,6 +71,14 @@ const isFirstTimeLoad = (allLoadedInstances) => {
idToUpdate.push(DEFAULT_ID);
}

// Filter out instances that are already loaded to get the actual count we need to load
const instancesToLoad = idToUpdate.filter(id => !allLoadedInstances?.find(i => i.metadata?.Id === id));

// If we have instances to load, set up bulk loading
if (instancesToLoad.length > 0) {
store.dispatch(setBulkLoadingCount(instancesToLoad.length));
}

idToUpdate?.forEach( id => {
// if it's the last ID in the list, we need to focus it
if (id === idToUpdate[idToUpdate.length - 1]) {
Expand Down Expand Up @@ -101,7 +109,7 @@ export const urlUpdaterMiddleware = store => next => (action) => {

// Only call isFirstTimeLoad if we haven't loaded the first ID yet
if (!firstIDLoaded) {
isFirstTimeLoad(allLoadedInstances);
isFirstTimeLoad(allLoadedInstances, store);
}

switch (action.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const vfbMiddleware = store => next => (action) => {
break;
}
case getGlobalTypes.SHOW_SLICE_DISPLAY : {
let matchInstance = store.getState().instances.allLoadedInstances.find( i => i.metadata?.Id === action.payload.id );
let objectFound = null;
for (let child of store.getState().instances.threeDObjects) {
if ( action.payload.data?.id === child.material?.name ) {
Expand All @@ -66,7 +65,6 @@ const vfbMiddleware = store => next => (action) => {
break;
}
case getGlobalTypes.MODIFY_SLICE_DISPLAY : {
let matchInstance = store.getState().instances.allLoadedInstances.find( i => i.metadata?.Id === action.payload.id );
let objectFound = null;
for (let child of store.getState().instances.threeDObjects) {
if ( action.payload.data?.id === child.material?.name ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CustomTableContainer = styled(TableContainer)(
content: '';
position: absolute;
top: 0;
z-index: 999;
z-index: 5;
display: block;
height: 100%;
width: 100%;
Expand All @@ -53,7 +53,7 @@ const CustomBox = styled(Box)(
content: '';
position: absolute;
right: 0;
z-index: 999;
z-index: 5;
width: 100%;
height: 100%;
display: block;
Expand Down Expand Up @@ -639,4 +639,4 @@ const SideBar = ({ open, setOpen }) => {
)
};

export default SideBar;
export default SideBar;
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const SubHeader = ({ setBottomNav, bottomNav }) => {
const finishedLoadedInstances = useSelector(
(state) => state.instances.finishedLoadedInstances
);
const isBulkLoading = useSelector(
(state) => state.instances.isBulkLoading
);
const bulkLoadingCount = useSelector(
(state) => state.instances.bulkLoadingCount
);
const dispatch = useDispatch();
const classes = {
root: {
Expand All @@ -103,15 +109,21 @@ const SubHeader = ({ setBottomNav, bottomNav }) => {
};

useEffect(() => {
if (loadingInstances > 0 && loadingInstances === finishedLoadedInstances) {
// For bulk loading, check if all instances are loaded using bulk count
// For individual loading, use the original logic
const allLoaded = isBulkLoading
? finishedLoadedInstances >= bulkLoadingCount
: loadingInstances > 0 && loadingInstances === finishedLoadedInstances;

if (allLoaded) {
// Add a small delay to show the final loading state before resetting
const timer = setTimeout(() => {
dispatch(resetLoadingState());
}, 150);

return () => clearTimeout(timer);
}
}, [loadingInstances, finishedLoadedInstances]);
}, [loadingInstances, finishedLoadedInstances, isBulkLoading, bulkLoadingCount, dispatch]);

return (
<Box
Expand Down Expand Up @@ -153,7 +165,9 @@ const SubHeader = ({ setBottomNav, bottomNav }) => {
<CircularProgress size={20} />
<Typography variant="body1" color={lightWhiteColor}>
Loading{" "}
{loadingInstances > 0 && finishedLoadedInstances > 0
{isBulkLoading && bulkLoadingCount > 0
? `instance ${finishedLoadedInstances} of ${bulkLoadingCount}`
: loadingInstances > 0 && finishedLoadedInstances > 0
? `instance ${finishedLoadedInstances} of ${loadingInstances}`
: " ..."}
</Typography>
Expand Down