I've got an Ember application and I want to add some functionality from Stimulsoft Reports.js
I've tried to add native js files () to my ember application, but it redefined Promise object, that was used by Ember. As a result I've got runtime error.
Then I found npm package for node.js (http://ift.tt/1RFPt95) and include it using ember-browserify package, but I've got build error: Cannot find module './path' from 'D:...\node_modules\stimulsoft-reports-js'
package.json:
{
"name": "ember-app",
"version": "0.0.0",
"description": "Small description for ember-app goes here",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"start": "ember server",
"test": "ember test"
},
"repository": "",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"ember-ajax": "0.7.1",
"ember-browserify": "^1.1.8",
"ember-cli": "2.3.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-babel": "^5.1.5",
"ember-cli-cordova": "0.0.19",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-htmlbars": "^1.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-moment-shim": "1.1.0",
"ember-cli-qunit": "^1.2.1",
"ember-cli-release": "0.2.8",
"ember-cli-sass": "5.3.0",
"ember-cli-sri": "^2.0.0",
"ember-cli-uglify": "^1.2.0",
"ember-data": "^2.3.0",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.4",
"ember-flexberry": "git+http://ift.tt/209QgRE",
"ember-flexberry-offline": "git+http://ift.tt/1RFPtpj",
"ember-load-initializers": "^0.5.0",
"ember-localforage-adapter": "git+http://ift.tt/209Qjgk",
"ember-moment": "6.0.0",
"ember-resolver": "^2.0.3",
"ember-simple-auth": "1.0.1",
"loader.js": "^4.0.0",
"opentype.js": "^0.6.2",
"semantic-ui-ember": "0.9.3",
"stimulsoft-reports-js": "^2016.1.5",
"strip-bom": "^2.0.0"
},
"dependencies": {}
}
component.js:
import Ember from 'ember';
import fs from 'npm:fs';
import stripBom from 'npm:strip-bom';
import opentype from 'npm:opentype.js';
import ReportJS from 'npm:stimulsoft-reports-js';
export default Ember.Component.extend({
didInsertElement() {
var Stimulsoft = ReportJS.Stimulsoft;
console.log("Stimulsoft Reports loaded");
var font = opentype.loadSync('node_modules/stimulsoft-reports-js/demo-files/Roboto-Black.ttf');
Stimulsoft.Base.StiFontCollection.addOpentypeFont(font);
console.log("Font loaded");
// Creating new report
var report = new Stimulsoft.Report.StiReport();
console.log("New report created");
// Loading report template
var reportTemplate = fs.readFileSync('node_modules/stimulsoft-reports-js/demo-files/SimpleList.mrt', "utf8");
report.load(reportTemplate);
console.log("Report template loaded");
// Loading demo data
var demoData = stripBom(fs.readFileSync('node_modules/stimulsoft-reports-js/demo-files/Demo.json', "utf8"));
report.dictionary.databases.clear();
report.regData("Demo", "Demo", demoData);
console.log("Demo data loaded into the report. Tables count: ", report.dataStore.count);
var viewer = new Stimulsoft.Viewer.StiViewer(null, "StiViewer", false);
viewer.report = report;
viewer.renderHtml("reportViewer");
}
});
Aucun commentaire:
Enregistrer un commentaire