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