Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

API calls to fetch druid cluster & data cubes. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,8 @@ dataCubes:
title: Unique Users
formula: $main.countDistinct($user)

settingsLocation:
location: file
format: 'json'
uri: 'temp.json'
writable: true
71 changes: 39 additions & 32 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"node-spawn-server": "1.0.1",
"nopt": "3.0.6",
"numeral": "1.5.3",
"plywood": "0.12.3",
"plywood": "^0.12.5",
"plywood-druid-requester": "1.5.4",
"plywood-mysql-requester": "1.3.1",
"plywood-postgres-requester": "0.9.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class CollectionViewDelegate {
const collectionURL = `#collection/${collection.name}`;
const oldIndex = collection.tiles.indexOf(tile);

const newCollection = collection.deleteTile(tile);
const newCollection = collection.deleteTile(tile.name);
const newSettings = appSettings.addOrUpdateCollection(newCollection);

const undo = () => this.addTile(newCollection, tile, oldIndex);
Expand Down Expand Up @@ -175,7 +175,7 @@ export class CollectionViewDelegate {
this.save(this.getSettings().addCollectionAt(collection, oldIndex));
};

return this.save(appSettings.deleteCollection(collection)).then( () => {
return this.save(appSettings.deleteCollection(collection.name)).then( () => {
window.location.hash = `#/home`;
Notifier.success('Collection removed', {label: STRINGS.undo, callback: undo});
});
Expand Down
20 changes: 17 additions & 3 deletions src/client/applications/swiv-application/swiv-application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { findByName } from 'plywood';
import { replaceHash } from '../../utils/url/url';
import { DataCube, AppSettings, User, Collection, CollectionTile, Essence, Timekeeper, ViewSupervisor } from '../../../common/models/index';
import { STRINGS } from '../../config/constants';
import { MANIFESTS } from '../../../common/manifests/index';

import { createFunctionSlot, FunctionSlot } from '../../utils/function-slot/function-slot';
import { Ajax } from '../../utils/ajax/ajax';
Expand Down Expand Up @@ -159,7 +160,17 @@ export class SwivApplication extends React.Component<SwivApplicationProps, SwivA
return appSettings.getVersion();
};
Ajax.onUpdate = () => {
console.log('UPDATE!!');
Ajax.query({ method: "GET", url: 'client-settings' })
.then(
(resp) => {
//if (!this.mounted) return; // ToDo: this
this.setState({
appSettings: AppSettings.fromJS(resp.clientSettings, { visualizations: MANIFESTS })
});
},
(e: Error) => {
}
);
};

require.ensure(['clipboard'], (require) => {
Expand Down Expand Up @@ -212,6 +223,10 @@ export class SwivApplication extends React.Component<SwivApplicationProps, SwivA
drawerOpen: false
};

if (viewType === COLLECTION) {
newState.cubeViewSupervisor = null;
}

if (this.viewTypeNeedsAnItem(viewType)) {
let items = viewType === CUBE ? dataCubes : collections;
let item = this.getSelectedItemFromHash(items, hash, viewType);
Expand Down Expand Up @@ -468,8 +483,7 @@ export class SwivApplication extends React.Component<SwivApplicationProps, SwivA

deleteDataCube(dataCube: DataCube) {
const appSettings = this.state.appSettings as AppSettings;

this.saveDataCubes(appSettings.deleteDataCube(dataCube));
this.saveDataCubes(appSettings.deleteDataCube(dataCube.name));
}


Expand Down
7 changes: 4 additions & 3 deletions src/client/components/dimension-tile/dimension-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { Clicker, Essence, Timekeeper, VisStrategy, Dimension, SortOn, SplitComb
granularityToString, getDefaultGranularityForKind, getGranularities } from '../../../common/models/index';

import { setDragGhost, classNames } from '../../utils/dom/dom';
import { QueryRunner } from '../../utils/query-runner/query-runner';
import { DragManager } from '../../utils/drag-manager/drag-manager';
import { STRINGS, getLocale } from '../../config/constants';
import { PIN_TITLE_HEIGHT, PIN_ITEM_HEIGHT, PIN_PADDING_BOTTOM, MAX_SEARCH_LENGTH, SEARCH_WAIT } from '../../config/constants';
Expand Down Expand Up @@ -101,7 +102,7 @@ export class DimensionTile extends React.Component<DimensionTileProps, Dimension

var filter = essence.getEffectiveFilter(timekeeper);
// don't remove filter if time
if (unfolded && dimension !== essence.getTimeDimension()) {
if (unfolded && dataCube.isMandatoryFilter(dimension.expression)) {
filter = filter.remove(dimension.expression);
}

Expand Down Expand Up @@ -156,7 +157,7 @@ export class DimensionTile extends React.Component<DimensionTileProps, Dimension
loading: true,
fetchQueued: false
});
dataCube.executor(query, { timezone: essence.timezone })
QueryRunner.fetch(dataCube, query, essence.timezone)
.then(
(dataset: Dataset) => {
if (!this.mounted) return;
Expand Down Expand Up @@ -323,7 +324,7 @@ export class DimensionTile extends React.Component<DimensionTileProps, Dimension
return {
selected: filterMode === value,
onSelect: this.changeFilterMode.bind(this, value),
displayValue: STRINGS[value],
displayValue: (STRINGS as any)[value],
keyString: value
};
});
Expand Down
8 changes: 4 additions & 4 deletions src/client/components/filter-tile/filter-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ export class FilterTile extends React.Component<FilterTileProps, FilterTileState
if (dimension) {
var dragPosition = this.calculateDragPosition(e);

var tryingToReplaceTime = false;
var tryingToReplaceMandatory = false;
if (dragPosition.replace !== null) {
var targetClause = filter.clauses.get(dragPosition.replace);
tryingToReplaceTime = targetClause && targetClause.expression.equals(dataCube.timeAttribute);
tryingToReplaceMandatory = targetClause && dataCube.isMandatoryFilter(targetClause.expression);
}

var existingClause = filter.clauseForExpression(dimension.expression);
Expand Down Expand Up @@ -333,7 +333,7 @@ export class FilterTile extends React.Component<FilterTileProps, FilterTileState
}

} else {
if (dragPosition && !tryingToReplaceTime) {
if (dragPosition && !tryingToReplaceMandatory) {
this.addDummy(dimension, dragPosition);
}

Expand Down Expand Up @@ -434,7 +434,7 @@ export class FilterTile extends React.Component<FilterTileProps, FilterTileState
renderRemoveButton(itemBlank: ItemBlank) {
var { essence } = this.props;
var dataCube = essence.dataCube;
if (itemBlank.dimension.expression.equals(dataCube.timeAttribute)) return null;
if (dataCube.isMandatoryFilter(itemBlank.dimension.expression)) return null;
return <div className="remove" onClick={this.removeFilter.bind(this, itemBlank)}>
<SvgIcon svg={require('../../icons/x.svg')}/>
</div>;
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/hiluk-menu/hiluk-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class HilukMenu extends React.Component<HilukMenuProps, HilukMenuState> {
const { dataCube, splits } = essence;
if (!getDownloadableDataset) return;

const filters = essence.getEffectiveFilter(timekeeper).getFileString(dataCube.timeAttribute);
const filters = essence.getEffectiveFilter(timekeeper).getFileString(dataCube.getPrimaryTimeExpression());
var splitsString = splits.toArray().map((split) => {
var dimension = split.getDimension(dataCube.dimensions);
if (!dimension) return '';
Expand Down
1 change: 1 addition & 0 deletions src/client/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export * from './immutable-input/immutable-input';
export * from './immutable-list/immutable-list';
export * from './line-chart-axis/line-chart-axis';
export * from './loader/loader';
export * from './loading-bar/loading-bar';
export * from './manual-fallback/manual-fallback';
export * from './measures-tile/measures-tile';
export * from './modal/modal';
Expand Down
41 changes: 41 additions & 0 deletions src/client/components/loading-bar/loading-bar.mocha.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2015-2016 Imply Data, Inc.
*
* 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.
*/

import { expect } from 'chai';
import * as sinon from 'sinon';
import * as React from 'react';
import * as TestUtils from 'react-addons-test-utils';
import { $, Expression } from 'plywood';

import { DataCubeMock, EssenceMock } from '../../../common/models/mocks';

import { findDOMNode } from '../../utils/test-utils/index';

import { LoadingBar } from './loading-bar';

describe('LoadingBar', () => {
it('adds the correct class', () => {
var renderedComponent = TestUtils.renderIntoDocument(
<LoadingBar

/>
);

expect(TestUtils.isCompositeComponent(renderedComponent), 'should be composite').to.equal(true);
expect((findDOMNode(renderedComponent) as any).className, 'should contain class').to.contain('loading-bar');
});

});
Loading