You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2019/03/29 06:17:19 UTC

[ignite] branch master updated: IGNITE-11259 Web Console: Added missing "enumValues" to binary configuration.

This is an automated email from the ASF dual-hosted git repository.

akuznetsov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 01c45aa  IGNITE-11259 Web Console: Added missing "enumValues" to binary configuration.
01c45aa is described below

commit 01c45aad5b19c29e810eb6373d53019d1f7d220d
Author: Vasiliy Sisko <vs...@gridgain.com>
AuthorDate: Fri Mar 29 13:17:02 2019 +0700

    IGNITE-11259 Web Console: Added missing "enumValues" to binary configuration.
---
 modules/web-console/backend/app/schemas.js         |  3 ++-
 .../cluster-edit-form/templates/binary.pug         | 26 ++++++++++++++++++++++
 .../generator/generator/ConfigurationGenerator.js  |  4 +++-
 .../generator/defaults/Cluster.service.js          |  7 +++++-
 .../frontend/app/configuration/mixins.pug          | 18 +++++++++++++++
 .../WebConsoleConfigurationSelfTest.java           |  1 +
 6 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/modules/web-console/backend/app/schemas.js b/modules/web-console/backend/app/schemas.js
index 808bfd4..10c294f 100644
--- a/modules/web-console/backend/app/schemas.js
+++ b/modules/web-console/backend/app/schemas.js
@@ -590,7 +590,8 @@ module.exports.factory = function(mongoose) {
                 idMapper: String,
                 nameMapper: String,
                 serializer: String,
-                enum: Boolean
+                enum: Boolean,
+                enumValues: [String]
             }],
             compactFooter: Boolean
         },
diff --git a/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/binary.pug b/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/binary.pug
index aa74620..07b02a6 100644
--- a/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/binary.pug
+++ b/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/binary.pug
@@ -105,6 +105,32 @@ panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`)
                                     name: 'enum',
                                     tip: 'Flag indicating that this type is the enum'
                                 })
+                            .pc-form-grid-col-60(ng-if='$item.enum')
+                                mixin enum-values
+                                    .ignite-form-field
+                                        -let items = '$item.enumValues'
+
+                                        list-editable(
+                                            ng-model=items
+                                            name='enumValues'
+                                            list-editable-cols=`::[{name: "Enum values:"}]`
+                                        )
+                                            list-editable-item-view {{ $item }}
+
+                                            list-editable-item-edit
+                                                +list-java-identifier-field('Value', '$item', '"value"', 'Enter Enum value', '$item.$item.enumValues')
+                                                    +form-field__error({error: 'igniteUnique', message: 'Value already configured!'})
+
+                                            list-editable-no-items
+                                                list-editable-add-item-button(
+                                                    add-item=`$editLast((${items} = ${items} || []).push(''))`
+                                                    label-single='enum value'
+                                                    label-multiple='enum values'
+                                                )
+
+                                - var form = '$parent.$parent.form'
+                                +enum-values
+                                - var form = '$parent.form'
 
                         list-editable-no-items
                             list-editable-add-item-button(
diff --git a/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js
index b330f6e..358a453 100644
--- a/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js
+++ b/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js
@@ -27,6 +27,7 @@ import IgniteIGFSDefaults from './defaults/IGFS.service';
 import JavaTypes from '../../../services/JavaTypes.service';
 import VersionService from 'app/services/Version.service';
 
+import _ from 'lodash';
 import isNil from 'lodash/isNil';
 import {nonNil, nonEmpty} from 'app/utils/lodashMixins';
 
@@ -469,7 +470,8 @@ export default class IgniteConfigurationGenerator {
                 .emptyBeanProperty('idMapper')
                 .emptyBeanProperty('nameMapper')
                 .emptyBeanProperty('serializer')
-                .intProperty('enum');
+                .boolProperty('enum')
+                .mapProperty('enumValues', _.map(type.enumValues, (v, idx) => ({name: v, value: idx})), 'enumValues');
 
             if (typeCfg.nonEmpty())
                 typeCfgs.push(typeCfg);
diff --git a/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js b/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js
index 8e82403..0457bc9 100644
--- a/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js
+++ b/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js
@@ -96,7 +96,12 @@ const DFLT_CLUSTER = {
     binary: {
         compactFooter: true,
         typeConfigurations: {
-            enum: false
+            enum: false,
+            enumValues: {
+                keyClsName: 'java.lang.String',
+                valClsName: 'java.lang.Integer',
+                entries: []
+            }
         }
     },
     collision: {
diff --git a/modules/web-console/frontend/app/configuration/mixins.pug b/modules/web-console/frontend/app/configuration/mixins.pug
index 75c96aa..92b4d39 100644
--- a/modules/web-console/frontend/app/configuration/mixins.pug
+++ b/modules/web-console/frontend/app/configuration/mixins.pug
@@ -209,6 +209,24 @@ mixin list-java-class-field(label, model, name, items)
         if block
             block
 
+mixin list-java-identifier-field(label, model, name, placeholder, items)
+    +form-field__text({
+        label,
+        model,
+        name,
+        required: true,
+        placeholder
+    })(
+        java-identifier='true'
+
+        ignite-unique=items
+        ignite-form-field-input-autofocus='true'
+    )
+        +form-field__error({ error: 'javaIdentifier', message: `${ label } is invalid Java identifier!` })
+
+        if block
+            block
+
 mixin list-url-field(label, model, name, items)
     +form-field__text({
         label,
diff --git a/modules/web-console/src/test/java/org/apache/ignite/console/configuration/WebConsoleConfigurationSelfTest.java b/modules/web-console/src/test/java/org/apache/ignite/console/configuration/WebConsoleConfigurationSelfTest.java
index cb8d5d7..c15b4c7 100644
--- a/modules/web-console/src/test/java/org/apache/ignite/console/configuration/WebConsoleConfigurationSelfTest.java
+++ b/modules/web-console/src/test/java/org/apache/ignite/console/configuration/WebConsoleConfigurationSelfTest.java
@@ -230,6 +230,7 @@ public class WebConsoleConfigurationSelfTest {
         binaryTypeCfgProps.add("nameMapper");
         binaryTypeCfgProps.add("serializer");
         binaryTypeCfgProps.add("enum");
+        binaryTypeCfgProps.add("enumValues");
         metadata.put(BinaryTypeConfiguration.class, new MetadataInfo(binaryTypeCfgProps, EMPTY_FIELDS, EMPTY_FIELDS));
 
         Set<String> sharedFsCheckpointProps = new HashSet<>();