mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-19 04:41:02 +00:00
Fix #5809 Show count of schemas and tables being deleted when a database service is being deleted. (#5963)
This commit is contained in:
parent
37e7c489e6
commit
eba5776a33
@ -216,3 +216,12 @@ export const getAdvancedFieldOptions = (
|
|||||||
|
|
||||||
return APIClient.get(`/search/suggest`, { params });
|
return APIClient.get(`/search/suggest`, { params });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getEntityCount = (
|
||||||
|
path: string,
|
||||||
|
database?: string
|
||||||
|
): Promise<AxiosResponse> => {
|
||||||
|
const params = { database, limit: 0 };
|
||||||
|
|
||||||
|
return APIClient.get(`/${path}`, { params });
|
||||||
|
};
|
||||||
|
@ -88,6 +88,8 @@ import {
|
|||||||
getServiceCategoryFromType,
|
getServiceCategoryFromType,
|
||||||
servicePageTabs,
|
servicePageTabs,
|
||||||
serviceTypeLogo,
|
serviceTypeLogo,
|
||||||
|
setServiceSchemaCount,
|
||||||
|
setServiceTableCount,
|
||||||
} from '../../utils/ServiceUtils';
|
} from '../../utils/ServiceUtils';
|
||||||
import { getEntityLink, getUsagePercentile } from '../../utils/TableUtils';
|
import { getEntityLink, getUsagePercentile } from '../../utils/TableUtils';
|
||||||
import { showErrorToast } from '../../utils/ToastUtils';
|
import { showErrorToast } from '../../utils/ToastUtils';
|
||||||
@ -125,6 +127,9 @@ const ServicePage: FunctionComponent = () => {
|
|||||||
const [isAirflowRunning, setIsAirflowRunning] = useState(false);
|
const [isAirflowRunning, setIsAirflowRunning] = useState(false);
|
||||||
const [connectionDetails, setConnectionDetails] = useState<ConfigData>();
|
const [connectionDetails, setConnectionDetails] = useState<ConfigData>();
|
||||||
|
|
||||||
|
const [schemaCount, setSchemaCount] = useState<number>(0);
|
||||||
|
const [tableCount, setTableCount] = useState<number>(0);
|
||||||
|
|
||||||
const getCountLabel = () => {
|
const getCountLabel = () => {
|
||||||
switch (serviceName) {
|
switch (serviceName) {
|
||||||
case ServiceCategory.DASHBOARD_SERVICES:
|
case ServiceCategory.DASHBOARD_SERVICES:
|
||||||
@ -370,6 +375,8 @@ const ServicePage: FunctionComponent = () => {
|
|||||||
.then((res: AxiosResponse) => {
|
.then((res: AxiosResponse) => {
|
||||||
if (res.data.data) {
|
if (res.data.data) {
|
||||||
setData(res.data.data);
|
setData(res.data.data);
|
||||||
|
setServiceSchemaCount(res.data.data, setSchemaCount);
|
||||||
|
setServiceTableCount(res.data.data, setTableCount);
|
||||||
setPaging(res.data.paging);
|
setPaging(res.data.paging);
|
||||||
setInstanceCount(res.data.paging.total);
|
setInstanceCount(res.data.paging.total);
|
||||||
setIsloading(false);
|
setIsloading(false);
|
||||||
@ -686,7 +693,10 @@ const ServicePage: FunctionComponent = () => {
|
|||||||
case ServiceCategory.DATABASE_SERVICES:
|
case ServiceCategory.DATABASE_SERVICES:
|
||||||
return getEntityDeleteMessage(
|
return getEntityDeleteMessage(
|
||||||
service || 'Service',
|
service || 'Service',
|
||||||
pluralize(instanceCount, 'Database')
|
`${pluralize(instanceCount, 'Database')}, ${pluralize(
|
||||||
|
schemaCount,
|
||||||
|
'Schema'
|
||||||
|
)} and ${pluralize(tableCount, 'Table')}`
|
||||||
);
|
);
|
||||||
|
|
||||||
case ServiceCategory.MESSAGING_SERVICES:
|
case ServiceCategory.MESSAGING_SERVICES:
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosError, AxiosResponse } from 'axios';
|
||||||
import cryptoRandomString from 'crypto-random-string-with-promisify-polyfill';
|
import cryptoRandomString from 'crypto-random-string-with-promisify-polyfill';
|
||||||
import {
|
import {
|
||||||
Bucket,
|
Bucket,
|
||||||
@ -23,6 +23,7 @@ import {
|
|||||||
ServiceTypes,
|
ServiceTypes,
|
||||||
} from 'Models';
|
} from 'Models';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { getEntityCount } from '../axiosAPIs/miscAPI';
|
||||||
import { getServiceDetails, getServices } from '../axiosAPIs/serviceAPI';
|
import { getServiceDetails, getServices } from '../axiosAPIs/serviceAPI';
|
||||||
import {
|
import {
|
||||||
addMetadataIngestionGuide,
|
addMetadataIngestionGuide,
|
||||||
@ -77,6 +78,7 @@ import {
|
|||||||
} from '../constants/services.const';
|
} from '../constants/services.const';
|
||||||
import { ServiceCategory } from '../enums/service.enum';
|
import { ServiceCategory } from '../enums/service.enum';
|
||||||
import { ConnectionType } from '../generated/api/services/ingestionPipelines/testServiceConnection';
|
import { ConnectionType } from '../generated/api/services/ingestionPipelines/testServiceConnection';
|
||||||
|
import { Database } from '../generated/entity/data/database';
|
||||||
import { MlModelServiceType } from '../generated/entity/data/mlmodel';
|
import { MlModelServiceType } from '../generated/entity/data/mlmodel';
|
||||||
import { DashboardServiceType } from '../generated/entity/services/dashboardService';
|
import { DashboardServiceType } from '../generated/entity/services/dashboardService';
|
||||||
import { DatabaseServiceType } from '../generated/entity/services/databaseService';
|
import { DatabaseServiceType } from '../generated/entity/services/databaseService';
|
||||||
@ -84,6 +86,7 @@ import { PipelineType as IngestionPipelineType } from '../generated/entity/servi
|
|||||||
import { MessagingServiceType } from '../generated/entity/services/messagingService';
|
import { MessagingServiceType } from '../generated/entity/services/messagingService';
|
||||||
import { PipelineServiceType } from '../generated/entity/services/pipelineService';
|
import { PipelineServiceType } from '../generated/entity/services/pipelineService';
|
||||||
import { ServiceResponse } from '../interface/service.interface';
|
import { ServiceResponse } from '../interface/service.interface';
|
||||||
|
import { showErrorToast } from './ToastUtils';
|
||||||
|
|
||||||
export const serviceTypeLogo = (type: string) => {
|
export const serviceTypeLogo = (type: string) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -592,3 +595,45 @@ export const getServiceCreatedLabel = (serviceCategory: ServiceCategory) => {
|
|||||||
|
|
||||||
return [serviceCat, 'service'].join(' ');
|
return [serviceCat, 'service'].join(' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setServiceSchemaCount = (
|
||||||
|
data: Database[],
|
||||||
|
callback: (value: React.SetStateAction<number>) => void
|
||||||
|
) => {
|
||||||
|
const promises = data.map((database) =>
|
||||||
|
getEntityCount('databaseSchemas', database.fullyQualifiedName)
|
||||||
|
);
|
||||||
|
|
||||||
|
Promise.allSettled(promises)
|
||||||
|
.then((results) => {
|
||||||
|
let count = 0;
|
||||||
|
results.forEach((result) => {
|
||||||
|
if (result.status === 'fulfilled') {
|
||||||
|
count += result.value.data?.paging?.total || 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callback(count);
|
||||||
|
})
|
||||||
|
.catch((err: AxiosError) => showErrorToast(err));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const setServiceTableCount = (
|
||||||
|
data: Database[],
|
||||||
|
callback: (value: React.SetStateAction<number>) => void
|
||||||
|
) => {
|
||||||
|
const promises = data.map((database) =>
|
||||||
|
getEntityCount('tables', database.fullyQualifiedName)
|
||||||
|
);
|
||||||
|
|
||||||
|
Promise.allSettled(promises)
|
||||||
|
.then((results) => {
|
||||||
|
let count = 0;
|
||||||
|
results.forEach((result) => {
|
||||||
|
if (result.status === 'fulfilled') {
|
||||||
|
count += result.value.data?.paging?.total || 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callback(count);
|
||||||
|
})
|
||||||
|
.catch((err: AxiosError) => showErrorToast(err));
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user