admin¶
panel_flowdash.admin
¶
The admin view: the project file's sections as settings, for the app's administrators.
Every project file section registered with a settings_view is a section
of the admin view. general, theme, ai and permissions are built in. The setup
wizard (/admin/setup) walks a first admin through them.
ADMIN_ROUTE = '/admin'
module-attribute
¶
AI = ProjectSection('ai', load_ai, title='AI', icon='smart_toy', description='Model providers, the models people can pick in the assistant and Explore, and what they may spend.', dump=dump_ai, settings_view=ai_settings, group='App')
module-attribute
¶
GENERAL = ProjectSection('general', settings_loader(GENERAL_GROUPS), title='General', icon='tune', description="Behaviour and defaults for everyone using this app. Each dashboard's own settings still override the dashboard defaults.", settings_view=general_settings, group='App')
module-attribute
¶
MCP = ProjectSection(MCP_SECTION, load_mcp, title='MCP', icon='hub', description='Connect Model Context Protocol (MCP) servers to give the assistant and Explore extra tools. MCP tools require user approval by default.', dump=dump_mcp, settings_view=mcp_settings, group='App')
module-attribute
¶
PERMISSIONS = ProjectSection('permissions', load_permissions, title='Permissions', icon='admin_panel_settings', description="Who can use the app, who administers it, and what the agent may do on someone's behalf.", settings_view=permissions_settings, group='App')
module-attribute
¶
THEME = ProjectSection('theme', settings_loader(THEME_GROUPS), title='Theme', icon='palette', description='Colours, type and branding for every page, in light and dark.', settings_view=theme_settings, group='App')
module-attribute
¶
__all__ = ['ADMIN_ROUTE', 'AI', 'GENERAL', 'MCP', 'PERMISSIONS', 'THEME', 'AISettings', 'AdminPage', 'Group', 'MCPSettings', 'PermissionDialog', 'PermissionEditor', 'PermissionsForm', 'Setting', 'SettingsForm', 'SetupWizard', 'WizardStep', 'admin_path', 'admin_sections', 'admin_token', 'current_app', 'format_name_list', 'is_admin', 'known_principals', 'parse_name_list', 'project_overrides', 'settings_loader']
module-attribute
¶
AISettings
¶
Bases: Viewer
The AI section: provider cards, the models table, the model drawer and the key dialog.
editable = param.Boolean(default=True)
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
ai()
¶
Return the ai section as the file has it now.
close_key_dialog()
¶
Close the key dialog, forgetting a typed key.
close_model()
¶
Close the drawer without saving.
entries(ai=None)
¶
Return the models, those given in code first, and the default model's id.
open_key_dialog(name)
¶
Open the key dialog of provider name.
open_model(model_id)
¶
Open the drawer on model model_id, or on a new model for None.
providers(ai, entries)
¶
Return the providers shown: those of the models, then the others the file configures.
refresh()
¶
Draw the cards and the table from the project file.
remove_model(model_id)
¶
Remove model model_id, which the project file added, and the fallbacks to it.
save_key()
¶
Write the dialog's key (as a reference, or encrypted) or server URL and close it.
save_model()
¶
Write the drawer's model to the project file and close the drawer.
set_default(model_id)
¶
Make model_id the default model.
suggest_models()
async
¶
Offer the models listed by every provider with a key (or a configured local server).
test(name)
async
¶
Test provider name's key as the file has it and show the result on its card.
test_typed()
async
¶
Test the key the dialog describes, without saving it.
write(ai, message='Saved')
¶
Write ai as the project file's ai section; show its problems if it is rejected.
AdminPage
¶
Bases: Viewer
The admin view of a FlowDash app.
It lists every registered project file section that has a
settings_view and shows the selected one. A section whose view is a
SettingsForm gets the page's Save and Discard and the unsaved-changes
dot; any other view is shown as it is and saves on its own.
dirty = param.Boolean(default=False, doc='Whether a section has unsaved changes.')
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
section = param.String(default=None, allow_None=True, doc='The section shown.')
class-attribute
instance-attribute
¶
sections
property
¶
Return the sections listed, by name.
dirty_sections()
¶
Return the titles of the sections with unsaved changes.
discard(name=None)
¶
Put section name (the one shown by default) back to what is saved.
discard_all()
¶
Put every section back to what is saved.
save(name=None)
¶
Save section name (the one shown by default); False if it was rejected.
save_all()
¶
Save every section with unsaved changes; False if one was rejected.
select(name)
¶
Show section name, through the app's routing when it has one.
show(name)
¶
Show section name, or the first one when it is not listed.
view(name)
¶
Return the settings view of section name, building it the first time.
Group
dataclass
¶
MCPSettings
¶
Bases: Viewer
MCP server configuration cards, discovered tools and admin edit drawer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
The loaded :class: |
required |
editable
|
bool
|
True for administrators (shows Add/Edit/Test/Delete/Enable controls); False for read-only viewers (hides secrets, stdio commands and edit controls). |
True
|
app
|
Any
|
The live :class: |
None
|
server_filter
|
Callable[[MCPServerConfig], bool] | None
|
Optional predicate |
None
|
tool_filter
|
Callable[[str, str], bool] | None
|
Optional predicate |
None
|
server_extra
|
Callable[[MCPServerConfig, bool], Any] | None
|
Optional callable |
None
|
show_access
|
bool
|
Whether to show built-in |
True
|
show_add
|
bool
|
Whether to render the section's top |
True
|
on_change
|
Callable[[], None] | None
|
Optional callback invoked with no arguments after a server is saved, toggled or removed. |
None
|
editable = param.Boolean(default=True)
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
close_server()
¶
Close the drawer without saving and clear typed secrets.
mcp_data()
¶
Return the mcp section as the project file has it now.
open_server(name=None)
¶
Open the configuration drawer for server name, or a new server when None.
refresh()
¶
Redraw the server cards from the project file and cached status checks.
remove_server(name)
¶
Remove file-configured MCP server name from flowdash.yaml.
save_server()
¶
Validate and save the drawer's MCP server to flowdash.yaml.
servers()
¶
Return configured MCP servers, merging code-defined and project file servers.
test_server(name)
async
¶
Test connection to server name, cache its tools and refresh the card.
toggle_server(name, enabled)
¶
Enable or disable file-configured server name.
write(data)
¶
Write data as the project file's mcp section after re-checking admin rights.
PermissionDialog
¶
Bases: Viewer
Modal dialog hosting a :class:PermissionEditor.
editor = PermissionEditor(framed=False, show_title=False, show_actions=True, save_label=save_label, app=app, project=project, effective_display=effective_display, lockout_check=lockout_check, effective_stylesheets=effective_stylesheets, on_save=self._handle_save, on_cancel=self.close)
instance-attribute
¶
is_open
property
¶
Whether the dialog is currently open.
close()
¶
Close the dialog.
open(title, permission, on_save, *, app=None, project=None, effective_display=_UNSET, lockout_check=_UNSET)
¶
Populate the dialog's editor and open it.
PermissionEditor
¶
Bases: Viewer
Admin editor for a :class:~panel_flowdash.auth.Permission's allow/deny fields.
Can be used standalone (show_actions=True, framed=True or in a
dialog) or embedded inside another form or drawer (show_actions=False,
framed=False).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permission
|
Permission | None
|
Initial :class: |
None
|
title
|
str
|
Heading text shown when show_title is True. |
'Edit access rules'
|
caption_text
|
str
|
Secondary helper text shown above the fields. |
'Comma-separated user or group names. Leave all fields empty to clear this rule.'
|
save_label
|
str
|
Label for the primary save button when show_actions is True. |
'Save access'
|
framed
|
bool
|
Whether to wrap the editor in an outlined |
True
|
show_actions
|
bool
|
Whether to render the Clear / Cancel / Save button row. |
True
|
show_title
|
bool | None
|
Whether to render the title above the caption; defaults to framed. |
None
|
disabled
|
bool
|
When True, disables all inputs and save/clear actions. |
False
|
app
|
Any
|
Optional app and project used by :func: |
None
|
project
|
Any
|
Optional app and project used by :func: |
None
|
effective_display
|
Callable[[Permission], Any] | None
|
Optional hook |
None
|
lockout_check
|
Callable[[Permission], str | None] | None
|
Optional hook |
None
|
on_save
|
Callable[[Permission], Sequence[Problem | str] | None] | None
|
Optional callback |
None
|
on_cancel
|
Callable[[], Any] | None
|
Optional callback invoked by :meth: |
None
|
on_change
|
Callable[[Permission], Any] | None
|
Optional callback |
None
|
effective_stylesheets
|
Sequence[str]
|
Extra CSS stylesheets attached to the HTML cell used when effective_display returns an HTML string. |
()
|
css_classes
|
Sequence[str]
|
Additional CSS classes added to the outer layout element. |
()
|
allow_groups_input
property
¶
Text input for allow_groups.
allow_users_input
property
¶
Text input for allow_users.
deny_groups_input
property
¶
Text input for deny_groups.
deny_users_input
property
¶
Text input for deny_users.
disabled = param.Boolean(default=False)
class-attribute
instance-attribute
¶
cancel()
¶
Clear problems and invoke on_cancel.
clear()
¶
Clear all four fields.
load(permission=None, *, title=None, app=None, project=None, disabled=None, effective_display=_UNSET, lockout_check=_UNSET)
¶
Populate the editor from permission and refresh hints and live previews.
permission()
¶
Return the :class:~panel_flowdash.auth.Permission represented by the inputs.
refresh_preview()
¶
Re-evaluate effective_display and lockout_check for the current inputs.
save()
¶
Invoke on_save with the current permission; show any returned problems.
show_problems(problems)
¶
Display validation or save problems in the editor's error alert.
PermissionsForm
¶
Bases: SettingsForm
The Permissions section, saved with the admin page's Save like the other forms.
extra
property
¶
Return the people, assistant groups, sensitive components and rules as edited.
add_pattern(pattern=None)
¶
Mark the components matching pattern (or the one typed) as sensitive.
add_person(user=None)
¶
List user (or the name typed) so their groups and assistant can be set.
add_rule(tool=None, when=None)
¶
Ask before calls to tool, or only those whose argument has a value (name=value).
changes()
¶
Return what changed since the form was loaded or saved, the tables included.
enable_rule(index, enabled)
¶
Turn the project file's rule index on or off.
people()
¶
Return everyone the app knows of, with their groups, role, dashboards and last visit.
remove_pattern(pattern)
¶
Stop treating the components matching pattern as sensitive, unless code says so.
remove_person(user)
¶
Drop what the project file says about user.
remove_rule(index)
¶
Remove the project file's rule index.
reset()
¶
Put the controls and tables back to the saved values.
save()
¶
Write the section and redraw the tables from what was saved.
set_assistant(user, allowed)
¶
Give the assistant to user, or keep it from them.
set_groups(user, groups)
¶
Give user groups, on top of those from code and sign-in.
Setting
dataclass
¶
One setting of a section: a key of the section's mapping and how it is edited.
kind picks the control: "switch" (on or off), "choice" (a
row of toggle buttons), "select", "number", "text",
"color" (swatches and a hex field), "slider", "names" (a
list of names, e.g. users, with a field to add one) or "numbers",
which lays out its parts (number settings) in a row under the label.
options maps labels to values, or is a callable returning that
mapping when the form is built. target names the app parameter the
setting configures, e.g. "home_dashboard" or
"editor_options.mode"; one the app was given in code shows locked,
with the parameter's value turned into the setting's by from_target.
validate(value, section) returns why a value the loader reads is
not acceptable, beyond what kind checks. normalize(name, app)
rewrites a name typed into a "names" setting before it is added.
allow_none = False
class-attribute
instance-attribute
¶
bounds = None
class-attribute
instance-attribute
¶
default = None
class-attribute
instance-attribute
¶
description = ''
class-attribute
instance-attribute
¶
from_target = None
class-attribute
instance-attribute
¶
integer = False
class-attribute
instance-attribute
¶
key
instance-attribute
¶
kind = 'switch'
class-attribute
instance-attribute
¶
label
instance-attribute
¶
normalize = None
class-attribute
instance-attribute
¶
options = None
class-attribute
instance-attribute
¶
parts = ()
class-attribute
instance-attribute
¶
step = None
class-attribute
instance-attribute
¶
swatches = ()
class-attribute
instance-attribute
¶
target = None
class-attribute
instance-attribute
¶
unit = ''
class-attribute
instance-attribute
¶
validate = None
class-attribute
instance-attribute
¶
check(value)
¶
Return why value is not valid for this setting, or None.
leaves()
¶
Return the settings holding a value: the parts of a "numbers" row, else itself.
resolved_options()
¶
Return the options' labels and values.
SettingsForm
¶
Bases: Viewer
The settings of one project file section, laid out in titled groups.
project and section name what is edited. The form starts from
to_form(project.get(section)) (by default the section's value as a
mapping) and save writes from_form(value) with Project.set.
Settings whose target the app was given in code, and those the
project context lists under locked_settings[section] (a mapping of
key to where it is set), are read-only with that source shown.
aside is shown next to the groups and below maps a setting's
key to a function that, given the form, returns a component to show
under the setting's row.
dirty = param.Boolean(default=False, doc='Whether a control differs from the saved value.')
class-attribute
instance-attribute
¶
editable = param.Boolean(default=True, doc='Whether the settings may be changed.')
class-attribute
instance-attribute
¶
groups = list(groups)
instance-attribute
¶
initial
property
¶
Return the values the form started from, defaults filled in.
locks
property
¶
Return where each locked setting is set, by key.
problems = param.List(default=[], doc='The problems shown, from the last save or load.')
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
section = section
instance-attribute
¶
values
property
¶
Return every setting's current value, from the controls.
changes()
¶
Return the settings changed in the controls since the form was loaded or saved.
lock(locks)
¶
Make the settings locks names read-only, showing where each is set.
reset()
¶
Put every control back to the saved value and clear the problems.
save()
¶
Write the form's value to the project file; show the problems if it is rejected.
show_problems(problems)
¶
Show problems at the fields their keys name, the others above the form.
value()
¶
Return the section's value to write: the changes over what the file has now.
The file is read again, so settings another admin saved since this form was loaded are kept unless this form changed them too.
widget(key)
¶
Return the control that edits the setting key.
SetupWizard
¶
Bases: Viewer
The setup wizard: its steps, then Review, which writes them with Finish.
on_close(finished) is called when Finish wrote the reviewed sections (True) or the wizard was cancelled (False).
plan = {}
instance-attribute
¶
problems = []
instance-attribute
¶
project = project
instance-attribute
¶
review_index
property
¶
Return the index of Review, the last step.
skipped = set()
instance-attribute
¶
step = param.Integer(default=0, doc='The index of the step shown; the last is Review.')
class-attribute
instance-attribute
¶
steps = wizard_steps(project, app)
instance-attribute
¶
titles
property
¶
Return the steps' labels, Review included.
written = []
instance-attribute
¶
back()
¶
Go back a step.
cancel()
¶
Leave the wizard without writing anything.
diff()
¶
Return the reviewed sections' YAML lines, old and new, as (kind, text).
finish()
¶
Write the reviewed sections with Project.set; False, writing nothing, on a problem.
next()
¶
Go on to the next step, or finish on Review.
review()
¶
Collect what each step not skipped writes, by section, and check it.
The result is what Finish writes. Sections the file already has as they would be written are left out.
show(index)
¶
Show step index; Review when it is the last.
skip()
¶
Leave this step's settings out and go on; on Welcome, leave the wizard.
WizardStep
¶
Bases: Viewer
A step of the setup wizard.
changes returns the sections to write, by name, each a value for
Project.set; it is asked when Review opens, and Finish writes exactly
what it returned then. It may raise ValueError to say why the step
cannot be written as it is. summary returns the lines of the step's
card on Review.
caption = param.String(default='', doc='The line under the label.')
class-attribute
instance-attribute
¶
description = param.String(default='', doc='The text under the page title.')
class-attribute
instance-attribute
¶
heading = param.String(default='', doc="The step's page title.")
class-attribute
instance-attribute
¶
icon = param.String(default='settings', doc="The step's icon on Review.")
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
title = param.String(default='', doc="The step's label in the stepper.")
class-attribute
instance-attribute
¶
changes()
¶
Return the sections this step writes, by name; none by default.
confirmations()
¶
Return what the admin must confirm on Review before Finish writes this step.
finalize(name, value)
¶
Return section name's reviewed value as Finish writes it; it as is by default.
A step whose Review shows a placeholder, such as a key to encrypt, replaces it here, so nothing is made before the admin finishes.
summary()
¶
Return what the step will do, one line each, for its card on Review.
view()
¶
Return the step's page below its title.
admin_path(prefix='')
¶
Return the path of the admin link, with the token in its fragment.
admin_sections()
¶
Return the sections with a settings view: the built-in ones first, then by group and title.
Assets, which works on the asset store rather than the project file, is listed with them.
admin_token()
¶
Return this process's admin token, made when first asked for.
It is FLOWDASH_ADMIN_TOKEN when that is set, for scripted setups,
and otherwise random and new every time the server starts. Either way
it claims the admin view once per start (see consume_token).
current_app()
¶
Return the app whose admin view is building a section's settings view, if any.
format_name_list(names)
¶
Format a set or sequence of user or group names as comma-separated text.
is_admin(identity, admin_groups, admins=(), *, token=False)
¶
Whether identity may open the admin view.
Members of admin_groups may, and so may the users admins names (the
project file's general.admins, see entry_matches) and a session
that presented the admin token (token). Where the session connects
from is checked by the caller (see session_is_local).
known_principals(app=None, project=None)
¶
Discover known user and group names from app and project for helper hints.
parse_name_list(text)
¶
Split comma- or newline-separated user or group names, stripping blanks and duplicates.
project_overrides(project, in_code)
¶
Return the target values the project file's general and theme sections set.
A target in_code says the app was given in code is left out, so
code wins over the file.
settings_loader(groups)
¶
Return a section loader that checks a mapping of the groups' settings.
The loaded value is a dict of the keys the file sets. Every problem is reported at its key, an unknown key where it is written.
access
¶
Who may open the admin view: members of the admin groups, or whoever has the admin link.
The admin link bootstraps the first admin. Like Jupyter's token, the
server makes a random admin token when it starts and, while the project
has no admin yet, prints a link with it, /admin#token=.... The token
rides in the URL fragment, which browsers never send to the server, so it
shows up in no access log; the page hands it over the websocket instead.
Whoever opens the link is recorded in the project file's
general.admins and is admin on every later start, with no token.
Without sign-in, every visitor is the account that runs the server, so
admin rights without sign-in apply only to a browser on that machine: a
session whose client is a loopback address (see client_address).
general.admins names a local account as local:<name> and a
signed-in user as auth:<name>, so one never matches the other; a name
without either prefix, as earlier versions wrote, is a local account.
LOCAL_PREFIX = 'local:'
module-attribute
¶
SIGNED_IN_PREFIX = 'auth:'
module-attribute
¶
TOKEN_ENV = 'FLOWDASH_ADMIN_TOKEN'
module-attribute
¶
AdminTokenExchange
¶
Bases: JSComponent
Hands the admin token in the page's URL fragment to the server.
The fragment is removed from the address bar as soon as it is read, and the token is left out of Panel's log of the values the page sends.
token = param.String(default='', doc="The token the page's URL fragment carried.")
class-attribute
instance-attribute
¶
adding_admins_allowed()
¶
Whether the admin link may add an admin to a project that already has admins.
admin_entry(identity)
¶
Return how general.admins names identity, or None for an anonymous one.
admin_name(entry)
¶
Return the user name of a general.admins entry, without its prefix.
admin_names(entries, signed_in)
¶
Return the names of the entries that apply with sign-in, or without it.
admin_path(prefix='')
¶
Return the path of the admin link, with the token in its fragment.
admin_token()
¶
Return this process's admin token, made when first asked for.
It is FLOWDASH_ADMIN_TOKEN when that is set, for scripted setups,
and otherwise random and new every time the server starts. Either way
it claims the admin view once per start (see consume_token).
allow_adding_admins(allowed=True)
¶
Let the admin link add an admin to a project that already has admins, as --admin-link does.
check_token(candidate)
¶
Whether candidate is the admin token and unused, compared in constant time.
client_address(request, trusted_proxies=())
¶
Return the IP address of the client that sent request, or None if unknown.
It is the socket peer. When that peer is one of trusted_proxies, the
client is the last address in X-Forwarded-For that is not a trusted
proxy. A request with forwarding headers from a peer that is not trusted
has an unknown client, so a reverse proxy on the same machine never
makes its visitors local. Headers are read from the request the server
received, never from the session token.
consume_token(candidate)
¶
Use the admin token: True the first time candidate is the token, False ever after.
entry_matches(entry, identity)
¶
Whether the general.admins entry names identity.
A signed-in user matches only auth: entries; a session without
sign-in matches local: entries and unprefixed ones, which earlier
versions wrote for the local account.
has_sign_in(identity)
¶
Whether identity signed in: OAuth or basic auth with users, not one shared password.
is_admin(identity, admin_groups, admins=(), *, token=False)
¶
Whether identity may open the admin view.
Members of admin_groups may, and so may the users admins names (the
project file's general.admins, see entry_matches) and a session
that presented the admin token (token). Where the session connects
from is checked by the caller (see session_is_local).
is_loopback(address)
¶
Whether address is a loopback address, e.g. 127.0.0.1 or ::1.
namespaced_entry(name, signed_in)
¶
Return name, typed by an admin, as a general.admins entry.
A name with a prefix keeps it, written in lower case; any other is a signed-in user on a server with sign-in and a local account on one without.
reset_admin_token()
¶
Forget the admin token, so the next admin_token makes a new one, as a restart does.
session_is_local(doc, trusted_proxies=())
¶
Whether the session of Bokeh document doc comes from this machine.
A document without a server session (a script, a notebook or a test)
is local. A served session is local when the client of the request that
opened it is a loopback address (see client_address).
shared_password_sign_in()
¶
Whether users sign in with Panel's basic auth and one shared password.
With a shared password any user name is accepted, so the name proves nothing and does not count as sign-in for admin rights. Basic auth with a mapping (or JSON file) of users and passwords does count.
show_admin_link(base_url='')
¶
Print the admin link once per token, e.g. when the server starts.
It is printed rather than logged, so the token stays out of log files that are kept or shipped elsewhere. base_url is the server's address; without it only the path is printed.
socket_peer(request)
¶
Return the IP address of the socket that sent request, or None if it has none.
It is the TCP peer as Tornado accepted it, which --use-xheaders
does not rewrite; a Unix socket has no IP address.
ai
¶
The AI section of the admin view: model providers and their keys, and the models people may pick.
Each change is written to the project file's ai section as it is made,
and sessions started afterwards offer the models as it says. A key is
write-only: the page shows where it comes from and its last four
characters, never the key, and a key typed into the Replace key dialog is
cleared from the field as soon as it is saved or the dialog closes.
AI = ProjectSection('ai', load_ai, title='AI', icon='smart_toy', description='Model providers, the models people can pick in the assistant and Explore, and what they may spend.', dump=dump_ai, settings_view=ai_settings, group='App')
module-attribute
¶
NOT_ADMIN = 'You are no longer an admin of this project, so this was not done.'
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
AISettings
¶
Bases: Viewer
The AI section: provider cards, the models table, the model drawer and the key dialog.
editable = param.Boolean(default=True)
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
ai()
¶
Return the ai section as the file has it now.
close_key_dialog()
¶
Close the key dialog, forgetting a typed key.
close_model()
¶
Close the drawer without saving.
entries(ai=None)
¶
Return the models, those given in code first, and the default model's id.
open_key_dialog(name)
¶
Open the key dialog of provider name.
open_model(model_id)
¶
Open the drawer on model model_id, or on a new model for None.
providers(ai, entries)
¶
Return the providers shown: those of the models, then the others the file configures.
refresh()
¶
Draw the cards and the table from the project file.
remove_model(model_id)
¶
Remove model model_id, which the project file added, and the fallbacks to it.
save_key()
¶
Write the dialog's key (as a reference, or encrypted) or server URL and close it.
save_model()
¶
Write the drawer's model to the project file and close the drawer.
set_default(model_id)
¶
Make model_id the default model.
suggest_models()
async
¶
Offer the models listed by every provider with a key (or a configured local server).
test(name)
async
¶
Test provider name's key as the file has it and show the result on its card.
test_typed()
async
¶
Test the key the dialog describes, without saving it.
write(ai, message='Saved')
¶
Write ai as the project file's ai section; show its problems if it is rejected.
ProviderStatus
¶
ai_settings(project, editable)
¶
Build the AI section of the admin view.
dump_ai(value)
¶
Return the ai section as plain data, without empty parts.
offered_summary(entry)
¶
Return who a model is offered to, e.g. Assistant, Explore or Assistant · analysts.
provider_name(model_id)
¶
Return the provider a pydantic-ai model id names, e.g. openai for openai:gpt-5.
provider_status(ai, name)
¶
Return where provider name's key comes from and whether it works, without the key.
settings_summary(settings)
¶
Return a model's settings in a few words, e.g. temperature 0 · max tokens 1,000.
assets
¶
The Assets section of the admin view: every dashboard and chat in the store, whoever owns it.
It works on the asset store, not the project file. Share, Change owner, Prune history and Delete act on the selected assets after a confirmation; each checks again that the caller is an admin before it changes anything and is written to the admin log with who did it and when.
ASSETS = ProjectSection('assets', _no_section, title='Assets', icon='dashboard', description='Every dashboard and chat in the store, whoever owns it.', settings_view=assets_admin, group='Content')
module-attribute
¶
FILTERS = {'all': 'All', 'mine': 'Mine', 'private': 'Private', 'issues': 'Has issues', 'stale': 'Not opened in 90 days'}
module-attribute
¶
KIND_FILTERS = {'all': 'All kinds', DASHBOARD_KIND: 'Dashboards', REPORT_KIND: 'Reports', CHAT_KIND: 'Chats'}
module-attribute
¶
OLD_SECTION_NAMES = {'dashboards': 'assets'}
module-attribute
¶
PAGE_SIZE = 25
module-attribute
¶
STALE_DAYS = 90
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
AssetRow
dataclass
¶
What the Assets table shows for one asset.
access = ()
class-attribute
instance-attribute
¶
edited_by = None
class-attribute
instance-attribute
¶
history_bytes = 0
class-attribute
instance-attribute
¶
id
property
¶
issues = ()
class-attribute
instance-attribute
¶
last_opened = None
class-attribute
instance-attribute
¶
model
instance-attribute
¶
private = False
class-attribute
instance-attribute
¶
tiles = 0
class-attribute
instance-attribute
¶
versions = 0
class-attribute
instance-attribute
¶
AssetsAdmin
¶
Bases: Viewer
The Assets section: the table, its filters, the bulk bar and their dialogs.
editable = editable
instance-attribute
¶
filter = param.Selector(default='all', objects=list(FILTERS))
class-attribute
instance-attribute
¶
kind = param.Selector(default=DASHBOARD_KIND, objects=list(KIND_FILTERS), doc='The kind of asset the table lists, or all of them.')
class-attribute
instance-attribute
¶
page = param.Integer(default=0, bounds=(0, None))
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
selection = set()
instance-attribute
¶
ask(action, asset_ids=None)
¶
Open the confirmation of action (share, owner, download, prune, delete).
cancel()
¶
Close the confirmation without doing anything.
change_owner(asset_ids, owner)
¶
Give the assets to owner.
clear_selection()
¶
Select nothing.
confirm()
¶
Carry out the action the dialog asks to confirm.
counts()
¶
Return how many assets each filter chip shows.
delete(asset_ids)
¶
Delete the assets and their history.
download(asset_ids)
¶
Download the assets as YAML, several in a zip file.
duplicate(asset_id)
¶
Copy a dashboard as "<title> copy", owned by the admin and not shared.
home_dashboard()
¶
Return the id or title the app opens as its home page, if any.
home_locked()
¶
Return where the home page is set in code, if it is.
load_rows()
¶
Read every asset of the chosen kind in the store with its history, access and health.
make_home(asset_id)
¶
Make asset_id the app's home page, in the project file's general section.
prune(asset_ids, keep)
¶
Drop all but the latest keep versions of each dashboard's history.
refresh()
¶
Read the store again and redraw everything.
run(action, asset_id)
¶
Run the row menu's action on asset_id.
select(asset_id, selected=True)
¶
Add asset_id to the selection, or take it out.
share(asset_ids, who, names=())
¶
Set who can view the dashboards: everyone, the owner only or names.
visible()
¶
Return the assets the filter chip passes.
assets_admin(project, editable)
¶
Build the Assets section of the admin view.
history_stats(records)
¶
Return a stored history's number of versions, their size and who made the latest.
components
¶
The Components section of the admin view: every registered component, and who may place it.
It edits the project file's components section (see
panel_flowdash.component_settings). The table's switch turns a
component off or on at once; the drawer shows what the component is and
saves who may place it, and whether the agent needs approval to, with
Done.
COMPONENTS = ProjectSection('components', load_components, title='Components', icon='widgets', description="Everything people can place on a dashboard: the project's own, the built-in ones and installed libraries.", dump=dump_components, settings_view=components_settings, group='Content')
module-attribute
¶
FILTERS = {**ROLE_FILTERS, 'off': 'Off'}
module-attribute
¶
ComponentsSettings
¶
Bases: Viewer
The Components section: the table of registered components and a drawer for one of them.
editable = param.Boolean(default=True)
class-attribute
instance-attribute
¶
filter = param.Selector(default='all', objects=list(FILTERS))
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
query = param.String(default='')
class-attribute
instance-attribute
¶
selected = param.String(default=None, allow_None=True, doc='The component the drawer shows.')
class-attribute
instance-attribute
¶
close_component()
¶
Close the drawer without saving.
counts(rows)
¶
Return how many rows each filter chip shows.
done()
¶
Save the drawer's access settings, if they changed, and close it.
open_component(component_id)
¶
Open the drawer on component_id.
refresh()
¶
Draw the chips and the table from the registry and the project file.
rows()
¶
Return what the table shows for each registered component, in display order.
sensitive_lock(component_id)
¶
Return where a pattern marking component_id sensitive is set, outside this section.
set_access(component_id, placed_by, approval=None)
¶
Save who may place component_id and whether the agent needs approval to.
set_enabled(component_id, enabled)
¶
Turn component_id on or off for everyone, writing the project file at once.
settings()
¶
Return the components section as the file has it now.
visible_rows()
¶
Return the rows passing the search and the filter chip.
component_source(entry, project_dir=None)
¶
Return where a component comes from: project, built in or a library and its version.
components_settings(project, editable)
¶
Build the Components section of the admin view.
form
¶
A settings form for a project file section, as the admin view shows it.
A section's settings_view may return any Panel component. Returning a
SettingsForm instead lets the admin view drive it: the page's Save writes
the form's value with Project.set, Discard resets it, the unsaved dot
follows its dirty and a rejected value's problems are shown at the
fields their Problem.keys name.
KINDS = ('switch', 'choice', 'select', 'number', 'text', 'color', 'slider', 'numbers', 'names')
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Group
dataclass
¶
Setting
dataclass
¶
One setting of a section: a key of the section's mapping and how it is edited.
kind picks the control: "switch" (on or off), "choice" (a
row of toggle buttons), "select", "number", "text",
"color" (swatches and a hex field), "slider", "names" (a
list of names, e.g. users, with a field to add one) or "numbers",
which lays out its parts (number settings) in a row under the label.
options maps labels to values, or is a callable returning that
mapping when the form is built. target names the app parameter the
setting configures, e.g. "home_dashboard" or
"editor_options.mode"; one the app was given in code shows locked,
with the parameter's value turned into the setting's by from_target.
validate(value, section) returns why a value the loader reads is
not acceptable, beyond what kind checks. normalize(name, app)
rewrites a name typed into a "names" setting before it is added.
allow_none = False
class-attribute
instance-attribute
¶
bounds = None
class-attribute
instance-attribute
¶
default = None
class-attribute
instance-attribute
¶
description = ''
class-attribute
instance-attribute
¶
from_target = None
class-attribute
instance-attribute
¶
integer = False
class-attribute
instance-attribute
¶
key
instance-attribute
¶
kind = 'switch'
class-attribute
instance-attribute
¶
label
instance-attribute
¶
normalize = None
class-attribute
instance-attribute
¶
options = None
class-attribute
instance-attribute
¶
parts = ()
class-attribute
instance-attribute
¶
step = None
class-attribute
instance-attribute
¶
swatches = ()
class-attribute
instance-attribute
¶
target = None
class-attribute
instance-attribute
¶
unit = ''
class-attribute
instance-attribute
¶
validate = None
class-attribute
instance-attribute
¶
check(value)
¶
Return why value is not valid for this setting, or None.
leaves()
¶
Return the settings holding a value: the parts of a "numbers" row, else itself.
resolved_options()
¶
Return the options' labels and values.
SettingsForm
¶
Bases: Viewer
The settings of one project file section, laid out in titled groups.
project and section name what is edited. The form starts from
to_form(project.get(section)) (by default the section's value as a
mapping) and save writes from_form(value) with Project.set.
Settings whose target the app was given in code, and those the
project context lists under locked_settings[section] (a mapping of
key to where it is set), are read-only with that source shown.
aside is shown next to the groups and below maps a setting's
key to a function that, given the form, returns a component to show
under the setting's row.
dirty = param.Boolean(default=False, doc='Whether a control differs from the saved value.')
class-attribute
instance-attribute
¶
editable = param.Boolean(default=True, doc='Whether the settings may be changed.')
class-attribute
instance-attribute
¶
groups = list(groups)
instance-attribute
¶
initial
property
¶
Return the values the form started from, defaults filled in.
locks
property
¶
Return where each locked setting is set, by key.
problems = param.List(default=[], doc='The problems shown, from the last save or load.')
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
section = section
instance-attribute
¶
values
property
¶
Return every setting's current value, from the controls.
changes()
¶
Return the settings changed in the controls since the form was loaded or saved.
lock(locks)
¶
Make the settings locks names read-only, showing where each is set.
reset()
¶
Put every control back to the saved value and clear the problems.
save()
¶
Write the form's value to the project file; show the problems if it is rejected.
show_problems(problems)
¶
Show problems at the fields their keys name, the others above the form.
value()
¶
Return the section's value to write: the changes over what the file has now.
The file is read again, so settings another admin saved since this form was loaded are kept unless this form changed them too.
widget(key)
¶
Return the control that edits the setting key.
current_app()
¶
Return the app whose admin view is building a section's settings view, if any.
settings_loader(groups)
¶
Return a section loader that checks a mapping of the groups' settings.
The loaded value is a dict of the keys the file sets. Every problem is reported at its key, an unknown key where it is written.
using_app(app)
¶
Make app the current_app while a settings view is built.
kit
¶
Building blocks of the admin sections: headings, chips and a table of Panel components.
DRAWER_SX = {'maxWidth': '100vw'}
module-attribute
¶
HEADING_SX = {'color': 'text.secondary', 'fontSize': '0.75rem', 'fontWeight': 500, 'letterSpacing': '1.2px', 'textTransform': 'uppercase'}
module-attribute
¶
KEY_SVG = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12.65 10C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H17v4h4v-4h2v-4zM7 14c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2"/></svg>'
module-attribute
¶
KIT_CSS = '\n:host { min-width: 0; }\n.k { font-family: inherit; font-size: 0.875rem; line-height: 1.43; letter-spacing: 0.15px;\n color: var(--mui-palette-text-primary); min-width: 0; }\n.k .main { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.k .mono { display: block; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 0.75rem;\n color: var(--mui-palette-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.k code { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 0.8125rem; }\n.k .muted { color: var(--mui-palette-text-secondary); }\n.k .small { font-size: 0.75rem; letter-spacing: 0.4px; }\n.k .lock { display: inline-flex; align-items: center; gap: 3px; font-size: 0.75rem;\n color: var(--mui-palette-text-secondary); letter-spacing: 0.4px; white-space: nowrap; }\n.k svg { width: 14px; height: 14px; fill: currentColor; flex: 0 0 auto; }\n.k .chip { display: inline-block; padding: 1px 7px; margin: 1px 4px 1px 0; border-radius: 10px;\n font-size: 0.75rem; line-height: 1.5; letter-spacing: 0.3px; white-space: nowrap;\n background: rgba(var(--mui-palette-text-primaryChannel) / 0.08);\n color: var(--mui-palette-text-primary); }\n.k .chip.outlined { background: transparent; border: 1px solid var(--mui-palette-divider); }\n.k .chip.success { background: rgba(var(--mui-palette-success-mainChannel) / 0.14);\n color: var(--mui-palette-success-dark, #1b5e20); }\n.k .chip.error { background: rgba(var(--mui-palette-error-mainChannel) / 0.12);\n color: var(--mui-palette-error-main, #d32f2f); }\n.k .chip.warning { background: rgba(var(--mui-palette-warning-mainChannel) / 0.14);\n color: var(--mui-palette-warning-dark, #e65100); }\n.k .chip.primary { background: rgba(var(--mui-palette-primary-mainChannel) / 0.12);\n color: var(--mui-palette-primary-text, var(--mui-palette-primary-main)); }\n.k .spend { display: flex; justify-content: space-between; gap: 8px; font-size: 0.75rem; }\n.k .bar { height: 4px; border-radius: 2px; margin-top: 4px;\n background: rgba(var(--mui-palette-text-primaryChannel) / 0.12); overflow: hidden; }\n.k .bar i { display: block; height: 100%; background: var(--mui-palette-primary-main); }\n.k .bar i.warning { background: var(--mui-palette-warning-main); }\n.k .bar i.error { background: var(--mui-palette-error-main); }\n.k .error-text { color: var(--mui-palette-error-main, #d32f2f); }\n:host-context(.dark) .k .chip.success, :host-context([data-mui-color-scheme="dark"]) .k .chip.success {\n color: var(--mui-palette-success-light, #81c784); }\n'
module-attribute
¶
LINK_SVG = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M17 16l-4-4V8.82C14.16 8.4 15 7.3 15 6c0-1.66-1.34-3-3-3S9 4.34 9 6c0 1.3.84 2.4 2 2.82V12l-4 4H3v5h5v-3.05l4-4.2 4 4.2V21h5v-5z"/></svg>'
module-attribute
¶
LOCK_SVG = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"/></svg>'
module-attribute
¶
Table
¶
Bases: Viewer
A table of Panel components in an outlined box, with a header row and an optional footer.
columns pairs each title (text, or a component such as a select-all
checkbox) with its width: "64px" or a share of what is left,
"2fr". Each row is a sequence of components, one per column.
set_rows(rows)
¶
Show rows, each a key (its CSS class suffix) and its cells.
caption(text, **params)
¶
Return secondary caption text.
cell(markup, **params)
¶
Return an HTML cell in the kit's style; markup must already be escaped.
chip(text, tone='')
¶
Return a small chip; tone is success, error, warning, primary or outlined.
clear_text(widget)
¶
Empty a text field, including what the browser last reported typing.
esc(value)
¶
Return value as escaped text.
field_size(width)
¶
Return the sizing of a text field width px wide that shrinks to fit a phone.
heading(text, *aside, margin=(24, 0, 8, 0))
¶
Return a section heading in overline style, with aside on the right.
lock(text, where=None)
¶
Return the lock note of something set in code: text, with where as its tooltip.
mcp
¶
The MCP section of the admin view: MCP servers, credentials, approvals and discovered tools.
Each change is written to the project file's mcp section as it is made,
and agent runs pick it up on the next request. Secrets (HTTP bearer tokens,
headers and stdio env vars) are write-only: the UI shows where each comes
from and its last four characters for admins, never the value, and clears
typed secrets as soon as they are saved or the drawer closes.
Host apps such as Lumen can embed :class:MCPSettings in their own section
(with editable=False for non-admins, show_add=False when the host
renders its own header button, server_extra for per-server host widgets,
and FlowDashApp.admin_section_redirects to hide/redirect /admin/mcp).
MCP = ProjectSection(MCP_SECTION, load_mcp, title='MCP', icon='hub', description='Connect Model Context Protocol (MCP) servers to give the assistant and Explore extra tools. MCP tools require user approval by default.', dump=dump_mcp, settings_view=mcp_settings, group='App')
module-attribute
¶
NOT_ADMIN = 'You are no longer an admin of this project, so this was not done.'
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
MCPSettings
¶
Bases: Viewer
MCP server configuration cards, discovered tools and admin edit drawer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
The loaded :class: |
required |
editable
|
bool
|
True for administrators (shows Add/Edit/Test/Delete/Enable controls); False for read-only viewers (hides secrets, stdio commands and edit controls). |
True
|
app
|
Any
|
The live :class: |
None
|
server_filter
|
Callable[[MCPServerConfig], bool] | None
|
Optional predicate |
None
|
tool_filter
|
Callable[[str, str], bool] | None
|
Optional predicate |
None
|
server_extra
|
Callable[[MCPServerConfig, bool], Any] | None
|
Optional callable |
None
|
show_access
|
bool
|
Whether to show built-in |
True
|
show_add
|
bool
|
Whether to render the section's top |
True
|
on_change
|
Callable[[], None] | None
|
Optional callback invoked with no arguments after a server is saved, toggled or removed. |
None
|
editable = param.Boolean(default=True)
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
close_server()
¶
Close the drawer without saving and clear typed secrets.
mcp_data()
¶
Return the mcp section as the project file has it now.
open_server(name=None)
¶
Open the configuration drawer for server name, or a new server when None.
refresh()
¶
Redraw the server cards from the project file and cached status checks.
remove_server(name)
¶
Remove file-configured MCP server name from flowdash.yaml.
save_server()
¶
Validate and save the drawer's MCP server to flowdash.yaml.
servers()
¶
Return configured MCP servers, merging code-defined and project file servers.
test_server(name)
async
¶
Test connection to server name, cache its tools and refresh the card.
toggle_server(name, enabled)
¶
Enable or disable file-configured server name.
write(data)
¶
Write data as the project file's mcp section after re-checking admin rights.
ServerStatus
¶
mcp_settings(project, editable)
¶
Build the MCP section of the admin view.
server_status(config, *, allowed_stdio=(), allowed_stdio_env=(), allowed_secret_env=None, project=None, project_key=None)
¶
Return the status chip, tone and detail message for config.
page
¶
The admin page: a list of the project file's sections and the selected section's settings.
ADMIN_ROUTE = '/admin'
module-attribute
¶
NARROW_WIDTH = 1100
module-attribute
¶
PHONE_WIDTH = 600
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
AdminPage
¶
Bases: Viewer
The admin view of a FlowDash app.
It lists every registered project file section that has a
settings_view and shows the selected one. A section whose view is a
SettingsForm gets the page's Save and Discard and the unsaved-changes
dot; any other view is shown as it is and saves on its own.
dirty = param.Boolean(default=False, doc='Whether a section has unsaved changes.')
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
section = param.String(default=None, allow_None=True, doc='The section shown.')
class-attribute
instance-attribute
¶
sections
property
¶
Return the sections listed, by name.
dirty_sections()
¶
Return the titles of the sections with unsaved changes.
discard(name=None)
¶
Put section name (the one shown by default) back to what is saved.
discard_all()
¶
Put every section back to what is saved.
save(name=None)
¶
Save section name (the one shown by default); False if it was rejected.
save_all()
¶
Save every section with unsaved changes; False if one was rejected.
select(name)
¶
Show section name, through the app's routing when it has one.
show(name)
¶
Show section name, or the first one when it is not listed.
view(name)
¶
Return the settings view of section name, building it the first time.
admin_sections()
¶
Return the sections with a settings view: the built-in ones first, then by group and title.
Assets, which works on the asset store rather than the project file, is listed with them.
permission_editor
¶
Reusable admin editor for per-resource :class:~panel_flowdash.auth.Permission rules.
Provides :class:PermissionEditor (embeddable inline in a drawer or form, or
standalone with Clear/Cancel/Save actions), :class:PermissionDialog (modal
dialog wrapper), and principal parsing/discovery helpers shared by MCP settings
and host apps such as Lumen.
PermissionDialog
¶
Bases: Viewer
Modal dialog hosting a :class:PermissionEditor.
editor = PermissionEditor(framed=False, show_title=False, show_actions=True, save_label=save_label, app=app, project=project, effective_display=effective_display, lockout_check=lockout_check, effective_stylesheets=effective_stylesheets, on_save=self._handle_save, on_cancel=self.close)
instance-attribute
¶
is_open
property
¶
Whether the dialog is currently open.
close()
¶
Close the dialog.
open(title, permission, on_save, *, app=None, project=None, effective_display=_UNSET, lockout_check=_UNSET)
¶
Populate the dialog's editor and open it.
PermissionEditor
¶
Bases: Viewer
Admin editor for a :class:~panel_flowdash.auth.Permission's allow/deny fields.
Can be used standalone (show_actions=True, framed=True or in a
dialog) or embedded inside another form or drawer (show_actions=False,
framed=False).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
permission
|
Permission | None
|
Initial :class: |
None
|
title
|
str
|
Heading text shown when show_title is True. |
'Edit access rules'
|
caption_text
|
str
|
Secondary helper text shown above the fields. |
'Comma-separated user or group names. Leave all fields empty to clear this rule.'
|
save_label
|
str
|
Label for the primary save button when show_actions is True. |
'Save access'
|
framed
|
bool
|
Whether to wrap the editor in an outlined |
True
|
show_actions
|
bool
|
Whether to render the Clear / Cancel / Save button row. |
True
|
show_title
|
bool | None
|
Whether to render the title above the caption; defaults to framed. |
None
|
disabled
|
bool
|
When True, disables all inputs and save/clear actions. |
False
|
app
|
Any
|
Optional app and project used by :func: |
None
|
project
|
Any
|
Optional app and project used by :func: |
None
|
effective_display
|
Callable[[Permission], Any] | None
|
Optional hook |
None
|
lockout_check
|
Callable[[Permission], str | None] | None
|
Optional hook |
None
|
on_save
|
Callable[[Permission], Sequence[Problem | str] | None] | None
|
Optional callback |
None
|
on_cancel
|
Callable[[], Any] | None
|
Optional callback invoked by :meth: |
None
|
on_change
|
Callable[[Permission], Any] | None
|
Optional callback |
None
|
effective_stylesheets
|
Sequence[str]
|
Extra CSS stylesheets attached to the HTML cell used when effective_display returns an HTML string. |
()
|
css_classes
|
Sequence[str]
|
Additional CSS classes added to the outer layout element. |
()
|
allow_groups_input
property
¶
Text input for allow_groups.
allow_users_input
property
¶
Text input for allow_users.
deny_groups_input
property
¶
Text input for deny_groups.
deny_users_input
property
¶
Text input for deny_users.
disabled = param.Boolean(default=False)
class-attribute
instance-attribute
¶
cancel()
¶
Clear problems and invoke on_cancel.
clear()
¶
Clear all four fields.
load(permission=None, *, title=None, app=None, project=None, disabled=None, effective_display=_UNSET, lockout_check=_UNSET)
¶
Populate the editor from permission and refresh hints and live previews.
permission()
¶
Return the :class:~panel_flowdash.auth.Permission represented by the inputs.
refresh_preview()
¶
Re-evaluate effective_display and lockout_check for the current inputs.
save()
¶
Invoke on_save with the current permission; show any returned problems.
show_problems(problems)
¶
Display validation or save problems in the editor's error alert.
format_name_list(names)
¶
Format a set or sequence of user or group names as comma-separated text.
known_principals(app=None, project=None)
¶
Discover known user and group names from app and project for helper hints.
parse_name_list(text)
¶
Split comma- or newline-separated user or group names, stripping blanks and duplicates.
permissions
¶
The Permissions section of the admin view: people and groups, and what the agent may do.
It edits the project file's permissions section (see
panel_flowdash.permissions) with the page's Save and Discard. Settings
the app was given in code, such as default_allow in __init__.py,
show locked, and the code's sensitive components and approval rules are
listed with the built-in ones, which cannot be removed.
BUILT_IN_RULES = (('save_dashboard, delete_*, share_*', "Always, and the palette's save, delete and share"), ('add_node, set_config, load YAML', 'places or changes a sensitive component'), ('mcp_*', 'Always, unless allowed on the MCP server'))
module-attribute
¶
EXTRA = ('people', 'assistant_groups', 'sensitive_components', 'approval_rules')
module-attribute
¶
PERMISSIONS = ProjectSection('permissions', load_permissions, title='Permissions', icon='admin_panel_settings', description="Who can use the app, who administers it, and what the agent may do on someone's behalf.", settings_view=permissions_settings, group='App')
module-attribute
¶
POLICY_GROUPS = (Group('Access policy', (Setting('default_allow', 'Without sharing rules', 'What a dashboard nobody has shared allows.', kind='choice', options={'Everyone can view': True, 'Only its owner': False}, default=True, target='auth_config.default_allow'), Setting('admin_groups', 'Admin groups', 'Members can open Admin and edit every dashboard.', kind='names', unit='a group', default=[], target='auth_config.admin_groups', from_target=lambda value: sorted(value or ())))),)
module-attribute
¶
PermissionsForm
¶
Bases: SettingsForm
The Permissions section, saved with the admin page's Save like the other forms.
extra
property
¶
Return the people, assistant groups, sensitive components and rules as edited.
add_pattern(pattern=None)
¶
Mark the components matching pattern (or the one typed) as sensitive.
add_person(user=None)
¶
List user (or the name typed) so their groups and assistant can be set.
add_rule(tool=None, when=None)
¶
Ask before calls to tool, or only those whose argument has a value (name=value).
changes()
¶
Return what changed since the form was loaded or saved, the tables included.
enable_rule(index, enabled)
¶
Turn the project file's rule index on or off.
people()
¶
Return everyone the app knows of, with their groups, role, dashboards and last visit.
remove_pattern(pattern)
¶
Stop treating the components matching pattern as sensitive, unless code says so.
remove_person(user)
¶
Drop what the project file says about user.
remove_rule(index)
¶
Remove the project file's rule index.
reset()
¶
Put the controls and tables back to the saved values.
save()
¶
Write the section and redraw the tables from what was saved.
set_assistant(user, allowed)
¶
Give the assistant to user, or keep it from them.
set_groups(user, groups)
¶
Give user groups, on top of those from code and sign-in.
permissions_settings(project, editable)
¶
Build the Permissions section of the admin view.
sections
¶
The built-in sections of the project file the admin view edits: general and theme.
Each setting names the app parameter it configures (its target). When
the app starts a session, a value the project file sets is used for every
parameter the app was not given in code; one given in code wins and the
admin view shows the setting locked.
AI_SECTION = 'ai'
module-attribute
¶
BUILTIN_SECTIONS = ('general', 'theme', AI_SECTION, 'permissions', 'mcp')
module-attribute
¶
CONVERT = {'edit_workspace': {'dataflow': 'wiring', 'layout': 'dashboard', 'split': 'split'}.get, 'live_values': lambda value: 'none' if value == 'off' else value, 'history_max_mb': lambda value: None if value is None else int(value * _MB), 'explore': lambda value: False if value == 'read_only' else None, 'color_scheme': lambda value: value == 'dark', 'primary_color': lambda value: {'main': value}, 'font_family': _font_stack}
module-attribute
¶
FONTS = {'Roboto': None, 'Inter': 'Inter:wght@400;500;600', 'IBM Plex Sans': 'IBM+Plex+Sans:wght@400;500;600', 'Source Sans 3': 'Source+Sans+3:wght@400;500;600', 'Open Sans': 'Open+Sans:wght@400;500;600', 'System UI': None}
module-attribute
¶
GENERAL = ProjectSection('general', settings_loader(GENERAL_GROUPS), title='General', icon='tune', description="Behaviour and defaults for everyone using this app. Each dashboard's own settings still override the dashboard defaults.", settings_view=general_settings, group='App')
module-attribute
¶
GENERAL_GROUPS = (Group('Administrators', (Setting('admins', 'Admins', 'People who may open Admin, besides the admin groups set in code: auth:<name> for a signed-in user, local:<name> for the account that runs the server without sign-in, which is admin only in a browser on that machine. A name you add gets the prefix of how this server runs.', kind='names', unit='a user', default=[], normalize=_admin_entry),)), Group('Dashboards', (Setting('edit_workspace', 'Edit workspace', 'Where Edit lands: the wiring canvas, the tile layout or both.', kind='choice', options={'Dataflow': 'dataflow', 'Layout': 'layout', 'Split': 'split'}, default='dataflow', target='editor_options.mode', from_target={'wiring': 'dataflow', 'dashboard': 'layout', 'split': 'split'}.get), Setting('home_dashboard', 'Home page', 'The dashboard grid, or one dashboard by id or title.', kind='select', options=_home_options, default=None, allow_none=True, target='home_dashboard'), Setting('templates', 'Dashboard templates', 'Offer templates when someone creates a dashboard, besides a blank one.', default=True, target='templates'), Setting('live_values', 'Live values on ports', "Open a port's value on click, on hover or not at all.", kind='choice', options={'Click': 'click', 'Hover': 'hover', 'Off': 'off'}, default='click', target='editor_options.popup_trigger', from_target=lambda value: 'off' if value == 'none' else value))), Group('Edit history', (Setting('history', 'Record edit history', 'Every edit becomes a version people can undo, browse and restore.', default=True, target='editor_options.history'), Setting('history_coalesce', 'Group edits within', 'A burst of edits becomes one version.', kind='number', unit='Seconds', bounds=(0, None), step=0.5, default=BURST_SECONDS, target='editor_options.history_coalesce'), Setting('history_keep', 'Keep at most', 'Whichever limit is reached first; the latest version is always kept.', kind='numbers', parts=(Setting('history_limit', 'Versions', kind='number', unit='Versions', integer=True, bounds=(1, None), default=500, allow_none=True, target='editor_options.history_limit'), Setting('history_max_days', 'Days', kind='number', unit='Days', integer=True, bounds=(0, None), default=90, allow_none=True, target='editor_options.history_max_days'), Setting('history_max_mb', 'MB', kind='number', unit='MB', integer=True, bounds=(0, None), default=HISTORY_MAX_BYTES // _MB, allow_none=True, target='editor_options.history_max_bytes', from_target=lambda value: None if value is None else round(value / _MB)))))), Group('Explore and the assistant', (Setting('explore', 'Explore view', "Ask about a dashboard's data, or keep a read-only record of its turns.", kind='choice', options={'Ask': 'ask', 'Read only': 'read_only'}, default='ask', target='explore_agent', from_target=lambda value: 'read_only' if value is False else 'ask'), Setting('agent_palette', 'Assistant may run commands', 'Give the agent the command palette, e.g. to open or refresh a dashboard.', default=True, target='agent_palette'), Setting('provenance', 'Show how a node was made', '“How was this made?” on nodes an agent request created.', default=True, target='editor_options.provenance')), column=1), Group('New dashboard defaults', (Setting('tile_cards', 'Frame tiles', 'Draw tiles as cards. Each dashboard can turn it off.', default=True, target='editor_options.tile_cards'), Setting('tile_titles', 'Show tile titles', 'Off: components show their own headings.', default=False, target='editor_options.tile_titles'), Setting('node_previews', 'Preview values on the canvas', 'Cards show the first rows, a sparkline or a few items.', default=False, target='editor_options.node_previews'), Setting('controls_position', 'Controls', 'Where controls go.', kind='choice', options={'Above': 'top', 'Left': 'left'}, default='top', target='controls_position')), column=1))
module-attribute
¶
GENERAL_SETTINGS = _leaves(GENERAL_GROUPS)
module-attribute
¶
PRIMARY = '#0072B5'
module-attribute
¶
SWATCHES = (PRIMARY, '#006D77', '#5E35B1', '#C2185B', '#E65100', '#37474F')
module-attribute
¶
THEME = ProjectSection('theme', settings_loader(THEME_GROUPS), title='Theme', icon='palette', description='Colours, type and branding for every page, in light and dark.', settings_view=theme_settings, group='App')
module-attribute
¶
THEME_GROUPS = (Group('Colours', (Setting('color_scheme', 'Colour scheme', 'What people see before they pick light or dark themselves.', kind='choice', options={'Follow the system': 'system', 'Light': 'light', 'Dark': 'dark'}, default='system', target='page_options.dark_theme', from_target=lambda value: 'dark' if value else 'light'), Setting('primary_color', 'Primary colour', 'Buttons, the selected rail item, links and focus rings.', kind='color', swatches=SWATCHES, default=PRIMARY, target='page_options.theme_config.palette.primary', from_target=lambda value: value.get('main') if isinstance(value, dict) else value))), Group('Type and shape', (Setting('font_family', 'Font', 'The interface font. Fonts other than Roboto load from Google Fonts.', kind='select', options={name: name for name in FONTS}, default='Roboto', target='page_options.theme_config.typography.fontFamily', from_target=lambda value: value.split(',')[0].strip().strip('"\'')), Setting('border_radius', 'Corner radius', 'Cards, buttons and fields.', kind='slider', unit='px', bounds=(0, 16), integer=True, default=4, target='page_options.theme_config.shape.borderRadius'))), Group('Branding', (Setting('title', 'Title', 'In the top bar and the browser tab.', kind='text', default='FlowDash', target='title'), Setting('logo', 'Logo', 'An image URL, or a path relative to the project file.', kind='text', unit='logo.svg', default=None, allow_none=True, target='page_options.logo', validate=_check_image('logo')), Setting('favicon', 'Favicon', "The browser tab's icon: an image URL, or a path relative to the project file. Without one, it is made from the logo.", kind='text', unit='favicon.png', default=None, allow_none=True, target='page_options.favicon', validate=_check_image('favicon')))))
module-attribute
¶
THEME_SETTINGS = _leaves(THEME_GROUPS)
module-attribute
¶
FaviconTools
¶
Bases: Viewer
The favicon pages will show, with an upload and a "Generate from logo" action.
Both write the file into the project directory and fill in the form's favicon field, which saving the form then records.
refresh()
¶
Show the favicon the form's values give and which actions are possible.
FontLoader
¶
Bases: JSComponent
Adds a font's stylesheet to the document head, where its font faces apply page-wide.
href = param.String(default=None, allow_None=True)
class-attribute
instance-attribute
¶
ThemePreview
¶
Bases: Viewer
A mini app in the theme the form's controls describe, in light and dark.
refresh()
¶
Draw the preview from the form's current values.
add_admin(project, user)
¶
Add the entry user to general.admins, keeping the section's other settings.
claim_admin(project, user, token, admin_groups=())
¶
Make user, a general.admins entry, an admin with the admin token; return how it went.
"claimed" when the token was valid and user is now recorded (or,
for no user, admin for the session only), "invalid" for a wrong or
already used token, and "taken" when the project already has admins
or admin groups and the server was not started to add one
(--admin-link). Checking, using the token and recording the user
happen under one lock, so of two claims at once only one succeeds. A
write that fails raises after the token was used.
dark_primary_text(primary, backgrounds)
¶
Return the tint panel-material-ui shows primary text in on dark backgrounds.
Mirrors pmui's primary_text_color: a primary reaching 4.5:1 on every
background is kept, else it is lightened by the least amount, but at least
35%, that does.
font_href(font_family)
¶
Return the Google Fonts stylesheet of font_family, if it loads one.
general_settings(project, editable)
¶
Build the General section of the admin view.
preview_html(*, title, primary, font, radius, schemes)
¶
Return the preview of a light and/or dark mini app in the given theme.
project_admins(project, fresh=False)
¶
Return the entries of the project file's general.admins (see access.entry_matches).
With fresh, the file is read again rather than the loaded copy used. A section the loader rejects names no one.
project_overrides(project, in_code)
¶
Return the target values the project file's general and theme sections set.
A target in_code says the app was given in code is left out, so
code wins over the file.
resolve_image(value, directory)
¶
Return the image value names: an http(s) URL, or a file inside directory.
None for anything else, such as a path that leads out of the project
directory with .., an absolute path elsewhere or another URL scheme.
theme_settings(project, editable)
¶
Build the Theme section of the admin view, with its live preview.
wizard
¶
The setup wizard: a first admin's walk through the project file's main sections.
It opens right after the admin link claims a project that has no settings
yet, and from Admin, General whenever an admin wants it. Each step edits
one or more project file sections with the same forms and loaders as the
admin view; nothing is written until Review's Finish, which writes every
changed section with Project.set. Cancel leaves the file as it was.
An extension adds a step with its section's wizard_view(project), which
returns a WizardStep or a SettingsForm. A "Data" section's step
takes the place of the built-in Data step, which only shows the served
data folder; any other comes after People.
DATA_SUFFIXES = ('.csv', '.tsv', '.parquet', '.json', '.jsonl', '.xlsx', '.xls', '.arrow', '.feather', '.duckdb', '.db', '.sqlite')
module-attribute
¶
NARROW_WIDTH = 900
module-attribute
¶
PENDING_SECRET = {'encrypted': 'pending', 'key_id': 'pending'}
module-attribute
¶
SETUP_SECTION = 'setup'
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
AIStep
¶
Bases: WizardStep
A model provider, its key (a reference to an environment variable by default) and a model.
last_check = None
instance-attribute
¶
provider
property
¶
Return the provider picked.
changes()
¶
Return the ai section with the provider's key and the model added.
finalize(name, value)
¶
Encrypt the key pasted when Review opened, in place of its placeholder.
suggest_models()
async
¶
Offer the models the picked provider lists for the key, if it can be read.
summary()
¶
Return the provider, where its key comes from and the model.
test()
async
¶
Ask the provider whether the key works, without saving it.
view()
¶
Return the provider and key on the left, the model on the right.
DataStep
¶
Bases: WizardStep
The data the app serves: the data files in the project folder. It writes nothing.
FormStep
¶
Bases: WizardStep
A step made of SettingsForm s: each form's changes are written to its section.
PeopleStep
¶
SetupWizard
¶
Bases: Viewer
The setup wizard: its steps, then Review, which writes them with Finish.
on_close(finished) is called when Finish wrote the reviewed sections (True) or the wizard was cancelled (False).
plan = {}
instance-attribute
¶
problems = []
instance-attribute
¶
project = project
instance-attribute
¶
review_index
property
¶
Return the index of Review, the last step.
skipped = set()
instance-attribute
¶
step = param.Integer(default=0, doc='The index of the step shown; the last is Review.')
class-attribute
instance-attribute
¶
steps = wizard_steps(project, app)
instance-attribute
¶
titles
property
¶
Return the steps' labels, Review included.
written = []
instance-attribute
¶
back()
¶
Go back a step.
cancel()
¶
Leave the wizard without writing anything.
diff()
¶
Return the reviewed sections' YAML lines, old and new, as (kind, text).
finish()
¶
Write the reviewed sections with Project.set; False, writing nothing, on a problem.
next()
¶
Go on to the next step, or finish on Review.
review()
¶
Collect what each step not skipped writes, by section, and check it.
The result is what Finish writes. Sections the file already has as they would be written are left out.
show(index)
¶
Show step index; Review when it is the last.
skip()
¶
Leave this step's settings out and go on; on Welcome, leave the wizard.
WelcomeStep
¶
Bases: WizardStep
What the app found when it started, and where its settings will be saved.
description = 'A few choices to get this app ready for other people. Every step can be skipped, nothing is saved until you finish, and everything can be changed later in Admin.'
instance-attribute
¶
heading = f'Set up {title}'
instance-attribute
¶
found()
¶
Return what the app found when it started: (icon, what, detail).
view()
¶
Return where settings are saved and what was found.
WizardStep
¶
Bases: Viewer
A step of the setup wizard.
changes returns the sections to write, by name, each a value for
Project.set; it is asked when Review opens, and Finish writes exactly
what it returned then. It may raise ValueError to say why the step
cannot be written as it is. summary returns the lines of the step's
card on Review.
caption = param.String(default='', doc='The line under the label.')
class-attribute
instance-attribute
¶
description = param.String(default='', doc='The text under the page title.')
class-attribute
instance-attribute
¶
heading = param.String(default='', doc="The step's page title.")
class-attribute
instance-attribute
¶
icon = param.String(default='settings', doc="The step's icon on Review.")
class-attribute
instance-attribute
¶
project = project
instance-attribute
¶
title = param.String(default='', doc="The step's label in the stepper.")
class-attribute
instance-attribute
¶
changes()
¶
Return the sections this step writes, by name; none by default.
confirmations()
¶
Return what the admin must confirm on Review before Finish writes this step.
finalize(name, value)
¶
Return section name's reviewed value as Finish writes it; it as is by default.
A step whose Review shows a placeholder, such as a key to encrypt, replaces it here, so nothing is made before the admin finishes.
summary()
¶
Return what the step will do, one line each, for its card on Review.
view()
¶
Return the step's page below its title.
check_section(project, name, value)
¶
Return why the section's loader would refuse value, without writing anything.
data_files(directory, limit=50, app=None)
¶
Return the data files directly in directory, by name, leaving out FlowDash's own store.
diff_lines(old, new)
¶
Return each changed section's YAML lines as (kind, text), kind add, del or ctx.
given_model(app)
¶
Return the id and label of the model the app was started with, or empty ones.
That is the app's agent_model (with its label from agent_models
when listed there), else the first of agent_models.
people_step(project, app=None)
¶
Return the People step: admins, admin groups and what an unshared dashboard allows.
project_is_new(project)
¶
Whether the project file has no settings yet: missing, empty, or only its admins.
Claiming the admin link writes general.admins, so a file holding only
that is still new.
section_data(name, value)
¶
Return value as plain YAML data, the way Project.set writes section name.
theme_step(project)
¶
Return the Theme step: colour scheme, primary colour, title, logo and favicon, with the preview.
wizard_steps(project, app=None)
¶
Return the wizard's steps before Review, extension steps included.