blob: ba0b238b1705ab50a3494ac069430c6526e3d948 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
Michael Landoefa037d2017-02-19 12:57:33 +02002 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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';
AviZi280f8012017-06-09 02:39:56 +030018import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx';
Michael Landoefa037d2017-02-19 12:57:33 +020019
20export const actionTypes = keyMirror({
21
22 ENTITLEMENT_POOLS_LIST_LOADED: null,
23 ADD_ENTITLEMENT_POOL: null,
24 EDIT_ENTITLEMENT_POOL: null,
25 DELETE_ENTITLEMENT_POOL: null,
Michael Landoefa037d2017-02-19 12:57:33 +020026
27 entitlementPoolsEditor: {
28 OPEN: null,
29 CLOSE: null,
30 DATA_CHANGED: null,
31 }
32
33});
34
35export const enums = keyMirror({
36 SELECTED_FEATURE_GROUP_TAB: {
37 GENERAL: 1,
38 ENTITLEMENT_POOLS: 2,
39 LICENCE_KEY_GROUPS: 3
40 },
41 SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: {
42 ASSOCIATED_ENTITLEMENT_POOLS: 1,
43 AVAILABLE_ENTITLEMENT_POOLS: 2
44 }
45});
46
47export const defaultState = {
48 ENTITLEMENT_POOLS_EDITOR_DATA: {
49 entitlementMetric: {choice: '', other: ''},
50 aggregationFunction: {choice: '', other: ''},
51 operationalScope: {choices: [], other: ''},
52 time: {choice: '', other: ''}
53 }
54};
55
56export const thresholdUnitType = {
57 ABSOLUTE: 'Absolute',
58 PERCENTAGE: 'Percentage'
59};
60
61export const optionsInputValues = {
62 OPERATIONAL_SCOPE: [
63 {enum: '', title: i18n('please select…')},
64 {enum: 'Network_Wide', title: 'Network Wide'},
65 {enum: 'Availability_Zone', title: 'Availability Zone'},
66 {enum: 'Data_Center', title: 'Data Center'},
67 {enum: 'Tenant', title: 'Tenant'},
68 {enum: 'VM', title: 'VM'},
69 {enum: 'CPU', title: 'CPU'},
70 {enum: 'Core', title: 'Core'}
71 ],
72 TIME: [
73 {enum: '', title: i18n('please select…')},
74 {enum: 'Hour', title: 'Hour'},
75 {enum: 'Day', title: 'Day'},
76 {enum: 'Month', title: 'Month'}
77 ],
78 AGGREGATE_FUNCTION: [
79 {enum: '', title: i18n('please select…')},
80 {enum: 'Peak', title: 'Peak'},
81 {enum: 'Average', title: 'Average'}
82 ],
83 ENTITLEMENT_METRIC: [
84 {enum: '', title: i18n('please select…')},
85 {enum: 'Software_Instances_Count', title: 'Software Instances'},
86 {enum: 'Core', title: 'Core'},
87 {enum: 'CPU', title: 'CPU'},
88 {enum: 'Trunks', title: 'Trunks'},
89 {enum: 'User', title: 'User'},
90 {enum: 'Subscribers', title: 'Subscribers'},
91 {enum: 'Tenants', title: 'Tenants'},
92 {enum: 'Tokens', title: 'Tokens'},
93 {enum: 'Seats', title: 'Seats'},
94 {enum: 'Units_TB', title: 'Units-TB'},
95 {enum: 'Units_GB', title: 'Units-GB'},
96 {enum: 'Units_MB', title: 'Units-MB'}
97 ],
98 THRESHOLD_UNITS: [
99 {enum: '', title: i18n('please select…')},
100 {enum: thresholdUnitType.ABSOLUTE, title: 'Absolute'},
101 {enum: thresholdUnitType.PERCENTAGE, title: '%'}
102 ]
103};
104
AviZi280f8012017-06-09 02:39:56 +0300105export const extractValue = (item) => {
106 if (item === undefined) {return '';} //TODO fix it later
107 return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : '';
108};
Michael Landoefa037d2017-02-19 12:57:33 +0200109
AviZi280f8012017-06-09 02:39:56 +0300110export const extractUnits = (units) => {
111 if (units === undefined) {return '';} //TODO fix it later
112 return units === 'Absolute' ? '' : '%';
113};
Michael Landoefa037d2017-02-19 12:57:33 +0200114
AviZi280f8012017-06-09 02:39:56 +0300115export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL';