Skip to content

Commit

Permalink
jsonpath works, so we can use this for our json queries, excellent
Browse files Browse the repository at this point in the history
  • Loading branch information
thehoneymad committed Apr 7, 2017
1 parent e0c458e commit f2565fc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"gulp-useref": "~3.1.2",
"jasmine-core": "~2.5.2",
"jquery": "^3.2.1",
"jsonpath": "^0.2.11",
"karma": "~1.5.0",
"karma-coverage": "~1.1.1",
"karma-ie-launcher": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/app/data/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ export class DataService {
type: 'bar-chart',
datamap: {
'labels': {
path: 'entry._id.CreateDate.$date', // Can be JSONPath?
path: '$[*]._id.CreateDate.$date', // Can be JSONPath?
type: 'datestring',
},
'datasets': [
{
label: 'Orders',
path: 'count'
path: '$[*].count'
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/ui-toolbox/widget-layout/widget-layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild, Type } from '@angular/core';
import { BarChartComponent, WidgetComponent } from '../index';
import { DataService } from '../../data/index';
import { UiRegistryService } from '../ui-registry.service';
import * as jsonpath from 'jsonpath';

@Component({
moduleId: module.id,
Expand All @@ -27,7 +28,8 @@ export class WidgetLayoutComponent implements OnInit {
if (result) {
// Need to parse this crap here
let res: any[] = result;
console.log(res);
let resolve = jsonpath.query(res, '$[*].count');
console.log(resolve);
for (let entry of res) {
barChartLabels.push(new Date(entry._id.CreateDate.$date).toDateString());
jobCountArray.push(entry.count);
Expand Down
7 changes: 6 additions & 1 deletion src/systemjs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
'primeng' : {
main: 'primeng.js',
defaultExtension: 'js'
},
'jsonpath' :{
main: 'jsonpath.js',
defaultExtension: 'js'
}
};

Expand All @@ -49,7 +53,8 @@
'angular2-jwt',
'angular2-letter-avatar',
'chart.js',
'primeng'
'primeng',
'jsonpath'
];

// Add package entries for packages that expose barrels using index.js
Expand Down

0 comments on commit f2565fc

Please sign in to comment.