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

Feat/msg infinite scrolling #345

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ npm run dev
```sh
cd buckaroo
uv venv
source ~/buckaroo/.venv/bin/activate
uv sync -q

```
Expand Down
8 changes: 4 additions & 4 deletions buckaroo/buckaroo_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,22 @@ def _payload_args_handler(self, change):
if processed_df is None:
return

print(self.payload_args)
try:
sort = self.payload_args.get('sort')
if sort:
sort_dir = self.payload_args.get('sort_direction')
ascending = sort_dir == 'asc'
sorted_df = processed_df.sort_values(by=[sort], ascending=ascending)
slice_df = pd_to_obj(sorted_df[start:end])
self.payload_response = {'key':self.payload_args, 'data':slice_df, 'length':len(sorted_df)}
self.send({ "type": "infinite_resp", 'key':self.payload_args, 'data':slice_df, 'length':len(processed_df)})
else:
slice_df = pd_to_obj(processed_df[start:end])
self.payload_response = {'key':self.payload_args, 'data':slice_df, 'length':len(processed_df)}
self.send({ "type": "infinite_resp", 'key':self.payload_args, 'data':slice_df, 'length':len(processed_df)})
except Exception as e:
print(e)
stack_trace = traceback.format_exc()
self.payload_response = {'key':self.payload_args, 'data':[], 'error_info':stack_trace, 'length':0}
self.send({ "type": "infinite_resp", 'key':self.payload_args, 'data':[], 'error_info':stack_trace, 'length':0})

raise

def _df_to_obj(self, df:pd.DataFrame):
Expand Down
16 changes: 11 additions & 5 deletions js/widget.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { createRender, useModelState } from "@anywidget/react";
import { createRender, useModelState, useModel } from "@anywidget/react";
import srt from "buckaroo-js-core";
import "./widget.css";
import "../packages/buckaroo-js-core/dist/style.css";
Expand Down Expand Up @@ -173,8 +173,10 @@ const renderBuckarooWidget = createRender(() => {
</div>
);
});
const renderBuckarooInfiniteWidget = createRender(() => {
console.log("renderInfiniteBuckarooWidget");
const renderBuckarooInfiniteWidget = createRender((a,b,c) => {
const model = useModel()
console.log("renderInfiniteBuckarooWidget", model);
model.send
const [payload_args, on_payload_args] = useModelState("payload_args");
const [payload_response, _set_payload_response] =
useModelState("payload_response");
Expand All @@ -201,14 +203,18 @@ const renderBuckarooInfiniteWidget = createRender(() => {
command_config={command_config}
buckaroo_state={buckaroo_state}
on_buckaroo_state={on_buckaroo_state}
buckaroo_options={buckaroo_options}
buckaroo_options={buckaroo_options}
model={model}
/>
);
});

const render = ({ el, model, experimental }) => {
console.log("model", model);
console.log("model.widget_manager", model.widget_manager);
console.log("model.widget_manager", model.widget_manager);
// model.send({"method":"custom", "foo":"bar"})
// model.send({"foo":8})

// console.log(
// "model.widget_manager.attributes",
// model.widget_manager.attributes,
Expand Down
Loading
Loading