Giter VIP home page Giter VIP logo

sane-reports's Introduction

Sane Reports by Demisto

CircleCI Coverage Status

Reports library that will keep you sane and not pulling your hair out

Quick start

Chromium/Chrome

$ npm install sane-reports
$ npm run make
$ ./reportsServer templates/test.json dist/test.pdf # for linux users.
$ ./reportsServer-macos templates/test.json dist/test.pdf # for macOS users.
$ ./reportsServer-win.exe templates/test.json dist/test.pdf # for windows users.

PhantomJS

$ npm install sane-reports
$ cd sane-reports
$ phantomjs reportsServer.js templates/test.json dist/test.pdf

Report will be generated in: dist/test.pdf

Generating dashboard mode (browser) report

$ git clone [email protected]:demisto/sane-reports.git
$ cd sane-reports
$ npm install
$ npm start

Now open browser at: http://localhost:8082

Generating PDF report

$ git clone [email protected]:demisto/sane-reports.git
$ cd sane-reports
$ npm install
$ npm run production
$ npm run generate-report

This will generate a PDF report in the dist folder. The name of the report will start with report-.

Generate report options:

You can create PDF report with the following command as well:

Chromium/Chrome

./reportsServer <report_template_file> [<output_file> <dist_folder> <orientation> <resourceTimeout> <type> <headerLeftImage> <headerRightImage> <customReportType> <pageSize> <disableTopHeaders> <chromiumPath>]

PhantomJS

phantomjs reportServer.js <report_template_file> [<output_file> <dist_folder> <orientation> <resourceTimeout> <type> <headerLeftImage> <headerRightImage> <customReportType> <pageSize> <disableTopHeaders>]

  • report_template_file: The template of the report (JSON format)
  • output_file: The name of the generated report (leave empty for default name)
  • dist_folder: should be dist
  • orientation: The orientation of the report: portrait/landscape (default portrait)
  • resourceTimeout: Timeout for generating the report (default is 4000ms)
  • type: The report type: pdf or csv (default is pdf)
  • headerLeftImage: The image to show at the left side of the report header of each page (base64 or url)
  • headerRightImage: The image to show at the right side of the report header of each page (base64 or url)
  • customReportType: Custom report type if needed. currently not used.
  • pageSize: The report page size to generate. Possible: A4, A3, A5, letter (default A4).
  • disableTopHeaders: true or "true" to disable the top headers and show icons in the footer. (default false)
  • chromiumPath: a custom chromium or chrome path. The service searches for installed chromium or chrome by order. Default usage by priority: Chromium -> Google Chrome Stable -> Google Chrome -> the default path '/usr/bin/chromium-browser'.

Example:

  • npm run production
  • npm run make
  • /reportsServer-macos templates/incidentDailyReportTempalte.json dist/incidentDailyReportTempalte.pdf dist portrait 4000 pdf '' '' '' A4 '' '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'

Debugging

  • Download the mamba-reports.patch
  • Apply the patch (In WebStorm: git -> patch -> apply patch...)
  • Debug the server and add a breakpoint in the beginning of the method servicereport.go/generatePdfReport
  • genereta a PDF report from the UI (web-client)
  • when it stops on the breakpoint:
    • refresh the files in Debug/lib/temp (right click -> reload from disk)
    • copy the last json content from the server folder to incidentDailyReportTemplate.json
    • while the project is running (npm start) the page will be auto-reloaded at localhost:8082

Demo

Reports templates (JSON) examples can be found in the templates folder.

Example reports outputs can be found in the examples folder.

Create your own report template

You can edit existing report templates or create your own template. Report templates are created in JSON format and includes sections. Sections are ordered according to their row and column positions.

Section types: Header, Divider, Date, Image, JSON, Markdown, Table, Text, Bar Chart, Line Chart, Pie Chart, HTML, List, Grouped List, Items Section.

Each section can have its own style (camled case css style: font-size -> fontSize).

Important notice:

HTML sections use dangerouslySetInnerHTML to set the given text as html. This method may cause a security risk, so before using, please validate the source of the text, and use with cautious at your own risk.

Contributor License Agreement

Contributions are welcome and appreciated. To contribute follow the Quick Start section and submit a PR.

Before merging any PRs, we need all contributors to sign a contributor license agreement. By signing a contributor license agreement, we ensure that the community is free to use your contributions.

When you open a new pull request, a bot will evaluate whether you have signed the CLA. If required, the bot will comment on the pull request, including a link to accept the agreement. The CLA document is also available for review as a PDF.

License

demisto/sane-reports is licensed under the Apache License 2.0

sane-reports's People

Contributors

bars92 avatar davidbinyamin avatar dependabot[bot] avatar dorsha avatar glicht avatar h88 avatar ikademisto avatar ikidon avatar itayronen avatar lmichalevich avatar nitzperetz avatar revahh avatar shaniacht1 avatar sivanisentinel avatar slav4ik avatar slavikm avatar yanyo87 avatar yonatan-roth avatar

Watchers

 avatar

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.