Skip to content

Commit

Permalink
Implement Log UI (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deardrops authored Feb 28, 2020
1 parent 195701e commit 2a0c625
Show file tree
Hide file tree
Showing 21 changed files with 908 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/apiserver/logsearch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (s *Service) DownloadLogs(c *gin.Context) {
// @Description list all log search tasks in a task group by providing task group ID
// @Produce json
// @Param id path string true "Task Group ID"
// @Success 200 {array} TaskGroupResponse
// @Success 200 {object} TaskGroupResponse
// @Failure 500 {object} utils.APIError
// @Router /logs/taskgroups/{id} [get]
func (s *Service) GetTaskGroup(c *gin.Context) {
Expand Down
2 changes: 1 addition & 1 deletion ui/.github_release_version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file contains a version number which will be used to release assets to
# GitHub. To trigger a new asset release, simply increase this version number.
20200225_2
20200228_1
23 changes: 23 additions & 0 deletions ui/src/apps/logsearch/LogSearching.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Col, Empty, Row } from 'antd'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { SearchHeader } from './components'

export default function LogSearchingPage() {
const { t } = useTranslation()
return (
<div>
<SearchHeader />
<Row type="flex" align="bottom" style={{ width: "100%", height: 500 }}>
<Col span={24}>
<Empty
description={
<span>
{t('logs.page.intro')}
</span>
} />
</Col>
</Row>
</div>
)
}
27 changes: 27 additions & 0 deletions ui/src/apps/logsearch/LogSearchingDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Alert, Col, Row } from 'antd'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { SearchHeader, SearchProgress, SearchResult } from './components'

export default function LogSearchingDetail() {
const { t } = useTranslation()
return (
<div>
<Row gutter={[16, 16]}>
<Col span={18}>
<SearchHeader />
<Alert
message={t('logs.page.tip')}
type="info"
showIcon
style={{ marginTop: 14, marginBottom: 14 }}
/>
<SearchResult />
</Col>
<Col span={6}>
<SearchProgress />
</Col>
</Row>
</div>
)
}
48 changes: 48 additions & 0 deletions ui/src/apps/logsearch/RootComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Breadcrumb } from 'antd'
import React, { useReducer } from 'react'
import { HashRouter as Router, Link, Route, Switch, withRouter } from 'react-router-dom'
import LogSearching from './LogSearching'
import LogSearchingDetail from './LogSearchingDetail'
import { Context, initialState, reducer } from './store'

const App = withRouter(props => {
const { location } = props
const page = location.pathname.split('/').pop()

const [store, dispatch] = useReducer(reducer, initialState);

return (
<Context.Provider value={{ store, dispatch }}>
<div>
<div style={{ margin: 12 }}>
<Breadcrumb>
<Breadcrumb.Item>
<Link to="/logsearch">Log Searching</Link>
</Breadcrumb.Item>
{page === 'detail' && (
<Breadcrumb.Item>Detail</Breadcrumb.Item>
)}
</Breadcrumb>
</div>
<div style={{ margin: 12 }}>
<Switch>
<Route exact path="/logsearch">
<LogSearching />
</Route>
<Route path="/logsearch/detail">
<LogSearchingDetail />
</Route>
</Switch>
</div>
</div>
</Context.Provider>
)
})

export default function () {
return (
<Router>
<App />
</Router>
)
}
25 changes: 25 additions & 0 deletions ui/src/apps/logsearch/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import ReactDOM from 'react-dom';
import singleSpaReact from 'single-spa-react';
import RootComponent from './RootComponent.js';

const reactLifecycles = singleSpaReact({
React,
ReactDOM,
rootComponent: RootComponent,
domElementGetter,
});

export const bootstrap = [
reactLifecycles.bootstrap,
];
export const mount = [
reactLifecycles.mount,
];
export const unmount = [
reactLifecycles.unmount,
];

function domElementGetter() {
return document.getElementById('__spa_content__');
}
18 changes: 18 additions & 0 deletions ui/src/apps/logsearch/components/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Icon } from 'antd'
import React from 'react'

export function LoadingIcon() {
return <Icon type="loading" />
}

export function SuccessIcon() {
return (
<Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a" />
)
}

export function FailIcon() {
return (
<Icon type="info-circle" theme="twoTone" twoToneColor="#faad14" />
)
}
Loading

0 comments on commit 2a0c625

Please sign in to comment.