Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 1363b0b95 -> bf7c7b266


IGNITE-843: WIP on link cluster an caches.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bf7c7b26
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bf7c7b26
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bf7c7b26

Branch: refs/heads/ignite-843
Commit: bf7c7b2660cee930d8a27fefdd403c1988291c02
Parents: 1363b0b
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Mon Aug 17 18:23:50 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Mon Aug 17 18:23:50 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    |   1 +
 .../src/main/js/controllers/models/caches.json  |   4 +-
 .../main/js/controllers/models/clusters.json    | 560 ++++++++++---------
 modules/control-center-web/src/main/js/db.js    |   1 +
 .../src/main/js/routes/caches.js                | 145 +++--
 .../src/main/js/routes/clusters.js              |  12 +-
 .../src/main/js/views/configuration/caches.jade |   4 +-
 .../main/js/views/configuration/clusters.jade   |   2 +-
 .../src/main/js/views/includes/controls.jade    |  14 +-
 9 files changed, 383 insertions(+), 360 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git 
a/modules/control-center-web/src/main/js/controllers/caches-controller.js 
b/modules/control-center-web/src/main/js/controllers/caches-controller.js
index 96b81f2..38a32ea 100644
--- a/modules/control-center-web/src/main/js/controllers/caches-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js
@@ -178,6 +178,7 @@ controlCenterModule.controller('cachesController', [
                 .success(function (data) {
                     $scope.spaces = data.spaces;
                     $scope.caches = data.caches;
+                    $scope.clusters = data.clusters;
 
                     _.forEach(data.metadatas, function (meta) {
                         var kind = meta.kind;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/controllers/models/caches.json
----------------------------------------------------------------------
diff --git 
a/modules/control-center-web/src/main/js/controllers/models/caches.json 
b/modules/control-center-web/src/main/js/controllers/models/caches.json
index 5046fd7..1b2ab4b 100644
--- a/modules/control-center-web/src/main/js/controllers/models/caches.json
+++ b/modules/control-center-web/src/main/js/controllers/models/caches.json
@@ -28,7 +28,7 @@
           "model": "name",
           "required": true,
           "placeholder": "Input name",
-          "id": "defaultFocusId"
+          "id": "cacheName"
         },
         {
           "label": "Clusters",
@@ -391,6 +391,7 @@
     },
     {
       "label": "Store",
+      "id": "store-data",
       "tip": [
         "Cache store settings."
       ],
@@ -584,6 +585,7 @@
         },
         {
           "label": "Read-through",
+          "id": "readThrough",
           "type": "check",
           "model": "readThrough",
           "tip": [

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/controllers/models/clusters.json
----------------------------------------------------------------------
diff --git 
a/modules/control-center-web/src/main/js/controllers/models/clusters.json 
b/modules/control-center-web/src/main/js/controllers/models/clusters.json
index 1c5afd5..a8884d2 100644
--- a/modules/control-center-web/src/main/js/controllers/models/clusters.json
+++ b/modules/control-center-web/src/main/js/controllers/models/clusters.json
@@ -24,300 +24,306 @@
   ],
   "general": [
     {
-      "label": "Name",
-      "type": "text",
-      "model": "name",
-      "required": true,
-      "placeholder": "Input name",
-      "id": "clusterName"
-    },
-    {
-      "label": "Caches",
-      "type": "dropdown-multiple",
-      "model": "caches",
-      "placeholder": "Choose caches",
-      "items": "caches",
-      "tip": [
-        "Select caches to start in cluster or add a new cache."
-      ],
-      "addLink": {
-        "label": "Add cache(s)",
-        "ref": "/configuration/caches"
-      }
-    },
-    {
-      "label": "Discovery",
-      "type": "dropdown-details",
-      "settings": false,
-      "path": "discovery",
-      "model": "kind",
-      "items": "discoveries",
-      "tip": [
-        "Discovery allows to discover remote nodes in grid."
-      ],
-      "details": {
-        "Vm": {
-          "fields": [
-            {
-              "label": "Addresses",
-              "type": "table-simple",
-              "path": "discovery.Vm",
-              "model": "addresses",
-              "reordering": true,
-              "ipaddress": true,
-              "placeholder": "IP address:port",
-              "focusId": "IpAddress",
-              "addTip": "Add new address.",
-              "removeTip": "Remove address.",
-              "tableTip": [
-                "Addresses may be represented as follows:",
-                "<ul>",
-                "  <li>IP address (e.g. 127.0.0.1, 9.9.9.9, etc);</li>",
-                "  <li>IP address and port (e.g. 127.0.0.1:47500, 
9.9.9.9:47501, etc);</li>",
-                "  <li>IP address and port range (e.g. 127.0.0.1:47500..47510, 
9.9.9.9:47501..47504, etc);</li>",
-                "  <li>Hostname (e.g. host1.com, host2, etc);</li>",
-                "  <li>Hostname and port (e.g. host1.com:47500, host2:47502, 
etc).</li>",
-                "  <li>Hostname and port range (e.g. host1.com:47500..47510, 
host2:47502..47508, etc).</li>",
-                "</ul>",
-                "If port is 0 or not provided then default port will be used 
(depends on discovery SPI configuration).",
-                "If port range is provided (e.g. host:port1..port2) the 
following should be considered:",
-                "<ul>",
-                "  <li>port1 < port2 should be true;</li>",
-                "  <li>Both port1 and port2 should be greater than 0.</li>",
-                "</ul>"
-              ]
-            }
-          ]
-        },
-        "Multicast": {
-          "fields": [
-            {
-              "label": "IP address",
-              "type": "text",
-              "path": "discovery.Multicast",
-              "model": "multicastGroup",
-              "placeholder": "228.1.2.4",
-              "tip": [
-                "IP address of multicast group."
-              ]
-            },
-            {
-              "label": "Port number",
-              "type": "number",
-              "path": "discovery.Multicast",
-              "model": "multicastPort",
-              "max": 65535,
-              "placeholder": 47400,
-              "tip": [
-                "Port number which multicast messages are sent to."
-              ]
-            },
-            {
-              "label": "Waits for reply",
-              "type": "number",
-              "path": "discovery.Multicast",
-              "model": "responseWaitTime",
-              "placeholder": 500,
-              "tip": [
-                "Time in milliseconds IP finder waits for reply to multicast 
address request."
-              ]
-            },
-            {
-              "label": "Attempts count",
-              "type": "number",
-              "path": "discovery.Multicast",
-              "model": "addressRequestAttempts",
-              "placeholder": 2,
-              "tip": [
-                "Number of attempts to send multicast address request.",
-                "IP finder re-sends request only in case if no reply for 
previous request is received."
-              ]
-            },
-            {
-              "label": "Local address",
-              "type": "text",
-              "path": "discovery.Multicast",
-              "model": "localAddress",
-              "tip": [
-                "Local host address used by this IP finder.",
-                "If provided address is non-loopback then multicast socket is 
bound to this interface.",
-                "If local address is not set or is any local address then IP 
finder creates multicast sockets for all found non-loopback addresses."
-              ]
-            }
-          ]
+      "label": "General",
+      "id": "general-data",
+      "fields": [
+        {
+          "label": "Name",
+          "type": "text",
+          "model": "name",
+          "required": true,
+          "placeholder": "Input name",
+          "id": "clusterName"
         },
-        "S3": {
-          "fields": [
-            {
-              "label": "Bucket name",
-              "type": "text",
-              "required": true,
-              "path": "discovery.S3",
-              "model": "bucketName",
-              "tip": [
-                "Bucket name for IP finder."
-              ]
-            },
-            {
-              "label": "Note, AWS credentials will be generated as stubs.",
-              "type": "label"
-            }
-          ]
+        {
+          "label": "Caches",
+          "type": "dropdown-multiple",
+          "model": "caches",
+          "placeholder": "Choose caches",
+          "items": "caches",
+          "tip": [
+            "Select caches to start in cluster or add a new cache."
+          ],
+          "addLink": {
+            "label": "Add cache(s)",
+            "ref": "/configuration/caches"
+          }
         },
-        "Cloud": {
-          "fields": [
-            {
-              "label": "Credential",
-              "type": "text",
-              "path": "discovery.Cloud",
-              "model": "credential",
-              "tip": [
-                "Credential that is used during authentication on the cloud.",
-                "Depending on a cloud platform it can be a password or access 
key."
-              ]
-            },
-            {
-              "label": "Path to credential",
-              "type": "text",
-              "path": "discovery.Cloud",
-              "model": "credentialPath",
-              "tip": [
-                "Path to a credential that is used during authentication on 
the cloud.",
-                "Access key or private key should be stored in a plain or PEM 
file without a passphrase."
-              ]
-            },
-            {
-              "label": "Identity",
-              "type": "text",
-              "required": true,
-              "path": "discovery.Cloud",
-              "model": "identity",
-              "tip": [
-                "Identity that is used as a user name during a connection to 
the cloud.",
-                "Depending on a cloud platform it can be an email address, 
user name, etc."
+        {
+          "label": "Discovery",
+          "type": "dropdown-details",
+          "settings": false,
+          "path": "discovery",
+          "model": "kind",
+          "items": "discoveries",
+          "tip": [
+            "Discovery allows to discover remote nodes in grid."
+          ],
+          "details": {
+            "Vm": {
+              "fields": [
+                {
+                  "label": "Addresses",
+                  "type": "table-simple",
+                  "path": "discovery.Vm",
+                  "model": "addresses",
+                  "reordering": true,
+                  "ipaddress": true,
+                  "placeholder": "IP address:port",
+                  "focusId": "IpAddress",
+                  "addTip": "Add new address.",
+                  "removeTip": "Remove address.",
+                  "tableTip": [
+                    "Addresses may be represented as follows:",
+                    "<ul>",
+                    "  <li>IP address (e.g. 127.0.0.1, 9.9.9.9, etc);</li>",
+                    "  <li>IP address and port (e.g. 127.0.0.1:47500, 
9.9.9.9:47501, etc);</li>",
+                    "  <li>IP address and port range (e.g. 
127.0.0.1:47500..47510, 9.9.9.9:47501..47504, etc);</li>",
+                    "  <li>Hostname (e.g. host1.com, host2, etc);</li>",
+                    "  <li>Hostname and port (e.g. host1.com:47500, 
host2:47502, etc).</li>",
+                    "  <li>Hostname and port range (e.g. 
host1.com:47500..47510, host2:47502..47508, etc).</li>",
+                    "</ul>",
+                    "If port is 0 or not provided then default port will be 
used (depends on discovery SPI configuration).",
+                    "If port range is provided (e.g. host:port1..port2) the 
following should be considered:",
+                    "<ul>",
+                    "  <li>port1 < port2 should be true;</li>",
+                    "  <li>Both port1 and port2 should be greater than 
0.</li>",
+                    "</ul>"
+                  ]
+                }
               ]
             },
-            {
-              "label": "Provider",
-              "type": "text",
-              "required": true,
-              "path": "discovery.Cloud",
-              "model": "provider",
-              "tip": [
-                "Cloud provider to use."
+            "Multicast": {
+              "fields": [
+                {
+                  "label": "IP address",
+                  "type": "text",
+                  "path": "discovery.Multicast",
+                  "model": "multicastGroup",
+                  "placeholder": "228.1.2.4",
+                  "tip": [
+                    "IP address of multicast group."
+                  ]
+                },
+                {
+                  "label": "Port number",
+                  "type": "number",
+                  "path": "discovery.Multicast",
+                  "model": "multicastPort",
+                  "max": 65535,
+                  "placeholder": 47400,
+                  "tip": [
+                    "Port number which multicast messages are sent to."
+                  ]
+                },
+                {
+                  "label": "Waits for reply",
+                  "type": "number",
+                  "path": "discovery.Multicast",
+                  "model": "responseWaitTime",
+                  "placeholder": 500,
+                  "tip": [
+                    "Time in milliseconds IP finder waits for reply to 
multicast address request."
+                  ]
+                },
+                {
+                  "label": "Attempts count",
+                  "type": "number",
+                  "path": "discovery.Multicast",
+                  "model": "addressRequestAttempts",
+                  "placeholder": 2,
+                  "tip": [
+                    "Number of attempts to send multicast address request.",
+                    "IP finder re-sends request only in case if no reply for 
previous request is received."
+                  ]
+                },
+                {
+                  "label": "Local address",
+                  "type": "text",
+                  "path": "discovery.Multicast",
+                  "model": "localAddress",
+                  "tip": [
+                    "Local host address used by this IP finder.",
+                    "If provided address is non-loopback then multicast socket 
is bound to this interface.",
+                    "If local address is not set or is any local address then 
IP finder creates multicast sockets for all found non-loopback addresses."
+                  ]
+                }
               ]
             },
-            {
-              "label": "Regions",
-              "type": "table-simple",
-              "path": "discovery.Cloud",
-              "model": "regions",
-              "placeholder": "Region name",
-              "focusId": "Region",
-              "addTip": "Add new region.",
-              "removeTip": "Remove region.",
-              "tableTip": [
-                "List of regions where VMs are located.",
-                "If the regions are not set then every region, that a cloud 
provider has, will be investigated. This could lead to significant performance 
degradation.",
-                "Note, that some cloud providers, like Google Compute Engine, 
doesn't have a notion of a region. For such providers regions are redundant."
-              ],
-              "tip": [
-                "Region where VMs are located."
+            "S3": {
+              "fields": [
+                {
+                  "label": "Bucket name",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.S3",
+                  "model": "bucketName",
+                  "tip": [
+                    "Bucket name for IP finder."
+                  ]
+                },
+                {
+                  "label": "Note, AWS credentials will be generated as stubs.",
+                  "type": "label"
+                }
               ]
             },
-            {
-              "label": "Zones",
-              "ui": "table-simple",
-              "type": "table-simple",
-              "path": "discovery.Cloud",
-              "model": "zones",
-              "placeholder": "Zone name",
-              "focusId": "Zone",
-              "addTip": "Add new zone.",
-              "removeTip": "Remove zone.",
-              "tableTip": [
-                "List of zones where VMs are located.",
-                "If the zones are not set then every zone from specified 
regions, will be taken into account.",
-                "Note, that some cloud providers, like Rackspace, doesn't have 
a notion of a zone. For such providers zones are redundant."
-              ],
-              "tip": [
-                "Zone where VMs are located."
-              ]
-            }
-          ]
-        },
-        "GoogleStorage": {
-          "fields": [
-            {
-              "label": "Project name",
-              "type": "text",
-              "required": true,
-              "path": "discovery.GoogleStorage",
-              "model": "projectName",
-              "tip": [
-                "Google Cloud Platforms project name.",
-                "Usually this is an auto generated project number (ex. 
208709979073) that can be found in 'Overview' section of Google Developer 
Console."
+            "Cloud": {
+              "fields": [
+                {
+                  "label": "Credential",
+                  "type": "text",
+                  "path": "discovery.Cloud",
+                  "model": "credential",
+                  "tip": [
+                    "Credential that is used during authentication on the 
cloud.",
+                    "Depending on a cloud platform it can be a password or 
access key."
+                  ]
+                },
+                {
+                  "label": "Path to credential",
+                  "type": "text",
+                  "path": "discovery.Cloud",
+                  "model": "credentialPath",
+                  "tip": [
+                    "Path to a credential that is used during authentication 
on the cloud.",
+                    "Access key or private key should be stored in a plain or 
PEM file without a passphrase."
+                  ]
+                },
+                {
+                  "label": "Identity",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.Cloud",
+                  "model": "identity",
+                  "tip": [
+                    "Identity that is used as a user name during a connection 
to the cloud.",
+                    "Depending on a cloud platform it can be an email address, 
user name, etc."
+                  ]
+                },
+                {
+                  "label": "Provider",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.Cloud",
+                  "model": "provider",
+                  "tip": [
+                    "Cloud provider to use."
+                  ]
+                },
+                {
+                  "label": "Regions",
+                  "type": "table-simple",
+                  "path": "discovery.Cloud",
+                  "model": "regions",
+                  "placeholder": "Region name",
+                  "focusId": "Region",
+                  "addTip": "Add new region.",
+                  "removeTip": "Remove region.",
+                  "tableTip": [
+                    "List of regions where VMs are located.",
+                    "If the regions are not set then every region, that a 
cloud provider has, will be investigated. This could lead to significant 
performance degradation.",
+                    "Note, that some cloud providers, like Google Compute 
Engine, doesn't have a notion of a region. For such providers regions are 
redundant."
+                  ],
+                  "tip": [
+                    "Region where VMs are located."
+                  ]
+                },
+                {
+                  "label": "Zones",
+                  "ui": "table-simple",
+                  "type": "table-simple",
+                  "path": "discovery.Cloud",
+                  "model": "zones",
+                  "placeholder": "Zone name",
+                  "focusId": "Zone",
+                  "addTip": "Add new zone.",
+                  "removeTip": "Remove zone.",
+                  "tableTip": [
+                    "List of zones where VMs are located.",
+                    "If the zones are not set then every zone from specified 
regions, will be taken into account.",
+                    "Note, that some cloud providers, like Rackspace, doesn't 
have a notion of a zone. For such providers zones are redundant."
+                  ],
+                  "tip": [
+                    "Zone where VMs are located."
+                  ]
+                }
               ]
             },
-            {
-              "label": "Bucket name",
-              "type": "text",
-              "required": true,
-              "path": "discovery.GoogleStorage",
-              "model": "bucketName",
-              "tip": [
-                "Google Cloud Storage bucket name.",
-                "If the bucket doesn't exist Ignite will automatically create 
it.",
-                "However the name must be unique across whole Google Cloud 
Storage and Service Account Id must be authorized to perform this operation."
+            "GoogleStorage": {
+              "fields": [
+                {
+                  "label": "Project name",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.GoogleStorage",
+                  "model": "projectName",
+                  "tip": [
+                    "Google Cloud Platforms project name.",
+                    "Usually this is an auto generated project number (ex. 
208709979073) that can be found in 'Overview' section of Google Developer 
Console."
+                  ]
+                },
+                {
+                  "label": "Bucket name",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.GoogleStorage",
+                  "model": "bucketName",
+                  "tip": [
+                    "Google Cloud Storage bucket name.",
+                    "If the bucket doesn't exist Ignite will automatically 
create it.",
+                    "However the name must be unique across whole Google Cloud 
Storage and Service Account Id must be authorized to perform this operation."
+                  ]
+                },
+                {
+                  "label": "Private key path",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.GoogleStorage",
+                  "model": "serviceAccountP12FilePath",
+                  "tip": [
+                    "Full path to the private key in PKCS12 format of the 
Service Account."
+                  ]
+                },
+                {
+                  "label": "Account id",
+                  "type": "text",
+                  "required": true,
+                  "path": "discovery.GoogleStorage",
+                  "model": "serviceAccountId",
+                  "tip": [
+                    "Service account ID (typically an e-mail address)."
+                  ]
+                }
               ]
             },
-            {
-              "label": "Private key path",
-              "type": "text",
-              "required": true,
-              "path": "discovery.GoogleStorage",
-              "model": "serviceAccountP12FilePath",
-              "tip": [
-                "Full path to the private key in PKCS12 format of the Service 
Account."
+            "Jdbc": {
+              "fields": [
+                {
+                  "label": "DB schema should be initialized by Ignite",
+                  "type": "check",
+                  "path": "discovery.Jdbc",
+                  "model": "initSchema",
+                  "tip": [
+                    "Flag indicating whether DB schema should be initialized 
by Ignite or was explicitly created by user."
+                  ]
+                }
               ]
             },
-            {
-              "label": "Account id",
-              "type": "text",
-              "required": true,
-              "path": "discovery.GoogleStorage",
-              "model": "serviceAccountId",
-              "tip": [
-                "Service account ID (typically an e-mail address)."
-              ]
-            }
-          ]
-        },
-        "Jdbc": {
-          "fields": [
-            {
-              "label": "DB schema should be initialized by Ignite",
-              "type": "check",
-              "path": "discovery.Jdbc",
-              "model": "initSchema",
-              "tip": [
-                "Flag indicating whether DB schema should be initialized by 
Ignite or was explicitly created by user."
+            "SharedFs": {
+              "fields": [
+                {
+                  "label": "File path",
+                  "type": "text",
+                  "path": "discovery.SharedFs",
+                  "model": "path",
+                  "placeholder": "disco/tcp"
+                }
               ]
             }
-          ]
-        },
-        "SharedFs": {
-          "fields": [
-            {
-              "label": "File path",
-              "type": "text",
-              "path": "discovery.SharedFs",
-              "model": "path",
-              "placeholder": "disco/tcp"
-            }
-          ]
+          }
         }
-      }
+      ]
     }
   ],
   "advanced": [

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/db.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/db.js 
b/modules/control-center-web/src/main/js/db.js
index 431eccc..bcd7331 100644
--- a/modules/control-center-web/src/main/js/db.js
+++ b/modules/control-center-web/src/main/js/db.js
@@ -87,6 +87,7 @@ exports.CacheTypeMetadata = 
mongoose.model('CacheTypeMetadata', CacheTypeMetadat
 var CacheSchema = new Schema({
     space: {type: ObjectId, ref: 'Space'},
     name: String,
+    clusters: [{type: ObjectId, ref: 'Cluster'}],
     mode: {type: String, enum: ['PARTITIONED', 'REPLICATED', 'LOCAL']},
     atomicityMode: {type: String, enum: ['ATOMIC', 'TRANSACTIONAL']},
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/caches.js 
b/modules/control-center-web/src/main/js/routes/caches.js
index 875f84e..35a82e2 100644
--- a/modules/control-center-web/src/main/js/routes/caches.js
+++ b/modules/control-center-web/src/main/js/routes/caches.js
@@ -24,6 +24,16 @@ router.get('/', function (req, res) {
     res.render('configuration/caches');
 });
 
+function _processed(err, res) {
+    if (err) {
+        res.status(500).send(err.message);
+
+        return false;
+    }
+
+    return true;
+}
+
 /**
  * Get spaces and caches accessed for user account.
  *
@@ -35,45 +45,51 @@ router.post('/list', function (req, res) {
 
     // Get owned space and all accessed space.
     db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: 
user_id}}}]}, function (err, spaces) {
-        if (err)
-            return res.status(500).send(err.message);
-
-        var space_ids = spaces.map(function (value) {
-            return value._id;
-        });
-
-        // Get all caches type metadata for spaces.
-        db.CacheTypeMetadata.find({space: {$in: space_ids}}, '_id name kind', 
function (err, metadatas) {
-            if (err)
-                return res.status(500).send(err);
-
-            // Get all caches for spaces.
-            db.Cache.find({space: {$in: 
space_ids}}).sort('name').exec(function (err, caches) {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                // Remove deleted metadata.
-                _.forEach(caches, function (cache) {
-                    cache.queryMetadata = _.filter(cache.queryMetadata, 
function (metaId) {
-                        return _.findIndex(metadatas, function (meta) {
-                            return meta._id.equals(metaId);
-                        }) >= 0;
-                    });
+        if (_processed(err, res)) {
+            var space_ids = spaces.map(function (value) {
+                return value._id;
+            });
 
-                    cache.storeMetadata = _.filter(cache.storeMetadata, 
function (metaId) {
-                        return _.findIndex(metadatas, function (meta) {
-                            return meta._id.equals(metaId);
-                        }) >= 0;
+            // Get all clusters for spaces.
+            db.Cluster.find({space: {$in: space_ids}}, '_id name', function 
(err, clusters) {
+                if (_processed(err, res)) {
+                    // Get all caches type metadata for spaces.
+                    db.CacheTypeMetadata.find({space: {$in: space_ids}}, '_id 
name kind', function (err, metadatas) {
+                        if (_processed(err, res)) {
+                            // Get all caches for spaces.
+                            db.Cache.find({space: {$in: 
space_ids}}).sort('name').exec(function (err, caches) {
+                                if (_processed(err, res)) {
+                                    // Remove deleted metadata.
+                                    _.forEach(caches, function (cache) {
+                                        cache.queryMetadata = 
_.filter(cache.queryMetadata, function (metaId) {
+                                            return _.findIndex(metadatas, 
function (meta) {
+                                                    return 
meta._id.equals(metaId);
+                                                }) >= 0;
+                                        });
+
+                                        cache.storeMetadata = 
_.filter(cache.storeMetadata, function (metaId) {
+                                            return _.findIndex(metadatas, 
function (meta) {
+                                                    return 
meta._id.equals(metaId);
+                                                }) >= 0;
+                                        });
+                                    });
+
+                                    res.json({
+                                        spaces: spaces,
+                                        clusters: 
clusters.map(function(cluster) {
+                                            return {value: cluster._id, label: 
cluster.name};
+                                        }),
+                                        metadatas: metadatas.map(function 
(meta) {
+                                            return {value: meta._id, label: 
meta.name, kind: meta.kind};
+                                        }),
+                                        caches: caches});
+                                }
+                            });
+                        }
                     });
-                });
-
-                var metadatasJson = metadatas.map(function (meta) {
-                    return {value: meta._id, label: meta.name, kind: 
meta.kind};
-                });
-
-                res.json({spaces: spaces, metadatas: metadatasJson, caches: 
caches});
+                }
             });
-        });
+        }
     });
 });
 
@@ -81,29 +97,38 @@ router.post('/list', function (req, res) {
  * Save cache.
  */
 router.post('/save', function (req, res) {
-    if (req.body._id)
-        db.Cache.update({_id: req.body._id}, req.body, {upsert: true}, 
function (err) {
-            if (err)
-                return res.status(500).send(err.message);
-
-            res.send(req.body._id);
+    var params = req.body;
+    var cacheId = params._id;
+
+    if (params._id)
+        db.Cache.update({_id: cacheId}, params, {upsert: true}, function (err, 
cache) {
+            if (_processed(err, res)) {
+                //_.forEach(params.clusters, function (cluster) {
+                //    db.Cluster.findOne({_id: cluster}, function (err, 
cluster) {
+                //        if (_processed(err, res))
+                //            cluster.caches.push(cacheId);
+                //
+                //            db.Cluster.update({_id: params._id}, cluster, 
{upsert: true}, function(err) {
+                //                _processed(err, res);
+                //            });
+                //    });
+                //});
+
+                res.send(params._id);
+            }
         });
-    else {
-        db.Cache.findOne({space: req.body.space, name: req.body.name}, 
function (err, cache) {
-            if (err)
-                return res.status(500).send(err.message);
-
-            if (cache)
-                return res.status(500).send('Cache with name: "' + cache.name 
+ '" already exist.');
-
-            (new db.Cache(req.body)).save(function (err, cache) {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                res.send(cache._id);
-            });
+    else
+        db.Cache.findOne({space: params.space, name: params.name}, function 
(err, cache) {
+            if (_processed(err, res)) {
+                if (cache)
+                    return res.status(500).send('Cache with name: "' + 
cache.name + '" already exist.');
+
+                (new db.Cache(params)).save(function (err, cache) {
+                    if (_processed(er, res))
+                        res.send(cache._id);
+                });
+            }
         });
-    }
 });
 
 /**
@@ -111,10 +136,8 @@ router.post('/save', function (req, res) {
  */
 router.post('/remove', function (req, res) {
     db.Cache.remove(req.body, function (err) {
-        if (err)
-            return res.status(500).send(err.message);
-
-        res.sendStatus(200);
+        if (_processed(err, res))
+            res.sendStatus(200);
     })
 });
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/clusters.js 
b/modules/control-center-web/src/main/js/routes/clusters.js
index 5feb185..0bf6061 100644
--- a/modules/control-center-web/src/main/js/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/routes/clusters.js
@@ -74,22 +74,24 @@ router.post('/list', function (req, res) {
  * Save cluster.
  */
 router.post('/save', function (req, res) {
-    if (req.body._id)
-        db.Cluster.update({_id: req.body._id}, req.body, {upsert: true}, 
function (err) {
+    var params = req.body;
+
+    if (params._id)
+        db.Cluster.update({_id: params._id}, params, {upsert: true}, function 
(err) {
             if (err)
                 return res.status(500).send(err.message);
 
-            res.send(req.body._id);
+            res.send(params._id);
         });
     else {
-        db.Cluster.findOne({space: req.body.space, name: req.body.name}, 
function (err, cluster) {
+        db.Cluster.findOne({space: params.space, name: params.name}, function 
(err, cluster) {
             if (err)
                 return res.status(500).send(err.message);
 
             if (cluster)
                 return res.status(500).send('Cluster with name: "' + 
cluster.name + '" already exist.');
 
-            (new db.Cluster(req.body)).save(function (err, cluster) {
+            (new db.Cluster(params)).save(function (err, cluster) {
                 if (err)
                     return res.status(500).send(err.message);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/views/configuration/caches.jade
----------------------------------------------------------------------
diff --git 
a/modules/control-center-web/src/main/js/views/configuration/caches.jade 
b/modules/control-center-web/src/main/js/views/configuration/caches.jade
index c5cdcae..4e1c9c4 100644
--- a/modules/control-center-web/src/main/js/views/configuration/caches.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/caches.jade
@@ -27,7 +27,7 @@ block content
         hr
     .docs-body(ng-controller='cachesController')
         +block-callout('{{screenTip.workflowTitle}}', 
'joinTip(screenTip.workflowContent)', '{{screenTip.whatsNextTitle}}', 
'joinTip(screenTip.whatsNextContent)')
-        +main-table('Caches:', 'caches', 'defaultFocusId', 'selectItem(row)', 
'{{$index + 1}}) {{row.name}}, {{row.mode | displayValue:modes:"Cache mode not 
set"}}, {{row.atomicityMode | displayValue:atomicities:"Cache atomicity not 
set"}}')
+        +main-table('Caches:', 'caches', 'cacheName', 'selectItem(row)', 
'{{$index + 1}}) {{row.name}}, {{row.mode | displayValue:modes:"Cache mode not 
set"}}, {{row.atomicityMode | displayValue:atomicities:"Cache atomicity not 
set"}}')
         .padding-top-dflt
             button.btn.btn-primary(on-click-focus='defaultFocusId' 
ng-click='createItem()') Add cache
         hr
@@ -36,8 +36,6 @@ block content
                 +groups('general', 'backupItem')
                 div(ng-show='ui.expanded')
                     +advanced-options-bottom
-                        i.fa.fa-chevron-circle-up(ng-click='toggleExpanded()')
-                        a(ng-click='toggleExpanded()') {{ui.expanded ? 'Hide 
advanced settings...' : 'Show advanced settings...'}}
                     +groups('advanced', 'backupItem')
             +advanced-options-top
             .section

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/views/configuration/clusters.jade
----------------------------------------------------------------------
diff --git 
a/modules/control-center-web/src/main/js/views/configuration/clusters.jade 
b/modules/control-center-web/src/main/js/views/configuration/clusters.jade
index 01dcc19..3358c3a 100644
--- a/modules/control-center-web/src/main/js/views/configuration/clusters.jade
+++ b/modules/control-center-web/src/main/js/views/configuration/clusters.jade
@@ -36,7 +36,7 @@ block content
         hr
         form.form-horizontal(name='inputForm' ng-if='backupItem' novalidate)
             .panel-group(bs-collapse ng-model='panels.activePanels' 
data-allow-multiple='true' ng-click='triggerDigest = true')
-                +group('General', 'general', 'backupItem')
+                +groups('general', 'backupItem')
                 div(ng-show='ui.expanded')
                     +advanced-options-bottom
                     +groups('advanced', 'backupItem')

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf7c7b26/modules/control-center-web/src/main/js/views/includes/controls.jade
----------------------------------------------------------------------
diff --git 
a/modules/control-center-web/src/main/js/views/includes/controls.jade 
b/modules/control-center-web/src/main/js/views/includes/controls.jade
index 6bffa21..8209ad9 100644
--- a/modules/control-center-web/src/main/js/views/includes/controls.jade
+++ b/modules/control-center-web/src/main/js/views/includes/controls.jade
@@ -120,7 +120,7 @@ mixin details-row
         div(ng-switch-when='label')
             label {{::detail.label}}
         div.checkbox(ng-switch-when='check')
-            label
+            label(id='{{::detail.id}}')
                 input(type='checkbox')&attributes(detailCommon)
                 |{{::detail.label}}
                 +tipLabel('detail.tip')
@@ -258,7 +258,7 @@ mixin form-row-custom(lblClasses, fieldClasses, dataSource)
         div(ng-switch-when='label')
             label {{::field.label}}
         div.checkbox(ng-switch-when='check' ng-hide=fieldHide)
-            label
+            label(id = '{{::field.id}}')
                 input(type='checkbox')&attributes(fieldCommon)
                 | {{::field.label}}
                 +tipLabel('field.tip')
@@ -426,16 +426,6 @@ mixin main-table(title, rows, focusId, click, rowTemplate)
                     td(ng-class='{active: row._id == selectedItem._id}')
                         a(on-click-focus=focusId ng-click=click) #{rowTemplate}
 
-mixin group(title, fields, dataSource)
-    .panel.panel-default
-        .panel-heading
-            h3
-                a(bs-collapse-toggle ng-click='hidePopover()') #{title}
-        .panel-collapse(bs-collapse-target id='#{fields + "-data"}' number='0')
-            .panel-body
-                .settings-row(ng-repeat='field in #{fields}')
-                    +form-row(dataSource)
-
 mixin groups(groups, dataSource)
     .panel.panel-default(ng-repeat='group in #{groups}' 
ng-click='triggerDigest=true')
         .panel-heading


Reply via email to