From 06b2f1462ce3047364b28049b8ee06abcc905a57 Mon Sep 17 00:00:00 2001 From: Aday BA Date: Thu, 18 Jul 2024 16:36:17 +0100 Subject: [PATCH] Added configurable default number of apps to show in the apps table (#3672) Added configurable default number of apps to show in the apps table. --- apps/dashboard/app/javascript/apps.js | 6 +++++- apps/dashboard/app/javascript/config.js | 5 +++++ apps/dashboard/app/models/user_configuration.rb | 5 ++++- apps/dashboard/app/views/layouts/_config.html.erb | 1 + apps/dashboard/test/models/user_configuration_test.rb | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/app/javascript/apps.js b/apps/dashboard/app/javascript/apps.js index 65ef46a9cd..84308f93d3 100644 --- a/apps/dashboard/app/javascript/apps.js +++ b/apps/dashboard/app/javascript/apps.js @@ -1,7 +1,11 @@ 'use strict'; +import { appsDatatablePageLength } from './config.js'; + jQuery(function() { + const pageLength = appsDatatablePageLength(); $('#all-apps-table').DataTable({ - stateSave: true + stateSave: false, + pageLength: pageLength }); }); diff --git a/apps/dashboard/app/javascript/config.js b/apps/dashboard/app/javascript/config.js index 19cf8b3ee7..710246c491 100644 --- a/apps/dashboard/app/javascript/config.js +++ b/apps/dashboard/app/javascript/config.js @@ -87,4 +87,9 @@ export function statusPollDelay() { export function statusIndexUrl() { const cfgData = configData(); return cfgData['statusIndexUrl']; +} + +export function appsDatatablePageLength() { + const cfgData = configData(); + return parseInt(cfgData['appsDatatablePageLength']); } \ No newline at end of file diff --git a/apps/dashboard/app/models/user_configuration.rb b/apps/dashboard/app/models/user_configuration.rb index 1fe33ea7d6..ac9f0ea684 100644 --- a/apps/dashboard/app/models/user_configuration.rb +++ b/apps/dashboard/app/models/user_configuration.rb @@ -77,7 +77,10 @@ class UserConfiguration # Custom pages configuration property ConfigurationProperty.property(name: :custom_pages, default_value: {}), # Support ticket configuration property - ConfigurationProperty.property(name: :support_ticket, default_value: {}) + ConfigurationProperty.property(name: :support_ticket, default_value: {}), + + # Datatables configuration for the apps pages + ConfigurationProperty.property(name: :apps_datatable, default_value: { page_length: 10 }) ].freeze def initialize(request_hostname: nil) diff --git a/apps/dashboard/app/views/layouts/_config.html.erb b/apps/dashboard/app/views/layouts/_config.html.erb index 560e55a560..14a0533333 100644 --- a/apps/dashboard/app/views/layouts/_config.html.erb +++ b/apps/dashboard/app/views/layouts/_config.html.erb @@ -11,4 +11,5 @@ data-bc-index-url="<%= batch_connect_sessions_path %>" data-status-poll-delay="<%= Configuration.status_poll_delay %>" data-status-index-url="<%= system_status_path if respond_to?(:system_status_path) %>" + data-apps-datatable-page-length="<%= @user_configuration.apps_datatable[:page_length] %>" > diff --git a/apps/dashboard/test/models/user_configuration_test.rb b/apps/dashboard/test/models/user_configuration_test.rb index d5308034f1..644d2c7354 100644 --- a/apps/dashboard/test/models/user_configuration_test.rb +++ b/apps/dashboard/test/models/user_configuration_test.rb @@ -79,6 +79,7 @@ def teardown interactive_apps_menu: [], custom_pages: {}, support_ticket: {}, + apps_datatable: { page_length: 10 }, } # ensure all properties are tested