couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [1/2] fauxton commit: updated refs/heads/master to a9e829c
Date Tue, 19 May 2015 17:11:38 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 30f65771d -> a9e829c44


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/shared-views.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/shared-views.js b/app/addons/documents/shared-views.js
index 5beee95..e5b5f17 100644
--- a/app/addons/documents/shared-views.js
+++ b/app/addons/documents/shared-views.js
@@ -42,8 +42,6 @@ function (app, FauxtonAPI, Components, Documents, Databases) {
 
     serialize: function () {
       var docLinks = FauxtonAPI.getExtensions('docLinks'),
-          newLinks = FauxtonAPI.getExtensions('sidebar:newLinks'),
-          addLinks = FauxtonAPI.getExtensions('sidebar:links'),
           extensionList = FauxtonAPI.getExtensions('sidebar:list'),
           safeDatabaseName = this.database.safeID(),
           changesLink = '#' + FauxtonAPI.urls('changes', 'app', safeDatabaseName, ''),
@@ -53,17 +51,13 @@ function (app, FauxtonAPI, Components, Documents, Databases) {
           base = FauxtonAPI.urls('base', 'app', safeDatabaseName);
 
       return {
-        changes_url: changesLink,
-        permissions_url: permissionsLink,
-        db_url: db_url,
-        database_url: '#' + databaseUrl,
-        database: this.collection.database,
+        changesUrl: changesLink,
+        permissionsUrl: permissionsLink,
         docLinks: docLinks,
-        addLinks: addLinks,
-        newLinks: newLinks,
-        extensionList: extensionList > 0,
         databaseUrl: databaseUrl,
-        base: base
+        base: base,
+        mangoQueryUrl: FauxtonAPI.urls('mango', 'query-app', safeDatabaseName),
+        runQueryWithMangoText: app.i18n.en_US['run-query-with-mango']
       };
     },
 
@@ -90,7 +84,19 @@ function (app, FauxtonAPI, Components, Documents, Databases) {
         title: 'New View',
         url: newUrlPrefix + '/new_view',
         icon: 'fonticon-plus-circled'
-      }]);
+      }, this.getMangoLink()]);
+    },
+
+    getMangoLink: function () {
+      var database = this.collection.database,
+          databaseName = database.id,
+          newUrlPrefix = '#' + FauxtonAPI.urls('databaseBaseURL', 'app', databaseName);
+
+      return {
+        title: app.i18n.en_US['new-mango-index'],
+        url: newUrlPrefix + '/_index',
+        icon: 'fonticon-plus-circled'
+      };
     },
 
     beforeRender: function (manage) {
@@ -107,13 +113,22 @@ function (app, FauxtonAPI, Components, Documents, Databases) {
         links: this.getNewButtonLinks()
       }];
 
-      this.setView("#new-all-docs-button", new Components.MenuDropDown({
-        links: newLinks,
+      [
+        '#new-all-docs-button',
+        '#new-design-docs-button'
+      ].forEach(function (id) {
+        this.setView(id, new Components.MenuDropDown({
+          links: newLinks,
+        }));
+      }.bind(this));
+
+      this.setView('#mango-query-button', new Components.MenuDropDown({
+        links: [{
+          title: 'Add new',
+          links: [this.getMangoLink()]
+        }]
       }));
 
-      this.setView("#new-design-docs-button", new Components.MenuDropDown({
-        links: newLinks,
-      }));
 
       _.each(this.designDocList, function (view) { view.remove(); view = undefined;});
       this.designDocList = [];

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/templates/sidebar.html
----------------------------------------------------------------------
diff --git a/app/addons/documents/templates/sidebar.html b/app/addons/documents/templates/sidebar.html
index 857aa0a..6d6a388 100644
--- a/app/addons/documents/templates/sidebar.html
+++ b/app/addons/documents/templates/sidebar.html
@@ -1,4 +1,4 @@
-<!--
+<%/*
 Licensed 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
@@ -10,22 +10,41 @@ 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.
--->
+*/%>
 
 <ul class="nav nav-list">
-  <li><a id="permissions" href="<%- permissions_url %>">Permissions</a><li>
-  <li><a id="changes" href="<%- changes_url %>">Changes</a><li>
+  <li><a id="permissions" href="<%- permissionsUrl %>">Permissions</a><li>
+  <li><a id="changes" href="<%- changesUrl %>">Changes</a><li>
   <% _.each(docLinks, function (link) { %>
-  <li><a id="docLink_<%-link.url%>" href="<%- base + link.url %>"><%-
link.title %></a></li>
+    <li><a id="docLink_<%-link.url%>" href="<%- base + link.url %>"><%-
link.title %></a></li>
   <% }); %>
   <li class="active"> 
-      <a id="all-docs" href="#/<%- databaseUrl %>" class="toggle-view"> All Documents</a>

-      <div id="new-all-docs-button" class="add-dropdown"> </div>
+    <a
+      id="all-docs"
+      href="#/<%- databaseUrl %>"
+      class="toggle-view">
+      All Documents
+    </a>
+    <div id="new-all-docs-button" class="add-dropdown"> </div>
    </li>
   <li>
-      <a id="design-docs" href='#/<%- databaseUrl %>?startkey="_design"&endkey="_design0"'
 class="toggle-view"> All Design Docs</a>
-      <div id="new-design-docs-button" class="add-dropdown"> </div>
-    </li>
+    <a
+      id="mango-query"
+      href='#/<%- mangoQueryUrl %>'
+      class="toggle-view">
+      <%- runQueryWithMangoText %>
+    </a>
+    <div id="mango-query-button" class="add-dropdown"> </div>
+  </li>
+  <li>
+    <a
+      id="design-docs"
+      href='#/<%- databaseUrl %>?startkey="_design"&endkey="_design0"'
+      class="toggle-view">
+      All Design Docs
+    </a>
+    <div id="new-design-docs-button" class="add-dropdown"> </div>
+  </li>
 </ul>
 
 <div id="delete-db-modal"> </div>

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/tests/nightwatch/mangoIndex.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/mangoIndex.js b/app/addons/documents/tests/nightwatch/mangoIndex.js
index b6d4018..f6a6b0d 100644
--- a/app/addons/documents/tests/nightwatch/mangoIndex.js
+++ b/app/addons/documents/tests/nightwatch/mangoIndex.js
@@ -12,8 +12,9 @@
 
 module.exports = {
 
-  'Creating new indexes with mango': function (client) {
+  'Creating new indexes with mango (mangoIndex.js)': function (client) {
     /*jshint multistr: true */
+
     var waitTime = client.globals.maxWaitTime,
         newDatabaseName = client.globals.testDatabaseName,
         baseUrl = client.globals.test_settings.launch_url;
@@ -22,12 +23,13 @@ module.exports = {
       .populateDatabase(newDatabaseName)
       .loginToGUI()
       .url(baseUrl + '/#/database/' + newDatabaseName + '/_index')
-      .waitForElementPresent('.watermark-logo', waitTime, false)
+      .waitForElementPresent('.prettyprint', waitTime, false)
+      .waitForElementNotPresent('.loading-lines', waitTime, false)
       .assert.containsText('.editor-description', 'is an easy way to find documents on predefined
indexes')
       .execute('\
         var json = \'{\
           "index": {\
-            "fields": ["ente_ente_mango"]\
+            "fields": ["gans_gans_mango"]\
           },\
           "name": "rocko-artischocko",\
           "type" : "json"\
@@ -36,14 +38,39 @@ module.exports = {
         editor.getSession().setValue(json);\
       ')
       .execute('$(".save")[0].scrollIntoView();')
-      .click('button.btn-success.save')
-      .waitForAttribute('#global-notifications', 'textContent', function (successAlertText)
{
-        return (/Index created/).test(successAlertText);
-      })
-      .waitForElementNotVisible('.global-notification', waitTime, false)
-      .url(baseUrl + '/#/database/' + newDatabaseName + '/_indexlist')
-      .waitForElementPresent('.prettyprint', waitTime, false)
-      .assert.containsText('#dashboard-lower-content', 'ente_ente_mango')
+      .clickWhenVisible('button.btn-success.save')
+
+      .waitForElementVisible('#global-notifications .alert.alert-success', waitTime, false)
+      .waitForElementNotVisible('#global-notifications .alert.alert-success', waitTime, false)
+      .assert.containsText('#dashboard-lower-content', 'gans_gans_mango')
     .end();
+  },
+
+  'Deleting new named indexes with mango': function (client) {
+    var waitTime = 10000,
+        newDatabaseName = client.globals.testDatabaseName,
+        baseUrl = client.globals.test_settings.launch_url;
+
+    client
+      .populateDatabase(newDatabaseName)
+      .loginToGUI()
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_index')
+      .waitForElementPresent('.control-toggle-alternative-header', waitTime, false)
+      .clickWhenVisible('.control-toggle-alternative-header')
+      .assert.containsText('#dashboard-lower-content', 'ente_ente_mango_ananas')
+      .waitForElementPresent('.control-select-all', waitTime, false)
+      .clickWhenVisible('.control-select-all')
+      .clickWhenVisible('.control-delete')
+      .acceptAlert()
+
+      .waitForElementVisible('#global-notifications .alert.alert-info', waitTime, false)
+      .waitForElementNotVisible('#global-notifications .alert.alert-info', waitTime, false)
+      .getText('body', function (result) {
+        var data = result.value;
+
+        this.verify.ok(data.indexOf('ente_ente_mango_ananas') === -1,
+          'Checking if documents were deleted');
+      })
+      .end();
   }
 };

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/tests/nightwatch/mangoIndexList.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/mangoIndexList.js b/app/addons/documents/tests/nightwatch/mangoIndexList.js
deleted file mode 100644
index 95a9e1c..0000000
--- a/app/addons/documents/tests/nightwatch/mangoIndexList.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Licensed 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.
-
-module.exports = {
-
-  'Creating new indexes with mango': function (client) {
-    var waitTime = client.globals.maxWaitTime,
-        newDatabaseName = client.globals.testDatabaseName,
-        baseUrl = client.globals.test_settings.launch_url;
-
-    client
-      .populateDatabase(newDatabaseName)
-      .loginToGUI()
-      .url(baseUrl + '/#/database/' + newDatabaseName + '/_indexlist')
-      .waitForElementPresent('.prettyprint', waitTime, false)
-      .waitForElementVisible('.header-doc-id', waitTime, false)
-      .assert.containsText('.header-doc-id', '_all_docs')
-      .waitForElementVisible('#doc-list', waitTime, false)
-      .assert.containsText('#doc-list', 'ente_ente_mango_ananas')
-    .end();
-  }
-};

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/tests/nightwatch/mangoQuery.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/nightwatch/mangoQuery.js b/app/addons/documents/tests/nightwatch/mangoQuery.js
new file mode 100644
index 0000000..2e5c8a5
--- /dev/null
+++ b/app/addons/documents/tests/nightwatch/mangoQuery.js
@@ -0,0 +1,44 @@
+// Licensed 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.
+
+module.exports = {
+
+  'Finding things with with mango': function (client) {
+    /*jshint multistr: true */
+    var waitTime = 10000,
+        newDatabaseName = client.globals.testDatabaseName,
+        baseUrl = client.globals.test_settings.launch_url;
+
+    client
+      .populateDatabase(newDatabaseName)
+      .loginToGUI()
+      .url(baseUrl + '/#/database/' + newDatabaseName + '/_find')
+      .waitForElementPresent('.watermark-logo', waitTime, false)
+      .assert.containsText('.editor-description', 'is an easy way to find documents on predefined
indexes')
+      .execute('\
+        var json = \'{\
+          "selector": {\
+            "ente_ente_mango_ananas": {"$gt": null}\
+          }\
+        }\';\
+        var editor = ace.edit("query-field");\
+        editor.getSession().setValue(json);\
+      ')
+      .execute('$(".save")[0].scrollIntoView();')
+      .click('button.btn-success.save')
+
+      .waitForElementPresent('.prettyprint', waitTime, false)
+      .assert.containsText('#dashboard-lower-content', 'number')
+      .assert.containsText('#dashboard-lower-content', 'ente_ente_mango_ananas_res')
+    .end();
+  }
+};

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/resourcesSpec.js b/app/addons/documents/tests/resourcesSpec.js
index 8d0e0c8..9e246c2 100644
--- a/app/addons/documents/tests/resourcesSpec.js
+++ b/app/addons/documents/tests/resourcesSpec.js
@@ -99,7 +99,62 @@ define([
     });
   });
 
-  describe('MangoIndexCollection', function () {
+  describe('MangoDocumentCollection', function () {
+    var collection;
+
+    it('gets 1 doc more to know if there are more than 20', function () {
+      collection = new Models.MangoDocumentCollection([{
+        name: 'myId1',
+        doc: 'num1'
+      },
+      {
+        name: 'myId2',
+        doc: 'num2'
+      }], {
+        database: {id: 'databaseId', safeID: function () { return this.id; }},
+        params: {limit: 20}
+      });
+      collection.setQuery({
+        selector: '$foo',
+        fields: 'bla'
+      });
+
+      assert.deepEqual({
+        selector: '$foo',
+        fields: 'bla',
+        limit: 21,
+        skip: undefined
+      }, collection.getPaginatedQuery());
+    });
+
+    it('on next page, skips first 20', function () {
+      collection = new Models.MangoDocumentCollection([{
+        name: 'myId1',
+        doc: 'num1'
+      },
+      {
+        name: 'myId2',
+        doc: 'num2'
+      }], {
+        database: {id: 'databaseId', safeID: function () { return this.id; }},
+        params: {limit: 20}
+      });
+      collection.setQuery({
+        selector: '$foo',
+        fields: 'bla'
+      });
+      collection.next();
+      assert.deepEqual({
+        selector: '$foo',
+        fields: 'bla',
+        limit: 21,
+        skip: 20
+      }, collection.getPaginatedQuery());
+    });
+
+  });
+
+  describe('MangoDocumentCollection', function () {
     var collection;
 
     it('is not editable', function () {
@@ -119,7 +174,6 @@ define([
     });
   });
 
-
   describe('IndexCollection', function () {
     var collection;
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/documents/views-mango.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views-mango.js b/app/addons/documents/views-mango.js
deleted file mode 100644
index 7b45984..0000000
--- a/app/addons/documents/views-mango.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed 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.
-
-define([
-  'api',
-  'addons/documents/mango/mango.components.react',
-  'addons/documents/mango/mango.actions',
-  'addons/documents/index-results/index-results.components.react'
-],
-
-function (FauxtonAPI, Mango, MangoActions, ViewResultList) {
-
-  var Views = {};
-
-
-  Views.HelpScreen = FauxtonAPI.View.extend({
-
-    afterRender: function () {
-      Mango.renderHelpScreen(this.el);
-    },
-
-    cleanup: function () {
-      Mango.removeHelpScreen(this.el);
-    }
-  });
-
-  Views.MangoIndexListReact = FauxtonAPI.View.extend({
-
-    afterRender: function () {
-      ViewResultList.renderViewResultList(this.el);
-    },
-
-    cleanup: function () {
-      ViewResultList.removeViewResultList(this.el);
-    }
-  });
-
-  Views.MangoIndexEditorReact = FauxtonAPI.View.extend({
-    initialize: function (options) {
-      this.database = options.database;
-    },
-
-    afterRender: function () {
-      MangoActions.setDatabase({
-        database: this.database
-      });
-
-      Mango.renderMangoIndexEditor(this.el);
-    },
-
-    cleanup: function () {
-      Mango.removeMangoIndexEditor(this.el);
-    }
-  });
-
-  return Views;
-});

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/app/addons/fauxton/components.js b/app/addons/fauxton/components.js
index b2fdcaf..ce58eb4 100644
--- a/app/addons/fauxton/components.js
+++ b/app/addons/fauxton/components.js
@@ -631,6 +631,8 @@ function (app, FauxtonAPI, ace, spin, ZeroClipboard) {
         this.removeIncorrectAnnotations();
       }
 
+      this.editor.getSession().setTabSize(2);
+
       this.editor.getSession().on('change', function () {
         this.setHeightToLineCount();
         this.edited = true;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/app/constants.js
----------------------------------------------------------------------
diff --git a/app/constants.js b/app/constants.js
index 5cef015..c0daca1 100644
--- a/app/constants.js
+++ b/app/constants.js
@@ -48,6 +48,7 @@ define([], function () {
       LOG: '/_utils/docs/api/server/common.html?highlight=stats#log',
       CONFIG: '/_utils/docs/config/index.html',
       VIEWS: '/_utils/docs/intro/overview.html#views',
+      MANGO: '/_utils/docs/intro/api.html#documents',
       CHANGES: '/_utils/docs/api/database/changes.html?highlight=changes#post--db-_changes'
     },
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/i18n.json.default
----------------------------------------------------------------------
diff --git a/i18n.json.default b/i18n.json.default
index aa89b17..69f0d0b 100644
--- a/i18n.json.default
+++ b/i18n.json.default
@@ -1,8 +1,11 @@
 {
   "en_US": {
     "mango-descripton": "Mango is an easy way to find documents on predefined indexes.",
-    "all-mango-indexes": "All Mango Indexes",
     "new-mango-index": "New Mango Index",
-    "mango-help-title": "Mango"
+    "mango-help-title": "Mango",
+    "run-query-with-mango": "Run A Query with Mango",
+    "mango-title-editor": "Mango Query",
+    "mango-descripton-index-editor": "Mango is an easy way to find documents on predefined
indexes. <br/><br/>Create an Index to query it afterwards. The example in the
editor shows how to create an index for the field '_id'. <br/><br/>The Indexes
that you already created are listed on the right.",
+    "mango-additional-indexes-heading": "Your additional Indexes:"
   }
 }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9e829c4/test/nightwatch_tests/custom-commands/populateDatabase.js
----------------------------------------------------------------------
diff --git a/test/nightwatch_tests/custom-commands/populateDatabase.js b/test/nightwatch_tests/custom-commands/populateDatabase.js
index b5cd161..e3884f9 100644
--- a/test/nightwatch_tests/custom-commands/populateDatabase.js
+++ b/test/nightwatch_tests/custom-commands/populateDatabase.js
@@ -32,8 +32,12 @@ PopulateDatabase.prototype.command = function (databaseName, count) {
     function () { return i < (count ? count : 20); },
     function (cb) {
       i++;
-      var document_id = 'document_' + i;
-      database.insert({ number: i }, document_id, cb);
+      var documentId = 'document_' + i;
+      database.insert({
+        number: i,
+        ente_ente_mango_ananas: i,
+        ente_ente_mango_ananas_res: 'foo'
+      }, documentId, cb);
     },
     function (err) {
       if (err) {


Mime
View raw message