GithubHelp home page GithubHelp logo

jsreport / jsreport Goto Github PK

View Code? Open in Web Editor NEW
1.1K 55.0 218.0 177.56 MB

javascript based business reporting platform :rocket:

Home Page: https://jsreport.net

License: GNU Lesser General Public License v3.0

JavaScript 97.62% Shell 0.03% Dockerfile 0.10% CSS 0.80% HTML 0.25% Handlebars 0.29% Python 0.88% XSLT 0.03%
reporting pdf excel

jsreport's Introduction

jsreport

Join the chat at https://gitter.im/jsreport/jsreport NPM Version NPM Downloads Docker Pulls build status

An open-source platform for designing and rendering various reports.

jsreport is a reporting server letting developers define reports using javascript templating engines like handlebars. It supports various report output formats like html, pdf, excel, docx, and others. It also includes advanced reporting features like user management, REST API, scheduling, designer, or sending emails.

You can find more information on the official project website https://jsreport.net

studio

Installation

Basic installation from the npm

npm install -g @jsreport/jsreport-cli
jsreport init
jsreport configure
jsreport start

You can also download compiled binary or pull from the official docker images. See https://jsreport.net/on-prem for the details.

Documentation

See the https://jsreport.net/learn for an overview of concepts, guides, clients, and general documentation.

Extensions

The jsreport official distribution in npm, docker, or compiled binary includes the most commonly used extensions. However, the list of available extensions is much longer, and you may want to install some of the missing ones as well. See the list of available packages here or in the documentation.

You are also not limited to extensions we provide to you. You can implement your extensions. See the Implementing custom extension article.

Node.js

You can find documentation for adapting this jsreport distribution using nodejs and also information for integrating it into an existing nodejs application in the article adapting jsreport.

The official jsreport distribution wires the most popular extensions into the ready-to-use package. However, if you are skilled, you are free to start from the ground using jsreport-core.

Development

We use yarn to manage the monorepo. The basic workflow is the following

git clone https://github.com/jsreport/jsreport
yarn install
yarn start

The tests for the individual package runs the following way

yarn workspace @jsreport/jsreport-scripts test

The studio extensions development with the hot reload can be started using

set NODE_ENV=jsreport-development&&yarn start

Roadmap

  • adding more features to docx/pptx/xlsx recipes
  • pdf compression
  • version control extension direct git integration and improvements
  • studio editor intellisense
  • html-to-xlsx - images, filters...

More in the backlog.

Missing a feature? Submit a feature request.

Vulnerabilities

We guarantee every release is stable and has 0 vulnerabilities mentioned in the npm audit. Please wait until we release the next version with the dependencies update when you see a security warning in your audit. There is no need to create a ticket for it. In case you see a direct impact on jsreport security that you can replicate, please send us an email to [email protected] and we will make sure it's fixed ASAP. Note there is no need to panic when there is a vulnerability mentioned in the audit because it is the most likely in the code path that is not used. A typical example of a vulnerability is an eventual DDoS attack through a dependency parsing some internal config, which in fact can't happen and isn't a vulnerability at all.

Licensing

Copyright (C) 2023 Jan Blaha

Do you want to use jsreport for a personal purpose, in a school project or a non-profit organization? Then you don't need the author's permission, just go on and use it. You can use jsreport without the author's permission also when having a maximum 5 templates stored in jsreport storage.

For commercial projects using more than 5 stored report templates see Pricing page.

Under any of the licenses, free or not, you are allowed to download the source code and make your own edits.

In every case, there are no warranties of any kind provided:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

jsreport's People

Contributors

ankit-github avatar bjrmatos avatar brendon1982 avatar davidrobertsorbis avatar gitter-badger avatar houldsg avatar jonathanhds avatar jorisdebock avatar kanalnik avatar lukashavrlant avatar notatestuser avatar pdecat avatar pofider avatar reediculous456 avatar smtx avatar vmikeska avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsreport's Issues

how to enable Authentication in jsreport

Install latest jsreport

after that i tried to enable authentication on my local server following instruction given on http://jsreport.net/learn/authentication

but not able to get login screen

my prod.config.json is

{
"authentication" : {
"cookieSession": {
"secret": "dasd321as56d1sd5s61vdv32",
"cookie": {
"domain": "192.168.177.10"
}
},
"admin": {
"username" : "nav",
"password": "test123N"
}
},
"cookieSession": {
"secret": "dasd321as56d1sd5s61vdv32",
"cookie": { "domain": "192.168.177.10" }
},
"certificate": {
"key": "certificates/jsreport.net.key",
"cert": "certificates/jsreport.net.cert"
},
"connectionString": { "name": "neDB" },

"httpPort": 3000,
"blobStorage": "fileSystem",
"cluster": {
  "numberOfWorkers": 2,
  "enabled":  false
},
"phantom": {
    "numberOfWorkers" : 2,
    "timeout": 180000
},
"tasks": {
    "numberOfWorkers" : 2,
    "timeout": 10000
},

"tempDirectory": "/root/node_modules111/",
"rootDirectory": "/root/node_modules/",

//"extensions": ["excel-parser", "express", "templates", "html", "phantom-pdf", "scripts", "data", "images", "statistics", "reports", "childTemplates", "sample-template", "authentication"]

}

Getting error on calling Report REST API

When doing a POST on https://localhost:4000/api/report from RESTCLient in Firefox, the following error is appearing in the console:
2014-07-30T09:17:16.037Z - error: Error during processing request: https://localhost:4000/api/report details: Could not parse report template, aren't you missing content type? undefined

The following is the body being sent in the POST request:
{
"template": { "shortid" : "W13faln1W" },
["options": { "saveResult" : "true" }]
}

When printing the request body in the console it is empty.

Child templates and helper data

I'm using helpers to request data to be rendered through an ajax call.
However it seems that this data is not passed on to the child templates.

Is this expected/desired behaviour?

Debugging

jsreport currently spins up child processes to evaluate report rendering. This freezes debugging session in webstorm.

It would be nice to be able to start jsreport without child processes and do the debugging. Consider a configuration option for this.

Layout templates and context based resolution of templates

Hi,

We currently have a .NET application where we use Razor views for the rendering of the emails that we send. We also use Microsoft Reports RDLC reports for rendering invoices and other documents. We'd like to move to jsreport for this as it seems perfect for this. However we like the ability of Razor views to define a layout template that is wrapped around a rendered template. Jsreport offers support for child templates, and I suppose the same could be achieved by rendering a "header" child template at the top of your template and a "footer" child template at the bottom, but something like {{ layout MyLayout }} would be nice and declarative I feel.

I suppose this is feasible by writing an extension, similar to childTemplates? I'd be up for contributing that, but I have no experience in node development.

Would it be correct to say I'd have to:

  1. Hook into handleBeforeRender,
  2. Test it the template contains the {{ layout }} tag
  3. If so render that template
  4. Back in handleBeforeRender replace {{ layout }} with nothing
  5. Let the main template be rendered
  6. Somehow replace a placeholder in the layout body with the rendered main template
  7. Profit?

To be clear, I'm suggesting something like:

Layout:

<html>
<body>
{{ body }}
</body>
</html>

Main template:

{{ layout MyLayout }}
<p>Hello world</p>

Or would you do this in some other way?

My second question is about how to resolve (child)templates dynamically based on context. Currently, our Razor views are resolved based on the context of the current user; mainly his preferred language. The views are organized in a folder structure, something like:

views/
    shared/
        nl/
            Layout.cshtml
        en/
            Layout.cshtml
        de/
            Layout.cshtml
    orders/
        nl/
            OrderShipped.cshtml
        en/
            OrderShipped.cshtml
        de/
            OrderShipped.cshtml
    partials/
        nl/
            CustomerAddress.cshtml
        en/
            CustomerAddress.cshtml
        de/
            CustomerAddress.cshtml

When we want to send an "your order is shipped" mail, we look at the language of the current user and find the right "OrderShipped.cshtml" mail and render it. That template contains a declaration that it uses Layout.cshtml for its layout so we resolve the right Layout based on the language and it also renders a partial (a child template) for a customer's address that is shared between templates so we resolve the right one for that.

The first step of finding the right OrderShipped would be no problem with jsreport, but how would this work for the child templates and (my proposed) layout templates?

Would really appreciate some help here :)

Start with pm2 [on premise]

I have problems starting jsreport on premise with "pm2".
I did install it on an ubuntu server. The client is node with jsreport-client.

After starting with pm2 start --name jsreport server.js, when I run a report, the client throws an Error: connect ECONNREFUSED.
When I start it with node server.js, everything works fine.

Do you know why or have a workaround?

Should be empty: []

After installing jsreport, I found out the app take longer to load, and it give me this message on the console:

Should be empty: []

Anything to do with the configuration?

End user report customization

This is the highest requested feature and should be the breaking one. The main goal is to bring jsreport into the end user's browser. This means report customization will not be exclusive job for the jsreport integrator but it will give opportunity to the end users to customize invoices or what ever other report.

We will start simple in the first phase and provide just a simple report editor similar to one in jsreport studio. Later we may build a full WYSIWYG editor on the top of it.

Concept

External web application embedding jsreport will download some jsreport init scripts first. When the user reaches a particular page or a button application triggers opening a lightweight jsreport designer. The designer will popup in the specified placeholder or in the dialog. The user should be able to preview and customize report there and save it back.

Designer

jsreport lightweight designer could be the same as the playground simplified studio. We only need to make it smaller so it fit to the placeholder.

Security

We want to support also the scenario where jsreport is used in the multitenant environment. For this is crucial to guarantee that one tenant cannot see the templates from the other tenant and so on. This should be at least partially supported in jsreport otherwise every application needs to implement some kind of a authentication proxy in front of jsreport.

Mirroring users from another system or calling another authentication service is maybe an overhead at least for now. Let's provide security in easier way.

First, on premise version must get some kind of an admin account authentication. Admin should be specified in the standard config.

External application then should be able to call a specific jsreport REST method to get a restricted permission token for some specified id. The id can be a tenant id or user id of the external application. Retrieved token will then used when creating and accesing jsreport. jsreport will filter by the token only objects that were create with particular id.

Widgets

We should not stick just to pdf reports. User should be able to easily design html live widgets running in the browser because it will be quite a quick win when we already have preview mechanisms and editor. The difference will be that recipe, javascript templating engine and script evaluation will run in the browser opposite to the typical server side rendering. We will introduce a client html recipe responsible for this.

jsreport server will be just a widget storage in this scenario. But where are widgets will be pdf printing required and a lot of work for jsreport server.

Implementation

Tasks need to be implemented:

  1. enable CORS on the jsreport
  2. test a playground jsreport studio embedding into an external web applications
  3. add admin user authentication through config file
  4. implement restricted permissions
  5. implement client side html recipe

Purge temporary files

The proposed solution:

  • clean temp folder when bootstrapping server
  • remote temp pdf and html file after stream is closed

API jsonData request problem/question

Hi, there, I am still learning JSReport so please bare with me. The question/issue I have might be due to a lack of understanding of how the jsreport server work. I am not totally sure.

Basically I am trying to make an API request to a report and passing the data via the jsonDATA . I assumed that you either use the JSONDATA or supply a shortid in Data section to denote which data set you want to use.

So here is my report:
report

Here is what the API says:
report-api

Here is a working API request when I reference shortID of the saved Data
request-working

But when I switch over to using JSONData, it stops working
request-notworking2

Am I doing something wrong?

Thanks
Ying

Using html-to-xlsx recipe

Hello,
I have been using jsreport for node js, I wish to use the html-to-xlsx recipe but always get this error:
Recipe html-to-xlsx not found, it was added in the config file in extensions property, there is a folder named html-to-xlsx too, but no success I cant find the way to generate the report.

Please tellme what is wrong here, I have tested it in windows 7 and ubuntu os

Windows 8.1 high dpi issue when generate pdf

Hi
I'm trying generate report on my dev laptop, but with default windows scaling settings everything in pdf looks too small.
When I disable windows scaling and restart pc, everything looks fine. It's not real solution, because every app now looks too small. It's really hard to read something.
Could you please resolve problem?

feature request - jade

Any chance that you can provide support for jade templating instead or raw html ?

It would be great if you could !

Automatic report preview inside studio

jsreport studio could be automatically previewing report after change.

This behavior should be configurable.
It should discard reports that fails during typing.

Scripts killing node process not retuning the exception text

A custom script (scripts extension) can easily kill node.js worker process where it runs. This is handled by jsreport core and particular worker is recycled so other scripts can continue to run. This is fine but the user doesn't get the exception message when it ends badly like this and what is even worse he gets very misleading ECONNRESET error.

Would be nice to return to the user the exception which caused the script to fail.

Set PDF title and metadata

Is it possible to set a title for the generated PDF?
Similarly but less important, is it possible to set metadata such as the author or subject fields?

I'm using Phantom calling from NodeJS.

Feature Request: Allow ordering of child templates before rendering

It would be great to be able to specify the order of child templates before rendering, e.g.:

Child Template 1: "Hello World"
Child Template 2: "Foo"
Child Template 3: "Bar"
Child Template 4: "Baz"

data: {reportSections: [1, 2, 3, 4]}
//returns "Hello World Foo Bar Baz"

data: {reportSections: [4, 3, 1]}
//returns "Baz Bar Hello World"

Avoid clearing os temp folder

jsreport tries to clear os temp folder when running as a part of node.js application.
It should rather create it's own folder and clear it.

rootDirectory

from prod.config.json rootDirectory node is not working although this is working as for js code

require('jsreport').bootstrapper({ httpPort: 3000, rootDirectory: '/root/node_modules/' }).start();

socket hang up during rendering

Hi Guys,
In a new deployment I get "socket hang up" error whenever I run the Sample report template. It takes several minutes before throwing this error!

Error occured - Error during rendering report: socket hang up
Stack - Error: socket hang up
at createHangUpError (http.js:1473:15)
at Socket.socketOnEnd as onend
at Socket.g (events.js:180:16)
at Socket.emit (events.js:117:20)
at _stream_readable.js:944:16
From previous event:
at Reporter.render (/opt/jsreport/node_modules/jsreport/lib/reporter.js:146:8)
at /opt/jsreport/node_modules/jsreport/extension/express/lib/routes.js:139:18
at Layer.handle as handle_request
at next (/opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/route.js:110:13)
at Route.dispatch (/opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/route.js:91:3)
at Layer.handle as handle_request
at /opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/index.js:267:22
at Function.proto.process_params (/opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/index.js:321:12)
at next (/opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/index.js:261:10)
at /opt/jsreport/node_modules/jsreport/extension/authentication/lib/authentication.js:165:20
at Layer.handle as handle_request
at trim_prefix (/opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/index.js:302:13)
at /opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/index.js:270:7
at Function.proto.process_params (/opt/jsreport/node_modules/jsreport/node_modules/express/lib/router/index.js:321:12)

problem with Excel rendering

I have a template that call external data like this (thanks to Jan Blaha, works great with version 0.2.4):

    function beforeRender(done) {
      var req = require('request');
      req.get({ url: 'http://localhost:8282/api/users', json:true }, function (err, response, body) {       
        request.data = { items : body };
        done();
      });
    }

Everything works ok with html recipe but I get an error on preview pane (Sorry, cannot find the file).

Pdf report not working with forever

I try to deploy it to production using forever, and the PDF report does not load at all:

I have a default prod.config.json:

{
    "certificate": {
        "key": "certificates/jsreport.net.key",    
        "cert": "certificates/jsreport.net.cert"
    },
    "connectionString": { "name": "neDB" },
    "httpsPort": 443,
    "blobStorage": "fileSystem",
    "cluster": {
      "numberOfWorkers": 2,
      "enabled":  false
    },
    "phantom": {
        "numberOfWorkers" : 2,
        "timeout": 180000
    },
    "tasks": {
        "numberOfWorkers" : 2,
        "timeout": 10000
    }
}

report.render hang most of the time

I am using jsreport with jade and express, but most of time it hang during report.render stage. I have no clue why?

         var html = jade.renderFile(path.resolve(__dirname + '/..') + '/views/report/report.jade',  JSON.parse(data));

                report.render({
                    template:{
                        content: html,
                        phantom: {
                            footer: "<div style='text-align:center'>{#pageNum}/{#numPages}</div>"
                        }
                    }
                }).then(function (out) {
                    out.result.pipe(res);
                });

pdf does not render when using with helmet

I am using helmet, now the pdf does load on the browser in pdf format, but is it garbage string.
Now the content type is hidden:

X-Content-Type-Options:nosniff

How can I present in pdf format using :

out.result.pipe(res);

Allow jsreport to run without https

Currently you can run jsreport on premise only on https. This behavior should be configurable and jsreport should be able to run just on http.

Can I use jsreport with bootstrap

When I try to generate PDFreport with html and bootstrap, it does not work.

Can I use stylesheet link when generate a report? Or do I have to write my css inside the html?

jsreport phantom render shortcut froze on unix based platforms

The shortcut usage of jsreport froze on unix based platforms.

//this will timeout when called
require("jsreport").render("<h1>Hello world</h1>").then(function(out) {
    out.result.pipe(resp);
});

The problem is that we are sending request to phantom-js server before it is actually created. This is not normally happening because report is not being rendered immediately after jsreport init.

Workaround to this bug is to initialize Reporter instance on your own

var jsreport = require('jsreport');
jsreport.bootstrapper(jsreport.renderDefaults).start().then(function(conf) {
  var http = require('http');
  http.createServer(function (req, res) {
    conf.reporter.render("<h1>Hello world</h1>").then(function(out) {
      out.result.pipe(res);
    }).fail(function(e) {
       console.log(e);
    });
  }).listen(80);
});

Bugs in the 0.4.0 release

We built a new server with the 0.4.0 release. The HTML-To-XLSX rendering is creating a non-valid XLSX doc. The Phantom PDF generation was still fine. We also tried the 0.3.0 release and noticed that the server was crashing on any render. Our code is the same as #56

We ended up reverting to the 0.2.10 release in order to get both Phantom PDF and XLSX generation to work properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.