Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some issues #193

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/MetricsFilterPanel/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
display: flex !important;
align-items: center;
}
.ant-tree-select-dropdown {
text-align: left;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/components/MetricsFilterPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const MetricsFilterPanel = (props: IProps, ref) => {
<TreeSelect
style={{ width: '220px', maxWidth: '500px' }}
treeData={treeData} treeCheckable
treeDefaultExpandAll
showCheckedStrategy={TreeSelect.SHOW_PARENT}
getPopupContainer={triggerNode => triggerNode.parentElement}
onChange={handleInstanceChange}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/MachineDashboard/Cards/DiskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const mapState = (state: IRootState) => {
if (instanceList.includes('all')) {
return true;
}
return instanceList.includes(item.name)
return instanceList.some(instance => item.name.includes(instance))
}),
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/pages/MachineDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function MachineDashboard(props: IProps) {
const { asyncGetMemorySizeStat, asyncGetDiskSizeStat, cluster, metricsFilterValues,
asyncGetCPUStatByRange, asyncGetMemoryStatByRange, asyncGetDiskStatByRange,
asyncGetLoadByRange, asyncGetNetworkStatByRange, updateMetricsFiltervalues, instanceList,
loading,
loading
} = props;

const [showLoading, setShowLoading] = useState<boolean>(false);
Expand Down Expand Up @@ -200,7 +200,7 @@ function MachineDashboard(props: IProps) {
<Row>
<Col span={12}>
<DashboardCard
title={<> {intl.get('device.cpu')} <span>{SUPPORT_METRICS.cpu[0].metric}</span></>}
title={<> {intl.get('device.cpu')} <span>{SUPPORT_METRICS.cpu[0].metric}</span></>}
viewPath={getViewPath("/machine/cpu")}
onConfigPanel={() => handleConfigPanel(MACHINE_TYPE.cpu)}
>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/ServiceDashboard/ServiceOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import _ from 'lodash';
import CustomServiceQueryPanel from './CustomServiceQueryPanel';
import ServiceHeader from '@/components/Service/ServiceHeader';
import { IServicePanelConfig, ServiceName } from '@/utils/interface';
import StatusPanel from '@/components/StatusPanel';
import Icon from '@/components/Icon';
import { trackPageView } from '@/utils/stat';
import './index.less';
Expand All @@ -26,7 +25,7 @@ class ServiceOverview extends React.Component<IProps> {
};

render() {
const { serviceType, configs, getStatus } = this.props;
const { serviceType, configs } = this.props;
return (
<div className="service-table-item">
<ServiceHeader serviceType={serviceType} title={`${serviceType} ${intl.get('common.service')}`}>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/ServiceDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ interface IProps

function ServiceDashboard(props: IProps) {

const { panelConfig, serviceMetric, updatePanelConfig, asyncGetStatus, onView, instanceList, updateMetricsFiltervalues, metricsFilterValues, asyncGetSpaces, cluster } = props;
const { panelConfig, serviceMetric, updatePanelConfig, asyncGetStatus,
onView, instanceList, updateMetricsFiltervalues, metricsFilterValues,
asyncGetSpaces, cluster } = props;

const [editPanelType, setEditPanelType] = useState<ServiceName>();
const [editPanelIndex, setEditPanelIndex] = useState(0)
Expand Down Expand Up @@ -97,7 +99,8 @@ function ServiceDashboard(props: IProps) {
return (
<>
<div className="service-table">
<div className='common-header' >
<div
className='common-header' >
<MetricsFilterPanel
onChange={handleMetricsChange}
instanceList={instanceList}
Expand Down
12 changes: 7 additions & 5 deletions src/store/models/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import serviceApi from '@/config/service';
import { NEED_ADD_SUM_QUERYS, getProperStep, getMetricsUniqName } from '@/utils/dashboard';
import { LINUX } from '@/utils/promQL';
import { IStatRangeItem, IStatSingleItem, MetricScene, MetricsPanelValue } from '@/utils/interface';
import { unique } from '@/utils';
import { isCommunityVersion, unique } from '@/utils';
import { InitMachineMetricsFilterValues } from '@/utils/metric';

const PROMQL = LINUX;
Expand All @@ -18,7 +18,7 @@ export interface IState {
networkStat: IStatRangeItem[];
memorySizeStat: IStatSingleItem[];
diskSizeStat: IStatSingleItem[];
instanceList: any[];
instanceList: string[];
metricsFilterValues: MetricsPanelValue;
}

Expand All @@ -34,7 +34,7 @@ export function MachineModelWrapper(service,) {
loadStat: [] as IStatRangeItem[],
memorySizeStat: [] as IStatSingleItem[],
diskSizeStat: [] as IStatSingleItem[],
instanceList: [],
instanceList: [] as string[],
metricsFilterValues: InitMachineMetricsFilterValues,
},
reducers: {
Expand Down Expand Up @@ -92,8 +92,10 @@ export function MachineModelWrapper(service,) {
result = data.result;
}
}
const instanceList = result.map(item => item.metric.instance).filter(instance => instance !== 'total');
this.updateInstanceList(instanceList);
if (isCommunityVersion()) {
const instanceList = result.map(item => item.metric.instance).filter(instance => instance !== 'total' );
this.updateInstanceList(instanceList);
}
return result;
},

Expand Down
14 changes: 8 additions & 6 deletions src/store/models/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import serviceApi from '@/config/service';
import { IPanelConfig, ServiceMetricsPanelValue } from '@/utils/interface';
import { DEFAULT_SERVICE_PANEL_CONFIG } from '@/utils/service';
import { AggregationType, getProperStep } from '@/utils/dashboard';
import { unique } from '@/utils';
import { isCommunityVersion, unique } from '@/utils';
import { getClusterPrefix } from '@/utils/promQL';
import { InitMetricsFilterValues } from '@/utils/metric';

Expand Down Expand Up @@ -127,11 +127,13 @@ export function SereviceModelWrapper(serviceApi) {
if (code === 0 && data.result.length !== 0) {
stat = data.result;
}
const list = stat.map(item => {
const instanceName = item.metric.instanceName || item.metric.instance;
return instanceName.slice(0, instanceName.indexOf('-'))
});
this.updateInstanceList(list)
if (isCommunityVersion()) {
const list = stat.map(item => {
const instanceName = item.metric.instanceName || item.metric.instance;
return instanceName.slice(0, instanceName.indexOf('-'))
});
this.updateInstanceList(list)
}
return stat;
},

Expand Down
10 changes: 5 additions & 5 deletions src/utils/promQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ export let SUPPORT_METRICS =
// metric: 'memory_utilization',
// valueType: VALUE_TYPE.percentage,
// },
{
metric: 'memory_used',
valueType: VALUE_TYPE.byte,
},
{
metric: 'memory_used_percentage',
valueType: VALUE_TYPE.percentage,
},
{
metric: 'memory_used',
valueType: VALUE_TYPE.byte,
},
{
metric: 'memory_actual_used_percentage',
valueType: VALUE_TYPE.percentage,
Expand Down Expand Up @@ -175,8 +175,8 @@ export let LINUX = (cluster?, device?: string): any => {

// memory relative:
// memory_utilization: `(1 - node_memory_MemFree_bytes${clusterSuffix2} / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`,
memory_used: `node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2}`,
memory_used_percentage: `((node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2}) / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`,
memory_used: `node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2}`,
memory_actual_used: `node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2} - node_memory_Buffers_bytes${clusterSuffix2} - node_memory_Cached_bytes${clusterSuffix2}`,
memory_actual_used_percentage: `((node_memory_MemTotal_bytes${clusterSuffix2} - node_memory_MemFree_bytes${clusterSuffix2} - node_memory_Buffers_bytes${clusterSuffix2} - node_memory_Cached_bytes${clusterSuffix2}) / node_memory_MemTotal_bytes${clusterSuffix2} )* 100`,
memory_free: `node_memory_MemFree_bytes${clusterSuffix2}`,
Expand Down