ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843: WIP saving presets.
Date Wed, 19 Aug 2015 11:11:55 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 7307836d3 -> a87cc90b8


IGNITE-843: WIP saving presets.


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

Branch: refs/heads/ignite-843
Commit: a87cc90b89f7976fc46f79f4e19f594b7838db9c
Parents: 7307836
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Aug 19 18:12:11 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Aug 19 18:12:11 2015 +0700

----------------------------------------------------------------------
 modules/control-center-web/src/main/js/app.js   |  2 +
 .../src/main/js/routes/presets.js               | 68 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a87cc90b/modules/control-center-web/src/main/js/app.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app.js b/modules/control-center-web/src/main/js/app.js
index 95b300a..81107ec 100644
--- a/modules/control-center-web/src/main/js/app.js
+++ b/modules/control-center-web/src/main/js/app.js
@@ -31,6 +31,7 @@ var notebooksRoutes = require('./routes/notebooks');
 var clustersRouter = require('./routes/clusters');
 var cachesRouter = require('./routes/caches');
 var metadataRouter = require('./routes/metadata');
+var presetsRouter = require('./routes/presets');
 var summary = require('./routes/summary');
 var adminRouter = require('./routes/admin');
 var profileRouter = require('./routes/profile');
@@ -132,6 +133,7 @@ app.use('/profile', mustAuthenticated, profileRouter);
 app.use('/configuration/clusters', clustersRouter);
 app.use('/configuration/caches', cachesRouter);
 app.use('/configuration/metadata', metadataRouter);
+app.use('/configuration/presets', presetsRouter);
 app.use('/configuration/summary', summary);
 
 app.use('/notebooks', mustAuthenticated, notebooksRoutes);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a87cc90b/modules/control-center-web/src/main/js/routes/presets.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/presets.js b/modules/control-center-web/src/main/js/routes/presets.js
new file mode 100644
index 0000000..119102a
--- /dev/null
+++ b/modules/control-center-web/src/main/js/routes/presets.js
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var router = require('express').Router();
+var db = require('../db');
+
+/**
+ * Get database presets.
+ *
+ * @param req Request.
+ * @param res Response.
+ */
+router.post('/list', function (req, res) {
+    var userId = req.currentUserId();
+
+    // Get owned space and all accessed space.
+    db.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch: {account: userId}}}]}, function
(err, spaces) {
+        if (db.processed(err, res)) {
+            var spaceIds = spaces.map(function (value) {
+                return value._id;
+            });
+
+            // Get all presets for spaces.
+            db.DatabasePreset.find({space: {$in: spaceIds}}).exec(function (err, presets)
{
+                if (db.processed(err, res))
+                    res.json({spaces: spaces, presets: presets});
+            });
+        }
+    });
+});
+
+/**
+ * Save database preset.
+ */
+router.post('/save', function (req, res) {
+    var params = req.body;
+
+    db.CacheTypeMetadata.findOne({space: params.space, jdbcDriverJar: params.jdbcDriverJar},
function (err, preset) {
+        if (db.processed(err, res)) {
+            if (preset)
+                db.CacheTypeMetadata.update({space: params.space, jdbcDriverJar: params.jdbcDriverJar},
params, {upsert: true}, function (err) {
+                    if (db.processed(err, res))
+                        return res.sendStatus(200);
+                });
+            else
+                (new db.CacheTypeMetadata(params)).save(function (err) {
+                    if (db.processed(err, res))
+                        return res.sendStatus(200);
+                });
+        }
+    });
+});
+
+module.exports = router;


Mime
View raw message