diff --git a/cypress/e2e/1_cluster-welcome.cy.js b/cypress/e2e/1_cluster-welcome.cy.js index 5144fbd8c..6022afed5 100644 --- a/cypress/e2e/1_cluster-welcome.cy.js +++ b/cypress/e2e/1_cluster-welcome.cy.js @@ -14,7 +14,7 @@ describe('Welcome page', () => { it('successfully logs in and logs out', () => { cy.login(Cypress.env('username'), Cypress.env('password')); - cy.contains('Default'); // cluster name + cy.contains('Data container'); cy.contains('Running'); // cluster status cy.contains('Cluster rebalancing on'); // rebalancing status cy.contains('15 Caches'); @@ -35,7 +35,7 @@ describe('Welcome page', () => { it('successfully opens and navigates side menu', () => { cy.login(Cypress.env('username'), Cypress.env('password')); - cy.contains('Default'); // cluster name + cy.contains('Data container'); cy.contains('Running'); // cluster status //Checks if navigation menu is hidden @@ -63,7 +63,7 @@ describe('Welcome page', () => { //Clicks the Data Container link and should go to Data Container page cy.contains('Data Container').click(); - cy.contains('Default').should('be.visible'); + cy.contains('Data container').should('be.visible'); cy.contains('Running'); // cluster status cy.contains('Cluster rebalancing on'); // rebalancing status }); diff --git a/cypress/e2e/1_data-container.cy.js b/cypress/e2e/1_data-container.cy.js index 797f64686..b42e1f467 100644 --- a/cypress/e2e/1_data-container.cy.js +++ b/cypress/e2e/1_data-container.cy.js @@ -7,7 +7,7 @@ describe('Data Container Overview', () => { //Data Container Overview it('successfully loads Data Container Overview', () => { - cy.contains('Default'); // cluster name + cy.contains('Data container'); cy.contains('Running'); // cluster status cy.contains('Cluster rebalancing on'); // rebalancing status cy.get('#cluster-manager-header').should('exist'); diff --git a/cypress/e2e/1_global-stats.cy.js b/cypress/e2e/1_global-stats.cy.js index cca5097ad..df4d572d6 100644 --- a/cypress/e2e/1_global-stats.cy.js +++ b/cypress/e2e/1_global-stats.cy.js @@ -16,7 +16,7 @@ describe('Global stats', () => { //click View all caches should navigate to console page cy.get('[data-cy="viewCachesLink"]').click(); //Verify that page is properly loaded after click; - cy.contains('Default'); // cluster name + cy.contains('Data container'); cy.contains('Running'); // cluster status cy.contains('Cluster rebalancing on'); // rebalancing status cy.contains('default'); // cache default diff --git a/cypress/e2e/1_rbac_func.cy.js b/cypress/e2e/1_rbac_func.cy.js index 0e85e75fc..39e255442 100644 --- a/cypress/e2e/1_rbac_func.cy.js +++ b/cypress/e2e/1_rbac_func.cy.js @@ -113,7 +113,7 @@ describe('RBAC Functionality Tests', () => { function checkDataContainerView(isMonitor, isDeployer, isAdmin, isSuperAdmin) { //Checking Data Container view - cy.contains('Default'); // cluster name + cy.contains('Data container'); // cluster name cy.contains('Running'); // cluster status if (isSuperAdmin) { cy.get('[data-cy=rebalancingSwitch]').should('exist'); // rebalancing status diff --git a/src/__tests__/views/caches/IgnoreCache.test.tsx b/src/__tests__/views/caches/IgnoreCache.test.tsx index b3dcc3148..1d6334dae 100644 --- a/src/__tests__/views/caches/IgnoreCache.test.tsx +++ b/src/__tests__/views/caches/IgnoreCache.test.tsx @@ -32,13 +32,7 @@ mockedCacheHook.useUndoIgnoreCache.mockImplementation(() => { describe('Ignore/Hide cache', () => { test('not render the dialog if the modal is closed', () => { renderWithRouter( - closeModalCalls++} - action="ignore" - /> + closeModalCalls++} action="ignore" /> ); expect(screen.queryByRole('modal')).toBeNull(); expect(closeModalCalls).toBe(0); @@ -48,16 +42,10 @@ describe('Ignore/Hide cache', () => { test('render the dialog and buttons work', () => { renderWithRouter( - closeModalCalls++} - action="ignore" - /> + closeModalCalls++} action="ignore" /> ); - expect(mockedCacheHook.useIgnoreCache).toHaveBeenCalledWith('cm-1', 'cache-1'); + expect(mockedCacheHook.useIgnoreCache).toHaveBeenCalledWith('cache-1'); expect(screen.queryByRole('modal')).toBeDefined(); expect(screen.queryAllByRole('button')).toHaveLength(3); @@ -77,13 +65,7 @@ describe('Ignore/Hide cache', () => { describe('Undo hide cache', () => { test('not render the dialog if the modal is closed', () => { renderWithRouter( - closeModalCalls++} - action="undo" - /> + closeModalCalls++} action="undo" /> ); expect(screen.queryByRole('modal')).toBeNull(); expect(closeModalCalls).toBe(0); @@ -93,16 +75,10 @@ describe('Undo hide cache', () => { test('render the dialog and buttons work', () => { renderWithRouter( - closeModalCalls++} - action="undo" - /> + closeModalCalls++} action="undo" /> ); - expect(mockedCacheHook.useIgnoreCache).toHaveBeenCalledWith('cm-1', 'cache-1'); + expect(mockedCacheHook.useIgnoreCache).toHaveBeenCalledWith('cache-1'); expect(screen.queryByRole('modal')).toBeDefined(); expect(screen.queryAllByRole('button')).toHaveLength(3); diff --git a/src/app/About/About.tsx b/src/app/About/About.tsx index 92555e0ef..940e081e6 100644 --- a/src/app/About/About.tsx +++ b/src/app/About/About.tsx @@ -14,7 +14,8 @@ import { TextList, TextListItem, TextListItemVariants, - TextListVariants + TextListVariants, + Spinner } from '@patternfly/react-core'; import icon from '!!url-loader!@app/assets/favicons/ms-icon-310x310.png'; import backgroundImage from '!!url-loader!@app/assets/images/infinispanbg_1200.png'; @@ -29,12 +30,13 @@ import { global_spacer_lg } from '@patternfly/react-tokens'; import { useFetchVersion } from '@app/services/serverHook'; import { useTranslation } from 'react-i18next'; import './About.css'; +import { useEffect } from 'react'; const About = (props: { isModalOpen: boolean; closeModal: () => void }) => { const { t } = useTranslation(); const brandname = t('brandname.brandname'); - const { version } = useFetchVersion(); + const { version, loading, setLoading } = useFetchVersion(); const infinispanGithubLink = 'https://github.com/infinispan/'; const infinispanZulipLink = 'https://infinispan.zulipchat.com/'; @@ -46,6 +48,12 @@ const About = (props: { isModalOpen: boolean; closeModal: () => void }) => { const license = t('welcome-page.license', { brandname: brandname }); const apacheLicense = t('welcome-page.apache-license'); + useEffect(() => { + if (props.isModalOpen) { + setLoading(true); + } + }, [props.isModalOpen]); + return ( void }) => { Version - {version} + + {loading ? : version} + diff --git a/src/app/CacheManagers/CacheManagers.tsx b/src/app/CacheManagers/CacheManagers.tsx index 42c6b97c7..f296f0d28 100644 --- a/src/app/CacheManagers/CacheManagers.tsx +++ b/src/app/CacheManagers/CacheManagers.tsx @@ -50,7 +50,6 @@ const CacheManagers = () => { const [showTasks, setShowTasks] = useState(false); const [showSerializationContext, setShowSerializationContext] = useState(false); const { t } = useTranslation(); - const brandname = t('brandname.brandname'); const handleTabClick = (nav) => { const tabIndex = nav.itemId; @@ -131,7 +130,7 @@ const CacheManagers = () => { return ( - {cm && } + {cm && } {cm && } {cm && ConsoleServices.security().hasConsoleACL(ConsoleACL.ADMIN, connectedUser) && ( @@ -157,7 +156,7 @@ const CacheManagers = () => { }; const buildHeader = () => { - let title = t('cache-managers.title'); + const title = t('cache-managers.title'); if (!cm) { return ( @@ -172,8 +171,6 @@ const CacheManagers = () => { ); } - title = displayUtils.capitalize(cm.name); - return ( diff --git a/src/app/CacheManagers/CacheTableDisplay.tsx b/src/app/CacheManagers/CacheTableDisplay.tsx index 8a0b8e0f9..b500468b1 100644 --- a/src/app/CacheManagers/CacheTableDisplay.tsx +++ b/src/app/CacheManagers/CacheTableDisplay.tsx @@ -67,7 +67,7 @@ interface CacheAction { action: '' | 'ignore' | 'undo' | 'delete' | 'available'; } -const CacheTableDisplay = (props: { cmName: string; setCachesCount: (count: number) => void; isVisible: boolean }) => { +const CacheTableDisplay = (props: { setCachesCount: (count: number) => void; isVisible: boolean }) => { const { t } = useTranslation(); const { connectedUser } = useConnectedUser(); const { setBanner } = useBanner(); @@ -466,7 +466,7 @@ const CacheTableDisplay = (props: { cmName: string; setCachesCount: (count: numb const cacheTemplateButton = ( @@ -810,7 +810,6 @@ const CacheTableDisplay = (props: { cmName: string; setCachesCount: (count: numb closeModal={closeDeleteModal} /> { const { t } = useTranslation(); - const cmName = useParams()['cmName'] as string; - const { cacheTemplates, loading, error } = useFetchCacheTemplates(cmName); + const { cacheTemplates, loading, error } = useFetchCacheTemplates(); const [filteredTemplates, setFilteredTemplates] = useState([]); const [rows, setRows] = useState([]); const [expandedTemplateNames, setExpandedRepoNames] = useState([]); diff --git a/src/app/Caches/Create/CacheConfigEditor.tsx b/src/app/Caches/Create/CacheConfigEditor.tsx index 1d77acf06..e6124335b 100644 --- a/src/app/Caches/Create/CacheConfigEditor.tsx +++ b/src/app/Caches/Create/CacheConfigEditor.tsx @@ -27,7 +27,6 @@ import { selectOptionPropsFromArray } from '@utils/selectOptionPropsCreator'; import { TableEmptyState } from '@app/Common/TableEmptyState'; const CacheConfigEditor = (props: { - cmName: string; cacheEditor: CacheEditorStep; cacheEditorModifier: (CacheEditorStep) => void; setReviewConfig: (string) => void; @@ -46,7 +45,6 @@ const CacheConfigEditor = (props: { const { addAlert } = useApiAlert(); const { t } = useTranslation(); - const cmName = props.cmName; const configurationDocs = t('brandname.configuration-docs-link'); const [selectedConfigDisabled, setSelectedConfigDisabled] = useState(false); @@ -62,7 +60,7 @@ const CacheConfigEditor = (props: { useEffect(() => { if (loading) { ConsoleServices.dataContainer() - .getCacheConfigurationTemplates(cmName) + .getCacheConfigurationTemplates() .then((eitherTemplates) => { if (eitherTemplates.isRight()) { const options: TemplateOptionSelect[] = []; diff --git a/src/app/Caches/Create/CreateCacheWizard.tsx b/src/app/Caches/Create/CreateCacheWizard.tsx index a003920db..f17cf0417 100644 --- a/src/app/Caches/Create/CreateCacheWizard.tsx +++ b/src/app/Caches/Create/CreateCacheWizard.tsx @@ -54,7 +54,6 @@ const CreateCacheWizard = (props: { cacheManager: CacheManager; create: boolean }); const [cacheEditor, setCacheEditor] = useState(CacheEditorInitialState); - const [stepIdReached, setStepIdReached] = useState(1); const [reviewConfig, setReviewConfig] = useState(''); const [isDownloadModalOpen, setIsDownloadModalOpen] = useState(false); const canCreateCache = ConsoleServices.security().hasConsoleACL(ConsoleACL.CREATE, connectedUser); @@ -211,7 +210,6 @@ const CreateCacheWizard = (props: { cacheManager: CacheManager; create: boolean diff --git a/src/app/Caches/CreateCache.tsx b/src/app/Caches/CreateCache.tsx index 4abf47931..315060274 100644 --- a/src/app/Caches/CreateCache.tsx +++ b/src/app/Caches/CreateCache.tsx @@ -35,7 +35,6 @@ const CreateCache = () => { const [loadingBackups, setLoadingBackups] = useState(true); const [isBackupAvailable, setIsBackupAvailable] = useState(false); const [localSite, setLocalSite] = useState(''); - const [title, setTitle] = useState('Data container is empty.'); const { connectedUser } = useConnectedUser(); const canCreateCache = ConsoleServices.security().hasConsoleACL(ConsoleACL.CREATE, connectedUser); @@ -47,7 +46,6 @@ const CreateCache = () => { if (r.isRight()) { const cm = r.value; setCacheManager(cm); - setTitle(displayUtils.capitalize(displayUtils.capitalize(cm.name))); setIsBackupAvailable(cm.backups_enabled); if (cm.backups_enabled && cm.local_site) { setLocalSite(cm.local_site); @@ -92,8 +90,8 @@ const CreateCache = () => { {localSite == '' - ? t(`caches.${id}.page-title`, { cmName: title }) - : t(`caches.${id}.page-title-with-backups`, { cmName: title, localsite: localSite })} + ? t(`caches.${id}.page-title`) + : t(`caches.${id}.page-title-with-backups`, { localsite: localSite })} diff --git a/src/app/Caches/IgnoreCache.tsx b/src/app/Caches/IgnoreCache.tsx index 072c442e9..8996217b9 100644 --- a/src/app/Caches/IgnoreCache.tsx +++ b/src/app/Caches/IgnoreCache.tsx @@ -9,15 +9,14 @@ import { useIgnoreCache, useUndoIgnoreCache } from '@app/services/cachesHook'; * Ignore cache modal */ const IgnoreCache = (props: { - cmName: string; cacheName: string; isModalOpen: boolean; closeModal: (boolean) => void; action: string; }) => { const { reloadCaches } = useCaches(); - const { onIgnore } = useIgnoreCache(props.cmName, props.cacheName); - const { onUndoIgnore } = useUndoIgnoreCache(props.cmName, props.cacheName); + const { onIgnore } = useIgnoreCache(props.cacheName); + const { onUndoIgnore } = useUndoIgnoreCache(props.cacheName); const { t } = useTranslation(); const brandname = t('brandname.brandname'); diff --git a/src/app/GlobalStats/GlobalStats.tsx b/src/app/GlobalStats/GlobalStats.tsx index d1f7ee23b..bdd9031db 100644 --- a/src/app/GlobalStats/GlobalStats.tsx +++ b/src/app/GlobalStats/GlobalStats.tsx @@ -409,7 +409,7 @@ const GlobalStats = () => { {buildStats()} { reload(); diff --git a/src/app/Rebalancing/RebalancingCacheManager.tsx b/src/app/Rebalancing/RebalancingCacheManager.tsx index 2ccbe20b1..e1b7bcdd0 100644 --- a/src/app/Rebalancing/RebalancingCacheManager.tsx +++ b/src/app/Rebalancing/RebalancingCacheManager.tsx @@ -43,7 +43,7 @@ const RebalancingCacheManager = () => { isModalOpen={confirmationModalOpened} confirmAction={() => ConsoleServices.dataContainer() - .rebalancing(cm.name, !cm.rebalancing_enabled) + .rebalancing(!cm.rebalancing_enabled) .then((r) => { addAlert(r); reload(); diff --git a/src/app/Welcome/Welcome.tsx b/src/app/Welcome/Welcome.tsx index 0938aabfe..c30fefd20 100644 --- a/src/app/Welcome/Welcome.tsx +++ b/src/app/Welcome/Welcome.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { Alert, Badge, @@ -39,7 +39,7 @@ const Welcome = () => { const navigate = useNavigate(); const [supportOpen, setSupportOpen] = useState(false); const { notSecuredModeOn, logUser } = useConnectedUser(); - const { version } = useFetchVersion(); + const { version, setLoading } = useFetchVersion(); const brandname = t('brandname.brandname'); @@ -47,15 +47,15 @@ const Welcome = () => { const description2 = t('welcome-page.description2', { brandname: brandname }); const license = t('welcome-page.license'); + useEffect(() => { + setLoading(true); + }, []); + const login = () => { navigate('/'); location.reload(); }; - const notSecured = () => { - navigate('/'); - }; - const goToTheConsole = t('welcome-page.go-to-console'); const buildConsoleButton = () => { diff --git a/src/app/assets/languages/en.json b/src/app/assets/languages/en.json index 5b5780257..c5ba80b24 100644 --- a/src/app/assets/languages/en.json +++ b/src/app/assets/languages/en.json @@ -198,8 +198,8 @@ }, "caches": { "setup": { - "page-title": "Configure a cache in {{cmName}}", - "page-title-with-backups": "Configure a cache in {{cmName}} on site {{localsite}}", + "page-title": "Configure a cache", + "page-title-with-backups": "Configure a cache on site {{localsite}}", "page-title-description": "You can generate a cache config. Note that the new cache will not be stored by {{brandname}}", "getting-started": { "cache-setup-title": "Select a way to configure your cache" diff --git a/src/app/providers/CacheManagerContextProvider.tsx b/src/app/providers/CacheManagerContextProvider.tsx index 7d1359a80..6336bef87 100644 --- a/src/app/providers/CacheManagerContextProvider.tsx +++ b/src/app/providers/CacheManagerContextProvider.tsx @@ -43,7 +43,7 @@ const ContainerDataProvider = ({ children }) => { if (loadingCaches && cm) { if (ConsoleServices.authentication().isNotSecured()) { ConsoleServices.dataContainer() - .getCaches(cm.name) + .getCaches() .then((either) => { if (either.isRight()) { setCaches(either.value); @@ -56,7 +56,7 @@ const ContainerDataProvider = ({ children }) => { reloadAcl().then((r) => { if (r) { ConsoleServices.dataContainer() - .getCaches(cm.name) + .getCaches() .then((either) => { if (either.isRight()) { setCaches(either.value); diff --git a/src/app/routes.tsx b/src/app/routes.tsx index 606a427ed..d7ceb0c0e 100644 --- a/src/app/routes.tsx +++ b/src/app/routes.tsx @@ -87,7 +87,7 @@ const routes: IAppRoute[] = [ component: , exact: true, label: 'Cache Manager Configurations', - path: '/container/:cmName/configurations', + path: '/container/configurations', title: 'Configurations', menu: false, admin: false @@ -178,7 +178,7 @@ const AppRoutes = () => { } return } />; })} - } /> + } /> } /> ); diff --git a/src/app/services/cachesHook.ts b/src/app/services/cachesHook.ts index 541a11548..e137bb880 100644 --- a/src/app/services/cachesHook.ts +++ b/src/app/services/cachesHook.ts @@ -3,7 +3,7 @@ import { CacheDetailContext } from '@app/providers/CacheDetailProvider'; import { ConsoleServices } from '@services/ConsoleServices'; import { useApiAlert } from '@app/utils/useApiAlert'; -export function useFetchCaches(cacheManager: string) { +export function useFetchCaches() { const [caches, setCaches] = useState([]); const [error, setError] = useState(''); const [loading, setLoading] = useState(true); @@ -11,7 +11,7 @@ export function useFetchCaches(cacheManager: string) { useEffect(() => { if (loading) { ConsoleServices.dataContainer() - .getCaches(cacheManager) + .getCaches() .then((either) => { if (either.isRight()) { setCaches(either.value); @@ -70,12 +70,12 @@ export function useDeleteCache(cacheName: string) { }; } -export function useIgnoreCache(cmName: string, cacheName: string) { +export function useIgnoreCache(cacheName: string) { const { addAlert } = useApiAlert(); const onIgnore = () => { ConsoleServices.caches() - .ignoreCache(cmName, cacheName) + .ignoreCache(cacheName) .then((actionResponse) => { addAlert(actionResponse); }); @@ -85,12 +85,12 @@ export function useIgnoreCache(cmName: string, cacheName: string) { }; } -export function useUndoIgnoreCache(cmName: string, cacheName: string) { +export function useUndoIgnoreCache(cacheName: string) { const { addAlert } = useApiAlert(); const onUndoIgnore = () => { ConsoleServices.caches() - .undoIgnoreCache(cmName, cacheName) + .undoIgnoreCache(cacheName) .then((actionResponse) => { addAlert(actionResponse); }); @@ -115,7 +115,7 @@ export function useSetAvailableCache(cacheName: string) { }; } -export function useFetchCacheTemplates(cmName) { +export function useFetchCacheTemplates() { const [cacheTemplates, setCacheTemplates] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); @@ -123,7 +123,7 @@ export function useFetchCacheTemplates(cmName) { useEffect(() => { if (loading) { ConsoleServices.dataContainer() - .getCacheConfigurationTemplates(cmName) + .getCacheConfigurationTemplates() .then((eitherConfigs) => { if (eitherConfigs.isRight()) { setCacheTemplates(eitherConfigs.value); diff --git a/src/app/services/serverHook.ts b/src/app/services/serverHook.ts index 2a98555a9..4fedbc6a6 100644 --- a/src/app/services/serverHook.ts +++ b/src/app/services/serverHook.ts @@ -5,7 +5,7 @@ import { groupConnections } from '@app/utils/connectedClientUtils'; export function useFetchVersion() { const [version, setVersion] = useState(''); const [error, setError] = useState(''); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState(false); useEffect(() => { if (loading && version == '') { diff --git a/src/app/services/statsHook.ts b/src/app/services/statsHook.ts index 487aeea0c..8b4b854e3 100644 --- a/src/app/services/statsHook.ts +++ b/src/app/services/statsHook.ts @@ -4,7 +4,6 @@ import { useApiAlert } from '@utils/useApiAlert'; export function useFetchGlobalStats() { const [stats, setStats] = useState({ - name: '', statistics_enabled: false, hits: -1, retrievals: -1, @@ -20,20 +19,12 @@ export function useFetchGlobalStats() { useEffect(() => { if (loading) { ConsoleServices.dataContainer() - .getDefaultCacheManager() - .then((eitherDefaultCm) => { - if (eitherDefaultCm.isRight()) { - ConsoleServices.dataContainer() - .getCacheManagerStats(eitherDefaultCm.value.name) - .then((eitherDetailedStats) => { - if (eitherDetailedStats.isRight()) { - setStats(eitherDetailedStats.value); - } else { - setError(eitherDetailedStats.value.message); - } - }); + .getCacheManagerStats() + .then((eitherDetailedStats) => { + if (eitherDetailedStats.isRight()) { + setStats(eitherDetailedStats.value); } else { - setError(eitherDefaultCm.value.message); + setError(eitherDetailedStats.value.message); } }) .then(() => setLoading(false)); @@ -93,7 +84,7 @@ export function useClearStats(name: string, type: 'query' | 'cache-metrics' | 'g } else if (type == 'cache-metrics') { actionResponsePromise = ConsoleServices.caches().clearStats(name); } else if (type == 'global-stats') { - actionResponsePromise = ConsoleServices.dataContainer().clearCacheManagerStats(name); + actionResponsePromise = ConsoleServices.dataContainer().clearCacheManagerStats(); } else { console.warn('Requesting a reset type that is not available. Do nothing'); actionResponsePromise = undefined; diff --git a/src/services/authService.ts b/src/services/authService.ts index 7a854f014..3533ddc74 100644 --- a/src/services/authService.ts +++ b/src/services/authService.ts @@ -4,7 +4,6 @@ import { ConsoleServices } from '@services/ConsoleServices'; /** * Authentication Service calls Infinispan endpoints related to Authentication * - * @author Katia Aresti * @since 1.0 */ export class AuthenticationService { @@ -20,51 +19,6 @@ export class AuthenticationService { return this.notSecured; } - /** - * Retrieve the http login endpoint - */ - public httpLoginUrl(): string { - return this.endpoint; - } - - public getUserName(): string { - return this.username; - } - - public isLoggedIn(): boolean { - return this.username != ''; // && this.authenticatedClient != undefined; - } - - public logOut() { - return fetch(ConsoleServices.endpoint() + '/server', { - headers: { Authorization: 'Basic xxx' } - }) - .then((response) => { - console.log(response); - if (response.ok) { - return { - success: true, - message: ' logged in' - }; - } - if (response.status == 401) { - return { - success: false, - message: 'not authorized' - }; - } - - throw response; - }) - .catch((err) => { - console.error(err); - return { - success: false, - message: 'Unexpected error. Check the logs' - }; - }); - } - public noSecurityMode() { this.notSecured = true; } diff --git a/src/services/cacheService.ts b/src/services/cacheService.ts index 208027d5d..09a189188 100644 --- a/src/services/cacheService.ts +++ b/src/services/cacheService.ts @@ -156,9 +156,9 @@ export class CacheService { * * @param cacheName, to be deleted if such exists */ - public async ignoreCache(cacheManager: string, cacheName: string): Promise { + public async ignoreCache(cacheName: string): Promise { return this.fetchCaller.post({ - url: this.endpoint + '/server/ignored-caches/' + cacheManager + '/' + encodeURIComponent(cacheName), + url: this.endpoint + '/server/ignored-caches/' + encodeURIComponent(cacheName), successMessage: `Cache ${cacheName} hidden.`, errorMessage: `Unexpected error hidding cache ${cacheName}.` }); @@ -169,9 +169,9 @@ export class CacheService { * * @param cacheName, to be deleted if such exists */ - public async undoIgnoreCache(cacheManager: string, cacheName: string): Promise { + public async undoIgnoreCache(cacheName: string): Promise { return this.fetchCaller.delete({ - url: this.endpoint + '/server/ignored-caches/' + cacheManager + '/' + encodeURIComponent(cacheName), + url: this.endpoint + '/server/ignored-caches/' + encodeURIComponent(cacheName), successMessage: `Cache ${cacheName} is now visible.`, errorMessage: `Unexpected error making cache ${cacheName} visible again.` }); diff --git a/src/services/dataContainerService.ts b/src/services/dataContainerService.ts index e68474736..34935a51b 100644 --- a/src/services/dataContainerService.ts +++ b/src/services/dataContainerService.ts @@ -1,5 +1,5 @@ import { FetchCaller } from './fetchCaller'; -import { Either, left } from './either'; +import { Either } from './either'; import { CacheConfigUtils } from '@services/cacheConfigUtils'; import displayUtils from '@services/displayUtils'; @@ -27,25 +27,14 @@ export class ContainerService { * For now there is a single cache manager */ public getDefaultCacheManager(): Promise> { - return this.fetchCaller - .get(this.endpoint + '/server/cache-managers/', (data) => data[0]) - .then((maybeCmName) => { - if (maybeCmName.isRight()) { - return this.getCacheManager(maybeCmName.value); - } - return left(maybeCmName); - }); - } - - private getCacheManager(name: string): Promise> { - const healthPromise: Promise> = this.fetchCaller.get( - this.endpoint + '/cache-managers/' + name + '/health', + const healthPromise: Promise> = this.fetchCaller.get( + this.endpoint + '/container/health', (data) => data.cluster_health.health_status ); return healthPromise.then((maybeHealth) => this.fetchCaller.get( - this.endpoint + '/cache-managers/' + name, + this.endpoint + '/container/', (data) => { name: data.name, @@ -81,22 +70,18 @@ export class ContainerService { /** * Retrieve the cache manager stats - * - * @param name, the name of the cache manager */ - public async getCacheManagerStats(name: string): Promise> { - return this.fetchCaller.get(this.endpoint + '/cache-managers/' + name + '/stats', (data) => { - const stats = data; - stats.name = name; - return stats; + public async getCacheManagerStats(): Promise> { + return this.fetchCaller.get(this.endpoint + '/container/stats', (data) => { + return data; }); } /** * Clear cache manager stats */ - public async clearCacheManagerStats(name: string): Promise { - const clearUrl = this.endpoint + '/cache-managers/' + name + '/stats?action=reset'; + public async clearCacheManagerStats(): Promise { + const clearUrl = this.endpoint + '/container/stats?action=reset'; return this.fetchCaller.post({ url: clearUrl, successMessage: `Global metrics cleared.`, @@ -107,10 +92,9 @@ export class ContainerService { /** * Get cache configuration templates for in the cache manager name * - * @param name, the name of the cache manager */ - public async getCacheConfigurationTemplates(name: string): Promise> { - return this.fetchCaller.get(this.endpoint + '/cache-managers/' + name + '/cache-configs/templates', (data) => + public async getCacheConfigurationTemplates(): Promise> { + return this.fetchCaller.get(this.endpoint + '/container/cache-configs/templates', (data) => data .filter((config) => !this.isInternalTemplate(config.name)) .map( @@ -127,8 +111,8 @@ export class ContainerService { * Get all caches for a cache manager * @param name */ - public async getCaches(name: string): Promise> { - return this.fetchCaller.get(this.endpoint + '/cache-managers/' + name + '/caches', (data) => + public async getCaches(): Promise> { + return this.fetchCaller.get(this.endpoint + '/caches?action=detailed', (data) => data .map( (cacheInfo) => @@ -155,12 +139,11 @@ export class ContainerService { /** * Enables or disables rebalancing on a cluster - * @param name of the cache manager * @param enable, true to enable, false for disable */ - public async rebalancing(name: string, enable: boolean): Promise { + public async rebalancing(enable: boolean): Promise { const action = enable ? 'enable' : 'disable'; - const url = this.endpoint + '/cache-managers/' + encodeURIComponent(name) + '?action=' + action + '-rebalancing'; + const url = this.endpoint + '/container?action=' + action + '-rebalancing'; return this.fetchCaller.post({ url: url, successMessage: `Rebalancing ${action}d.`, diff --git a/src/types/InfinispanTypes.ts b/src/types/InfinispanTypes.ts index 0dfb04c68..58541fd9b 100644 --- a/src/types/InfinispanTypes.ts +++ b/src/types/InfinispanTypes.ts @@ -29,7 +29,6 @@ interface ClusterMember { } interface CacheManagerStats { - name: string; statistics_enabled: boolean; time_since_start?: number; time_since_reset?: number;