diff options
Diffstat (limited to 'openecomp-ui/src/nfvo-utils')
-rw-r--r-- | openecomp-ui/src/nfvo-utils/Validator.js | 28 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/i18n/en.json | 330 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/i18n/i18n.js | 26 | ||||
-rw-r--r-- | openecomp-ui/src/nfvo-utils/i18n/locale.json | 1 |
4 files changed, 352 insertions, 33 deletions
diff --git a/openecomp-ui/src/nfvo-utils/Validator.js b/openecomp-ui/src/nfvo-utils/Validator.js index 708179e9fb..8fcf24a714 100644 --- a/openecomp-ui/src/nfvo-utils/Validator.js +++ b/openecomp-ui/src/nfvo-utils/Validator.js @@ -21,6 +21,7 @@ class Validator { static get globalValidationFunctions() { return { required: value => value !== '', + requiredChooseOption: value => value !== '', maxLength: (value, length) => ValidatorJS.isLength(value, {max: length}), minLength: (value, length) => ValidatorJS.isLength(value, {min: length}), pattern: (value, pattern) => ValidatorJS.matches(value, pattern), @@ -31,10 +32,10 @@ class Validator { } return ValidatorJS.isNumeric(value); }, - maximum: (value, maxValue) => value <= maxValue, - minimum: (value, minValue) => value >= minValue, - maximumExclusive: (value, maxValue) => value < maxValue, - minimumExclusive: (value, minValue) => value > minValue, + maximum: (value, maxValue) => {return (value === undefined) ? true : (value <= maxValue);}, + minimum: (value, minValue) => {return (value === undefined) ? true : (value >= minValue);}, + maximumExclusive: (value, maxValue) => {return (value === undefined) ? true : (value < maxValue);}, + minimumExclusive: (value, minValue) => {return (value === undefined) ? true : (value > minValue);}, alphanumeric: value => ValidatorJS.isAlphanumeric(value), alphanumericWithSpaces: value => ValidatorJS.isAlphanumeric(value.replace(/ /g, '')), validateName: value => ValidatorJS.isAlphanumeric(value.replace(/\s|\.|\_|\-/g, ''), 'en-US'), @@ -42,24 +43,26 @@ class Validator { freeEnglishText: value => ValidatorJS.isAlphanumeric(value.replace(/\s|\.|\_|\-|\,|\(|\)|\?/g, ''), 'en-US'), email: value => ValidatorJS.isEmail(value), ip: value => ValidatorJS.isIP(value), - url: value => ValidatorJS.isURL(value) + url: value => ValidatorJS.isURL(value), + alphanumericWithUnderscores: value => ValidatorJS.isAlphanumeric(value.replace(/_/g, '')) }; } static get globalValidationMessagingFunctions() { return { required: () => i18n('Field is required'), + requiredChooseOption: () => i18n('Field should have one of these options'), maxLength: (value, maxLength) => i18n('Field value has exceeded it\'s limit, {maxLength}. current length: {length}', { length: value.length, maxLength }), - minLength: (value, minLength) => i18n('Field value should contain at least {minLength} characters.', {minLength}), - pattern: (value, pattern) => i18n('Field value should match the pattern: {pattern}.', {pattern}), + minLength: (value, minLength) => i18n(`Field value should contain at least ${minLength} characters.`), + pattern: (value, pattern) => i18n(`Field value should match the pattern: ${pattern}.`), numeric: () => i18n('Field value should contain numbers only.'), - maximum: (value, maxValue) => i18n('Field value should be less or equal to: {maxValue}.', {maxValue}), - minimum: (value, minValue) => i18n('Field value should be at least: {minValue}.', {minValue: minValue.toString()}), - maximumExclusive: (value, maxValue) => i18n('Field value should be less than: {maxValue}.', {maxValue}), - minimumExclusive: (value, minValue) => i18n('Field value should be more than: {minValue}.', {minValue: minValue.toString()}), + maximum: (value, maxValue) => i18n(`Field value should be less or equal to: ${maxValue}.`), + minimum: (value, minValue) => i18n(`Field value should be at least: ${minValue.toString()}.`), + maximumExclusive: (value, maxValue) => i18n(`Field value should be less than: ${maxValue}.`), + minimumExclusive: (value, minValue) => i18n(`Field value should be more than: ${minValue.toString()}.`), alphanumeric: () => i18n('Field value should contain letters or digits only.'), alphanumericWithSpaces: () => i18n('Field value should contain letters, digits or spaces only.'), validateName: ()=> i18n('Field value should contain English letters, digits , spaces, underscores, dashes and dots only.'), @@ -68,7 +71,8 @@ class Validator { email: () => i18n('Field value should be a valid email address.'), ip: () => i18n('Field value should be a valid ip address.'), url: () => i18n('Field value should be a valid url address.'), - general: () => i18n('Field value is invalid.') + general: () => i18n('Field value is invalid.'), + alphanumericWithUnderscores: () => i18n('Field value should contain letters, digits or _ only.') }; } diff --git a/openecomp-ui/src/nfvo-utils/i18n/en.json b/openecomp-ui/src/nfvo-utils/i18n/en.json new file mode 100644 index 0000000000..8ed638352c --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/i18n/en.json @@ -0,0 +1,330 @@ +{ + "VSP Errors": "VSP Errors", + "Components Errors": "Components Errors", + "Upload Data Errors": "Upload Data Errors", + "Error: Upload Data Error": "Error: Upload Data Error", + "Field is required": "Field is required", + "Field should have one of these options": "Field should have one of these options", + "Field value has exceeded it\\": "Field value has exceeded it\\", + "Field value should contain at least {minLength} characters.": "Field value should contain at least {minLength} characters.", + "Field value should match the pattern: {pattern}.": "Field value should match the pattern: {pattern}.", + "Field value should contain numbers only.": "Field value should contain numbers only.", + "Field value should be less or equal to: {maxValue}.": "Field value should be less or equal to: {maxValue}.", + "Field value should be at least: {minValue}.": "Field value should be at least: {minValue}.", + "Field value should be less than: {maxValue}.": "Field value should be less than: {maxValue}.", + "Field value should be more than: {minValue}.": "Field value should be more than: {minValue}.", + "Field value should contain letters or digits only.": "Field value should contain letters or digits only.", + "Field value should contain letters, digits or spaces only.": "Field value should contain letters, digits or spaces only.", + "Field value should contain English letters, digits , spaces, underscores, dashes and dots only.": "Field value should contain English letters, digits , spaces, underscores, dashes and dots only.", + "Field value should contain English letters digits and spaces only.": "Field value should contain English letters digits and spaces only.", + "Field value should contain English letters, digits , spaces, underscores, dashes and dots only.": "Field value should contain English letters, digits , spaces, underscores, dashes and dots only.", + "Field value should be a valid email address.": "Field value should be a valid email address.", + "Field value should be a valid ip address.": "Field value should be a valid ip address.", + "Field value should be a valid url address.": "Field value should be a valid url address.", + "Field value is invalid.": "Field value is invalid.", + "Field value should contain letters, digits or _ only.": "Field value should contain letters, digits or _ only.", + "Success": "Success", + "Failure": "Failure", + "Activity Log": "Activity Log", + "OK": "OK", + "Cancel": "Cancel", + "Error": "Error", + "This item is checkedin/submitted, Click Check Out to continue": "This item is checkedin/submitted, Click Check Out to continue", + "Name": "Name", + "Description": "Description", + "Add Workflow": "Add Workflow", + "Edit Workflow": "Edit Workflow", + "Create New Workflow": "Create New Workflow", + "Save": "Save", + "Close": "Close", + "Save Failed": "Save Failed", + "Ok": "Ok", + "File Upload Failed": "File Upload Failed", + "License Model": "License Model", + "Software Products": "Software Products", + "Overview": "Overview", + "License Agreements": "License Agreements", + "Feature Groups": "Feature Groups", + "Entitlement Pools": "Entitlement Pools", + "License Key Groups": "License Key Groups", + "General": "General", + "Deployment Flavors": "Deployment Flavors", + "Process Details": "Process Details", + "Networks": "Networks", + "Components Dependencies": "Components Dependencies", + "Attachments": "Attachments", + "Components": "Components", + "Compute": "Compute", + "High Availability & Load Balancing": "High Availability & Load Balancing", + "Storage": "Storage", + "Images": "Images", + "Monitoring": "Monitoring", + "other": "other", + "One or more tabs are invalid": "One or more tabs are invalid", + "Check In": "Check In", + "Check Out": "Check Out", + "Submit": "Submit", + "Revert": "Revert", + "Submit Succeeded": "Submit Succeeded", + "This license model successfully submitted": "This license model successfully submitted", + "VLM": "VLM", + "VSP": "VSP", + "CREATE NEW VLM": "CREATE NEW VLM", + "CREATE NEW VSP": "CREATE NEW VSP", + "New License Model": "New License Model", + "New Software Product": "New Software Product", + "WORKSPACE": "WORKSPACE", + "ONBOARD CATALOG": "ONBOARD CATALOG", + "Component Dependencies": "Component Dependencies", + "This software product successfully submitted": "This software product successfully submitted", + "Submit Failed": "Submit Failed", + "Vendor Name": "Vendor Name", + "License model by the name \\": "License model by the name \\", + "please select…": "please select…", + "Warning": "Warning", + "Operational Scope": "Operational Scope", + "Threshold Units": "Threshold Units", + "Threshold Value": "Threshold Value", + "Entitlement Metric": "Entitlement Metric", + "Aggregate Function": "Aggregate Function", + "Manufacturer Reference Number": "Manufacturer Reference Number", + "Time": "Time", + "Increments": "Increments", + "Entitlement pool by the name \\": "Entitlement pool by the name \\", + "Add Entitlement Pool": "Add Entitlement Pool", + "Edit Entitlement Pool": "Edit Entitlement Pool", + "Create New Entitlement Pool": "Create New Entitlement Pool", + "Entitlement": "Entitlement", + "Are you sure you want to delete \"{poolName}\"?": "Are you sure you want to delete \"{poolName}\"?", + "This entitlement pool is associated with one or more feature groups": "This entitlement pool is associated with one or more feature groups", + "Part Number": "Part Number", + "Available Entitlement Pools": "Available Entitlement Pools", + "Selected Entitlement Pools": "Selected Entitlement Pools", + "There is no available entitlement pools": "There is no available entitlement pools", + "Available License Key Groups": "Available License Key Groups", + "Selected License Key Groups": "Selected License Key Groups", + "There is no available licsense key groups": "There is no available licsense key groups", + "Feature group by the name \\": "Feature group by the name \\", + "Add Feature Group": "Add Feature Group", + "Edit Feature Group": "Edit Feature Group", + "Create New Feature Group": "Create New Feature Group", + "Pools": "Pools", + "License key": "License key", + "Groups": "Groups", + "Are you sure you want to delete \"{name}\"?": "Are you sure you want to delete \"{name}\"?", + "This feature group is associated with one ore more license agreements": "This feature group is associated with one ore more license agreements", + "Available Feature Groups": "Available Feature Groups", + "Selected Feature Groups": "Selected Feature Groups", + "Requirements and Constraints": "Requirements and Constraints", + "License Term": "License Term", + "There is no available feature groups": "There is no available feature groups", + "License Agreement by the name \\": "License Agreement by the name \\", + "Add License Agreement": "Add License Agreement", + "Edit License Agreement": "Edit License Agreement", + "Create New License Agreement": "Create New License Agreement", + "Type": "Type", + "Feature": "Feature", + "License key group by the name \\": "License key group by the name \\", + "Add License Key Group": "Add License Key Group", + "Edit License Key Group": "Edit License Key Group", + "Create New License Key Group": "Create New License Key Group", + "This license key group is associated with one or more feature groups": "This license key group is associated with one or more feature groups", + "VLM List View": "VLM List View", + "Entities not in Use": "Entities not in Use", + "Create New ": "Create New ", + "overview": "overview", + "{name} needs to be updated. Click ‘Checkout & Update’, to proceed.": "{name} needs to be updated. Click ‘Checkout & Update’, to proceed.", + "Please don’t forget to submit afterwards": "Please don’t forget to submit afterwards", + "{name} is locked by user {lockingUser} for self-healing": "{name} is locked by user {lockingUser} for self-healing", + "Checkout & Update": "Checkout & Update", + "ALL": "ALL", + "BY VENDOR": "BY VENDOR", + "Create new VSP": "Create new VSP", + "Recently Edited": "Recently Edited", + "See More": "See More", + "Upload will erase existing data. Do you want to continue?": "Upload will erase existing data. Do you want to continue?", + "Continue": "Continue", + "Upload validation failed": "Upload validation failed", + "Download HEAT": "Download HEAT", + "Go to Overview": "Go to Overview", + "Upload New HEAT": "Upload New HEAT", + "Are you sure you want to delete {name}?": "Are you sure you want to delete {name}?", + "Virtual Function Components": "Virtual Function Components", + "Filter Components": "Filter Components", + "Add Component": "Add Component", + "Create": "Create", + "Vendor": "Vendor", + "Category": "Category", + "please select...": "please select...", + "Software product by the name \\": "Software product by the name \\", + "Onboarding procedure": "Onboarding procedure", + "HEAT file": "HEAT file", + "Manual": "Manual", + "Dependencies": "Dependencies", + "Add Rule": "Add Rule", + "There is a loop between selections": "There is a loop between selections", + "Select VFC...": "Select VFC...", + "Are you sure you want to delete \"{model}\"?": "Are you sure you want to delete \"{model}\"?", + "Add Deployment Flavor": "Add Deployment Flavor", + "Filter Deployment": "Filter Deployment", + "Licenses": "Licenses", + "Licensing Version": "Licensing Version", + "License Agreement": "License Agreement", + "Select...": "Select...", + "Availability": "Availability", + "Use Availability Zones for High Availability": "Use Availability Zones for High Availability", + "Regions": "Regions", + "Storage Data Replication": "Storage Data Replication", + "Storage Replication Size (GB)": "Storage Replication Size (GB)", + "Storage Replication Source": "Storage Replication Source", + "Storage Replication Freq. (min)": "Storage Replication Freq. (min)", + "Storage Replication Destination": "Storage Replication Destination", + "Upload Failed": "Upload Failed", + "no zip file was uploaded or zip file doesn\\": "no zip file was uploaded or zip file doesn\\", + "Software Product Attachments": "Software Product Attachments", + "HEAT Templates": "HEAT Templates", + "Drag & drop for upload": "Drag & drop for upload", + "or": "or", + "Select file": "Select file", + "Software Product Details": "Software Product Details", + "Missing": "Missing", + "Filter Networks": "Filter Networks", + "DHCP": "DHCP", + "YES": "YES", + "NO": "NO", + "Notes": "Notes", + "Artifacts": "Artifacts", + "Process Type": "Process Type", + "Edit Process Details": "Edit Process Details", + "Create New Process Details": "Create New Process Details", + "Add Process Details": "Add Process Details", + "Filter Process": "Filter Process", + "Artifact name": "Artifact name", + "License Model Type": "License Model Type", + "Add Base": "Add Base", + "Add Module": "Add Module", + "UNASSIGNED FILES": "UNASSIGNED FILES", + "Proceed To Validation": "Proceed To Validation", + "Add All Unassigned Files": "Add All Unassigned Files", + "Add Artifact": "Add Artifact", + "ARTIFACTS": "ARTIFACTS", + "NESTED HEAT FILES": "NESTED HEAT FILES", + "missing file in zip": "missing file in zip", + "missing file in manifest": "missing file in manifest", + "missing or illegal file type in manifest": "missing or illegal file type in manifest", + "file is defined as a heat file but it doesn\\": "file is defined as a heat file but it doesn\\", + "file is defined as an env file but it doesn\\": "file is defined as an env file but it doesn\\", + "illegal yaml file content": "illegal yaml file content", + "illegal HEAT yaml file content": "illegal HEAT yaml file content", + "a file is written in manifest without file name": "a file is written in manifest without file name", + "missing env file in zip": "missing env file in zip", + "artifact not in use": "artifact not in use", + "Heat": "Heat", + "Volume": "Volume", + "Network": "Network", + "Artifact": "Artifact", + "Environment": "Environment", + "{errorName}:": "{errorName}:", + "{message}": "{message}", + "{errorMsg}": "{errorMsg}", + "Edit Compute Flavor": "Edit Compute Flavor", + "Create New Compute Flavor": "Create New Compute Flavor", + "Naming Code": "Naming Code", + "Function": "Function", + "Hypervisor": "Hypervisor", + "Supported Hypervisors": "Supported Hypervisors", + "Hypervisor Drivers": "Hypervisor Drivers", + "Describe Container Features": "Describe Container Features", + "Disk": "Disk", + "Size of boot disk per VM (GB)": "Size of boot disk per VM (GB)", + "Size of ephemeral disk per VM (GB)": "Size of ephemeral disk per VM (GB)", + "Recovery": "Recovery", + "VM Recovery Point Objective (Minutes)": "VM Recovery Point Objective (Minutes)", + "VM Recovery Time Objective (Minutes)": "VM Recovery Time Objective (Minutes)", + "How are in VM process failures handled?": "How are in VM process failures handled?", + "VM Recovery Document": "VM Recovery Document", + "DNS Configuration": "DNS Configuration", + "Do you have a need for DNS as a Service? Please describe.": "Do you have a need for DNS as a Service? Please describe.", + "Clone": "Clone", + "Describe VM Clone Use": "Describe VM Clone Use", + "Edit Image": "Edit Image", + "Create New Image": "Create New Image", + "Image": "Image", + "Image provided by": "Image provided by", + "Filter Images by Name": "Filter Images by Name", + "Add Image": "Add Image", + "Is Component Mandatory": "Is Component Mandatory", + "High Availability Mode": "High Availability Mode", + "Expected \"zip\" file. Please check the provided file type.": "Expected \"zip\" file. Please check the provided file type.", + "Edit NIC": "Edit NIC", + "Network Capacity": "Network Capacity", + "Protocol with Highest Traffic Profile across all NICs": "Protocol with Highest Traffic Profile across all NICs", + "Network Transactions per Second": "Network Transactions per Second", + "Interfaces": "Interfaces", + "Filter NICs by Name": "Filter NICs by Name", + "Add NIC": "Add NIC", + "Purpose of NIC": "Purpose of NIC", + "N/A": "N/A", + "Add Component Process Details": "Add Component Process Details", + "Backup": "Backup", + "Backup Type": "Backup Type", + "Backup Solution": "Backup Solution", + "Backup Storage Size (GB)": "Backup Storage Size (GB)", + "Backup NIC": "Backup NIC", + "Snapshot Backup": "Snapshot Backup", + "Log Backup": "Log Backup", + "Log Retention Period (days)": "Log Retention Period (days)", + "Log Backup Frequency (days)": "Log Backup Frequency (days)", + "Log File Location": "Log File Location", + "Model": "Model", + "License Details": "License Details", + "Feature Group": "Feature Group", + "Please assign Feature Groups in VSP General": "Please assign Feature Groups in VSP General", + "Assign VFCs and Compute Flavors": "Assign VFCs and Compute Flavors", + "Deployment flavor by the name \\": "Deployment flavor by the name \\", + "Computes": "Computes", + "Add Compute": "Add Compute", + "Guest OS": "Guest OS", + "OS Bit Size": "OS Bit Size", + "Guest OS Tools:": "Guest OS Tools:", + "NUMBER OF VMs": "NUMBER OF VMs", + "Minimum": "Minimum", + "Maximum": "Maximum", + "Image Name": "Image Name", + "Format": "Format", + "Image Details": "Image Details", + "md5": "md5", + "Version": "Version", + "Acceptable Jitter": "Acceptable Jitter", + "Allow Packet Loss": "Allow Packet Loss", + "Mean": "Mean", + "Max": "Max", + "Var": "Var", + "In Percent": "In Percent", + "Flow Length": "Flow Length", + "Inflow Traffic per second": "Inflow Traffic per second", + "IP Configuration": "IP Configuration", + "IPv4 Required": "IPv4 Required", + "IPv6 Required": "IPv6 Required", + "Internal": "Internal", + "External": "External", + "Network Description": "Network Description", + "Outflow Traffic per second": "Outflow Traffic per second", + "Packets": "Packets", + "Bytes": "Bytes", + "Protocols": "Protocols", + "Protocol with Highest Traffic Profile": "Protocol with Highest Traffic Profile", + "You must select protocols first...": "You must select protocols first...", + "Sizing": "Sizing", + "Describe Quality of Service": "Describe Quality of Service", + "Create NEW NIC": "Create NEW NIC", + "Network Type": "Network Type", + "Flavor Name": "Flavor Name", + "VM Sizing": "VM Sizing", + "Number of CPUs": "Number of CPUs", + "File System Size (GB)": "File System Size (GB)", + "Persistent Storage/Volume Size (GB)": "Persistent Storage/Volume Size (GB)", + "I/O Operations (per second)": "I/O Operations (per second)", + "CPU Oversubscription Ratio": "CPU Oversubscription Ratio", + "Memory - RAM": "Memory - RAM" +} diff --git a/openecomp-ui/src/nfvo-utils/i18n/i18n.js b/openecomp-ui/src/nfvo-utils/i18n/i18n.js index 4d03ddb8dd..2f63dfe605 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/i18n.js +++ b/openecomp-ui/src/nfvo-utils/i18n/i18n.js @@ -14,27 +14,17 @@ * permissions and limitations under the License. */ import IntlObj from 'intl'; -import IntlMessageFormatObj from 'intl-messageformat'; import IntlRelativeFormatObj from 'intl-relativeformat'; import createFormatCacheObj from 'intl-format-cache'; import i18nJson from 'i18nJson'; - /* Intl libs are using out dated transpailer from ecmascript6. * TODO: As soon as they fix it, remove this assignments!!! * */ var Intl = window.Intl || IntlObj.default, - IntlMessageFormat = IntlMessageFormatObj.default, IntlRelativeFormat = IntlRelativeFormatObj.default, createFormatCache = createFormatCacheObj.default; -var i18nData; - -if(i18nJson) { - i18nData = i18nJson.dataWrapperArr[i18nJson.i18nDataIdx]; -} - - /*extract locale*/ var _locale = window.localStorage && localStorage.getItem('user_locale'); if(!_locale) { @@ -53,12 +43,11 @@ if(!_locale) { } var _localeUpper = _locale.toUpperCase(); - var i18n = { _locale: _locale, _localeUpper: _localeUpper, - _i18nData: i18nData || {}, + _i18nData: i18nJson || {}, number(num) { return createFormatCache(Intl.NumberFormat)(this._locale).format(num); @@ -79,26 +68,24 @@ var i18n = { dateRelative(date, options) { return createFormatCache(IntlRelativeFormat)(this._locale, options).format(date); }, - - message(messageId, options) { - return createFormatCache(IntlMessageFormat)(this._i18nData[messageId] || String(messageId), this._locale).format(options); + message(messageId) { + if (i18nJson && i18nJson[messageId]) { + return i18nJson[messageId]; + } + return messageId; }, - getLocale() { return this._locale; }, - getLocaleUpper() { return this._localeUpper; }, - setLocale(locale) { localStorage.setItem('user_locale', locale); window.location.reload(); } }; - function i18nWrapper() { return i18nWrapper.message.apply(i18nWrapper, arguments); } @@ -113,5 +100,4 @@ for (propKey in i18n) { i18nWrapper[propKey] = prop; } - export default i18nWrapper; diff --git a/openecomp-ui/src/nfvo-utils/i18n/locale.json b/openecomp-ui/src/nfvo-utils/i18n/locale.json deleted file mode 100644 index d9047ba582..0000000000 --- a/openecomp-ui/src/nfvo-utils/i18n/locale.json +++ /dev/null @@ -1 +0,0 @@ -{"dataWrapperArr":["I18N_IDENTIFIER_START",{},"I18N_IDENTIFIER_END"],"i18nDataIdx":1}
\ No newline at end of file |