blob: ab0f3dd1005858979e7f710692b19548d0de1c2f [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
svishnev8f133302018-08-06 23:08:39 +03002 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
Michael Landoefa037d2017-02-19 12:57:33 +02004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
AviZi280f8012017-06-09 02:39:56 +03007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Michael Landoefa037d2017-02-19 12:57:33 +020010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
AviZi280f8012017-06-09 02:39:56 +030012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
Michael Landoefa037d2017-02-19 12:57:33 +020015 */
Michael Landoefa037d2017-02-19 12:57:33 +020016import keyMirror from 'nfvo-utils/KeyMirror.js';
17import i18n from 'nfvo-utils/i18n/i18n.js';
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020018import InputOptions, {
19 other as optionInputOther
20} from 'nfvo-components/input/validation/InputOptions.jsx';
Michael Landoefa037d2017-02-19 12:57:33 +020021
22export const actionTypes = keyMirror({
svishnev8f133302018-08-06 23:08:39 +030023 ENTITLEMENT_POOLS_LIST_LOADED: 'ENTITLEMENT_POOLS_LIST_LOADED',
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020024 entitlementPoolsEditor: {
svishnev8f133302018-08-06 23:08:39 +030025 OPEN: 'epEditor/OPEN',
26 CLOSE: 'epEditor/CLOSE',
27 DATA_CHANGED: 'epEditor/DATA_CHANGED',
28 LIMITS_LIST_LOADED: 'epEditor/LIMITS_LIST_LOADED'
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020029 }
Michael Landoefa037d2017-02-19 12:57:33 +020030});
31
32export const enums = keyMirror({
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020033 SELECTED_FEATURE_GROUP_TAB: {
34 GENERAL: 1,
35 ENTITLEMENT_POOLS: 2,
36 LICENCE_KEY_GROUPS: 3
37 },
38 SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: {
39 ASSOCIATED_ENTITLEMENT_POOLS: 1,
40 AVAILABLE_ENTITLEMENT_POOLS: 2
41 }
Michael Landoefa037d2017-02-19 12:57:33 +020042});
43
44export const defaultState = {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020045 ENTITLEMENT_POOLS_EDITOR_DATA: {
46 entitlementMetric: { choice: '', other: '' },
47 aggregationFunction: { choice: '', other: '' },
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020048 time: { choice: '', other: '' }
49 }
Michael Landoefa037d2017-02-19 12:57:33 +020050};
51
52export const thresholdUnitType = {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020053 ABSOLUTE: 'Absolute',
54 PERCENTAGE: 'Percentage'
Michael Landoefa037d2017-02-19 12:57:33 +020055};
56
57export const optionsInputValues = {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020058 TIME: [
59 { enum: '', title: i18n('please select…') },
60 { enum: 'Hour', title: 'Hour' },
61 { enum: 'Day', title: 'Day' },
62 { enum: 'Month', title: 'Month' }
63 ],
64 AGGREGATE_FUNCTION: [
65 { enum: '', title: i18n('please select…') },
66 { enum: 'Peak', title: 'Peak' },
67 { enum: 'Average', title: 'Average' }
68 ],
69 ENTITLEMENT_METRIC: [
70 { enum: '', title: i18n('please select…') },
71 { enum: 'Software_Instances_Count', title: 'Software Instances' },
72 { enum: 'Core', title: 'Core' },
73 { enum: 'CPU', title: 'CPU' },
74 { enum: 'Trunks', title: 'Trunks' },
75 { enum: 'User', title: 'User' },
76 { enum: 'Subscribers', title: 'Subscribers' },
77 { enum: 'Tenants', title: 'Tenants' },
78 { enum: 'Tokens', title: 'Tokens' },
79 { enum: 'Seats', title: 'Seats' },
80 { enum: 'Units_TB', title: 'Units-TB' },
81 { enum: 'Units_GB', title: 'Units-GB' },
82 { enum: 'Units_MB', title: 'Units-MB' }
83 ]
Michael Landoefa037d2017-02-19 12:57:33 +020084};
85
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020086export const extractValue = item => {
87 if (item === undefined) {
88 return '';
89 } //TODO fix it later
90 return item
91 ? item.choice === optionInputOther.OTHER
92 ? item.other
93 : InputOptions.getTitleByName(optionsInputValues, item.choice)
94 : '';
AviZi280f8012017-06-09 02:39:56 +030095};
Michael Landoefa037d2017-02-19 12:57:33 +020096
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020097export const extractUnits = units => {
98 if (units === undefined) {
99 return '';
100 } //TODO fix it later
101 return units === 'Absolute' ? '' : '%';
AviZi280f8012017-06-09 02:39:56 +0300102};
Michael Landoefa037d2017-02-19 12:57:33 +0200103
Avi Ziv61070c92017-07-26 17:37:57 +0300104export const tabIds = {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200105 GENERAL: 'GENERAL',
106 SP_LIMITS: 'SP_LIMITS',
107 VENDOR_LIMITS: 'VENDOR_LIMITS',
108 ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON'
Avi Ziv61070c92017-07-26 17:37:57 +0300109};
Avi Zivb8e2faf2017-07-18 19:45:38 +0300110
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +0200111export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL';