Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0' into doc/qp-panel
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtuev authored Nov 21, 2024
2 parents b470049 + 69acc3a commit 025b49d
Show file tree
Hide file tree
Showing 31 changed files with 538 additions and 9,110 deletions.
2 changes: 1 addition & 1 deletion app/packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@fiftyone/state": "*",
"@mui/icons-material": "^5.10.2",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.9.0",
"@react-spring/web": "^9.7.3",
"@textea/json-viewer": "^3.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ const PillBadge = ({
success: "#8BC18D",
};

const getColor = (colorValue: string): string => {
return COLORS[colorValue] || colorValue;
};

const chipStyle: { [key: string]: string | number } = {
color: COLORS[chipColor || "default"] || COLORS.default,
color: getColor(chipColor || color || "default"),
fontSize: 14,
fontWeight: 500,
paddingLeft: 1,
Expand Down
2 changes: 1 addition & 1 deletion app/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@fiftyone/state": "*",
"@fiftyone/utilities": "*",
"@monaco-editor/react": "^4.5.0",
"@mui/icons-material": "^5.10.2",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.9.0",
"@react-spring/web": "^9.4.3",
"@use-gesture/react": "^10.3.0",
Expand Down
36 changes: 0 additions & 36 deletions app/packages/core/src/components/FieldLabelAndInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { InfoIcon, useTheme } from "@fiftyone/components";
import * as fos from "@fiftyone/state";
import { coloring } from "@fiftyone/state";
import { Field, formatDate, formatDateTime } from "@fiftyone/utilities";
import Bolt from "@mui/icons-material/Bolt";
import PaletteIcon from "@mui/icons-material/Palette";
import React, {
MutableRefObject,
Expand All @@ -20,7 +19,6 @@ import {
} from "recoil";
import styled from "styled-components";
import { ExternalLink } from "../../utils/generic";
import { QP_MODE } from "../../utils/links";
import { activeColorEntry } from "../ColorModal/state";

const selectedFieldInfo = atom<string | null>({
Expand Down Expand Up @@ -321,40 +319,6 @@ function FieldInfoExpanded({
);
}

const QueryPerformance: React.FunctionComponent<{
color: string;
path: string;
}> = ({ color, path }) => {
const queryPerformance = useRecoilValue(fos.queryPerformance);
const indexed = useRecoilValue(fos.pathHasIndexes(path));
const theme = useTheme();
if (!queryPerformance || !indexed) {
return null;
}

return (
<FieldInfoTableContainer color={color}>
<tbody>
<tr>
<td>
<Bolt sx={{ color }} fontSize={"small"} />
</td>
<td>
<ContentValue>
<ExternalLink
style={{ color: theme.text.primary }}
href={QP_MODE}
>
Lightning indexed
</ExternalLink>
</ContentValue>
</td>
</tr>
</tbody>
</FieldInfoTableContainer>
);
};

type CustomizeColorProp = {
color: string;
onClick: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const NumericFieldFilter = ({ color, modal, named = true, path }: Props) => {
};

return (
<Container onClick={(e) => e.stopPropagation()}>
<Container
data-cy={`numeric-filter-${path}`}
onClick={(e) => e.stopPropagation()}
>
{named && name && (
<FieldLabelAndInfo
nested
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Selector, useTheme } from "@fiftyone/components";
import * as fos from "@fiftyone/state";
import Bolt from "@mui/icons-material/Bolt";
import React from "react";
import type { RecoilState } from "recoil";
import { useRecoilValue } from "recoil";
import styled from "styled-components";
import FieldLabelAndInfo from "../../FieldLabelAndInfo";
import { LightningBolt } from "../../Sidebar/Entries/FilterablePathEntry/Icon";
import { isInKeypointsField } from "../state";
import useQueryPerformanceTimeout from "../use-query-performance-timeout";
import Checkboxes from "./Checkboxes";
Expand Down Expand Up @@ -103,9 +103,7 @@ const StringFilter = ({
template={({ label, hoverTarget }) => (
<NamedStringFilterHeader>
<span ref={hoverTarget}>{label}</span>
{showQueryPerformanceIcon && (
<Bolt fontSize={"small"} sx={{ color: theme.action.active }} />
)}
{showQueryPerformanceIcon && <LightningBolt />}
</NamedStringFilterHeader>
)}
/>
Expand Down
4 changes: 4 additions & 0 deletions app/packages/core/src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function Grid() {
looker?.destroy();
lookerStore.delete(id.description);
},
detach: (id) => {
const looker = lookerStore.get(id.description);
looker?.detach();
},
onItemClick: setSample,
retainItems: true,
rowAspectRatioThreshold: threshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import { useRecoilValue } from "recoil";
import styled from "styled-components";
import Arrow from "./Arrow";

export const LightningIcon = styled(Bolt)`
const LightningIcon = styled(Bolt)`
color: ${({ theme }) => theme.text.secondary};
`;

export const LightningBolt: React.FC = (_) => {
return (
<Tooltip placement="top-center" text={"Indexed"}>
<LightningIcon style={{ height: 16, marginRight: 2, width: 16 }} />
<LightningIcon
data-cy={"query-performance"}
style={{ height: 16, marginRight: 2, width: 16 }}
/>
</Tooltip>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ export default function Evaluation(props: EvaluationProps) {
variant="outlined"
color="secondary"
sx={{ width: "100%" }}
onClick={closeConfusionMatrixConfigDialog}
onClick={closeClassPerformanceConfigDialog}
>
Cancel
</Button>
Expand Down
117 changes: 117 additions & 0 deletions app/packages/core/src/plugins/SchemaIO/components/TimerView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { useEffect, useRef } from "react";
import { usePanelEvent } from "@fiftyone/operators";
import { usePanelId } from "@fiftyone/spaces";
import { ViewPropsType } from "../utils/types";

export type TimerViewParams = {
on_interval?: string;
on_timeout?: string;
interval?: number;
timeout?: number;
params?: object;
};

class Timer {
protected _ref: NodeJS.Timeout | null = null;

start() {}
stop() {}
}

class IntervalTimer extends Timer {
constructor(private interval: number, private onInterval: () => void) {
super();
}

start() {
this.stop();
this._ref = setInterval(() => this.onInterval(), this.interval);
}
stop() {
if (this._ref) {
clearInterval(this._ref);
this._ref = null;
}
}
}

class TimeoutTimer extends Timer {
constructor(private timeout: number, private onTimeout: () => void) {
super();
}

start() {
this.stop();
this._ref = setTimeout(() => this.onTimeout(), this.timeout);
}
stop(): void {
if (this._ref) {
clearTimeout(this._ref);
this._ref = null;
}
}
}

function useTimer(params: TimerViewParams) {
const panelId = usePanelId();
const triggerEvent = usePanelEvent();
const {
on_interval,
interval,
timeout,
on_timeout,
params: operator_params,
} = params;
const ref = useRef<Timer | null>(null);

useEffect(() => {
if (!interval && !timeout) {
console.warn(
"useTimer requires either `interval` or `timeout` to be defined."
);
return;
}

const TimerType = interval ? IntervalTimer : TimeoutTimer;
const handleTimerEvent = interval
? () => {
if (on_interval) {
triggerEvent(panelId, {
operator: on_interval,
params: operator_params || {},
prompt: null,
});
}
}
: () => {
if (on_timeout) {
triggerEvent(panelId, {
operator: on_timeout,
params: operator_params || {},
prompt: null,
});
}
};

// Clean up existing timer
if (ref.current) {
ref.current.stop();
}

// Initialize and start the timer
ref.current = new TimerType(interval || timeout!, handleTimerEvent);
ref.current.start();

return () => {
ref.current?.stop();
};
}, [on_interval, interval, on_timeout, timeout, triggerEvent, panelId]);
}

export default function TimerView(props: ViewPropsType) {
const { schema } = props;
const { view = {} } = schema;

useTimer(view as TimerViewParams);
return null;
}
1 change: 1 addition & 0 deletions app/packages/core/src/plugins/SchemaIO/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export { default as TagsView } from "./TagsView";
export { default as TextFieldView } from "./TextFieldView";
export { default as TextView } from "./TextView";
export { default as TimelineView } from "./TimelineView";
export { default as TimerView } from "./TimerView";
export { default as ToastView } from "./ToastView";
export { default as TreeSelectionView } from "./TreeSelectionView";
export { default as TupleView } from "./TupleView";
Expand Down
6 changes: 3 additions & 3 deletions app/packages/spotlight/src/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class Row<K, V> {
}

destroy(destroyItems = false) {
destroyItems && this.#destroyItems();
this.#destroyItems(destroyItems);
this.#aborter.abort();
}

Expand Down Expand Up @@ -231,8 +231,8 @@ export default class Row<K, V> {
return set.size === ONE ? this.#row[ZERO].item.aspectRatio : null;
}

#destroyItems() {
const destroy = this.#config.destroy;
#destroyItems(destroyItems = false) {
const destroy = destroyItems ? this.#config.destroy : this.#config.detach;
if (!destroy) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions app/packages/spotlight/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type Request<K, V> = (key: K) => Promise<{
export interface SpotlightConfig<K, V> {
at?: At;
destroy?: (id: ID) => void;
detach?: (id: ID) => void;
get: Get<K, V>;
key: K;
offset?: number;
Expand Down
12 changes: 6 additions & 6 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ __metadata:
"@emotion/styled": ^11.10.4
"@fiftyone/state": "*"
"@mdx-js/react": ^1.6.22
"@mui/icons-material": ^5.10.2
"@mui/icons-material": ^5.16.7
"@mui/material": ^5.9.0
"@react-spring/web": ^9.7.3
"@textea/json-viewer": ^3.4.1
Expand Down Expand Up @@ -1937,7 +1937,7 @@ __metadata:
"@fiftyone/state": "*"
"@fiftyone/utilities": "*"
"@monaco-editor/react": ^4.5.0
"@mui/icons-material": ^5.10.2
"@mui/icons-material": ^5.16.7
"@mui/material": ^5.9.0
"@react-spring/web": ^9.4.3
"@types/lodash": ^4.14.182
Expand Down Expand Up @@ -3140,9 +3140,9 @@ __metadata:
languageName: node
linkType: hard

"@mui/icons-material@npm:^5.10.2":
version: 5.15.14
resolution: "@mui/icons-material@npm:5.15.14"
"@mui/icons-material@npm:^5.16.7":
version: 5.16.7
resolution: "@mui/icons-material@npm:5.16.7"
dependencies:
"@babel/runtime": ^7.23.9
peerDependencies:
Expand All @@ -3152,7 +3152,7 @@ __metadata:
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 719036244167c7cb5456074d7d66df0c26d4b200c11620ba177a4e75186f6ecc4930a3b4bcb7300d92aa37df19ca8406fa63ad4347214cc167ddca986eb1a198
checksum: a875f2837897d79a83173d80461e06ab090b64d08913d26433cf2cbeb8e7c7456468632a7aa495d722718f09111a8043255777d73b4dfbe9e0f863a170fc7190
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/source/model_zoo/models.rst
source/model_zoo/models.rst
Binary file modified docs/source/images/app/app-field-tooltips.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/app/app-fields.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/app/app-filters.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/app/app-granular.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/app/app-query-performance-mode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/source/images/app/app-sidebar-mode.gif
Binary file not shown.
Loading

0 comments on commit 025b49d

Please sign in to comment.