Skip to content

Commit acc95ad

Browse files
committed
Refactor viewer state model
Signed-off-by: Andrew Stein <steinlink@gmail.com>
1 parent d175656 commit acc95ad

73 files changed

Lines changed: 2740 additions & 1900 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/blocks/src/fractal/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ c`;
5656
function generate_layout(params) {
5757
return {
5858
plugin: "Heatmap",
59+
table: "raw_data",
5960
settings: true,
6061
group_by: [`floor("index" / ${params.resolution})`],
6162
split_by: [`"index" % ${params.resolution}`],
@@ -116,10 +117,16 @@ const make_run_click_callback = (worker, state) => async () => {
116117

117118
window.run.disabled = true;
118119
if (!state.table) {
119-
state.table = await worker.table({
120-
index: "integer",
121-
});
122-
window.viewer.load(Promise.resolve(state.table));
120+
state.table = await worker.table(
121+
{
122+
index: "integer",
123+
},
124+
{
125+
name: "raw_data",
126+
},
127+
);
128+
129+
window.viewer.load(worker);
123130
}
124131

125132
const run = document.getElementById("run");
@@ -154,4 +161,5 @@ run.addEventListener(
154161
"click",
155162
make_run_click_callback(await perspective.worker(), {}),
156163
);
164+
157165
run.dispatchEvent(new Event("click"));

packages/viewer-datagrid/src/ts/style_handlers/body.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,20 @@ export function applyBodyCellStyles(
6565

6666
// Calculate aggregate depth visibility
6767
// @ts-ignore
68-
metadata._is_hidden_by_aggregate_depth = ((x?: number) =>
69-
x === 0 || x === undefined
70-
? false
71-
: x - 1 <
72-
Math.min(
73-
this._config.group_by.length,
74-
plugin?.aggregate_depth || 0,
75-
))(
76-
(metadata.row_header as unknown[] | undefined)?.filter(
77-
(x) => x !== undefined,
78-
)?.length,
79-
);
68+
metadata._is_hidden_by_aggregate_depth =
69+
this._config.group_rollup_mode === "rollup" &&
70+
((x?: number) =>
71+
x === 0 || x === undefined
72+
? false
73+
: x - 1 <
74+
Math.min(
75+
this._config.group_by.length,
76+
plugin?.aggregate_depth || 0,
77+
))(
78+
(metadata.row_header as unknown[] | undefined)?.filter(
79+
(x) => x !== undefined,
80+
)?.length,
81+
);
8082

8183
// Apply type-specific cell styling
8284
if (is_numeric) {

rust/perspective-client/src/rust/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<U: Copy + 'static> SystemInfo<U> {
8888

8989
/// Metadata about what features are supported by the `Server` to which this
9090
/// [`Client`] connects.
91-
#[derive(Clone, Debug, Default)]
91+
#[derive(Clone, Debug, Default, PartialEq)]
9292
pub struct Features(Arc<GetFeaturesResp>);
9393

9494
impl Features {

rust/perspective-client/src/rust/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub struct UpdateOptions {
152152

153153
/// Result of a call to [`Table::validate_expressions`], containing a schema
154154
/// for valid expressions and error messages for invalid ones.
155-
#[derive(Clone, Debug, Serialize, Deserialize)]
155+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
156156
pub struct ExprValidationResult {
157157
pub expression_schema: Schema,
158158
pub errors: HashMap<String, table_validate_expr_resp::ExprValidationError>,

rust/perspective-client/src/rust/virtual_server/features.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::proto::{ColumnType, GetFeaturesResp};
2424
/// This struct is returned by
2525
/// [`VirtualServerHandler::get_features`](super::VirtualServerHandler::get_features)
2626
/// to inform clients about which operations are available.
27-
#[derive(Debug, Default, Deserialize, Serialize)]
27+
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
2828
pub struct Features<'a> {
2929
/// Whether group-by aggregation is supported.
3030
#[serde(default)]
@@ -63,7 +63,7 @@ pub struct Features<'a> {
6363
///
6464
/// Aggregates can either take no additional arguments ([`AggSpec::Single`])
6565
/// or require column type arguments ([`AggSpec::Multiple`]).
66-
#[derive(Clone, Debug, Deserialize, Serialize)]
66+
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
6767
#[serde(untagged)]
6868
pub enum AggSpec<'a> {
6969
/// An aggregate function with no additional arguments.

rust/perspective-js/src/rust/utils/futures.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ where
6464
pub fn spawn<U: Future<Output = ApiResult<T>> + 'static>(x: U) {
6565
drop(js_sys::Promise::from(Self::new(x)))
6666
}
67+
68+
pub fn spawn_throttled<U: Future<Output = ApiResult<T>> + 'static>(x: U) {
69+
drop(js_sys::Promise::from(Self::new_throttled(x)))
70+
}
6771
}
6872

6973
impl<T> Default for ApiFuture<T>

0 commit comments

Comments
 (0)