Administrator tools

Creating reports

Create a Health Department report for the current month - how many requests were closed.

On the Administrator menu (UI / Reports) Create a new report

report_creating

In the TEMPLATE section, create a data output template using the mustache template
https://github.com/janl/mustache.js#variables

The template is written in a simple language consisting of several types of tags. Tags are framed by two or three braces on each side. You can use nested templates.
Data that the template works with is called a context. The tag name indicates to which context field it is necessary to address.
There are four basic types of tags in Mustache: variable, section, comment and connection of an additional template.

  • The variable outputs data with escaping the HTML entities {{header}} and without escaping {{{content}}}. They differ in the number of brackets.
  • The section is a paired tag. The principle of its operation depends on the type of data with which it operates. If there is a combo box in the context of the section name, the template passes through its elements and the text inside the pair tag is processed once for each list item. A list item is substituted for a tag point. If the function name matches the function, then the result of its execution will be used for the substitution. If the field corresponding to the section name is neither a list nor a function, it will be used as the context for processing the contents of the tag.
  • The comment is made in the form of a tag with an exclamation mark, for example, {{! Comment content}}.

To describe a section for a table row, in the first column, double-click or select it in the Edit / Section menu.

Use the editor to build such a template

report_template

As a result, you should get code like this (Tools / Source code)

<h1 style="text-align: center;">Request List current month</h1>
<p><span style="font-size: 12pt;">current month: {{curMonth}} , year: 2017</span></p>
<p><span style="font-size: 14pt;">Closed requests</span></p>
<table style="word-break: break-all; width: 779px;" border="1px" width="779px" cellspacing="0" cellpadding="3px">
<tbody>
<tr>
<td style="width: 808px; cursor: w-resize; text-align: center;"><strong><span style="font-size: 10pt;">Request date</span></strong></td>
<td style="width: 772px; cursor: default; text-align: center;"><strong><span style="font-size: 10pt;">Applicant info</span></strong></td>
<td style="width: 772px; cursor: default; text-align: center;"><strong><span style="font-size: 10pt;">Request text</span></strong></td>
<td style="width: 760px; cursor: default; text-align: center;"><strong><span style="font-size: 10pt;">Answer</span></strong></td>
</tr>
<!--{{#req_reqList}}-->
<tr>
<td class=" tinymce_templated_td" style="width: 808px; cursor: w-resize;">{{reqDate}}</td>
<td style="width: 772px;">{{applicantInfo}}</td>
<td style="width: 772px;">{{reqText}}</td>
<td style="width: 760px; cursor: w-resize;">{{answer}}</td>
</tr>
<!--{{/req_reqList}}-->
</tbody>
</table>

In the CODE section, you need to describe the operation of the template and getting the data.
To request data from the database, use the Repository for the client side.
Documents reference
https://unitybase.info/api/adminUI/#!/api/ClientRepository

Add this code to the CODE section

exports.reportCode = {
buildReport: function(reportParams){
  var me = this

  var today = new Date(),
  curMonth = today.getMonth();
  var mBegin = new Date(today.getFullYear(), today.getMonth(), 1) //Get first date of current month
  var mEnd = new Date(today.getFullYear(), today.getMonth()+1, 1) //Get first date of next month

  return UB.Repository('req_reqList')
    .attrs(['reqDate', 'applicantInfo', 'reqText','answer','status'])
	.where('department','equal', 331308542722153) //Set your departments ID from Departmments form!!
    .where('status', 'equal', 'CLOSED') //get closed requests
    .where('reqDate', '>=', mBegin) //get requests in current month
    .where('reqDate', '<', mEnd)
  	.selectAsObject()
    .then( function (resp) {
	  var data = {
		req_reqList: resp,
                curMonth: curMonth + 1
      }
      var result = me.buildHTML(data);
       if (me.reportType === 'pdf') {
          result = me.transformToPdf(result);
      }
      return result;
    })
}
};

Save the template and test it using the Test button.
The template and the code to it are stored in the `models\requests\public\reports' folder - you can remove templates from there only manually.

Creating diagramm entity

For a visual display of the links between entities of the model we use the Diagrams tool in the Administrator/UI/ER diagrams menu.
To use ER diagrams you must install the @ub-e/ube-pub package
npm install --save @ub-e/ube-pub

Configure UBE model in ubConfig.json

{
     "name": "UBE",
     "publicPath": "./node_modules/@ub-e/ube-pub",
     "path": "_public_only_",
     "moduleName": "@ub-e/ube-pub"
    },
   /// ...
    

Restart the UB Server after configuring.

Construct a diagram using visual components.

diagram_creating

Audit

Audit of occurring processes in the system can be performed on the Security page.

audit

On the Audit item, you can perform a customized action search, and on the Security audit page, all processes are listed as a list.
Find all the updates made by the admin user during this week in the RequestList model.
Next step