diff --git a/.github/workflows/ci_cd.yaml b/.github/workflows/ci_cd.yaml index c8037e7..45bd45d 100644 --- a/.github/workflows/ci_cd.yaml +++ b/.github/workflows/ci_cd.yaml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install pypa/build @@ -36,7 +36,7 @@ jobs: - name: Build a binary wheel and a source tarball run: python3 -m build - name: Store the distribution packages - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: python-package-distributions path: dist/ @@ -58,7 +58,7 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: python-package-distributions path: dist/ @@ -74,6 +74,7 @@ jobs: environment: name: release + url: https://github.com/Michele-Alberti/data-lunch/releases permissions: contents: write # IMPORTANT: mandatory for making GitHub Releases @@ -81,7 +82,7 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: python-package-distributions path: dist/ @@ -127,22 +128,22 @@ jobs: with: ref: main - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} + username: ${{ vars.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: ./ file: ./docker/web/Dockerfile.web builder: ${{ steps.buildx.outputs.name }} push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/data-lunch-app:stable - cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache,mode=max + tags: ${{ vars.DOCKER_HUB_USERNAME }}/data-lunch-app:stable + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache,mode=max # If on development just publish to TestPyPI # Build the package for TestPyPI @@ -157,7 +158,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" - name: Install pypa/build @@ -174,7 +175,7 @@ jobs: - name: Build a binary wheel and a source tarball run: python3 -m build - name: Store the distribution packages - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: python-package-distributions path: dist/ @@ -194,7 +195,7 @@ jobs: steps: - name: Download all the dists - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: python-package-distributions path: dist/ diff --git a/.github/workflows/manual_build.yaml b/.github/workflows/manual_build.yaml index e66e2dc..7750b3e 100755 --- a/.github/workflows/manual_build.yaml +++ b/.github/workflows/manual_build.yaml @@ -27,19 +27,19 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} + username: ${{ vars.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: ./ file: ./docker/web/Dockerfile.web builder: ${{ steps.buildx.outputs.name }} push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/data-lunch-app:${{ github.event.inputs.tag }} - cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache,mode=max + tags: ${{ vars.DOCKER_HUB_USERNAME }}/data-lunch-app:${{ github.event.inputs.tag }} + cache-from: type=registry,ref=${{ vars.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache + cache-to: type=registry,ref=${{ vars.DOCKER_HUB_USERNAME }}/data-lunch-app:buildcache,mode=max diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa4e644..1f79bc5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black language_version: python3 diff --git a/dlunch/__init__.py b/dlunch/__init__.py index 196f662..b71b36a 100755 --- a/dlunch/__init__.py +++ b/dlunch/__init__.py @@ -90,8 +90,9 @@ def create_app(config: DictConfig) -> pn.Template: # Build dashboard (the header object is used if defined) app.header.append(gi.header_row) app.sidebar.append(gi.sidebar_tabs) + app.main.append(gi.no_menu_col) app.main.append(gi.guest_override_alert) - app.main.append(gi.no_more_order_text) + app.main.append(gi.no_more_order_alert) app.main.append(gi.main_header_row) app.main.append(gi.quote) app.main.append(pn.Spacer(height=15)) diff --git a/dlunch/__main__.py b/dlunch/__main__.py index 3095dfc..5a58de8 100755 --- a/dlunch/__main__.py +++ b/dlunch/__main__.py @@ -65,10 +65,7 @@ def run_app(config: DictConfig): # Backend exist only if auth is active # Health is an endpoint for app health assessments # Pass a dictionary for a multipage app - pages = { - "": lambda: create_app(config=config), - "health": pn.Column("Data-Lunch is alive!"), - } + pages = {"": lambda: create_app(config=config)} if auth.is_auth_active(config=config): pages["backend"] = lambda: create_backend(config=config) diff --git a/dlunch/conf/panel/gui/default.yaml b/dlunch/conf/panel/gui/default.yaml index 214a0f4..c7a9ab9 100644 --- a/dlunch/conf/panel/gui/default.yaml +++ b/dlunch/conf/panel/gui/default.yaml @@ -9,6 +9,12 @@ logo_filename: logo.png logo_static_dir: images logo_path: ${panel.gui.logo_static_dir}/${panel.gui.logo_filename} +# IMAGES +# No menu +no_menu_image_static_dir: images +no_menu_image_filename: no_menu.jpg +no_menu_image_path: ${panel.gui.no_menu_image_static_dir}/${panel.gui.no_menu_image_filename} + # CSS FILES css_static_dir: css css_files: diff --git a/dlunch/conf/server/common.yaml b/dlunch/conf/server/common.yaml index e3b71c0..e1e3978 100644 --- a/dlunch/conf/server/common.yaml +++ b/dlunch/conf/server/common.yaml @@ -12,4 +12,5 @@ static_dirs: css: ${package_path}/static/css compress_response: true cookie_secret: ${oc.env:DATA_LUNCH_COOKIE_SECRET} # Secure cookies are required (this vakue can't be null) -enable_xsrf_cookies: true \ No newline at end of file +enable_xsrf_cookies: true +liveness: health \ No newline at end of file diff --git a/dlunch/core.py b/dlunch/core.py index 2b67f7f..0e4742e 100644 --- a/dlunch/core.py +++ b/dlunch/core.py @@ -356,6 +356,24 @@ def reload_menu( gi.dataframe.hidden_columns = [] gi.dataframe.disabled = False + # If menu is empty show banner image, otherwise show menu + if df.empty: + gi.no_menu_col.visible = True + gi.main_header_row.visible = False + gi.quote.visible = False + gi.menu_flexbox.visible = False + gi.buttons_flexbox.visible = False + gi.results_divider.visible = False + gi.res_col.visible = False + else: + gi.no_menu_col.visible = False + gi.main_header_row.visible = True + gi.quote.visible = True + gi.menu_flexbox.visible = True + gi.buttons_flexbox.visible = True + gi.results_divider.visible = True + gi.res_col.visible = True + log.debug("menu reloaded") # Load results @@ -847,6 +865,7 @@ def df_list_by_lunch_time( def clean_up_table(config, df_in): # Add columns of totals df = df_in.copy() + df = df.astype(object) # Avoid mixed types (float and notes str) df[config.panel.gui.total_column_name] = df.sum(axis=1) if config.panel.drop_unused_menu_items: df = df[df[config.panel.gui.total_column_name] > 0] @@ -875,9 +894,9 @@ def clean_up_table(config, df_in): # TAKEAWAY if not df_users_takeaways.empty: df_users_takeaways = clean_up_table(config, df_users_takeaways) - df_dict[ - f"{time} {config.panel.gui.takeaway_id}" - ] = df_users_takeaways + df_dict[f"{time} {config.panel.gui.takeaway_id}"] = ( + df_users_takeaways + ) return df_dict diff --git a/dlunch/gui.py b/dlunch/gui.py index 5ec7123..edb43b5 100644 --- a/dlunch/gui.py +++ b/dlunch/gui.py @@ -273,7 +273,7 @@ def reload_on_guest_override_callback( styles={"text-align": "center"}, ) # "no more order" message - self.no_more_order_text = pn.pane.HTML( + self.no_more_order_alert = pn.pane.HTML( """