[#43,demo][s]: fix up demo to use new form for creating datasets and backends.

This commit is contained in:
Rufus Pollock
2012-02-17 09:20:19 +00:00
parent 747212aaea
commit b179ab50cf

View File

@@ -29,15 +29,15 @@ $(function() {
function demoDataset() { function demoDataset() {
var datasetId = 'test-dataset'; var datasetId = 'test-dataset';
var metadata = { var inData = {
title: 'My Test Dataset' metadata: {
, name: '1-my-test-dataset' title: 'My Test Dataset'
, id: datasetId , name: '1-my-test-dataset'
}; , id: datasetId
var indata = { , headers: ['x', 'y', 'z']
headers: ['x', 'y', 'z'] },
, rows: [ documents: [
{id: 0, x: 1, y: 2, z: 3} {id: 0, x: 1, y: 2, z: 3}
, {id: 1, x: 2, y: 4, z: 6} , {id: 1, x: 2, y: 4, z: 6}
, {id: 2, x: 3, y: 6, z: 9} , {id: 2, x: 3, y: 6, z: 9}
, {id: 3, x: 4, y: 8, z: 12} , {id: 3, x: 4, y: 8, z: 12}
@@ -45,12 +45,9 @@ function demoDataset() {
, {id: 5, x: 6, y: 12, z: 18} , {id: 5, x: 6, y: 12, z: 18}
] ]
}; };
var dataset = new recline.Model.Dataset(metadata); var backend = new recline.Model.BackendMemory();
dataset.backendConfig = { backend.addDataset(inData);
type: 'memory' var dataset = new recline.Model.Dataset({id: datasetId}, backend);
// deep copy so we do not touch original data ...
, data: $.extend(true, {}, indata)
};
return dataset; return dataset;
} }
@@ -62,11 +59,12 @@ function setupLoadFromWebstore(callback) {
e.preventDefault(); e.preventDefault();
var $form = $(e.target); var $form = $(e.target);
var source = $form.find('input[name="source"]').val(); var source = $form.find('input[name="source"]').val();
var dataset = new recline.Model.Dataset(); var dataset = new recline.Model.Dataset({
dataset.backendConfig = { id: 'gold-prices',
type: 'webstore', webstore_url: source
url: source },
}; 'webstore'
);
callback(dataset); callback(dataset);
}); });
} }