Skip to content

Commit

Permalink
Remove need for persistence object from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Joanne Cheng committed Nov 2, 2015
1 parent 5e18012 commit b2543a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ You can read more about Keen.js here: [The Keen.js client library](https://githu

### 3. Optionally include Saved Queries support

Persistence support is optional. If you include it, a "saved queries" feature will be shown and you can persist the state of the query you're working with to be looked up at a later time. If you do not want to use saved queries, just do not include it in the Keen.Explorer.App initialization, like above.
Saved query support is optional. If you include it, you can persist the state of the query you're working with to be looked up at a later time. If you do not want to use saved queries, just do not include it in the Keen.Explorer.App initialization, like above.

To include saved queries, create a new `KeenSavedQueries` object, and then pass that object to the `Keen.Explorer.App` initialization. So, instead of what you see above, you would have:
To include saved queries, just set the `savedQueries` config variable to `true`. You *must* include a master key if you want saved queries support.

```html
<script type="text/javascript">
Expand All @@ -103,15 +103,9 @@ To include saved queries, create a new `KeenSavedQueries` object, and then pass
requestType: "xhr"
});
// Initialization of new KeenSavedQueries object:
var keenSavedQueries = new Keen.Explorer.Persistence.KeenSavedQueries({
masterKey: "your_master_key",
baseUrl: "https://staging-api.keen.io/3.0/projects/{PROJECT_ID}/queries/saved"
});
var app = new Keen.Explorer.App({
client: client,
persistence: keenSavedQueries, // saved queries are supported
savedQueries: true, // saved queries are supported
targetId: 'content'
});
Expand Down
9 changes: 7 additions & 2 deletions client/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ var QueryStringUtils = require('./utils/QueryStringUtils');
function App(config) {
this.appDispatcher = AppDispatcher;
this.targetNode = document.getElementById(config.targetId);
this.persistence = config.persistence || null;
this.persistence = null;
this.client = config.client;

ProjectActions.create({ client: this.client });
ProjectActions.fetchProjectSchema();
if (this.persistence) {

if (config.savedQueries) {
this.persistence = new Keen.Explorer.Persistence.KeenSavedQueries({
baseUrl: this.client.config.protocol + "://" + this.client.config.host +
"/projects/" + this.client.config.projectId + "/queries/saved"
});
if (_.isUndefined(this.client.masterKey())) {
throw new Error("You must include your project's master key for saved query support.");
}
Expand Down
11 changes: 8 additions & 3 deletions dist/keen-explorer.js

Large diffs are not rendered by default.

0 comments on commit b2543a8

Please sign in to comment.