cors support
This commit is contained in:
parent
fcee8943a9
commit
059bb512a4
107
api/init.go
107
api/init.go
|
@ -4,7 +4,6 @@ import (
|
|||
log "github.com/cihub/seelog"
|
||||
"infini.sh/framework/core/api"
|
||||
"infini.sh/framework/core/task"
|
||||
"infini.sh/framework/core/ui"
|
||||
"infini.sh/search-center/api/index_management"
|
||||
"infini.sh/search-center/config"
|
||||
"infini.sh/search-center/service/alerting"
|
||||
|
@ -17,66 +16,66 @@ func Init(cfg *config.AppConfig) {
|
|||
}
|
||||
var pathPrefix = "/_search-center/"
|
||||
var esPrefix = "/elasticsearch/:id/"
|
||||
//ui.HandleUIMethod(api.POST, "/api/get_indices",index_management.API1)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "elasticsearch/overview"), handler.ElasticsearchOverviewAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "elasticsearch/overview"), handler.ElasticsearchOverviewAction)
|
||||
//api.HandleAPIMethod(api.POST, "/api/get_indices",index_management.API1)
|
||||
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "dict/_search"), handler.GetDictListAction)
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "dict/*id"), handler.CreateDictItemAction)
|
||||
//ui.HandleUIMethod(api.GET, "/api/dict/:id",handler.GetDictItemAction)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "dict/:id"), handler.DeleteDictItemAction)
|
||||
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "dict/:id"), handler.UpdateDictItemAction)
|
||||
ui.HandleUIMethod(api.POST, path.Join(esPrefix, "doc/:index/_search"), handler.HandleSearchDocumentAction)
|
||||
ui.HandleUIMethod(api.POST, path.Join(esPrefix, "doc/:index"), handler.HandleAddDocumentAction)
|
||||
ui.HandleUIMethod(api.PUT, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleUpdateDocumentAction)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleDeleteDocumentAction)
|
||||
ui.HandleUIMethod(api.GET, path.Join(esPrefix, "doc/_validate"), handler.ValidateDocIDAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "dict/_search"), handler.GetDictListAction)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix, "dict/*id"), handler.CreateDictItemAction)
|
||||
//api.HandleAPIMethod(api.GET, "/api/dict/:id",handler.GetDictItemAction)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(pathPrefix, "dict/:id"), handler.DeleteDictItemAction)
|
||||
api.HandleAPIMethod(api.PUT, path.Join(pathPrefix, "dict/:id"), handler.UpdateDictItemAction)
|
||||
api.HandleAPIMethod(api.POST, path.Join(esPrefix, "doc/:index/_search"), handler.HandleSearchDocumentAction)
|
||||
api.HandleAPIMethod(api.POST, path.Join(esPrefix, "doc/:index"), handler.HandleAddDocumentAction)
|
||||
api.HandleAPIMethod(api.PUT, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleUpdateDocumentAction)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(esPrefix, "doc/:index/:docId"), handler.HandleDeleteDocumentAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(esPrefix, "doc/_validate"), handler.ValidateDocIDAction)
|
||||
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "rebuild/*id"), handler.HandleReindexAction)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "rebuild/_search"), handler.HandleGetRebuildListAction)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "rebuild/:id"), handler.HandleDeleteRebuildAction)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix, "rebuild/*id"), handler.HandleReindexAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "rebuild/_search"), handler.HandleGetRebuildListAction)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(pathPrefix, "rebuild/:id"), handler.HandleDeleteRebuildAction)
|
||||
|
||||
ui.HandleUIMethod(api.GET, path.Join(esPrefix, "_cat/indices"), handler.HandleGetIndicesAction)
|
||||
ui.HandleUIMethod(api.GET, path.Join(esPrefix, "index/:index/_mappings"), handler.HandleGetMappingsAction)
|
||||
ui.HandleUIMethod(api.GET, path.Join(esPrefix, "index/:index/_settings"), handler.HandleGetSettingsAction)
|
||||
ui.HandleUIMethod(api.PUT, path.Join(esPrefix, "index/:index/_settings"), handler.HandleUpdateSettingsAction)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(esPrefix, "index/:index"), handler.HandleDeleteIndexAction)
|
||||
ui.HandleUIMethod(api.POST, path.Join(esPrefix, "index/:index"), handler.HandleCreateIndexAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(esPrefix, "_cat/indices"), handler.HandleGetIndicesAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(esPrefix, "index/:index/_mappings"), handler.HandleGetMappingsAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(esPrefix, "index/:index/_settings"), handler.HandleGetSettingsAction)
|
||||
api.HandleAPIMethod(api.PUT, path.Join(esPrefix, "index/:index/_settings"), handler.HandleUpdateSettingsAction)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(esPrefix, "index/:index"), handler.HandleDeleteIndexAction)
|
||||
api.HandleAPIMethod(api.POST, path.Join(esPrefix, "index/:index"), handler.HandleCreateIndexAction)
|
||||
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "elasticsearch/command"), handler.HandleSaveCommonCommandAction)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "elasticsearch/command"), handler.HandleQueryCommonCommandAction)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "elasticsearch/command/:cid"), handler.HandleDeleteCommonCommandAction)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix, "elasticsearch/command"), handler.HandleSaveCommonCommandAction)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "elasticsearch/command"), handler.HandleQueryCommonCommandAction)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(pathPrefix, "elasticsearch/command/:cid"), handler.HandleDeleteCommonCommandAction)
|
||||
|
||||
//new api
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "alerting/overview"), alerting.GetAlertOverview)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "alerting/overview/alerts"), alerting.GetAlerts)
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix,"alerting/destinations/email_accounts"), alerting.CreateEmailAccount)
|
||||
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "alerting/email_accounts/:emailAccountId"), alerting.UpdateEmailAccount)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix,"alerting/email_accounts/:emailAccountId"), alerting.DeleteEmailAccount)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix,"alerting/destinations/email_accounts"), alerting.GetEmailAccounts)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix,"alerting/email_accounts/:emailAccountId"), alerting.GetEmailAccount)
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix,"alerting/destinations/email_groups"), alerting.CreateEmailGroup)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix,"alerting/destinations/email_groups"), alerting.GetEmailGroups)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix,"alerting/email_groups/:emailGroupId"), alerting.DeleteEmailGroup)
|
||||
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix,"alerting/email_groups/:emailGroupId"), alerting.UpdateEmailGroup)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix,"alerting/email_groups/:emailGroupId"), alerting.GetEmailGroup)
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "alerting/destinations"), alerting.GetDestinations)
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix,"alerting/destinations"), alerting.CreateDestination)
|
||||
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix,"alerting/destinations/:destinationId"), alerting.UpdateDestination)
|
||||
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "alerting/destinations/:destinationId"), alerting.DeleteDestination)
|
||||
ui.HandleUIMethod(api.GET, "/elasticsearch/:id/alerting/monitors/:monitorID", alerting.GetMonitor)
|
||||
ui.HandleUIMethod(api.PUT, "/elasticsearch/:id/alerting/monitors/:monitorID", alerting.UpdateMonitor)
|
||||
ui.HandleUIMethod(api.GET, "/elasticsearch/:id/alerting/monitors", alerting.GetMonitors)
|
||||
ui.HandleUIMethod(api.POST, "/elasticsearch/:id/alerting/monitors", alerting.CreateMonitor)
|
||||
ui.HandleUIMethod(api.POST, "/elasticsearch/:id/alerting/monitors/_execute", alerting.ExecuteMonitor)
|
||||
ui.HandleUIMethod(api.DELETE, "/elasticsearch/:id/alerting/monitors/:monitorID", alerting.DeleteMonitor)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "alerting/overview"), alerting.GetAlertOverview)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "alerting/overview/alerts"), alerting.GetAlerts)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix,"alerting/destinations/email_accounts"), alerting.CreateEmailAccount)
|
||||
api.HandleAPIMethod(api.PUT, path.Join(pathPrefix, "alerting/email_accounts/:emailAccountId"), alerting.UpdateEmailAccount)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(pathPrefix,"alerting/email_accounts/:emailAccountId"), alerting.DeleteEmailAccount)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix,"alerting/destinations/email_accounts"), alerting.GetEmailAccounts)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix,"alerting/email_accounts/:emailAccountId"), alerting.GetEmailAccount)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix,"alerting/destinations/email_groups"), alerting.CreateEmailGroup)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix,"alerting/destinations/email_groups"), alerting.GetEmailGroups)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(pathPrefix,"alerting/email_groups/:emailGroupId"), alerting.DeleteEmailGroup)
|
||||
api.HandleAPIMethod(api.PUT, path.Join(pathPrefix,"alerting/email_groups/:emailGroupId"), alerting.UpdateEmailGroup)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix,"alerting/email_groups/:emailGroupId"), alerting.GetEmailGroup)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix, "alerting/destinations"), alerting.GetDestinations)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix,"alerting/destinations"), alerting.CreateDestination)
|
||||
api.HandleAPIMethod(api.PUT, path.Join(pathPrefix,"alerting/destinations/:destinationId"), alerting.UpdateDestination)
|
||||
api.HandleAPIMethod(api.DELETE, path.Join(pathPrefix, "alerting/destinations/:destinationId"), alerting.DeleteDestination)
|
||||
api.HandleAPIMethod(api.GET, "/elasticsearch/:id/alerting/monitors/:monitorID", alerting.GetMonitor)
|
||||
api.HandleAPIMethod(api.PUT, "/elasticsearch/:id/alerting/monitors/:monitorID", alerting.UpdateMonitor)
|
||||
api.HandleAPIMethod(api.GET, "/elasticsearch/:id/alerting/monitors", alerting.GetMonitors)
|
||||
api.HandleAPIMethod(api.POST, "/elasticsearch/:id/alerting/monitors", alerting.CreateMonitor)
|
||||
api.HandleAPIMethod(api.POST, "/elasticsearch/:id/alerting/monitors/_execute", alerting.ExecuteMonitor)
|
||||
api.HandleAPIMethod(api.DELETE, "/elasticsearch/:id/alerting/monitors/:monitorID", alerting.DeleteMonitor)
|
||||
|
||||
ui.HandleUIMethod(api.GET, path.Join(pathPrefix,"alerting/_settings"), alerting.GetSettings)
|
||||
ui.HandleUIMethod(api.POST, "/elasticsearch/:id/alerting/_indices", alerting.GetIndices)
|
||||
ui.HandleUIMethod(api.POST, "/elasticsearch/:id/alerting/_aliases", alerting.GetAliases)
|
||||
ui.HandleUIMethod(api.POST, "/elasticsearch/:id/alerting/_mappings", alerting.GetMappings)
|
||||
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "alerting/_search"), alerting.Search)
|
||||
ui.HandleUIMethod(api.GET, "/elasticsearch/:id/alerting/alerts", alerting.GetAlerts)
|
||||
ui.HandleUIMethod(api.POST, "/elasticsearch/:id/alerting/_monitors/:monitorID/_acknowledge/alerts", alerting.AcknowledgeAlerts)
|
||||
api.HandleAPIMethod(api.GET, path.Join(pathPrefix,"alerting/_settings"), alerting.GetSettings)
|
||||
api.HandleAPIMethod(api.POST, "/elasticsearch/:id/alerting/_indices", alerting.GetIndices)
|
||||
api.HandleAPIMethod(api.POST, "/elasticsearch/:id/alerting/_aliases", alerting.GetAliases)
|
||||
api.HandleAPIMethod(api.POST, "/elasticsearch/:id/alerting/_mappings", alerting.GetMappings)
|
||||
api.HandleAPIMethod(api.POST, path.Join(pathPrefix, "alerting/_search"), alerting.Search)
|
||||
api.HandleAPIMethod(api.GET, "/elasticsearch/:id/alerting/alerts", alerting.GetAlerts)
|
||||
api.HandleAPIMethod(api.POST, "/elasticsearch/:id/alerting/_monitors/:monitorID/_acknowledge/alerts", alerting.AcknowledgeAlerts)
|
||||
|
||||
|
||||
task.RegisterScheduleTask(task.ScheduleTask{
|
||||
|
|
8
main.go
8
main.go
|
@ -67,6 +67,14 @@ func main() {
|
|||
appUI = &UI{Config: appConfig}
|
||||
appUI.InitUI()
|
||||
|
||||
//uiConfig := ui.UIConfig{}
|
||||
//env.ParseConfig("web", &uiConfig)
|
||||
//
|
||||
//if len(global.Env().SystemConfig.APIConfig.CrossDomain.AllowedOrigins)==0{
|
||||
// global.Env().SystemConfig.APIConfig.CrossDomain.AllowedOrigins=
|
||||
// append(global.Env().SystemConfig.APIConfig.CrossDomain.AllowedOrigins,uiConfig.NetworkConfig.GetBindingAddr())
|
||||
//}
|
||||
|
||||
//start each module, with enabled provider
|
||||
module.Start()
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ export default {
|
|||
},
|
||||
define: {
|
||||
APP_TYPE: process.env.APP_TYPE || '',
|
||||
ENV: process.env.NODE_ENV,
|
||||
API_ENDPOINT: 'http://localhost:2900',
|
||||
},
|
||||
// 路由配置
|
||||
routes: pageRoutes,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @ts-ignore
|
||||
import React, { useRef, useMemo,useEffect, useLayoutEffect } from 'react';
|
||||
import React, { useRef, useMemo,useEffect, useLayoutEffect, useState } from 'react';
|
||||
import ConsoleInput from './ConsoleInput';
|
||||
import ConsoleOutput from './ConsoleOutput';
|
||||
import { Panel } from './Panel';
|
||||
|
@ -40,61 +40,68 @@ const ConsoleWrapper = ({
|
|||
} = useRequestReadContext();
|
||||
|
||||
const lastDatum = requestData?.[requestData.length - 1] ?? requestError;
|
||||
const getElementTop = (elem: any)=>{
|
||||
var elemTop=elem.offsetTop;
|
||||
elem=elem.offsetParent;
|
||||
|
||||
while(elem!=null){
|
||||
elemTop+=elem.offsetTop;
|
||||
elem=elem.offsetParent;
|
||||
}
|
||||
|
||||
return elemTop;
|
||||
|
||||
}
|
||||
const statusBarRef = useRef<HTMLDivElement>(null);
|
||||
const consoleRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// useEffect(()=>{
|
||||
// const winScroll = ()=>{
|
||||
// const wsTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
|
||||
// if(wsTop>getElementTop(consoleRef.current)) {
|
||||
// statusBarRef.current && (statusBarRef.current.style.position='relative');
|
||||
// }else{
|
||||
// statusBarRef.current && (statusBarRef.current.style.position='fixed');
|
||||
// }
|
||||
// }
|
||||
// window.addEventListener('scroll', winScroll, {passive:true})
|
||||
// return ()=>{
|
||||
// window.removeEventListener('scroll', winScroll)
|
||||
// }
|
||||
// },[])
|
||||
|
||||
useEventListener('resize', ()=>{
|
||||
statusBarRef.current && consoleRef.current && (statusBarRef.current.style.width=consoleRef.current.offsetWidth+'px');
|
||||
})
|
||||
|
||||
useLayoutEffect(()=>{
|
||||
// console.log(consoleRef.current?.offsetWidth)
|
||||
if(consoleRef.current.offsetWidth>0)
|
||||
statusBarRef.current && consoleRef.current && (statusBarRef.current.style.width=consoleRef.current.offsetWidth+'px');
|
||||
}, [consoleRef.current?.offsetWidth])
|
||||
|
||||
const calcHeight = height > 0 ? (height-35)+'px' : '100%';
|
||||
const leftBarRef = useRef(null)
|
||||
const rightBarRef = useRef(null)
|
||||
const [widths, setWidths] = useState(['50%', '50%'])
|
||||
const onPanelWidthChange = (widths:any)=>{
|
||||
const [lp, rp] = widths;
|
||||
setWidths([lp+2+'%', rp+'%']);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{height: calcHeight}}>
|
||||
<div ref={consoleRef} className="Console" style={{height:'100%'}}>
|
||||
<PanelsContainer resizerClassName="resizer">
|
||||
<div className="Console" style={{height:'100%'}}>
|
||||
<PanelsContainer resizerClassName="resizer" onPanelWidthChange={onPanelWidthChange}>
|
||||
<Panel style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} initialWidth={INITIAL_PANEL_WIDTH}>
|
||||
<ConsoleInput clusterID={selectedCluster.id} saveEditorContent={saveEditorContent} initialText={initialText} paneKey={paneKey} />
|
||||
<div ref={leftBarRef} style={{background:'#fff', position:'fixed', left:0, bottom:0, width: widths[0], height:30, zIndex:1001, borderTop: '1px solid #eee'}}>
|
||||
<RequestStatusBar
|
||||
requestInProgress={requestInProgress}
|
||||
selectedCluster={selectedCluster}
|
||||
left={true}
|
||||
requestResult={
|
||||
lastDatum
|
||||
? {
|
||||
method: lastDatum.request.method.toUpperCase(),
|
||||
endpoint: lastDatum.request.path,
|
||||
statusCode: lastDatum.response.statusCode,
|
||||
statusText: lastDatum.response.statusText,
|
||||
timeElapsedMs: lastDatum.response.timeMs,
|
||||
requestHeader: lastDatum.request.header,
|
||||
responseHeader: lastDatum.response.header,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Panel>
|
||||
<Panel style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} initialWidth={INITIAL_PANEL_WIDTH}>
|
||||
<ConsoleOutput clusterID={selectedCluster.id} />
|
||||
<div ref={rightBarRef} style={{background:'#fff', position:'fixed', right:0, bottom:0, width: widths[1], height:30, zIndex:1001, borderTop: '1px solid #eee'}}>
|
||||
<RequestStatusBar
|
||||
requestInProgress={requestInProgress}
|
||||
selectedCluster={selectedCluster}
|
||||
requestResult={
|
||||
lastDatum
|
||||
? {
|
||||
method: lastDatum.request.method.toUpperCase(),
|
||||
endpoint: lastDatum.request.path,
|
||||
statusCode: lastDatum.response.statusCode,
|
||||
statusText: lastDatum.response.statusText,
|
||||
timeElapsedMs: lastDatum.response.timeMs,
|
||||
requestHeader: lastDatum.request.header,
|
||||
responseHeader: lastDatum.response.header,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Panel>
|
||||
</PanelsContainer>
|
||||
</div>
|
||||
<div ref={statusBarRef} style={{ position:'fixed', bottom:0, borderTop: '1px solid #eee', zIndex:1001, width:'100%'}}>
|
||||
{/* <div ref={statusBarRef} style={{ position:'fixed', bottom:0, borderTop: '1px solid #eee', zIndex:1001, width:'100%'}}>
|
||||
<div style={{background:'#fff',height:30, width:'100%'}}>
|
||||
<RequestStatusBar
|
||||
requestInProgress={requestInProgress}
|
||||
|
@ -115,7 +122,7 @@ const ConsoleWrapper = ({
|
|||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
align-items: center;
|
||||
height: 100%;
|
||||
.bar-item{
|
||||
flex: 0 0 50%;
|
||||
flex: 0 0 100%;
|
||||
.base-info{
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
|
|
|
@ -65,85 +65,11 @@ const mapStatusCodeToBadgeColor = (statusCode: number) => {
|
|||
return 'danger';
|
||||
};
|
||||
|
||||
// export const RequestStatusBar: FunctionComponent<Props> = ({
|
||||
// requestInProgress,
|
||||
// requestResult,
|
||||
// selectedCluster,
|
||||
// }) => {
|
||||
// let content: React.ReactNode = null;
|
||||
// const clusterContent = (<EuiFlexItem grow={false} style={{marginRight:'auto'}}>
|
||||
// <EuiBadge style={{position:'relative', paddingLeft: 20}}>
|
||||
// <i style={{marginRight:3, position:'absolute', top: 1, left:3}}><HealthStatusCircle status={selectedCluster.status}/></i>{selectedCluster.host} - {selectedCluster.version}
|
||||
// </EuiBadge>
|
||||
// </EuiFlexItem>);
|
||||
|
||||
// if (requestInProgress) {
|
||||
// content = (
|
||||
// <EuiFlexItem grow={false}>
|
||||
// <EuiBadge color="hollow">
|
||||
// Request in progress
|
||||
// </EuiBadge>
|
||||
// </EuiFlexItem>
|
||||
// );
|
||||
// } else if (requestResult) {
|
||||
// const { endpoint, method, statusCode, statusText, timeElapsedMs } = requestResult;
|
||||
|
||||
// content = (
|
||||
// <>
|
||||
// <EuiFlexItem grow={false}>
|
||||
// <EuiToolTip
|
||||
// position="top"
|
||||
// content={
|
||||
// <EuiText size="s">{`${method} ${
|
||||
// endpoint.startsWith('/') ? endpoint : '/' + endpoint
|
||||
// }`}</EuiText>
|
||||
// }
|
||||
// >
|
||||
// <EuiBadge color={mapStatusCodeToBadgeColor(statusCode)}>
|
||||
// {/* Use to ensure that no matter the width we don't allow line breaks */}
|
||||
// {statusCode} - {statusText}
|
||||
// </EuiBadge>
|
||||
// </EuiToolTip>
|
||||
// </EuiFlexItem>
|
||||
// <EuiFlexItem grow={false}>
|
||||
// <EuiToolTip
|
||||
// position="top"
|
||||
// content={
|
||||
// <EuiText size="s">
|
||||
// Time Elapsed
|
||||
// </EuiText>
|
||||
// }
|
||||
// >
|
||||
// <EuiText size="s">
|
||||
// <EuiBadge color="default">
|
||||
// {timeElapsedMs} {'ms'}
|
||||
// </EuiBadge>
|
||||
// </EuiText>
|
||||
// </EuiToolTip>
|
||||
// </EuiFlexItem>
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
|
||||
// return (
|
||||
// <EuiFlexGroup
|
||||
// justifyContent="flexEnd"
|
||||
// alignItems="center"
|
||||
// direction="row"
|
||||
// gutterSize="s"
|
||||
// responsive={false}
|
||||
// >
|
||||
// {clusterContent}
|
||||
// {content}
|
||||
// </EuiFlexGroup>
|
||||
// );
|
||||
// };
|
||||
|
||||
export const RequestStatusBar = ({
|
||||
requestInProgress,
|
||||
requestResult,
|
||||
selectedCluster,
|
||||
container,
|
||||
left,
|
||||
}:Props) => {
|
||||
let content: React.ReactNode = null;
|
||||
const clusterContent = (<div className="base-info">
|
||||
|
@ -225,8 +151,8 @@ const [headerInfoVisible, setHeaderInfoVisible] = React.useState(false)
|
|||
|
||||
return (
|
||||
<div className="request-status-bar">
|
||||
<div className="bar-item">{clusterContent}</div>
|
||||
<div className="bar-item">{content}</div>
|
||||
{left? <div className="bar-item">{clusterContent}</div>:
|
||||
[<div className="bar-item">{content}</div>,
|
||||
<Drawer title="Request header info"
|
||||
style={{zIndex:1004}}
|
||||
width={520}
|
||||
|
@ -251,7 +177,8 @@ const [headerInfoVisible, setHeaderInfoVisible] = React.useState(false)
|
|||
</EuiCodeBlock>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</Drawer>
|
||||
</Drawer>]
|
||||
}
|
||||
</div>
|
||||
|
||||
);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
import $ from 'jquery';
|
||||
// @ts-ignore
|
||||
import { stringify } from 'query-string';
|
||||
import {pathPrefix} from '@/services/common';
|
||||
import {pathPrefix, ESPrefix} from '@/services/common';
|
||||
|
||||
interface SendOptions {
|
||||
asSystemRequest?: boolean;
|
||||
|
@ -48,7 +48,7 @@ export function getVersion() {
|
|||
}
|
||||
|
||||
export function getContentType(body: unknown) {
|
||||
if (!body) return;
|
||||
if (!body) return 'text/plain';
|
||||
return 'application/json';
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,12 @@ export function send(
|
|||
// }
|
||||
// @ts-ignore
|
||||
const options: JQuery.AjaxSettings = {
|
||||
url: `/elasticsearch/${clusterID}/_proxy?` + stringify({ path, method }),
|
||||
headers: {
|
||||
'infini-xsrf': 'search-center',
|
||||
...(asSystemRequest && { 'infini-request': 'true' }),
|
||||
},
|
||||
url: `${ESPrefix}/${clusterID}/_proxy?` + stringify({ path, method }),
|
||||
// headers: {
|
||||
// 'infini-xsrf': 'search-center',
|
||||
// 'origin': location.origin,
|
||||
// ...(asSystemRequest && { 'infini-request': 'true' }),
|
||||
// },
|
||||
data,
|
||||
contentType: getContentType(data),
|
||||
cache: false,
|
||||
|
|
|
@ -7,6 +7,7 @@ import {ScopedHistory} from '../../components/kibana/core/public/application/sco
|
|||
import {notification} from 'antd';
|
||||
import {connect} from 'dva'
|
||||
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
|
||||
import {ESPrefix} from '@/services/common'
|
||||
|
||||
const httpClient = new Fetch({
|
||||
basePath:{
|
||||
|
@ -41,7 +42,7 @@ const AlertingUI = (props)=>{
|
|||
}
|
||||
useMemo(()=>{
|
||||
httpClient.params.basePath.prepend = (url)=>{
|
||||
return '/elasticsearch/'+ props.selectedCluster.id +"/" + url;
|
||||
return `${ESPrefix}/${props.selectedCluster.id}/${url}`;
|
||||
}
|
||||
}, [props.selectedCluster]);
|
||||
const isDarkMode = false;
|
||||
|
|
|
@ -19,6 +19,7 @@ const NewOverview = ()=>{
|
|||
onChange={()=>{}}
|
||||
type="card"
|
||||
tabBarGutter={10}
|
||||
tabindex="-1"
|
||||
>
|
||||
{panes.map(pane => (
|
||||
<TabPane tab={pane.title} key={pane.key}>
|
||||
|
|
|
@ -49,7 +49,8 @@ import {generateFilters} from '../../components/kibana/data/public/query/filter_
|
|||
import Table from '../../components/kibana/discover/public/application/components/discover_table/table';
|
||||
|
||||
import {useQueryParam, StringParam, QueryParamProvider, ArrayParam} from 'use-query-params';
|
||||
import {Route} from 'umi'
|
||||
import {Route} from 'umi';
|
||||
import {ESPrefix} from '@/services/common';
|
||||
|
||||
const SidebarMemoized = React.memo(DiscoverSidebar);
|
||||
|
||||
|
@ -550,7 +551,7 @@ const DiscoverUI = (props)=>{
|
|||
useMemo(()=>{
|
||||
const {http} = getContext();
|
||||
http.getServerBasePath = ()=>{
|
||||
return '/elasticsearch/'+ props.selectedCluster.id;
|
||||
return `${ESPrefix}/`+ props.selectedCluster.id;
|
||||
}
|
||||
}, [props.selectedCluster])
|
||||
useEffect(()=>{
|
||||
|
|
|
@ -15,6 +15,7 @@ import styles from '../System/Cluster/step.less';
|
|||
import clusterBg from '@/assets/cluster_bg.png';
|
||||
|
||||
import { connect } from 'dva';
|
||||
import {ESPrefix} from '@/services/common';
|
||||
|
||||
|
||||
const createContent = (
|
||||
|
@ -42,7 +43,7 @@ const IndexPatterns = (props)=> {
|
|||
const createComponentKey = useMemo(()=>{
|
||||
const {http, uiSettings} = useGlobalContext();
|
||||
http.getServerBasePath = ()=>{
|
||||
return '/elasticsearch/'+ props.selectedCluster.id;
|
||||
return `${ESPrefix}/`+ props.selectedCluster.id;
|
||||
}
|
||||
return 'CreateIndexPatternWizard_'+Math.random();
|
||||
},[props.selectedCluster]);
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
import {FieldFormatsRegistry,} from '../../components/kibana/data/common/field_formats';
|
||||
import {baseFormattersPublic} from '../../components/kibana/data/public/field_formats';
|
||||
import { deserializeFieldFormat } from '../../components/kibana/data/public/field_formats/utils/deserialize';
|
||||
import {ESPrefix} from '@/services/common'
|
||||
|
||||
const timeBucketConfig = {
|
||||
'histogram:maxBars': 100,
|
||||
|
@ -304,7 +305,7 @@ const getSearchParams = (indexPattern, internal, sort) =>{
|
|||
}
|
||||
|
||||
const fetchESRequest = (params, clusterID) => {
|
||||
return fetch(`/elasticsearch/${clusterID}/search/ese`, {
|
||||
return fetch(`${ESPrefix}/${clusterID}/search/ese`, {
|
||||
headers:{
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import request from '@/utils/request';
|
||||
//import {pathPrefix} from './common';
|
||||
import {ESPrefix} from './common';
|
||||
|
||||
export async function getAliasList(params){
|
||||
let url = `/elasticsearch/${params.clusterID}/alias`;
|
||||
let url = `${ESPrefix}/${params.clusterID}/alias`;
|
||||
return request(url,{
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function doAlias(params){
|
||||
let url = `/elasticsearch/${params.clusterID}/alias`;
|
||||
let url = `${ESPrefix}/${params.clusterID}/alias`;
|
||||
return request(url,{
|
||||
method: 'POST',
|
||||
body: params.data,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import request from '@/utils/request';
|
||||
import {buildQueryArgs, pathPrefix} from './common';
|
||||
import {buildQueryArgs, ESPrefix} from './common';
|
||||
|
||||
export async function getClusterVersion(params) {
|
||||
return request(`/elasticsearch/${params.cluster}/version`, {
|
||||
return request(`${ESPrefix}/${params.cluster}/version`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ export async function getClusterVersion(params) {
|
|||
export async function getClusterMetrics(params) {
|
||||
let id = params.cluster_id;
|
||||
delete(params['cluster_id']);
|
||||
return request(`/elasticsearch/${id}/metrics?min=${params.timeRange.min}&max=${params.timeRange.max}`, {
|
||||
return request(`${ESPrefix}/${id}/metrics?min=${params.timeRange.min}&max=${params.timeRange.max}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
}
|
||||
|
||||
export async function createClusterConfig(params) {
|
||||
return request(`/elasticsearch/`, {
|
||||
return request(`${ESPrefix}/`, {
|
||||
method: 'POST',
|
||||
body: params,
|
||||
});
|
||||
|
@ -25,21 +25,21 @@ export async function createClusterConfig(params) {
|
|||
export async function updateClusterConfig(params) {
|
||||
let id = params.id;
|
||||
delete(params['id']);
|
||||
return request(`/elasticsearch/${id}`, {
|
||||
return request(`${ESPrefix}/${id}`, {
|
||||
method: 'PUT',
|
||||
body: params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteClusterConfig(params) {
|
||||
return request(`/elasticsearch/${params.id}`, {
|
||||
return request(`${ESPrefix}/${params.id}`, {
|
||||
method: 'DELETE',
|
||||
body: params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function searchClusterConfig(params) {
|
||||
let url = `/elasticsearch/_search`;
|
||||
let url = `${ESPrefix}/_search`;
|
||||
let args = buildQueryArgs({
|
||||
name: params.name,
|
||||
enabled: params.enabled,
|
||||
|
@ -55,14 +55,14 @@ export async function searchClusterConfig(params) {
|
|||
}
|
||||
|
||||
export async function getClusterStatus(params) {
|
||||
let url = `/elasticsearch/status`;
|
||||
let url = `${ESPrefix}/status`;
|
||||
return request(url, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function tryConnect(params) {
|
||||
let url = `/elasticsearch/try_connect`;
|
||||
let url = `${ESPrefix}/try_connect`;
|
||||
return request(url, {
|
||||
method: 'POST',
|
||||
body: params,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const pathPrefix = '/_search-center';
|
||||
export const pathPrefix = (API_ENDPOINT || '') + '/_search-center';
|
||||
|
||||
export function buildQueryArgs(params){
|
||||
let argsStr = '';
|
||||
|
@ -14,4 +14,4 @@ export function buildQueryArgs(params){
|
|||
return argsStr;
|
||||
}
|
||||
|
||||
export const ESPrefix = '/elasticsearch';
|
||||
export const ESPrefix = (API_ENDPOINT || '') + '/elasticsearch';
|
Loading…
Reference in New Issue