AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 4 | * 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 |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 12 | * 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 Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import keyMirror from 'nfvo-utils/KeyMirror.js'; |
| 17 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 18 | import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 19 | |
| 20 | export 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 Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 26 | |
| 27 | entitlementPoolsEditor: { |
| 28 | OPEN: null, |
| 29 | CLOSE: null, |
| 30 | DATA_CHANGED: null, |
| 31 | } |
| 32 | |
| 33 | }); |
| 34 | |
| 35 | export 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 | |
| 47 | export 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 | |
| 56 | export const thresholdUnitType = { |
| 57 | ABSOLUTE: 'Absolute', |
| 58 | PERCENTAGE: 'Percentage' |
| 59 | }; |
| 60 | |
| 61 | export 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 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 105 | export 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 Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 109 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 110 | export const extractUnits = (units) => { |
| 111 | if (units === undefined) {return '';} //TODO fix it later |
| 112 | return units === 'Absolute' ? '' : '%'; |
| 113 | }; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 114 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 115 | export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL'; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 116 | |
| 117 | export const EP_TIME_FORMAT = 'MM/DD/YYYY'; |