mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
added vrei for showing client strategies
This commit is contained in:
parent
88bb97656c
commit
cc04f463c9
@ -0,0 +1,34 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import Table from 'react-toolbox/lib/table';
|
||||||
|
|
||||||
|
const Model = {
|
||||||
|
appName: { type: String, title: 'Application Name' },
|
||||||
|
strategies: { type: String },
|
||||||
|
};
|
||||||
|
|
||||||
|
class ClientStrategies extends Component {
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
this.props.fetchClientStrategies();
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const source = this.props.clientStrategies.map(item => (
|
||||||
|
{
|
||||||
|
appName: item.appName,
|
||||||
|
strategies: item.strategies.join(', '),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table
|
||||||
|
model={Model}
|
||||||
|
source={source}
|
||||||
|
selectable={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default ClientStrategies;
|
@ -0,0 +1,9 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import ClientStrategies from './strategy-component';
|
||||||
|
import { fetchClientStrategies } from '../../store/client-strategy-actions';
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({ clientStrategies: state.clientStrategies.toJS() });
|
||||||
|
|
||||||
|
const StrategiesContainer = connect(mapStateToProps, { fetchClientStrategies })(ClientStrategies);
|
||||||
|
|
||||||
|
export default StrategiesContainer;
|
@ -19,6 +19,7 @@ export default class UnleashNav extends Component {
|
|||||||
{createListItem('/history', 'Event history')}
|
{createListItem('/history', 'Event history')}
|
||||||
{createListItem('/archive', 'Archived toggles')}
|
{createListItem('/archive', 'Archived toggles')}
|
||||||
{createListItem('/metrics', 'Client metrics')}
|
{createListItem('/metrics', 'Client metrics')}
|
||||||
|
{createListItem('/Clients', 'Clients')}
|
||||||
|
|
||||||
<ListDivider />
|
<ListDivider />
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
const URI = '/client/strategies';
|
||||||
|
|
||||||
|
function throwIfNotSuccess (response) {
|
||||||
|
if (!response.ok) {
|
||||||
|
let error = new Error('API call failed');
|
||||||
|
error.status = response.status;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchAll () {
|
||||||
|
return fetch(URI)
|
||||||
|
.then(throwIfNotSuccess)
|
||||||
|
.then(response => response.json());
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
fetchAll,
|
||||||
|
};
|
@ -16,6 +16,7 @@ import CreateStrategies from './page/strategies/create';
|
|||||||
import HistoryPage from './page/history';
|
import HistoryPage from './page/history';
|
||||||
import Archive from './page/archive';
|
import Archive from './page/archive';
|
||||||
import Metrics from './page/metrics';
|
import Metrics from './page/metrics';
|
||||||
|
import Clients from './page/clients';
|
||||||
|
|
||||||
const unleashStore = createStore(
|
const unleashStore = createStore(
|
||||||
store,
|
store,
|
||||||
@ -37,6 +38,7 @@ ReactDOM.render(
|
|||||||
<Route path="/history" component={HistoryPage} />
|
<Route path="/history" component={HistoryPage} />
|
||||||
<Route path="/archive" component={Archive} />
|
<Route path="/archive" component={Archive} />
|
||||||
<Route path="/metrics" component={Metrics} />
|
<Route path="/metrics" component={Metrics} />
|
||||||
|
<Route path="/clients" component={Clients} />
|
||||||
</Route>
|
</Route>
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>, document.getElementById('app'));
|
</Provider>, document.getElementById('app'));
|
||||||
|
6
packages/unleash-frontend-next/src/page/clients/index.js
Normal file
6
packages/unleash-frontend-next/src/page/clients/index.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ClientStrategy from '../../component/client-strategy/strategy-container';
|
||||||
|
|
||||||
|
const render = () => <ClientStrategy />;
|
||||||
|
|
||||||
|
export default render;
|
@ -0,0 +1,20 @@
|
|||||||
|
import api from '../data/client-strategy-api';
|
||||||
|
|
||||||
|
export const RECEIVE_CLIENT_STRATEGIES = 'RECEIVE_CLIENT_STRATEGIES';
|
||||||
|
export const ERROR_RECEIVE_CLIENT_STRATEGIES = 'ERROR_RECEIVE_CLIENT_STRATEGIES';
|
||||||
|
|
||||||
|
const receiveMetrics = (json) => ({
|
||||||
|
type: RECEIVE_CLIENT_STRATEGIES,
|
||||||
|
value: json,
|
||||||
|
});
|
||||||
|
|
||||||
|
const errorReceiveMetrics = (statusCode) => ({
|
||||||
|
type: RECEIVE_CLIENT_STRATEGIES,
|
||||||
|
statusCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
export function fetchClientStrategies () {
|
||||||
|
return dispatch => api.fetchAll()
|
||||||
|
.then(json => dispatch(receiveMetrics(json)))
|
||||||
|
.catch(error => dispatch(errorReceiveMetrics(error)));
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
import { fromJS } from 'immutable';
|
||||||
|
import { RECEIVE_CLIENT_STRATEGIES } from './client-strategy-actions';
|
||||||
|
|
||||||
|
function getInitState () {
|
||||||
|
return fromJS([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const store = (state = getInitState(), action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case RECEIVE_CLIENT_STRATEGIES:
|
||||||
|
return fromJS(action.value);
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default store;
|
@ -6,6 +6,7 @@ import history from './history-store'; // eslint-disable-line
|
|||||||
import archive from './archive-store';
|
import archive from './archive-store';
|
||||||
import error from './error-store';
|
import error from './error-store';
|
||||||
import metrics from './metrics-store';
|
import metrics from './metrics-store';
|
||||||
|
import clientStrategies from './client-strategy-store';
|
||||||
|
|
||||||
const unleashStore = combineReducers({
|
const unleashStore = combineReducers({
|
||||||
features,
|
features,
|
||||||
@ -15,6 +16,7 @@ const unleashStore = combineReducers({
|
|||||||
archive,
|
archive,
|
||||||
error,
|
error,
|
||||||
metrics,
|
metrics,
|
||||||
|
clientStrategies,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default unleashStore;
|
export default unleashStore;
|
||||||
|
@ -77,6 +77,10 @@ module.exports = {
|
|||||||
target: 'http://localhost:4242',
|
target: 'http://localhost:4242',
|
||||||
secure: false,
|
secure: false,
|
||||||
},
|
},
|
||||||
|
'/client/strategies': {
|
||||||
|
target: 'http://localhost:4242',
|
||||||
|
secure: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user