instruction
stringlengths
0
1k
input
stringlengths
1
1k
output
stringlengths
10
6.51k
return if is_add_operation: new_customer = CustomerData( customer_id=self._next_customer_id, first_name=first_name, last_name=last_name, email=email_from_form, phone=form_data.get("phone"), status=status, avatar_url="/favicon.ico", role=role_from_form, tags=self._parse_tags_string(tags_str_from_form), created_at=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id:
self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_custom
self._all_customers_data[i]["first_name"] = first_name
mer = CustomerData( customer_id=self._next_customer_id, first_name=first_name, last_name=last_name, email=email_from_form, phone=form_data.get("phone"), status=status, avatar_url="/favicon.ico", role=role_from_form, tags=self._parse_tags_string(tags_str_from_form), created_at=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False s
self._all_customers_data[i]["last_name"] = last_name
first_name=first_name, last_name=last_name, email=email_from_form, phone=form_data.get("phone"), status=status, avatar_url="/favicon.ico", role=role_from_form, tags=self._parse_tags_string(tags_str_from_form), created_at=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_cu
self._all_customers_data[i]["email"] = email_from_form
email=email_from_form, phone=form_data.get("phone"), status=status, avatar_url="/favicon.ico", role=role_from_form, tags=self._parse_tags_string(tags_str_from_form), created_at=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers
self._all_customers_data[i]["status"] = status
ata.get("phone"), status=status, avatar_url="/favicon.ico", role=role_from_form, tags=self._parse_tags_string(tags_str_from_form), created_at=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_f
self._all_customers_data[i]["role"] = role_from_form
rl="/favicon.ico", role=role_from_form, tags=self._parse_tags_string(tags_str_from_form), created_at=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tag
self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form )
=datetime.datetime.now().isoformat(), updated_at=datetime.datetime.now().isoformat(), selected=False, ) self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form )
customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.
self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() )
self._all_customers_data.append(new_customer) self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() )
break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected
customer_found = True
self._next_customer_id += 1 toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break
toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_custome
if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return
toast_message = "User added successfully!" else: customer_found = False for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found:
return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event de
self.error_message = f"Customer with ID {customer_id} not found."
e for i, cust in enumerate(self._all_customers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return
self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after
toast_message = "User updated successfully!"
mers_data): if cust["customer_id"] == customer_id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!"
self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(
self._target_customer_email_for_tags = email_from_form
id: self._all_customers_data[i]["first_name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form
self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_custom
self._target_customer_tag_str = tags_str_from_form
name"] = first_name self._all_customers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form
self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id:
self._target_customer_role = role_from_form
tomers_data[i]["last_name"] = last_name self._all_customers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form
self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["sel
self.show_edit_dialog = False
stomers_data[i]["email"] = email_from_form self._all_customers_data[i]["status"] = status self._all_customers_data[i]["role"] = role_from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields()
yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"]
self.total_db_customers = len(self._all_customers_data)
from_form self._all_customers_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event
@rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_
def set_form_status(self, status: str): self.form_status = status
s_data[i]["tags"] = self._parse_tags_string( tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str):
@rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_
self.form_status = status
tags_str_from_form ) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event
@rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(
def set_form_tags(self, tags: str): self.form_tags = tags
) self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str):
@rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(
self.form_tags = tags
self._all_customers_data[i]["updated_at"] = ( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event
@rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data:
def set_form_role(self, role: str): self.form_role = role
( datetime.datetime.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str):
@rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data:
self.form_role = role
me.now().isoformat() ) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event
@rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000,
def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected
) customer_found = True break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self):
for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first
self.all_selected = not self.all_selected
break if not customer_found: self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected
@rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000,
for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected
self.error_message = f"Customer with ID {customer_id} not found." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)):
@rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000,
self._all_customers_data[i]["selected"] = self.all_selected
." return toast_message = "User updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event
@rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_da
def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle
updated successfully!" self._target_customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int):
found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try
all_are_selected_after_toggle = True
customer_email_for_tags = email_from_form self._target_customer_tag_str = tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True
for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_expor
found = False
tags_str_from_form self._target_customer_role = role_from_form self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)):
if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name":
if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True
self.show_edit_dialog = False self._reset_form_fields() self.total_db_customers = len(self._all_customers_data) yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id:
found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"],
self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"]
yield CustomerState.fetch_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"]
if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name":
found = True
_customers yield rx.toast(toast_message, duration=3000) @rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True
if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"],
if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False
@rx.event def set_form_status(self, status: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]:
if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"],
all_are_selected_after_toggle = False
tatus: str): self.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False
@rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_da
if found: self.all_selected = all_are_selected_after_toggle
elf.form_status = status @rx.event def set_form_tags(self, tags: str): self.form_tags = tags @rx.event def set_form_role(self, role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found:
@rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_da
self.all_selected = all_are_selected_after_toggle
role: str): self.form_role = role @rx.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self:
self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data:
if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return
x.event def toggle_select_all(self): self.all_selected = not self.all_selected for i in range(len(self._all_customers_data)): self._all_customers_data[i]["selected"] = self.all_selected @rx.event def toggle_select_customer(self, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data:
yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["cr
self.error_message = "No customer data available to download. Please fetch customers first."
lf, customer_id: int): all_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return
self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self:
self.loading = True
ll_are_selected_after_toggle = True found = False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True
try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message =
self.error_message = ""
= False for i in range(len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try:
for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message = "No customers to download." y
df_export_data = []
len(self._all_customers_data)): if self._all_customers_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = []
if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.
for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } )
rs_data[i]["customer_id"] == customer_id: self._all_customers_data[i]["selected"] = not self._all_customers_data[ i ]["selected"] found = True if not self._all_customers_data[i]["selected"]: all_are_selected_after_toggle = False if found: self.all_selected = all_are_selected_after_toggle @rx.event(background=True) async def download_csv(self): async with self: if not self._all_customers_data: self.error_message = "No customer data available to download. Please fetch customers first." yield rx.toast( "No customer data to download.", duration=3000, ) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data:
df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000,
tags_str_repr = ", ".join(cust_data_item["tags"])
) return self.loading = True self.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } )
df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return
lf.error_message = "" try: df_export_data = [] for cust_data_item in self._all_customers_data: tags_str_repr = ", ".join(cust_data_item["tags"]) df_export_data.append( { "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self:
yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
self.error_message = "No customers to download."
{ "ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return
csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
df = pd.DataFrame(df_export_data)
"ID": cust_data_item["customer_id"], "First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data)
filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
csv_data = df.to_csv(index=False)
"First Name": cust_data_item["first_name"], "Last Name": cust_data_item["last_name"], "Email": cust_data_item["email"], "Phone": cust_data_item.get("phone", ""), "Status": cust_data_item["status"], "Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False)
yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" )
"Role": cust_data_item["role"], "Tags": tags_str_repr, "Created At": cust_data_item["created_at"], "Updated At": cust_data_item["updated_at"], } ) if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self:
yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
self.error_message = f"Failed to download CSV: {e!s}"
} ) if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self:
@rx.event def set_search_query(self, query: str): self.search_query = query self.current_page = 1
self.loading = False
if not df_export_data: async with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event
def set_search_query(self, query: str): self.search_query = query self.current_page = 1
with self: self.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str):
self.current_page = 1
self.search_query = query
f.error_message = "No customers to download." yield rx.toast( "No customer data available to download.", duration=3000, ) return df = pd.DataFrame(df_export_data) csv_data = df.to_csv(index=False) filename = ( f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" ) yield rx.download(data=csv_data, filename=filename) yield rx.toast("CSV download started.", duration=3000) except Exception as e: async with self: self.error_message = f"Failed to download CSV: {e!s}" yield rx.toast( f"Error downloading CSV: {e!s}", duration=5000, ) finally: async with self: self.loading = False @rx.event def set_search_query(self, query: str): self.search_query = query
self.current_page = 1
from . import styles # Import all the pages. from .pages import * app = rx.App( style=styles.base_style, stylesheets=styles.base_stylesheets, html_lang="en", html_custom_attrs={"className": "!scroll-smooth"}, theme=rx.theme( appearance="inherit", has_background=True, scaling="100%", radius="none", accent_color="violet", ), )
import reflex as rx
import reflex as rx
# Import all the pages. from .pages import * app = rx.App( style=styles.base_style, stylesheets=styles.base_stylesheets, html_lang="en", html_custom_attrs={"className": "!scroll-smooth"}, theme=rx.theme( appearance="inherit", has_background=True, scaling="100%", radius="none", accent_color="violet", ), )
from . import styles
import reflex as rx from . import styles # Import all the pages.
app = rx.App( style=styles.base_style, stylesheets=styles.base_stylesheets, html_lang="en", html_custom_attrs={"className": "!scroll-smooth"}, theme=rx.theme( appearance="inherit", has_background=True, scaling="100%", radius="none", accent_color="violet", ), )
from .pages import *
sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px" sidebar_bg = rx.color("gray", 2) content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"] image_props = { "style": image_style, "width": "100%", "height": image_height, } button_props = { "size": "2", "cursor": "pointer", "variant": "outline", } box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
import reflex as rx
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}"
sidebar_bg = rx.color("gray", 2) content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"] image_props = { "style": image_style, "width": "100%", "height": image_height, } button_props = { "size": "2", "cursor": "pointer", "variant": "outline", } box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
content_max_width = "1280px"
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px"
content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"] image_props = { "style": image_style, "width": "100%", "height": image_height, } button_props = { "size": "2", "cursor": "pointer", "variant": "outline", } box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
sidebar_bg = rx.color("gray", 2)
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px" sidebar_bg = rx.color("gray", 2)
image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"] image_props = { "style": image_style, "width": "100%", "height": image_height, } button_props = { "size": "2", "cursor": "pointer", "variant": "outline", } box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
content_bg_color = rx.color("gray", 1)
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px" sidebar_bg = rx.color("gray", 2) content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", }
image_props = { "style": image_style, "width": "100%", "height": image_height, } button_props = { "size": "2", "cursor": "pointer", "variant": "outline", } box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
image_height = ["400px", "500px", "650px", "850px"]
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px" sidebar_bg = rx.color("gray", 2) content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"]
button_props = { "size": "2", "cursor": "pointer", "variant": "outline", } box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
image_props = { "style": image_style, "width": "100%", "height": image_height, }
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px" sidebar_bg = rx.color("gray", 2) content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"] image_props = { "style": image_style, "width": "100%", "height": image_height, }
box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
button_props = { "size": "2", "cursor": "pointer", "variant": "outline", }
import reflex as rx sidebar_width = ["100%", "100%", "100%", "375px", "450px"] border = f"1.5px solid {rx.color('gray', 5, True)}" content_max_width = "1280px" sidebar_bg = rx.color("gray", 2) content_bg_color = rx.color("gray", 1) image_style = { "decoding": "auto", "loading": "eager", "vertical_align": "middle", "object_fit": "contain", "width": "auto", } image_height = ["400px", "500px", "650px", "850px"] image_props = { "style": image_style, "width": "100%", "height": image_height, } button_props = { "size": "2", "cursor": "pointer", "variant": "outline", }
base_stylesheets = [ "https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap", "react-zoom.css", ] base_style = { "font_family": "Roboto Flex", rx.icon: { "stroke_width": "1.75px", }, }
box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"
import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return
import asyncio
import asyncio
import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_u
import datetime
import asyncio import datetime import os
import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield
from enum import Enum
import asyncio import datetime import os from enum import Enum
import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wai
import reflex as rx
import asyncio import datetime import os from enum import Enum import reflex as rx
import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image t
import replicate
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests
DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return
from .options import OptionsState
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self:
DEFAULT_IMAGE = "/default.webp"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp"
CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsSt
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensio
class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum):
PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter
STARTING = "starting"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting"
SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") ret
PROCESSING = "processing"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing"
FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = {
SUCCEEDED = "succeeded"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded"
CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width":
FAILED = "failed"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed"
class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensio
CANCELED = "canceled"
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event
@rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.schedule
def set_output_image(self, value: str): self.output_image = value
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str):
@rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.schedule
self.output_image = value
import asyncio import datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set
if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = O
if not self._check_api_token(): return
ort datetime import os from enum import Enum import reflex as rx import replicate import requests from .options import OptionsState DEFAULT_IMAGE = "/default.webp" API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return
async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create(
if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return
PI_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" CopyLocalState = rx._x.client_state(default=False, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self:
# If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f",
Options = await self.get_state(OptionsState)
e, var_name="copying") class ResponseStatus(Enum): STARTING = "starting" PROCESSING = "processing" SUCCEEDED = "succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty
input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self:
if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return
"succeeded" FAILED = "failed" CANCELED = "canceled" class GeneratorState(rx.State): is_generating: bool = False is_upscaling: bool = False _request_id: str = None output_image: str = DEFAULT_IMAGE output_list: list[str] = [] upscaled_image: str = "" is_downloading: bool = False @rx.event def set_output_image(self, value: str): self.output_image = value @rx.event(background=True) async def generate_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return
# Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in (
input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, }
if not self._check_api_token(): return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0
# Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ):
if Options.seed != 0: input["seed"] = Options.seed
return if self.is_upscaling: yield rx.toast.warning("Wait for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0:
# Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ):
input["seed"] = Options.seed
for the image to upscale first") return async with self: Options = await self.get_state(OptionsState) # If prompt is empty if Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API
if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}"
response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, )
f Options.prompt == "": yield rx.toast.warning("Please enter a prompt") return input = { "width": Options.selected_dimensions[0], "height": Options.selected_dimensions[1], "prompt": Options.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, )
async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self:
if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return
tions.prompt + Options.selected_style_prompt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self:
self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = re
self.is_generating = True
pt, "negative_prompt": Options.negative_prompt, "num_inference_steps": Options.steps, "num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True
yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = response.output[0] self.output_li
self._request_id = response.id
"num_outputs": Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header")
async with self: self.upscaled_image = "" self.output_image = response.output[0] self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.toast.warning("Please generate an image first") return if self.upscaled_image != "": yield rx.toast.warning("Image already upscaled")
while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15)
Options.num_outputs, "scheduler": Options.scheduler, "guidance_scale": Options.guidance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True:
async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = response.output[0] self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._res
response = await replicate.predictions.async_get(response.id)
ance_scale, } # Add "seed" to the input if it is not 0 if Options.seed != 0: input["seed"] = Options.seed # Await the output from the replicate API response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self:
await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = response.output[0] self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.toast.warning("Please generate an image first") return if self.upscaled_image != "": yield rx.
if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break
response = await replicate.predictions.async_create( "5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f", input=input, ) if response.status != ResponseStatus.STARTING.value or not response: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state()
return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = response.output[0] self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.t
if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" )
se: async with self: self._reset_state() yield rx.toast.error("Error starting generation") return async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return
await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = response.output[0] self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.toast.warning("Please generate an image first") return if self.upscaled_image != "": yield rx.
elif response.status == ResponseStatus.SUCCEEDED.value: break
async with self: self.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self:
self.output_image = response.output[0] self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.toast.warning("Please generate an image first") return if self.upscaled_image != "": yield rx.toast.warning("Image already upscaled") return async with self: Opti
self.upscaled_image = ""
f.is_generating = True self._request_id = response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self: self.upscaled_image = ""
self.output_list = [] if len(response.output) == 1 else response.output self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.toast.warning("Please generate an image first") return if self.upscaled_image != "": yield rx.toast.warning("Image already upscaled") return async with self: Options = await self.get_state(OptionsState) in
self.output_image = response.output[0]
= response.id yield yield rx.scroll_to(elem_id="mobile-header") while True: response = await replicate.predictions.async_get(response.id) async with self: if response.status in ( ResponseStatus.CANCELED.value, ResponseStatus.FAILED.value, ): self._reset_state() if response.status == ResponseStatus.FAILED.value: yield rx.toast.warning( f"Error generating image: {response.error}" ) return elif response.status == ResponseStatus.SUCCEEDED.value: break await asyncio.sleep(0.15) async with self: self.upscaled_image = "" self.output_image = response.output[0]
self._reset_state() except Exception as e: async with self: self._reset_state() yield rx.toast.error(f"Error, please try again: {e}") @rx.event(background=True) async def upscale_image(self): try: # Check if the env variable is set if not self._check_api_token(): return if self.is_generating: yield rx.toast.warning("Wait for the image to generate first") return if self.output_image == DEFAULT_IMAGE: yield rx.toast.warning("Please generate an image first") return if self.upscaled_image != "": yield rx.toast.warning("Image already upscaled") return async with self: Options = await self.get_state(OptionsState) input = { "prompt": "masterpiece, best quality, highres, <lora:more_detail
self.output_list = [] if len(response.output) == 1 else response.output