Skip to content

Commit

Permalink
works well with npm3
Browse files Browse the repository at this point in the history
  • Loading branch information
vogievetsky committed Dec 25, 2015
1 parent 8f05c13 commit c62d12a
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 24 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Then you are ready to

**Recent improvements:**

- Better comparison behavior and legend interaction
- Support for query time lookups (ex. `$language.lookup('wikipedia-language-lookup')`)
- Support for the extract function (ex. `resourceVersion: $resource.extract("(\d+\.\d+\.\d+)")`)
- Custom dimensions (ex. `$user.substr(0,1)`)
Expand All @@ -135,6 +136,8 @@ Then you are ready to
- Additional visualizations (bar chart, geo, heatmap)
- Exclusion filters
- Better time selection
- String / RegExp filters
- Better time selection with date picker
- Various additions, improvements and fixes to make the app more complete

## Questions & Support
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"gulp": "3.9.0",
"gulp-watch": "4.3.5",
"jsdom": "7.2.1",
"laborer": "2.4.4",
"laborer": "2.4.5",
"mkdirp": "0.5.1",
"mocha": "2.3.4",
"react-addons-test-utils": "0.14.3",
Expand Down
39 changes: 27 additions & 12 deletions src/client/components/header-bar/header-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import MouseEventHandler = __React.MouseEventHandler;
'use strict';
require('./header-bar.css');

Expand All @@ -8,14 +7,12 @@ import { SvgIcon } from '../svg-icon/svg-icon';
import { $, Expression, Datum, Dataset } from 'plywood';
import { Essence } from "../../../common/models/index";

function panic() {
window.location.assign(Essence.getBaseURL());
}

export interface HeaderBarProps extends React.Props<any> {
essence: Essence;
onNavClick: MouseEventHandler;
onNavClick: React.MouseEventHandler;
showLastUpdated?: boolean;
hideGitHubIcon?: boolean;
color?: string;
}

export interface HeaderBarState {
Expand All @@ -28,8 +25,16 @@ export class HeaderBar extends React.Component<HeaderBarProps, HeaderBarState> {
//this.state = {}
}

onPanicClick(e: MouseEvent) {
if (e.altKey) {
console.log(this.props.essence.dataSource.toJS());
return;
}
window.location.assign(Essence.getBaseURL());
}

render() {
var { essence, onNavClick, showLastUpdated } = this.props;
var { essence, onNavClick, showLastUpdated, hideGitHubIcon, color } = this.props;
var { dataSource } = essence;

var updated: JSX.Element = null;
Expand All @@ -40,22 +45,32 @@ export class HeaderBar extends React.Component<HeaderBarProps, HeaderBarState> {
}
}

return <header className="header-bar">
var gitHubIcon: JSX.Element = null;
if (!hideGitHubIcon) {
gitHubIcon = <a className="icon-button github" href="https://github.com/implydata/pivot" target="_blank">
<SvgIcon className="github-icon" svg={require('../../icons/github.svg')}/>
</a>;
}

var headerStyle: React.CSSProperties = null;
if (color) {
headerStyle = { background: color };
}

return <header className="header-bar" style={headerStyle}>
<div className="burger-bar" onClick={onNavClick}>
<SvgIcon className="menu" svg={require('../../icons/menu.svg')}/>
<div className="dataset-title">{dataSource.title}</div>
</div>
<div className="right-bar">
{updated}
<div className="icon-button panic" onClick={panic}>
<div className="icon-button panic" onClick={this.onPanicClick.bind(this)}>
<SvgIcon className="panic-icon" svg={require('../../icons/panic.svg')}/>
</div>
<a className="icon-button help" href="https://groups.google.com/forum/#!forum/imply-user-group" target="_blank">
<SvgIcon className="help-icon" svg={require('../../icons/help.svg')}/>
</a>
<a className="icon-button github" href="https://github.com/implydata/pivot" target="_blank">
<SvgIcon className="github-icon" svg={require('../../icons/github.svg')}/>
</a>
{gitHubIcon}
</div>
</header>;
}
Expand Down
12 changes: 10 additions & 2 deletions src/client/components/pivot-application/pivot-application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface PivotApplicationProps extends React.Props<any> {
maxFilters?: number;
maxSplits?: number;
showLastUpdated?: boolean;
hideGitHubIcon?: boolean;
headerColor?: string;
}

export interface PivotApplicationState {
Expand Down Expand Up @@ -276,7 +278,7 @@ export class PivotApplication extends React.Component<PivotApplicationProps, Piv

render() {
var clicker = this.clicker;
var { homeLink, maxFilters, maxSplits, showLastUpdated } = this.props;
var { homeLink, maxFilters, maxSplits, showLastUpdated, hideGitHubIcon, headerColor } = this.props;
var { ReactCSSTransitionGroupAsync, SideDrawerAsync, essence, menuStage, visualizationStage, dragOver, drawerOpen } = this.state;

if (!essence) return null;
Expand Down Expand Up @@ -331,7 +333,13 @@ export class PivotApplication extends React.Component<PivotApplicationProps, Piv
}

return <main className='pivot-application' id='portal-cont'>
<HeaderBar essence={essence} onNavClick={this.sideDrawerOpen.bind(this, true)} showLastUpdated={showLastUpdated}/>
<HeaderBar
essence={essence}
onNavClick={this.sideDrawerOpen.bind(this, true)}
showLastUpdated={showLastUpdated}
hideGitHubIcon={hideGitHubIcon}
color={headerColor}
/>
<div className='container' ref='container'>
<DimensionMeasurePanel
clicker={clicker}
Expand Down
4 changes: 3 additions & 1 deletion src/client/pivot-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ if (config && Array.isArray(config.dataSources)) {
version,
dataSources,
homeLink: config.homeLink,
showLastUpdated: config.showLastUpdated
showLastUpdated: config.showLastUpdated,
hideGitHubIcon: config.hideGitHubIcon,
headerColor: config.headerColor
});

} else {
Expand Down
4 changes: 2 additions & 2 deletions src/client/visualizations/bar-chart/bar-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export class BarChart extends React.Component<VisualizationProps, BarChartState>
);
}

return Resolve.ready(8);
//return Resolve.manual(0, 'The Bar Chart visualization is not ready, please select another visualization.', []);
//return Resolve.ready(8);
return Resolve.manual(0, 'The Bar Chart visualization is not ready, please select another visualization.', []);
}

public mounted: boolean;
Expand Down
17 changes: 11 additions & 6 deletions src/server/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (!WallTime.rules) {
WallTime.init(tzData.rules, tzData.zones);
}

import { VERSION, DATA_SOURCE_MANAGER } from './config';
import { VERSION, DATA_SOURCE_MANAGER, HIDE_GITHUB_ICON, HEADER_COLOR } from './config';
import * as plywoodRoutes from './routes/plywood/plywood';

var app = express();
Expand Down Expand Up @@ -45,13 +45,18 @@ app.use(bodyParser.json());
app.get('/', (req: Request, res: Response, next: Function) => {
DATA_SOURCE_MANAGER.getQueryableDataSources().then((dataSources) => {
if (dataSources.length) {
var config: any = {
version: VERSION,
dataSources: dataSources.map((ds) => ds.toClientDataSource()),
//homeLink: '/',
};

if (HIDE_GITHUB_ICON) config.hideGitHubIcon = HIDE_GITHUB_ICON;
if (HEADER_COLOR) config.headerColor = HEADER_COLOR;

res.render('pivot', {
version: VERSION,
config: JSON.stringify({
version: VERSION,
dataSources: dataSources.map((ds) => ds.toClientDataSource())
//homeLink: '/'
}),
config: JSON.stringify(config),
title: 'Pivot'
});
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface PivotConfig {
sourceListScan?: string;
sourceListRefreshInterval?: number;
dataSources?: DataSourceJS[];

hideGitHubIcon?: boolean;
headerColor?: string;
}

var packageObj = loadFileSync(path.join(__dirname, '../../package.json'), 'json') || {};
Expand Down Expand Up @@ -161,6 +164,9 @@ export const USE_SEGMENT_METADATA = Boolean(parsedArgs["use-segment-metadata"] |
export const SOURCE_LIST_SCAN = START_SERVER ? config.sourceListScan : 'disable';
export const SOURCE_LIST_REFRESH_INTERVAL = START_SERVER ? (parseInt(<any>config.sourceListRefreshInterval, 10) || 10000) : 0;

export const HIDE_GITHUB_ICON = Boolean(config.hideGitHubIcon);
export const HEADER_COLOR: string = config.headerColor || null;

if (SOURCE_LIST_REFRESH_INTERVAL && SOURCE_LIST_REFRESH_INTERVAL < 1000) {
errorExit(new Error('can not refresh more often than once per second'));
}
Expand Down

0 comments on commit c62d12a

Please sign in to comment.