gui
Module that defines main graphic interface and backend graphic interface.
Classes that uses param
are then used to create Panel widget directly (see Panel docs <https://panel.holoviz.org/how_to/param/uis.html>
__).
Modules:
Name | Description |
---|---|
auth |
Module with classes and functions used for authentication and password handling. |
core |
|
models |
Module with database tables definitions. |
Classes:
Name | Description |
---|---|
BackendAddPrivilegedUser |
Param class used inside the backend to create the widget add new users to the |
BackendInterface |
Class with widgets for the backend graphic interface. |
BackendPasswordRenewer |
Param class used inside the backend to create the widget that collect info to renew users password. |
BackendUserEraser |
Param class used inside the backend to create the widget that delete users. |
GraphicInterface |
Class with widgets for the main graphic interface. |
PasswordRenewer |
Param class used to create the widget that collect info to renew users password. |
Person |
Param class that define user data and lunch preferences for its order. |
Attributes:
Name | Type | Description |
---|---|---|
backend_min_height |
int
|
Backend minimum height. |
df_quote |
DataFrame
|
Dataframe with the quote of the day. |
df_quotes |
DataFrame
|
Dataframe with quotes. |
download_text |
str
|
info Text used in |
generic_button_height |
int
|
Button height. |
guest_user_text |
str
|
info Text used in guest |
header_button_width |
int
|
Width for buttons used in top header. |
header_row_height |
int
|
Top header height. |
log |
Logger
|
Module logger. |
main_area_min_width |
int
|
Main area width. It's the area with menu and order summary. |
person_text |
str
|
info Text used in |
quotes_filename |
Path
|
Excel file with quotes. |
seed_day |
int
|
seed to Select the quote of the day. |
sidebar_content_width |
int
|
Sidebar content width. Should be smaller than sidebar width. |
sidebar_width |
int
|
Sidebar width. |
time_col_spacer_width |
int
|
Time column spacer width. |
time_col_width |
int
|
Time column width (the time column is on the side of the menu table). |
upload_text |
str
|
info Text used in |
df_quote
module-attribute
Dataframe with the quote of the day.
df_quotes
module-attribute
df_quotes: DataFrame = read_excel(quotes_filename)
Dataframe with quotes.
download_text
module-attribute
download_text: str = (
"\n### Download Orders\nDownload the order list.\n"
)
info Text used in Download Orders
tab.
guest_user_text
module-attribute
guest_user_text: str = '\n### Guest user\n'
info Text used in guest Password
widget.
header_button_width
module-attribute
header_button_width: int = 50
Width for buttons used in top header.
main_area_min_width
module-attribute
main_area_min_width: int = (
580 + time_col_spacer_width + time_col_width
)
Main area width. It's the area with menu and order summary.
person_text
module-attribute
person_text: str = (
"\n### User Data\n\n_Privileged users_ do not need to fill the username.<br>\n_Guest users_ shall use a valid _unique_ name and select a guest type.\n"
)
info Text used in User
tab.
quotes_filename
module-attribute
quotes_filename: Path = parent / 'quotes.xlsx'
Excel file with quotes.
seed_day
module-attribute
seed to Select the quote of the day.
sidebar_content_width
module-attribute
sidebar_content_width: int = sidebar_width - 10
Sidebar content width. Should be smaller than sidebar width.
time_col_width
module-attribute
time_col_width: int = 90
Time column width (the time column is on the side of the menu table).
upload_text
module-attribute
upload_text: str = (
"\n### Menu Upload\nSelect a .png, .jpg or .xlsx file with the menu.<br>\nThe app may add some default items to the menu.\n\n**For .xlsx:** list menu items starting from cell A1, one per each row.\n"
)
info Text used in Menu Upload
tab.
BackendAddPrivilegedUser
Bases: Parameterized
Param class used inside the backend to create the widget add new users to the privileged_user
table.
Methods:
Name | Description |
---|---|
__str__ |
String representation of this object. |
Attributes:
Name | Type | Description |
---|---|---|
admin |
Boolean
|
Admin flag (true if admin). |
user |
String
|
Username of the new user. |
Source code in dlunch/gui.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
admin
class-attribute
instance-attribute
Admin flag (true if admin).
user
class-attribute
instance-attribute
Username of the new user.
__str__
__str__()
String representation of this object.
Returns:
Type | Description |
---|---|
str
|
string representation. |
Source code in dlunch/gui.py
176 177 178 179 180 181 182 |
|
BackendInterface
Class with widgets for the backend graphic interface.
All widgets are instantiated at class initialization.
Class methods handle specific operations that may be repeated multiple time after class instantiation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Methods:
Name | Description |
---|---|
__init__ |
|
exit_backend |
Return to main homepage. |
reload_backend |
Reload backend by updating user lists and privileges. |
Attributes:
Source code in dlunch/gui.py
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 |
|
access_denied_text
instance-attribute
access_denied_text = HTML(
'\n <div class="no-more-order-flag">\n <div class="icon-container">\n <svg class="flashing-animation" xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-shield-lock-filled" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>\n <path d="M11.998 2l.118 .007l.059 .008l.061 .013l.111 .034a.993 .993 0 0 1 .217 .112l.104 .082l.255 .218a11 11 0 0 0 7.189 2.537l.342 -.01a1 1 0 0 1 1.005 .717a13 13 0 0 1 -9.208 16.25a1 1 0 0 1 -.502 0a13 13 0 0 1 -9.209 -16.25a1 1 0 0 1 1.005 -.717a11 11 0 0 0 7.531 -2.527l.263 -.225l.096 -.075a.993 .993 0 0 1 .217 -.112l.112 -.034a.97 .97 0 0 1 .119 -.021l.115 -.007zm.002 7a2 2 0 0 0 -1.995 1.85l-.005 .15l.005 .15a2 2 0 0 0 .995 1.581v1.769l.007 .117a1 1 0 0 0 1.993 -.117l.001 -1.768a2 2 0 0 0 -1.001 -3.732z" stroke-width="0" fill="currentColor"></path>\n </svg>\n <span><strong>Insufficient privileges!</strong></span>\n </div>\n </div>\n ',
margin=5,
sizing_mode="stretch_width",
stylesheets=[no_more_orders_path],
)
add_privileged_user_button
instance-attribute
add_privileged_user_button = Button(
name="Add",
button_type="success",
height=generic_button_height,
icon="user-plus",
icon_size="2em",
sizing_mode="stretch_width",
)
add_privileged_user_column
instance-attribute
add_privileged_user_column = Column(
add_privileged_user_widget,
VSpacer(),
add_privileged_user_button,
width=sidebar_width,
sizing_mode="stretch_height",
min_height=backend_min_height,
)
add_privileged_user_widget
instance-attribute
add_privileged_user_widget = Param(
param,
name="Add Privileged User",
width=sidebar_content_width,
)
add_update_user_column
instance-attribute
add_update_user_column = Column(
psw_text,
password_widget,
VSpacer(),
submit_password_button,
width=sidebar_width,
sizing_mode="stretch_height",
min_height=backend_min_height,
)
backend_controls
instance-attribute
backend_controls = Row(
name="Actions",
sizing_mode="stretch_both",
min_height=backend_min_height,
)
clear_flags_button
instance-attribute
clear_flags_button = Button(
name="Clear Guest Override Flags",
button_type="danger",
height=generic_button_height,
icon="file-shredder",
icon_size="2em",
sizing_mode="stretch_width",
)
clear_flags_column
instance-attribute
clear_flags_column = Column(
HTML("<b>Flags Table Content</b>"),
flags_content,
clear_flags_button,
width=sidebar_width,
sizing_mode="stretch_height",
min_height=backend_min_height,
)
delete_user_button
instance-attribute
delete_user_button = Button(
name="Delete",
button_type="danger",
height=generic_button_height,
icon="user-minus",
icon_size="2em",
sizing_mode="stretch_width",
)
delete_user_column
instance-attribute
delete_user_column = Column(
user_eraser,
VSpacer(),
delete_user_button,
width=sidebar_width,
sizing_mode="stretch_height",
min_height=backend_min_height,
)
exit_button
instance-attribute
exit_button = Button(
name="",
button_type="primary",
button_style="solid",
width=header_button_width,
height=generic_button_height,
icon="home-move",
icon_size="2em",
)
flags_content
instance-attribute
flags_content = Tabulator(
value=df_flags, sizing_mode="stretch_height"
)
header_row
instance-attribute
header_row = Row(
height=header_row_height, sizing_mode="stretch_width"
)
list_user_column
instance-attribute
list_user_column = Column(
HTML("<b>Users and Privileges</b>"),
users_tabulator,
width=sidebar_width,
sizing_mode="stretch_height",
min_height=backend_min_height,
)
password_widget
instance-attribute
password_widget = Param(
param,
widgets={
"new_password": PasswordInput(
name="New password", placeholder="New Password"
),
"repeat_new_password": PasswordInput(
name="Repeat new password",
placeholder="Repeat New Password",
),
},
name="Add/Update User Credentials",
width=sidebar_content_width,
)
submit_password_button
instance-attribute
submit_password_button = Button(
name="Submit",
button_type="success",
height=generic_button_height,
icon="key",
icon_size="2em",
sizing_mode="stretch_width",
)
user_eraser
instance-attribute
user_eraser = Param(
param, name="Delete User", width=sidebar_content_width
)
users_tabulator
instance-attribute
users_tabulator = Tabulator(
value=list_users_guests_and_privileges(config),
sizing_mode="stretch_height",
)
__init__
__init__(config: DictConfig)
Source code in dlunch/gui.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 |
|
exit_backend
exit_backend() -> None
Return to main homepage.
Source code in dlunch/gui.py
1404 1405 1406 1407 1408 1409 1410 |
|
reload_backend
reload_backend(config: DictConfig) -> None
Reload backend by updating user lists and privileges.
Read also flags from flags
table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Source code in dlunch/gui.py
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
|
BackendPasswordRenewer
Bases: Parameterized
Param class used inside the backend to create the widget that collect info to renew users password.
It has more options compared to the standard PasswordRenewer
.
This widget is used only if basic authentication is active.
Methods:
Name | Description |
---|---|
__str__ |
String representation of this object. |
Attributes:
Name | Type | Description |
---|---|---|
admin |
Boolean
|
Admin flag (true if admin). |
guest |
Boolean
|
Guest flag (true if guest). |
new_password |
String
|
New password. |
repeat_new_password |
String
|
Repeat the new password. This field tests if the new password is as intended. |
user |
String
|
Username. |
Source code in dlunch/gui.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
admin
class-attribute
instance-attribute
Admin flag (true if admin).
guest
class-attribute
instance-attribute
guest: Boolean = Boolean(
default=False,
doc="guest account (don't add user to privileged users' table)",
)
Guest flag (true if guest).
User credentials are added to credentials
table, but the user is not listed in privileged_users
table.
new_password
class-attribute
instance-attribute
New password.
repeat_new_password
class-attribute
instance-attribute
Repeat the new password. This field tests if the new password is as intended.
user
class-attribute
instance-attribute
user: String = String(
default="",
doc="username for password update (use 'guest' for guest user)",
)
Username.
__str__
__str__()
String representation of this object.
Returns:
Type | Description |
---|---|
str
|
string representation. |
Source code in dlunch/gui.py
157 158 159 160 161 162 163 |
|
BackendUserEraser
Bases: Parameterized
Param class used inside the backend to create the widget that delete users.
Users are deleted from both credentials
and privileged_user
tables.
Methods:
Name | Description |
---|---|
__str__ |
String representation of this object. |
Attributes:
Name | Type | Description |
---|---|---|
user |
String
|
User to be deleted. |
Source code in dlunch/gui.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
user
class-attribute
instance-attribute
User to be deleted.
__str__
__str__()
String representation of this object.
Returns:
Type | Description |
---|---|
str
|
string representation. |
Source code in dlunch/gui.py
193 194 195 196 197 198 199 |
|
GraphicInterface
Class with widgets for the main graphic interface.
All widgets are instantiated at class initialization.
Class methods handle specific operations that may be repeated multiple time after class instantiation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
app
|
Template
|
App panel template (see |
required |
person
|
Person
|
Object with user data and preferences for the lunch order. |
required |
guest_password
|
str
|
guest password to show in password tab. Used only if basic authentication is active.
Defaults to empty string ( |
''
|
Methods:
Name | Description |
---|---|
__init__ |
|
build_order_table |
Build |
build_stats_and_info_text |
Build text used for statistics under the |
build_time_label |
Build HTML field to display the time label. |
load_sidebar_tabs |
Append tabs to the app template sidebar. |
Attributes:
Source code in dlunch/gui.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 |
|
additional_items_details
instance-attribute
additional_items_details = HTML(
render(items=additional_items_to_concat),
width=sidebar_content_width,
)
backend_button
instance-attribute
backend_button = Button(
name="",
button_type="primary",
button_style="solid",
width=header_button_width,
height=generic_button_height,
icon="adjustments",
icon_size="2em",
)
build_menu_button
instance-attribute
build_menu_button = Button(
name="Build Menu",
button_type="primary",
sizing_mode="stretch_width",
icon="tools-kitchen-2",
icon_size="2em",
)
buttons_flexbox
instance-attribute
buttons_flexbox = FlexBox(
*[
send_order_button,
toggle_no_more_order_button,
change_order_time_takeaway_button,
delete_order_button,
],
flex_wrap="nowrap",
min_width=main_area_min_width,
sizing_mode="stretch_width"
)
change_order_time_takeaway_button
instance-attribute
change_order_time_takeaway_button = Button(
name="Change Time/Takeaway",
button_type="primary",
button_style="outline",
height=generic_button_height,
icon="clock-edit",
icon_size="2em",
sizing_mode="stretch_width",
)
dataframe
instance-attribute
dataframe = Tabulator(
name="Order",
widths={note_column_name: 180},
selectable=False,
stylesheets=[custom_tabulator_path],
)
delete_order_button
instance-attribute
delete_order_button = Button(
name="Delete Order",
button_type="danger",
height=generic_button_height,
icon="trash-filled",
icon_size="2em",
sizing_mode="stretch_width",
)
download_button
instance-attribute
download_button = FileDownload(
callback=lambda: download_dataframe(config, self),
filename=file_name + ".xlsx",
sizing_mode="stretch_width",
icon="download",
icon_size="2em",
)
error_message
instance-attribute
error_message = HTML(
styles={"color": "red", "font-weight": "bold"},
sizing_mode="stretch_width",
)
file_widget
instance-attribute
file_widget = FileInput(
accept=".png,.jpg,.jpeg,.xlsx",
sizing_mode="stretch_width",
)
guest_override_alert
instance-attribute
guest_override_alert = HTML(
'\n <div class="guest-override-flag">\n <div class="icon-container">\n <svg class="flashing-animation" xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-radioactive-filled" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/>\n <path d="M21 11a1 1 0 0 1 1 1a10 10 0 0 1 -5 8.656a1 1 0 0 1 -1.302 -.268l-.064 -.098l-3 -5.19a.995 .995 0 0 1 -.133 -.542l.01 -.11l.023 -.106l.034 -.106l.046 -.1l.056 -.094l.067 -.089a.994 .994 0 0 1 .165 -.155l.098 -.064a2 2 0 0 0 .993 -1.57l.007 -.163a1 1 0 0 1 .883 -.994l.117 -.007h6z" stroke-width="0" fill="currentColor" />\n <path d="M7 3.344a10 10 0 0 1 10 0a1 1 0 0 1 .418 1.262l-.052 .104l-3 5.19l-.064 .098a.994 .994 0 0 1 -.155 .165l-.089 .067a1 1 0 0 1 -.195 .102l-.105 .034l-.107 .022a1.003 1.003 0 0 1 -.547 -.07l-.104 -.052a2 2 0 0 0 -1.842 -.082l-.158 .082a1 1 0 0 1 -1.302 -.268l-.064 -.098l-3 -5.19a1 1 0 0 1 .366 -1.366z" stroke-width="0" fill="currentColor" />\n <path d="M9 11a1 1 0 0 1 .993 .884l.007 .117a2 2 0 0 0 .861 1.645l.237 .152a.994 .994 0 0 1 .165 .155l.067 .089l.056 .095l.045 .099c.014 .036 .026 .07 .035 .106l.022 .107l.011 .11a.994 .994 0 0 1 -.08 .437l-.053 .104l-3 5.19a1 1 0 0 1 -1.366 .366a10 10 0 0 1 -5 -8.656a1 1 0 0 1 .883 -.993l.117 -.007h6z" stroke-width="0" fill="currentColor" />\n </svg>\n <span><strong>Watch out! You are a guest now...</strong></span>\n </div>\n <div>\n Guest override is active.\n </div>\n </div>\n ',
margin=5,
sizing_mode="stretch_width",
stylesheets=[guest_override_path],
)
guest_password_widget
instance-attribute
guest_password_widget = PasswordInput(
name="Password",
placeholder="If empty reload this page.",
value=guest_password,
)
guest_username_widget
instance-attribute
guest_username_widget = TextInput(
name="Username",
placeholder="If empty reload this page.",
value="guest",
)
header_object
instance-attribute
header_object = instantiate(header_object)
header_row
instance-attribute
header_row = Row(
height=header_row_height, sizing_mode="stretch_width"
)
logout_button
instance-attribute
logout_button = Button(
name="",
button_type="primary",
button_style="solid",
width=header_button_width,
height=generic_button_height,
icon="door-exit",
icon_size="2em",
)
main_header_row
instance-attribute
main_header_row = Row('# Menu', HSpacer(), refresh_button)
menu_flexbox
instance-attribute
menu_flexbox = FlexBox(
*[
dataframe,
Spacer(width=time_col_spacer_width),
time_col,
],
min_width=main_area_min_width
)
no_menu_col
instance-attribute
no_menu_col = Column(
no_menu_image,
no_menu_image_attribution,
sizing_mode="stretch_width",
min_width=main_area_min_width,
)
no_menu_image
instance-attribute
no_menu_image = JPG(no_menu_image_path, alt_text='no menu')
no_menu_image_attribution
instance-attribute
no_menu_image_attribution = HTML(
'\n <i>\n Image by\n <a\n href="https://www.freepik.com/free-vector/tiny-cooks-making-spaghetti-dinner-isolated-flat-illustration_11235909.htm"\n referrerpolicy="no-referrer"\n rel="external"\n target="_blank"\n >\n pch.vector\n </a>\n on Freepik\n </i>\n ',
align="end",
styles={
"color": "darkgray",
"font-size": "10px",
"font-weight": "light",
},
)
no_more_order_alert
instance-attribute
no_more_order_alert = HTML(
'\n <div class="no-more-order-flag">\n <div class="icon-container">\n <svg class="flashing-animation" xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-alert-circle-filled" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">\n <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>\n <path d="M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm.01 13l-.127 .007a1 1 0 0 0 0 1.986l.117 .007l.127 -.007a1 1 0 0 0 0 -1.986l-.117 -.007zm-.01 -8a1 1 0 0 0 -.993 .883l-.007 .117v4l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-4l-.007 -.117a1 1 0 0 0 -.993 -.883z" stroke-width="0" fill="currentColor"></path>\n </svg>\n <span><strong>Oh no! You missed this train...</strong></span>\n </div>\n <div>\n Orders are closed, better luck next time.\n </div>\n </div>\n ',
margin=5,
sizing_mode="stretch_width",
stylesheets=[no_more_orders_path],
)
password_widget
instance-attribute
password_widget = Param(
param,
widgets={
"old_password": PasswordInput(
name="Old password", placeholder="Old Password"
),
"new_password": PasswordInput(
name="New password", placeholder="New Password"
),
"repeat_new_password": PasswordInput(
name="Repeat new password",
placeholder="Repeat New Password",
),
},
name="Change password",
width=sidebar_content_width,
)
person_widget
instance-attribute
person_widget = Param(
param,
widgets={
"guest": RadioButtonGroup(
options=to_container(guest_types, resolve=True),
button_type="primary",
button_style="outline",
),
"username": TextInput(
value=username,
value_input=username,
description=doc,
),
},
width=sidebar_content_width,
)
quote
instance-attribute
quote = Markdown(f'
_{iloc[0]}_
**{iloc[0]}**
')
refresh_button
instance-attribute
refresh_button = Button(
name="",
button_style="outline",
button_type="light",
width=45,
height=generic_button_height,
icon="reload",
icon_size="2em",
)
reload_on_guest_override
instance-attribute
reload_on_guest_override = reload_on_guest_override_callback
reload_on_no_more_order
instance-attribute
reload_on_no_more_order = reload_on_no_more_order_callback
res_col
instance-attribute
res_col = Column(
sizing_mode="stretch_width",
min_width=main_area_min_width,
)
results_divider
instance-attribute
results_divider = Divider(
sizing_mode="stretch_width",
min_width=main_area_min_width,
)
send_order_button
instance-attribute
send_order_button = Button(
name="Send Order",
button_type="success",
height=generic_button_height,
icon="circle-check-filled",
icon_size="2em",
sizing_mode="stretch_width",
)
sidebar_download_orders_col
instance-attribute
sidebar_download_orders_col = Column(
download_text,
download_button,
name="Download Orders",
width=sidebar_content_width,
)
sidebar_menu_upload_col
instance-attribute
sidebar_menu_upload_col = Column(
upload_text,
file_widget,
build_menu_button,
name="Menu Upload",
width=sidebar_content_width,
)
sidebar_password
instance-attribute
sidebar_password = Column(
psw_text,
password_widget,
submit_password_button,
Spacer(height=5),
Divider(),
guest_user_text,
guest_username_widget,
guest_password_widget,
name="Password",
width=sidebar_content_width,
)
sidebar_person_column
instance-attribute
sidebar_person_column = Column(
person_text,
person_widget,
Spacer(height=5),
additional_items_details,
name="User",
width=sidebar_content_width,
)
sidebar_stats_col
instance-attribute
sidebar_stats_col = Column(
name="Stats", width=sidebar_content_width
)
stats_widget
instance-attribute
stats_widget = Tabulator(
name="Statistics",
hidden_columns=["index"],
width=sidebar_content_width - 20,
layout="fit_columns",
stylesheets=[
custom_tabulator_path,
stats_tabulator_path,
],
)
submit_password_button
instance-attribute
submit_password_button = Button(
name="Submit",
button_type="success",
button_style="outline",
height=generic_button_height,
icon="key",
icon_size="2em",
sizing_mode="stretch_width",
)
takeaway_alert_sign
instance-attribute
takeaway_alert_sign = f"<span {takeaway_alert_icon_options}>{takeaway_svg_icon}</span>"
takeaway_alert_text
instance-attribute
takeaway_alert_text = f"<span {takeaway_alert_text_options}>{takeaway_id}</span> "
time_col_title
instance-attribute
time_col_title = Markdown(
time_column_text,
sizing_mode="stretch_width",
styles={"text-align": "center"},
)
toggle_guest_override_button
instance-attribute
toggle_guest_override_button = Toggle(
button_type="primary",
button_style="solid",
width=header_button_width,
height=generic_button_height,
icon="user-bolt",
icon_size="2em",
stylesheets=[guest_override_path],
)
toggle_no_more_order_button
instance-attribute
toggle_no_more_order_button = Toggle(
name="Stop Orders",
button_style="outline",
button_type="warning",
height=generic_button_height,
icon="hand-stop",
icon_size="2em",
sizing_mode="stretch_width",
)
__init__
Source code in dlunch/gui.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
|
build_order_table
build_order_table(
config: DictConfig,
df: DataFrame,
time: str,
guests_lists: dict = {},
) -> Tabulator
Build Tabulator
object to display placed orders.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
df
|
DataFrame
|
Table with orders. It has columns for each user that placed an order, total and a note columns. |
required |
time
|
str
|
Lunch time. |
required |
guests_lists
|
dict
|
Dictionary with lists of users dived by guest type.
Keys of the dictionary are the type of guest listed.
Defaults to empty dictionary ( |
{}
|
Returns:
Type | Description |
---|---|
Tabulator
|
Panel |
Source code in dlunch/gui.py
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
|
build_stats_and_info_text
build_stats_and_info_text(
config: DictConfig,
df_stats: DataFrame,
user: str,
version: str,
host_name: str,
stylesheets: list = [],
) -> dict
Build text used for statistics under the stats
tab, and info under the user
tab.
This functions needs Data-Lunch version and the name of the hosting machine to populate the info section.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
df_stats
|
DataFrame
|
dataframe with statistics. |
required |
user
|
str
|
username. |
required |
version
|
str
|
Data-Lunch version. |
required |
host_name
|
str
|
host name. |
required |
stylesheets
|
list
|
Stylesheets to assign to the resulting HTML pane
(see |
[]
|
Returns:
Type | Description |
---|---|
dict
|
description |
Source code in dlunch/gui.py
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 |
|
build_time_label
build_time_label(
time: str,
diners_n: str,
separator: str = " ❘ ",
emoji: str = "🍕",
per_icon: str = " ✖ ",
is_takeaway: bool = False,
takeaway_alert_sign: str = "TAKEAWAY",
css_classes: list = [],
stylesheets: list = [],
**kwargs
) -> HTML
Build HTML field to display the time label.
This function is used to display labels that summarize an order.
Those are shown on the side of the menu table as well as labels above each order table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
str
|
Lunch time. |
required |
diners_n
|
str
|
Number of people that placed an order. |
required |
separator
|
str
|
Separator between lunch time and order data. Defaults to " ❘ ". |
' ❘ '
|
emoji
|
str
|
Emoji used as number lunch symbol. Defaults to "🍕". |
'🍕'
|
per_icon
|
str
|
icon used between the lunch emoji and the number of people that placed an order. Usually a multiply operator. Defaults to " ✖ ". |
' ✖ '
|
is_takeaway
|
bool
|
takeaway flag (true if the order is to takeaway). Defaults to False. |
False
|
takeaway_alert_sign
|
str
|
warning text to highlight that the order is to takeaway. Defaults to "TAKEAWAY". |
'TAKEAWAY'
|
css_classes
|
list
|
CSS classes to assign to the resulting HTML pane. Defaults to []. |
[]
|
stylesheets
|
list
|
Stylesheets to assign to the resulting HTML pane
(see |
[]
|
Returns:
Type | Description |
---|---|
HTML
|
HTML pane representing a label with order summary. |
Source code in dlunch/gui.py
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
|
load_sidebar_tabs
load_sidebar_tabs(
config: DictConfig, clear_before_loading: bool = True
) -> None
Append tabs to the app template sidebar.
The flag clear_before_loading
is set to true only during first instantiation, because the sidebar is empty at first.
Use the default value during normal operation to avoid tabs duplication.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
clear_before_loading
|
bool
|
Set to true to remove all tabs before appending the new ones. Defaults to True. |
True
|
Source code in dlunch/gui.py
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 |
|
PasswordRenewer
Bases: Parameterized
Param class used to create the widget that collect info to renew users password.
This widget is used only if basic authentication is active.
Methods:
Name | Description |
---|---|
__str__ |
String representation of this object. |
Attributes:
Name | Type | Description |
---|---|---|
new_password |
String
|
New password. |
old_password |
String
|
Old password. |
repeat_new_password |
String
|
Repeat the new password. This field tests if the new password is as intended. |
Source code in dlunch/gui.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
new_password
class-attribute
instance-attribute
New password.
old_password
class-attribute
instance-attribute
Old password.
repeat_new_password
class-attribute
instance-attribute
Repeat the new password. This field tests if the new password is as intended.
__str__
__str__()
String representation of this object.
Returns:
Type | Description |
---|---|
str
|
string representation. |
Source code in dlunch/gui.py
114 115 116 117 118 119 120 |
|
Person
Bases: Parameterized
Param class that define user data and lunch preferences for its order.
username
is automatically set for privileged users. It's left empty for guest users.
lunch_time
and guest
available value are set when instantiation happens.
Check panel.lunch_times_options
and panel.guest_types
config keys.
Methods:
Name | Description |
---|---|
__init__ |
|
__str__ |
String representation of this object. |
Attributes:
Name | Type | Description |
---|---|---|
guest |
ObjectSelector
|
List of available guest types. |
lunch_time |
ObjectSelector
|
List of available lunch times. |
takeaway |
Boolean
|
Takeaway flag (true if takeaway). |
username |
String
|
Username |
Source code in dlunch/gui.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
guest
class-attribute
instance-attribute
guest: ObjectSelector = guest_types[0]
List of available guest types.
lunch_time
class-attribute
instance-attribute
lunch_time: ObjectSelector = ObjectSelector(
default="12:30",
doc="choose your lunch time",
objects=["12:30"],
)
List of available lunch times.
takeaway
class-attribute
instance-attribute
Takeaway flag (true if takeaway).
username
class-attribute
instance-attribute
Username
__init__
__init__(config: OmegaConf, **params)
Source code in dlunch/gui.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
__str__
__str__()
String representation of this object.
Returns:
Type | Description |
---|---|
str
|
string representation. |
Source code in dlunch/gui.py
93 94 95 96 97 98 99 |
|