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

Geospatial interface #236

Open
wants to merge 54 commits into
base: schema-8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4d25c15
first pass at geospatial interface
buckhalt Nov 22, 2024
0268f7f
reset filter on reset
buckhalt Nov 22, 2024
5d1b9f6
simulate getting mapbox key and geojsons from the protocol
buckhalt Nov 27, 2024
d6c8fb8
add filter config to protocol
buckhalt Nov 27, 2024
9fbd0fc
working flow to select map areas for nodes
buckhalt Dec 6, 2024
9386f29
add index.tsx
buckhalt Dec 6, 2024
66a0552
rethink stage layout based on sociogram
buckhalt Dec 10, 2024
bc301d7
implement multiple prompts
buckhalt Dec 10, 2024
01d3c7f
reimplement reset
buckhalt Dec 10, 2024
1b26074
add button import
buckhalt Dec 10, 2024
fd1062e
move nodes to prompt box, add dir aware animation
buckhalt Dec 11, 2024
33ed27f
rm selection state and use node attribute instead
buckhalt Dec 11, 2024
40ad4cf
optimize map initialization to prevent rerenders when node changes
buckhalt Dec 11, 2024
bb2dd23
fix prompt rerendering, animation dir, schema, spacing
buckhalt Dec 12, 2024
9e0b183
linting
buckhalt Dec 12, 2024
43b2bd9
reset active index when prompt changes
buckhalt Dec 12, 2024
0f81663
wip cleanup
buckhalt Dec 12, 2024
365b419
get geojson layers, mapbox token from assets
buckhalt Dec 13, 2024
1563e06
use nc primary color seq for map layers
buckhalt Dec 16, 2024
38d657d
refactor schema to make layers props of prompt
buckhalt Dec 16, 2024
d4d4dfd
improve state management and consts
buckhalt Dec 17, 2024
13f42c4
refactor mapbox stuff into custom hook
buckhalt Dec 17, 2024
266def4
improve layers types
buckhalt Dec 17, 2024
5d49cb6
clean up selection and onSelectionChange
buckhalt Dec 17, 2024
a5d8711
fix type issues
buckhalt Dec 18, 2024
edbf769
feature: skip response for node
buckhalt Dec 18, 2024
26335ad
make node smaller
buckhalt Dec 18, 2024
e812e91
refactor for simpler schema
buckhalt Dec 20, 2024
356eee6
fix resetting selection, rename prop for clarity
buckhalt Dec 20, 2024
76f3922
only allow skip if theres no value
buckhalt Dec 20, 2024
8f063e4
rename data prop to dataSource
buckhalt Jan 7, 2025
9f15e9c
schema udpates, relocate button as icon, prompt box ui improvements
buckhalt Jan 14, 2025
53db3bf
wip fill areas on hover
buckhalt Jan 14, 2025
522837e
action button for reset, fix hover
buckhalt Jan 15, 2025
4622169
zoom can be float
buckhalt Jan 15, 2025
cd77ed1
Merge branch 'schema-8' into geospatial-interface
buckhalt Jan 16, 2025
1e3d78a
fix getting token, schema 8 changes
buckhalt Jan 17, 2025
c882f7b
refactor how mapbox key is selected/used
buckhalt Jan 17, 2025
6d69eaa
a few small improvements to get things building
jthrilly Jan 22, 2025
f5456a5
add schema migration to add value column to asset table
jthrilly Jan 22, 2025
683e340
knip
jthrilly Jan 22, 2025
a18f058
fix test protocol styles
buckhalt Jan 22, 2025
e6631be
implement adding apikey assets to db
buckhalt Jan 22, 2025
f536868
knip
jthrilly Jan 23, 2025
28ede8c
reuse existing types for fetching assets
buckhalt Jan 23, 2025
6bfeae0
add asset types to json schema & compile schemas
buckhalt Jan 23, 2025
8230f08
allow schema versions 7 & 8
buckhalt Jan 23, 2025
90cd778
rm symbol
buckhalt Jan 24, 2025
683049c
add zoom buttons for better ux
buckhalt Jan 24, 2025
2d1b852
feature: introduction panel
buckhalt Jan 24, 2025
4599fe9
fix backwards nav, animation between intro and map
buckhalt Jan 24, 2025
db7da08
fix error related to redux upgrade
buckhalt Jan 27, 2025
b94c2d9
handle existing apikeys as existing assets to fix duplicate key
buckhalt Jan 27, 2025
aeed61e
correct checking for existing api key asset implementation
buckhalt Jan 27, 2025
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 app/(interview)/interview/[interviewId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { notFound, redirect } from 'next/navigation';
import { syncInterview } from '~/actions/interviews';
import FeedbackBanner from '~/components/Feedback/FeedbackBanner';
import { getAppSetting } from '~/queries/appSettings';
import { TESTING_getInterviewById } from '~/queries/interviews';
import { getInterviewById } from '~/queries/interviews';
import { getServerSession } from '~/utils/auth';
import InterviewShell from '../_components/InterviewShell';

Expand All @@ -18,7 +18,7 @@ export default async function Page({
return 'No interview id found';
}

const interview = await TESTING_getInterviewById(interviewId);
const interview = await getInterviewById(interviewId);
const session = await getServerSession();

// If the interview is not found, redirect to the 404 page
Expand Down
3 changes: 2 additions & 1 deletion fresco.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const PROTOCOL_EXTENSION = '.netcanvas';
export const APP_SUPPORTED_SCHEMA_VERSIONS = [7];
export const APP_SUPPORTED_SCHEMA_VERSIONS = [7, 8];

// If unconfigured, the app will shut down after 2 hours (7200000 ms)
export const UNCONFIGURED_TIMEOUT = 7200000;

Expand Down
40 changes: 27 additions & 13 deletions hooks/useProtocolImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { AlertDialogDescription } from '~/components/ui/AlertDialog';
import { APP_SUPPORTED_SCHEMA_VERSIONS } from '~/fresco.config';
import { uploadFiles } from '~/lib/uploadthing-client-helpers';
import { getExistingAssetIds, getProtocolByHash } from '~/queries/protocols';
import { getNewAssetIds, getProtocolByHash } from '~/queries/protocols';
import { type AssetInsertType } from '~/schemas/protocol';
import { DatabaseError } from '~/utils/databaseError';
import { ensureError } from '~/utils/ensureError';
Expand Down Expand Up @@ -176,30 +176,44 @@ export const useProtocolImport = () => {
return;
}

const assets = await getProtocolAssets(protocolJson, zip);

const newAssets: typeof assets = [];
const { fileAssets, apikeyAssets } = await getProtocolAssets(
protocolJson,
zip,
);

const newAssets: typeof fileAssets = [];
const existingAssetIds: string[] = [];

let newAssetsWithCombinedMetadata: AssetInsertType = [];
let newAssetsWithCombinedMetadata: AssetInsertType[] = [];
const newApikeyAssets: typeof apikeyAssets = [];

// Check if the assets are already in the database.
// If yes, add them to existingAssetIds to be connected to the protocol.
// If not, add them to newAssets to be uploaded.

// If not, add files to newAssets to be uploaded
// and add apikeys to newApikeyAssets to be created in the database with the protocol
try {
const newAssetIds = await getExistingAssetIds(
assets.map((asset) => asset.assetId),
const newFileAssetIds = await getNewAssetIds(
fileAssets.map((asset) => asset.assetId),
);

assets.forEach((asset) => {
if (newAssetIds.includes(asset.assetId)) {
fileAssets.forEach((asset) => {
if (newFileAssetIds.includes(asset.assetId)) {
newAssets.push(asset);
} else {
existingAssetIds.push(asset.assetId);
}
});

const newApikeyAssetIds = await getNewAssetIds(
apikeyAssets.map((apiKey) => apiKey.assetId),
);

apikeyAssets.forEach((apiKey) => {
if (newApikeyAssetIds.includes(apiKey.assetId)) {
newApikeyAssets.push(apiKey);
} else {
existingAssetIds.push(apiKey.assetId);
}
});
} catch (e) {
throw new Error('Error checking for existing assets');
}
Expand Down Expand Up @@ -304,7 +318,7 @@ export const useProtocolImport = () => {
const result = await insertProtocol({
protocol: protocolJson,
protocolName: fileName,
newAssets: newAssetsWithCombinedMetadata,
newAssets: [...newAssetsWithCombinedMetadata, ...newApikeyAssets],
existingAssetIds: existingAssetIds,
});

Expand Down
2 changes: 1 addition & 1 deletion lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StaticTag =
| 'getProtocols'
| 'getInterviewsForExport'
| 'getProtocolsByHash'
| 'getExistingAssetIds'
| 'getNewAssetIds'
| 'interviewCount'
| 'protocolCount'
| 'participantCount';
Expand Down
4 changes: 3 additions & 1 deletion lib/interviewer/components/CollapsablePrompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from 'react';
import Prompts from './Prompts';

const CollapsablePrompts = (props) => {
const { currentPromptIndex, dragConstraints } = props;
const { currentPromptIndex, dragConstraints, children } = props;
const ref = useRef(null);
const [minimized, setMinimized] = useState(false);

Expand Down Expand Up @@ -66,8 +66,10 @@ const CollapsablePrompts = (props) => {
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
className="flex flex-col items-center"
>
<Prompts />
{children}
</motion.div>
)}
</AnimatePresence>
Expand Down
10 changes: 4 additions & 6 deletions lib/interviewer/components/Node.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { useSelector } from 'react-redux';
import { getEntityAttributes } from '~/lib/interviewer/ducks/modules/network';
import UINode from '~/lib/ui/components/Node';
import {
getNodeColor, labelLogic,
} from '../selectors/network';
import { getNodeColor, labelLogic } from '../selectors/network';
import { getProtocolCodebook } from '../selectors/protocol';
import { getEntityAttributes } from '~/lib/interviewer/ducks/modules/network';

/**
* Renders a Node.
*/
* Renders a Node.
*/

const Node = (props) => {
const { type } = props;
Expand Down
1 change: 0 additions & 1 deletion lib/interviewer/containers/Interfaces/DyadCensus/index.js

This file was deleted.

Loading
Loading