foreman_acd 0.0.6 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
- data/app/controllers/foreman_acd/app_definitions_controller.rb +29 -1
- data/app/controllers/foreman_acd/app_instances_controller.rb +70 -21
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/ui_acd_controller.rb +0 -1
- data/app/models/foreman_acd/app_definition.rb +0 -1
- data/app/views/foreman_acd/app_definitions/_form.html.erb +6 -14
- data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
- data/app/views/foreman_acd/app_instances/_form.html.erb +5 -5
- data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +6 -5
- data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/config/routes.rb +7 -0
- data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
- data/db/migrate/20190625140305_create_app_instances.rb +1 -1
- data/lib/foreman_acd/plugin.rb +19 -2
- data/lib/foreman_acd/version.rb +1 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +261 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +211 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +9 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +147 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +6 -0
- data/webpack/components/ApplicationDefinition/index.js +29 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +342 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +210 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +12 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +223 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +8 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
- data/webpack/components/ApplicationInstance/components/Service.js +30 -0
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
- data/webpack/components/ApplicationInstance/index.js +33 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
- data/webpack/components/ApplicationInstanceReport/index.js +27 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +65 -161
- data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +42 -71
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +12 -19
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -3
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +76 -75
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -6
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
- data/webpack/components/ParameterSelection/index.js +4 -6
- data/webpack/components/common/AddTableEntry.js +30 -0
- data/webpack/components/common/DeleteTableEntry.js +39 -0
- data/webpack/components/common/ExtSelect.js +43 -0
- data/webpack/components/common/RailsData.js +27 -0
- data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
- data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
- data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
- data/webpack/components/common/__tests__/RailsData.test.js +16 -0
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
- data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
- data/webpack/helper.js +20 -0
- data/webpack/index.js +6 -0
- data/webpack/reducer.js +40 -3
- metadata +47 -46
@@ -0,0 +1,210 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import api from 'foremanReact/API';
|
3
|
+
import {
|
4
|
+
setModalOpen,
|
5
|
+
setModalClosed,
|
6
|
+
} from 'foremanReact/components/ForemanModal/ForemanModalActions';
|
7
|
+
|
8
|
+
import {
|
9
|
+
actionHeaderCellFormatter,
|
10
|
+
} from 'patternfly-react';
|
11
|
+
|
12
|
+
import {
|
13
|
+
propsToSnakeCase,
|
14
|
+
propsToCamelCase,
|
15
|
+
} from 'foremanReact/common/helpers';
|
16
|
+
|
17
|
+
import {
|
18
|
+
APPLICATION_INSTANCE_INIT,
|
19
|
+
APPLICATION_INSTANCE_HOST_DELETE,
|
20
|
+
APPLICATION_INSTANCE_HOST_ADD,
|
21
|
+
APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
|
22
|
+
APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
23
|
+
APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
24
|
+
APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
25
|
+
APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
|
26
|
+
APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
|
27
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
|
28
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
29
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
|
30
|
+
} from './ApplicationInstanceConstants';
|
31
|
+
|
32
|
+
export const initApplicationInstance = (
|
33
|
+
appDefinition,
|
34
|
+
hosts,
|
35
|
+
headerFormatter,
|
36
|
+
inlineEditFormatter,
|
37
|
+
inlineEditButtonsFormatter,
|
38
|
+
) => dispatch => {
|
39
|
+
const initialState = {};
|
40
|
+
|
41
|
+
initialState.columns = [
|
42
|
+
{
|
43
|
+
property: 'hostname',
|
44
|
+
header: {
|
45
|
+
label: 'Hostname',
|
46
|
+
formatters: [headerFormatter],
|
47
|
+
props: {
|
48
|
+
index: 0,
|
49
|
+
style: {
|
50
|
+
width: '20%'
|
51
|
+
}
|
52
|
+
},
|
53
|
+
},
|
54
|
+
cell: {
|
55
|
+
formatters: [inlineEditFormatter]
|
56
|
+
}
|
57
|
+
},
|
58
|
+
{
|
59
|
+
property: 'description',
|
60
|
+
header: {
|
61
|
+
label: 'Description',
|
62
|
+
formatters: [headerFormatter],
|
63
|
+
props: {
|
64
|
+
index: 1,
|
65
|
+
style: {
|
66
|
+
width: '20%'
|
67
|
+
}
|
68
|
+
},
|
69
|
+
},
|
70
|
+
cell: {
|
71
|
+
formatters: [inlineEditFormatter]
|
72
|
+
}
|
73
|
+
},
|
74
|
+
{
|
75
|
+
property: 'service',
|
76
|
+
header: {
|
77
|
+
label: 'Service',
|
78
|
+
formatters: [headerFormatter],
|
79
|
+
props: {
|
80
|
+
index: 2,
|
81
|
+
style: {
|
82
|
+
width: '20%'
|
83
|
+
}
|
84
|
+
},
|
85
|
+
},
|
86
|
+
cell: {
|
87
|
+
formatters: [inlineEditFormatter]
|
88
|
+
}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
property: 'actions',
|
92
|
+
header: {
|
93
|
+
label: 'Actions',
|
94
|
+
formatters: [actionHeaderCellFormatter],
|
95
|
+
props: {
|
96
|
+
index: 4,
|
97
|
+
style: {
|
98
|
+
width: '20%'
|
99
|
+
}
|
100
|
+
},
|
101
|
+
},
|
102
|
+
cell: {
|
103
|
+
formatters: [inlineEditButtonsFormatter]
|
104
|
+
}
|
105
|
+
}
|
106
|
+
];
|
107
|
+
|
108
|
+
initialState.appDefinition = appDefinition;
|
109
|
+
initialState.hosts = hosts;
|
110
|
+
|
111
|
+
dispatch({
|
112
|
+
type: APPLICATION_INSTANCE_INIT,
|
113
|
+
payload: initialState,
|
114
|
+
});
|
115
|
+
};
|
116
|
+
|
117
|
+
const errorHandler = (msg, err) => {
|
118
|
+
const error = {
|
119
|
+
errorMsg: 'Failed to fetch data from server.',
|
120
|
+
statusText: err,
|
121
|
+
};
|
122
|
+
return { type: msg, payload: { error } };
|
123
|
+
};
|
124
|
+
|
125
|
+
export const loadApplicationDefinition = (
|
126
|
+
applicationDefinitionId,
|
127
|
+
additionalData,
|
128
|
+
) => dispatch => {
|
129
|
+
dispatch({ type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST });
|
130
|
+
|
131
|
+
const realUrl = additionalData.url.replace("__id__", applicationDefinitionId);
|
132
|
+
|
133
|
+
return api
|
134
|
+
.get(realUrl, {}, {})
|
135
|
+
.then(({ data }) =>
|
136
|
+
dispatch({
|
137
|
+
type: APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
138
|
+
payload: data,
|
139
|
+
})
|
140
|
+
)
|
141
|
+
.catch(error => dispatch(errorHandler(APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE, error)));
|
142
|
+
};
|
143
|
+
|
144
|
+
export const addApplicationInstanceHost = (additionalData) => ({
|
145
|
+
type: APPLICATION_INSTANCE_HOST_ADD,
|
146
|
+
payload: {
|
147
|
+
...additionalData,
|
148
|
+
},
|
149
|
+
});
|
150
|
+
|
151
|
+
export const deleteApplicationInstanceHost = (additionalData) => ({
|
152
|
+
type: APPLICATION_INSTANCE_HOST_DELETE,
|
153
|
+
payload: {
|
154
|
+
...additionalData,
|
155
|
+
},
|
156
|
+
});
|
157
|
+
|
158
|
+
export const activateEditApplicationInstanceHost = (additionalData) => ({
|
159
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
|
160
|
+
payload: {
|
161
|
+
...additionalData,
|
162
|
+
},
|
163
|
+
});
|
164
|
+
|
165
|
+
export const confirmEditApplicationInstanceHost = (rowData) => ({
|
166
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
167
|
+
payload: {
|
168
|
+
...rowData,
|
169
|
+
},
|
170
|
+
});
|
171
|
+
|
172
|
+
export const cancelEditApplicationInstanceHost = (rowData) => ({
|
173
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
174
|
+
payload: {
|
175
|
+
...rowData,
|
176
|
+
},
|
177
|
+
});
|
178
|
+
|
179
|
+
export const changeEditApplicationInstanceHost = (value, additionalData) => ({
|
180
|
+
type: APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
181
|
+
payload: {
|
182
|
+
value,
|
183
|
+
...additionalData,
|
184
|
+
},
|
185
|
+
});
|
186
|
+
|
187
|
+
export const openParameterSelectionModal = (additionalData) => dispatch => {
|
188
|
+
dispatch({
|
189
|
+
type: APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
|
190
|
+
payload: {
|
191
|
+
...additionalData,
|
192
|
+
}
|
193
|
+
});
|
194
|
+
dispatch(
|
195
|
+
setModalOpen({ id: 'AppInstanceParamSelection' })
|
196
|
+
);
|
197
|
+
}
|
198
|
+
|
199
|
+
export const closeParameterSelectionModal = (additionalData) => dispatch => {
|
200
|
+
dispatch({
|
201
|
+
type: APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
|
202
|
+
payload: {
|
203
|
+
...additionalData,
|
204
|
+
}
|
205
|
+
});
|
206
|
+
|
207
|
+
dispatch(
|
208
|
+
setModalClosed({ id: 'AppInstanceParamSelection' })
|
209
|
+
);
|
210
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export const APPLICATION_INSTANCE_INIT = 'APPLICATION_INSTANCE_INIT';
|
2
|
+
export const APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST = 'APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST';
|
3
|
+
export const APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS = 'APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS';
|
4
|
+
export const APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE = 'APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE';
|
5
|
+
export const APPLICATION_INSTANCE_HOST_DELETE = 'APPLICATION_INSTANCE_HOST_DELETE';
|
6
|
+
export const APPLICATION_INSTANCE_HOST_ADD = 'APPLICATION_INSTANCE_HOST_ADD';
|
7
|
+
export const APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE = 'APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE';
|
8
|
+
export const APPLICATION_INSTANCE_HOST_EDIT_CONFIRM = 'APPLICATION_INSTANCE_HOST_EDIT_CONFIRM';
|
9
|
+
export const APPLICATION_INSTANCE_HOST_EDIT_CHANGE = 'APPLICATION_INSTANCE_HOST_EDIT_CHANGE';
|
10
|
+
export const APPLICATION_INSTANCE_HOST_EDIT_CANCEL = 'APPLICATION_INSTANCE_HOST_EDIT_CANCEL';
|
11
|
+
export const APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN = 'APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN';
|
12
|
+
export const APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE = 'APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE';
|
@@ -0,0 +1,223 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
|
3
|
+
import {
|
4
|
+
cloneDeep,
|
5
|
+
findIndex,
|
6
|
+
findLastIndex,
|
7
|
+
} from 'lodash';
|
8
|
+
|
9
|
+
import {
|
10
|
+
APPLICATION_INSTANCE_INIT,
|
11
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE,
|
12
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST,
|
13
|
+
APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS,
|
14
|
+
APPLICATION_INSTANCE_HOST_DELETE,
|
15
|
+
APPLICATION_INSTANCE_HOST_ADD,
|
16
|
+
APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE,
|
17
|
+
APPLICATION_INSTANCE_HOST_EDIT_CONFIRM,
|
18
|
+
APPLICATION_INSTANCE_HOST_EDIT_CHANGE,
|
19
|
+
APPLICATION_INSTANCE_HOST_EDIT_CANCEL,
|
20
|
+
APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN,
|
21
|
+
APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE,
|
22
|
+
} from './ApplicationInstanceConstants';
|
23
|
+
|
24
|
+
export const initialState = Immutable({
|
25
|
+
name: false,
|
26
|
+
error: { errorMsg: '', status: '', statusText: '' },
|
27
|
+
});
|
28
|
+
|
29
|
+
const applicationInstanceConf = (state = initialState, action) => {
|
30
|
+
const { payload } = action;
|
31
|
+
|
32
|
+
switch (action.type) {
|
33
|
+
case APPLICATION_INSTANCE_INIT: {
|
34
|
+
return state.merge(payload);
|
35
|
+
}
|
36
|
+
case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_FAILURE: {
|
37
|
+
return state.merge({ error: payload.error, loading: false });
|
38
|
+
}
|
39
|
+
case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_REQUEST: {
|
40
|
+
return state.set('loading', true);
|
41
|
+
}
|
42
|
+
case APPLICATION_INSTANCE_LOAD_APPLICATION_DEFINITION_SUCCESS: {
|
43
|
+
const services = JSON.parse(payload.app_definition.services);
|
44
|
+
|
45
|
+
// initialize all services count with 0
|
46
|
+
services.map(serv => {
|
47
|
+
serv['currentCount'] = 0;
|
48
|
+
})
|
49
|
+
|
50
|
+
// Update count
|
51
|
+
if (state.hosts !== undefined) {
|
52
|
+
state.hosts.map((host, index) => {
|
53
|
+
const hostServiceId = Number(host.service);
|
54
|
+
const service = services.find(serv => serv['id'] == hostServiceId);
|
55
|
+
service['currentCount'] += 1;
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
return state.merge({
|
60
|
+
appDefinition: payload.app_definition,
|
61
|
+
services: services,
|
62
|
+
loading: false,
|
63
|
+
});
|
64
|
+
}
|
65
|
+
case APPLICATION_INSTANCE_HOST_ADD: {
|
66
|
+
let hosts = [];
|
67
|
+
let index = 1;
|
68
|
+
|
69
|
+
if ('hosts' in state && state.hosts !== undefined && state.hosts.length > 0) {
|
70
|
+
hosts = cloneDeep(state.hosts);
|
71
|
+
index = Math.max(...hosts.map(e => e.id)) + 1;
|
72
|
+
}
|
73
|
+
|
74
|
+
const newRow = {id: index, hostname: "", description: '', service: '', parameters: [], newEntry: true };
|
75
|
+
newRow.backup = cloneDeep(newRow)
|
76
|
+
hosts.push(newRow);
|
77
|
+
|
78
|
+
return state.merge({
|
79
|
+
editMode: true,
|
80
|
+
hosts: hosts
|
81
|
+
});
|
82
|
+
}
|
83
|
+
case APPLICATION_INSTANCE_HOST_DELETE: {
|
84
|
+
const services = cloneDeep(state.services);
|
85
|
+
const host = state.hosts.find(v => v.id == payload.rowData.id);
|
86
|
+
const hostServiceId = Number(host.service);
|
87
|
+
const hosts = state.hosts.filter(v => v.id !== host.id);
|
88
|
+
|
89
|
+
// Update count
|
90
|
+
const service = services.find(serv => serv['id'] == hostServiceId);
|
91
|
+
service['currentCount'] -= 1;
|
92
|
+
|
93
|
+
return state.merge({
|
94
|
+
hosts: hosts,
|
95
|
+
services: services,
|
96
|
+
})
|
97
|
+
}
|
98
|
+
case APPLICATION_INSTANCE_HOST_EDIT_ACTIVATE: {
|
99
|
+
const hosts = cloneDeep(state.hosts);
|
100
|
+
const index = findIndex(hosts, { id: payload.rowData.id });
|
101
|
+
|
102
|
+
hosts[index].backup = cloneDeep(hosts[index]);
|
103
|
+
|
104
|
+
return state.merge({
|
105
|
+
editMode: true,
|
106
|
+
hosts: hosts
|
107
|
+
});
|
108
|
+
}
|
109
|
+
case APPLICATION_INSTANCE_HOST_EDIT_CONFIRM: {
|
110
|
+
const hosts = cloneDeep(state.hosts);
|
111
|
+
const index = findIndex(hosts, { id: payload.rowData.id });
|
112
|
+
const services = cloneDeep(state.services);
|
113
|
+
|
114
|
+
const thisHost = hosts[index];
|
115
|
+
|
116
|
+
if (thisHost.hostname == '') {
|
117
|
+
window.alert("Every host needs to have a valid name");
|
118
|
+
return state;
|
119
|
+
}
|
120
|
+
|
121
|
+
if (thisHost.service == '') {
|
122
|
+
window.alert("Every host needs to be assigned to a service");
|
123
|
+
return state;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (state.hosts.filter(v => v.hostname === thisHost.hostname && v.id != thisHost.id).length > 0) {
|
127
|
+
window.alert("Host name already used for this Application Instance. Please make sure that every host name is unique");
|
128
|
+
return state;
|
129
|
+
}
|
130
|
+
|
131
|
+
// Initialize the new Instance with the parameters of the Application Definition.
|
132
|
+
if (thisHost.newEntry === true) {
|
133
|
+
const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
|
134
|
+
hosts[index].parameters = selectedService.parameters;
|
135
|
+
|
136
|
+
const hostServiceId = Number(thisHost.service);
|
137
|
+
const service = services.find(serv => serv['id'] == hostServiceId);
|
138
|
+
if ('currentCount' in service) {
|
139
|
+
service['currentCount'] += 1;
|
140
|
+
} else {
|
141
|
+
service['currentCount'] = 1;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
delete hosts[index].backup;
|
146
|
+
delete hosts[index].newEntry;
|
147
|
+
|
148
|
+
return state.merge({
|
149
|
+
editMode: false,
|
150
|
+
services: services,
|
151
|
+
hosts: hosts
|
152
|
+
});
|
153
|
+
}
|
154
|
+
case APPLICATION_INSTANCE_HOST_EDIT_CHANGE: {
|
155
|
+
const hosts = cloneDeep(state.hosts);
|
156
|
+
const index = findIndex(hosts, { id: payload.rowData.id });
|
157
|
+
|
158
|
+
hosts[index][payload.property] = payload.value;
|
159
|
+
|
160
|
+
return state.set('hosts', hosts);
|
161
|
+
}
|
162
|
+
case APPLICATION_INSTANCE_HOST_EDIT_CANCEL: {
|
163
|
+
const hosts = cloneDeep(state.hosts);
|
164
|
+
const index = findIndex(hosts, { id: payload.rowData.id });
|
165
|
+
|
166
|
+
hosts[index] = cloneDeep(hosts[index].backup);
|
167
|
+
delete hosts[index].backup;
|
168
|
+
|
169
|
+
if (hosts[index].newEntry === true) {
|
170
|
+
hosts.splice(index, 1);
|
171
|
+
}
|
172
|
+
|
173
|
+
return state.merge({
|
174
|
+
editMode: false,
|
175
|
+
hosts: hosts
|
176
|
+
});
|
177
|
+
}
|
178
|
+
case APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_OPEN: {
|
179
|
+
let parametersData = {};
|
180
|
+
|
181
|
+
if (payload && payload.rowData) {
|
182
|
+
const selectedService = state.services.filter(entry => entry.id == payload.rowData.service)[0];
|
183
|
+
|
184
|
+
parametersData.serviceDefinition = {
|
185
|
+
id: selectedService.id,
|
186
|
+
name: selectedService.name,
|
187
|
+
hostgroup_id: selectedService.hostgroup,
|
188
|
+
hostId: payload.rowData.id,
|
189
|
+
};
|
190
|
+
parametersData.parameters = payload.rowData.parameters;
|
191
|
+
|
192
|
+
if (parametersData.parameters.length > 0) {
|
193
|
+
parametersData.mode = 'editInstance';
|
194
|
+
} else {
|
195
|
+
parametersData.mode = 'newInstance';
|
196
|
+
}
|
197
|
+
}
|
198
|
+
return state.merge({
|
199
|
+
parametersData: parametersData,
|
200
|
+
});
|
201
|
+
}
|
202
|
+
case APPLICATION_INSTANCE_PARAMETER_SELECTION_MODAL_CLOSE: {
|
203
|
+
if (payload.mode == 'save') {
|
204
|
+
const hosts = cloneDeep(state.hosts);
|
205
|
+
const index = findIndex(hosts, { id: state.parametersData.serviceDefinition.hostId });
|
206
|
+
hosts[index].parameters = cloneDeep(payload.hostParameterSelection);
|
207
|
+
|
208
|
+
return state.merge({
|
209
|
+
parametersData: null,
|
210
|
+
hosts: hosts
|
211
|
+
});
|
212
|
+
} else {
|
213
|
+
return state.merge({
|
214
|
+
parametersData: null,
|
215
|
+
});
|
216
|
+
}
|
217
|
+
}
|
218
|
+
default:
|
219
|
+
return state;
|
220
|
+
}
|
221
|
+
};
|
222
|
+
|
223
|
+
export default applicationInstanceConf;
|