Commit ae2c0566 authored by Matthieu Lamalle's avatar Matthieu Lamalle
Browse files

remove serverselection display of _DEFAULT

parent 387a03f9
......@@ -7,7 +7,7 @@ import {
IconButton,
Select,
Chip
} from '@material-ui/core';
} from '@material-ui/core';
import CachedIcon from '@material-ui/icons/Cached';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
......@@ -34,15 +34,8 @@ class ServerModelSelector extends React.Component {
}
handleSelectedChange(event) {
console.log(this.state)
console.log(this.props)
let joined = this.state.servermodelselected.concat(event.target.value);
console.log(joined)
this.setState({ servermodelselected: joined })
this.setState({ servermodelselected: joined });
}
render() {
// eslint-disable-next-line
......@@ -51,7 +44,7 @@ class ServerModelSelector extends React.Component {
if (multi === 'true') {
return (
<Select
{...otherProps}
{...otherProps}
multiple
value={servermodelselected}
onChange={this.handleSelectedChange}
......@@ -63,13 +56,13 @@ class ServerModelSelector extends React.Component {
</div>
)}
>
{
Object.keys(servermodelGroups).map(groupName => {
return [...this.renderServerModelsGroup(groupName, servermodelGroups[groupName]), <Divider key={`divider-${groupName}`} />];
})
}
{
Object.keys(servermodelGroups).map(groupName => {
return [...this.renderServerModelsGroup(groupName, servermodelGroups[groupName]), <Divider key={`divider-${groupName}`} />];
})
}
</Select>
)
);
}else {
return (
<TextField {...otherProps} select
......@@ -88,7 +81,7 @@ class ServerModelSelector extends React.Component {
</InputAdornment>
}}
disabled={otherProps.disabled}
>
>
{
Object.keys(servermodelGroups).map(groupName => {
return [...this.renderServerModelsGroup(groupName, servermodelGroups[groupName]), <Divider key={`divider-${groupName}`} />];
......
......@@ -47,17 +47,16 @@ const app = (
keycloak.init({onLoad: 'login-required', token, refreshToken})
.success(authenticated => {
if (authenticated) {
keycloak.updateToken(10).error(() => keycloak.logout());
updateLocalStorage();
keycloak.updateToken(10).error(() => keycloak.logout());
updateLocalStorage();
if(sessionStorage.getItem('kc_token') != null){
ReactDOM.render(app, document.getElementById('root'));
}
setInterval(() => {
keycloak.updateToken(10).error(() => keycloak.logout());
console.log("KEYCLOAK")
sessionStorage.setItem('kctoken', keycloak.token);
}, 10000);
if(sessionStorage.getItem('kc_token') != null){
ReactDOM.render(app, document.getElementById('root'));
}
setInterval(() => {
keycloak.updateToken(10).error(() => keycloak.logout());
sessionStorage.setItem('kctoken', keycloak.token);
}, 10000);
} else {
keycloak.login();
}
......
......@@ -13,23 +13,21 @@ import bg from '../../assets/login-bg.jpg';
import { getInstanceLabel, getAppClass } from '../../helpers/apps';
class AppDetail extends React.Component {
render() {
const { classes, instance, onClose } = this.props;
const title = getInstanceLabel(instance);
console.log(this.props)
let id = '';
let type = '';
if (instance.opts.server) {id = instance.opts.server.serverid ; type = 'servers'}
if (instance.opts.servermodel) {id = instance.opts.servermodel.servermodelid; type = 'servermodels'}
console.log(type)
if (instance.opts.server) {id = instance.opts.server.serverid ; type = 'servers';}
if (instance.opts.servermodel) {id = instance.opts.servermodel.servermodelid; type = 'servermodels';}
return (
<Page title={title}
className={`${classes.root} ${classes.appBar}`} navLeft={
<div className={classes.leftIcon}>
<AppIcon icon={instance.icon} />
</div>
} navRight={
}
navRight={
<IconButton onClick={() => onClose(instance.id, id, type)} color="inherit">
<CloseIcon />
</IconButton>
......
......@@ -24,7 +24,6 @@ import {
import {
Edit as EditIcon,
Delete as DeleteIcon,
ViewModule as ServerSelectionIcon
} from '@material-ui/icons';
import {
selectServerById,
......@@ -77,9 +76,7 @@ class ServerDetail extends React.Component {
render(){
const { classes, theme, fullScreen, inner, sm, availableApps, isLoading, server, servermodel } = this.props;
const prevServerSelection = this.props.location.serverselection;
console.log(classes)
const back = (prevServerSelection && "/serverselections/"+prevServerSelection) || `/servers`
console.log(server)
const back = (prevServerSelection && "/serverselections/"+prevServerSelection) || `/servers`;
return (
<Page
title={server && server.servername}
......@@ -134,7 +131,7 @@ class ServerDetail extends React.Component {
Sélections :
</Typography>
{server.selections && server.selections.map((selection) =>
<Chip
<Chip
variant="outlined"
className={classes.chip}
key={`${selection.serverselectionid}`}
......@@ -158,8 +155,6 @@ class ServerDetail extends React.Component {
</GridListTile>
</GridList>
</div>
}
{isLoading && <Loader />}
<Dialog
......@@ -193,7 +188,6 @@ class ServerDetail extends React.Component {
this.props.dispatch(appActions.openApp(app.name, {server}))
.then(instance => this.props.history.push(`/apps/${instance.id}`));
}
}
const styles = theme => ({
......@@ -237,7 +231,7 @@ function mapStateToProps({ apps, servers, servermodels}, { match }) {
servermodels.byId,
server.servermodelid
);
server.selections = servers.selections
server.selections = servers.selections;
}
return {
availableApps: apps.available,
......
......@@ -78,13 +78,16 @@ function handleServerListSuccess(state, action) {
};
}
function handleServerSelectionsListSuccess(state, action) {
for (let [i, serverselection] of action.selections.entries()) {
if (serverselection.serverselectionname.includes('_DEFAULT')) {
action.selections.splice(i,1);
}
}
return {
...state,
selections: action.selections
}
};
}
function handleServerDescribeSuccess(state, action) {
return {
......
import {
SERVERSELECTION_LIST_REQUEST,
SERVERSELECTION_LIST_SUCCESS,
SERVERSELECTION_LIST_FAILURE,
SERVERSELECTION_DESCRIBE_SUCCESS,
SERVERSELECTION_CREATE_REQUEST,
SERVERSELECTION_CREATE_SUCCESS,
SERVERSELECTION_CREATE_FAILURE,
SERVERSELECTION_UPDATE_REQUEST,
SERVERSELECTION_UPDATE_SUCCESS,
SERVERSELECTION_UPDATE_FAILURE,
SERVERSELECTION_UPDATE_LOCAL_FILTER,
SERVERSELECTION_SERVER_SET_REQUEST,
SERVERSELECTION_SERVER_SET_FAILURE,
SERVERSELECTION_SERVER_SET_SUCCESS,
SERVERSELECTION_USER_ADD_REQUEST,
SERVERSELECTION_USER_ADD_SUCCESS,
SERVERSELECTION_USER_ADD_FAILURE,
SERVERSELECTION_USER_DEL_REQUEST,
SERVERSELECTION_USER_DEL_SUCCESS,
SERVERSELECTION_USER_DEL_FAILURE,
SERVERSELECTION_USER_UPDATE_REQUEST,
SERVERSELECTION_USER_UPDATE_SUCCESS,
SERVERSELECTION_USER_UPDATE_FAILURE
SERVERSELECTION_LIST_REQUEST,
SERVERSELECTION_LIST_SUCCESS,
SERVERSELECTION_LIST_FAILURE,
SERVERSELECTION_DESCRIBE_SUCCESS,
SERVERSELECTION_CREATE_REQUEST,
SERVERSELECTION_CREATE_SUCCESS,
SERVERSELECTION_CREATE_FAILURE,
SERVERSELECTION_UPDATE_REQUEST,
SERVERSELECTION_UPDATE_SUCCESS,
SERVERSELECTION_UPDATE_FAILURE,
SERVERSELECTION_UPDATE_LOCAL_FILTER,
SERVERSELECTION_SERVER_SET_REQUEST,
SERVERSELECTION_SERVER_SET_FAILURE,
SERVERSELECTION_SERVER_SET_SUCCESS,
SERVERSELECTION_USER_ADD_REQUEST,
SERVERSELECTION_USER_ADD_SUCCESS,
SERVERSELECTION_USER_ADD_FAILURE,
SERVERSELECTION_USER_DEL_REQUEST,
SERVERSELECTION_USER_DEL_SUCCESS,
SERVERSELECTION_USER_DEL_FAILURE,
SERVERSELECTION_USER_UPDATE_REQUEST,
SERVERSELECTION_USER_UPDATE_SUCCESS,
SERVERSELECTION_USER_UPDATE_FAILURE
} from '../actions/serverselection.actions';
const initialState = {
isLoading: false,
byId: {}
isLoading: false,
byId: {}
};
export default function serverselections(state = initialState, action) {
switch (action.type) {
switch (action.type) {
// Mise à jour du flag "isLoading" à true pour
// toutes les requetes
case SERVERSELECTION_CREATE_REQUEST:
case SERVERSELECTION_LIST_REQUEST:
case SERVERSELECTION_UPDATE_REQUEST:
case SERVERSELECTION_SERVER_SET_REQUEST:
case SERVERSELECTION_USER_ADD_REQUEST:
case SERVERSELECTION_USER_DEL_REQUEST:
case SERVERSELECTION_USER_UPDATE_REQUEST:
return updateLoadingFlag(state, true);
// Mise à jour du flag "isLoading" à true pour
// toutes les requetes
case SERVERSELECTION_CREATE_REQUEST:
case SERVERSELECTION_LIST_REQUEST:
case SERVERSELECTION_UPDATE_REQUEST:
case SERVERSELECTION_SERVER_SET_REQUEST:
case SERVERSELECTION_USER_ADD_REQUEST:
case SERVERSELECTION_USER_DEL_REQUEST:
case SERVERSELECTION_USER_UPDATE_REQUEST:
return updateLoadingFlag(state, true);
// Mise à jour du flag "isLoading" à false pour
// tous les échecs
case SERVERSELECTION_CREATE_FAILURE:
case SERVERSELECTION_UPDATE_FAILURE:
case SERVERSELECTION_LIST_FAILURE:
case SERVERSELECTION_SERVER_SET_FAILURE:
case SERVERSELECTION_USER_ADD_FAILURE:
case SERVERSELECTION_USER_DEL_FAILURE:
case SERVERSELECTION_USER_UPDATE_FAILURE:
return updateLoadingFlag(state, false);
// Mise à jour du flag "isLoading" à false pour
// tous les échecs
case SERVERSELECTION_CREATE_FAILURE:
case SERVERSELECTION_UPDATE_FAILURE:
case SERVERSELECTION_LIST_FAILURE:
case SERVERSELECTION_SERVER_SET_FAILURE:
case SERVERSELECTION_USER_ADD_FAILURE:
case SERVERSELECTION_USER_DEL_FAILURE:
case SERVERSELECTION_USER_UPDATE_FAILURE:
return updateLoadingFlag(state, false);
case SERVERSELECTION_CREATE_SUCCESS:
case SERVERSELECTION_UPDATE_SUCCESS:
case SERVERSELECTION_SERVER_SET_SUCCESS:
case SERVERSELECTION_USER_ADD_SUCCESS:
case SERVERSELECTION_USER_DEL_SUCCESS:
case SERVERSELECTION_USER_UPDATE_SUCCESS:
return updateLoadingFlag(handleServerSelectionUpdateSuccess(state, action), false);
case SERVERSELECTION_CREATE_SUCCESS:
case SERVERSELECTION_UPDATE_SUCCESS:
case SERVERSELECTION_SERVER_SET_SUCCESS:
case SERVERSELECTION_USER_ADD_SUCCESS:
case SERVERSELECTION_USER_DEL_SUCCESS:
case SERVERSELECTION_USER_UPDATE_SUCCESS:
return updateLoadingFlag(handleServerSelectionUpdateSuccess(state, action), false);
case SERVERSELECTION_LIST_SUCCESS:
return updateLoadingFlag(handleServerSelectionListSuccess(state, action), false);
case SERVERSELECTION_LIST_SUCCESS:
return updateLoadingFlag(handleServerSelectionListSuccess(state, action), false);
case SERVERSELECTION_DESCRIBE_SUCCESS:
return updateLoadingFlag(handleServerSelectionDescribeSuccess(state, action), false);
case SERVERSELECTION_DESCRIBE_SUCCESS:
return updateLoadingFlag(handleServerSelectionDescribeSuccess(state, action), false);
case SERVERSELECTION_UPDATE_LOCAL_FILTER:
return handleUpdateLocalFilter(state, action);
case SERVERSELECTION_UPDATE_LOCAL_FILTER:
return handleUpdateLocalFilter(state, action);
default:
return state;
}
default:
return state;
}
}
function updateLoadingFlag(state, isLoading) {
......@@ -84,13 +84,18 @@ function updateLoadingFlag(state, isLoading) {
}
function handleServerSelectionListSuccess(state, action) {
return {
...state,
byId: action.serverselections.reduce((serverselections, serverselection) => {
serverselections[serverselection.serverselectionid] = serverselection;
return serverselections;
}, {...state.serverselectionsById})
};
for (let [i, serverselection] of action.serverselections.entries()) {
if (serverselection.serverselectionname.includes('_DEFAULT')) {
action.serverselections.splice(i,1);
}
}
return {
...state,
byId: action.serverselections.reduce((serverselections, serverselection) => {
serverselections[serverselection.serverselectionid] = serverselection;
return serverselections;
}, {...state.serverselectionsById})
};
}
function handleServerSelectionDescribeSuccess(state, action) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment