AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
svishnev | 8f13330 | 2018-08-06 23:08:39 +0300 | [diff] [blame] | 2 | * Copyright © 2016-2018 European Support Limited |
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'; |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 18 | import InputOptions, { |
| 19 | other as optionInputOther |
| 20 | } from 'nfvo-components/input/validation/InputOptions.jsx'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 21 | |
svishnev | bacc715 | 2018-11-05 12:11:30 +0200 | [diff] [blame] | 22 | export const actionTypes = keyMirror( |
| 23 | { |
| 24 | ENTITLEMENT_POOLS_LIST_LOADED: null, |
| 25 | entitlementPoolsEditor: { |
| 26 | OPEN: null, |
| 27 | CLOSE: null, |
| 28 | DATA_CHANGED: null, |
| 29 | LIMITS_LIST_LOADED: null |
| 30 | } |
| 31 | }, |
| 32 | 'entitlementPoolsEditor' |
| 33 | ); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 34 | |
| 35 | export const enums = keyMirror({ |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 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 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 45 | }); |
| 46 | |
| 47 | export const defaultState = { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 48 | ENTITLEMENT_POOLS_EDITOR_DATA: { |
| 49 | entitlementMetric: { choice: '', other: '' }, |
| 50 | aggregationFunction: { choice: '', other: '' }, |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 51 | time: { choice: '', other: '' } |
| 52 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | export const thresholdUnitType = { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 56 | ABSOLUTE: 'Absolute', |
| 57 | PERCENTAGE: 'Percentage' |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | export const optionsInputValues = { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 61 | TIME: [ |
| 62 | { enum: '', title: i18n('please select…') }, |
| 63 | { enum: 'Hour', title: 'Hour' }, |
| 64 | { enum: 'Day', title: 'Day' }, |
| 65 | { enum: 'Month', title: 'Month' } |
| 66 | ], |
| 67 | AGGREGATE_FUNCTION: [ |
| 68 | { enum: '', title: i18n('please select…') }, |
| 69 | { enum: 'Peak', title: 'Peak' }, |
| 70 | { enum: 'Average', title: 'Average' } |
| 71 | ], |
| 72 | ENTITLEMENT_METRIC: [ |
| 73 | { enum: '', title: i18n('please select…') }, |
| 74 | { enum: 'Software_Instances_Count', title: 'Software Instances' }, |
| 75 | { enum: 'Core', title: 'Core' }, |
| 76 | { enum: 'CPU', title: 'CPU' }, |
| 77 | { enum: 'Trunks', title: 'Trunks' }, |
| 78 | { enum: 'User', title: 'User' }, |
| 79 | { enum: 'Subscribers', title: 'Subscribers' }, |
| 80 | { enum: 'Tenants', title: 'Tenants' }, |
| 81 | { enum: 'Tokens', title: 'Tokens' }, |
| 82 | { enum: 'Seats', title: 'Seats' }, |
| 83 | { enum: 'Units_TB', title: 'Units-TB' }, |
| 84 | { enum: 'Units_GB', title: 'Units-GB' }, |
| 85 | { enum: 'Units_MB', title: 'Units-MB' } |
| 86 | ] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 89 | export const extractValue = item => { |
| 90 | if (item === undefined) { |
| 91 | return ''; |
| 92 | } //TODO fix it later |
| 93 | return item |
| 94 | ? item.choice === optionInputOther.OTHER |
| 95 | ? item.other |
| 96 | : InputOptions.getTitleByName(optionsInputValues, item.choice) |
| 97 | : ''; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 98 | }; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 99 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 100 | export const extractUnits = units => { |
| 101 | if (units === undefined) { |
| 102 | return ''; |
| 103 | } //TODO fix it later |
| 104 | return units === 'Absolute' ? '' : '%'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 105 | }; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 106 | |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 107 | export const tabIds = { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 108 | GENERAL: 'GENERAL', |
| 109 | SP_LIMITS: 'SP_LIMITS', |
| 110 | VENDOR_LIMITS: 'VENDOR_LIMITS', |
| 111 | ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 112 | }; |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 113 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 114 | export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL'; |