@docbrasil/api-systemmanager 1.1.23 → 1.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/user/dashboard.js +150 -0
- package/api/user/index.js +2 -0
- package/dist/bundle.cjs +5 -2
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +59 -0
- package/docs/Admin.html +1 -1
- package/docs/AdminDocuments.html +1 -1
- package/docs/AdminForm.html +1 -1
- package/docs/AdminLists.html +1 -1
- package/docs/AdminMessage.html +1 -1
- package/docs/AdminNotification.html +1 -1
- package/docs/AdminPlugin.html +1 -1
- package/docs/AdminPolicy.html +1 -1
- package/docs/AdminProcesses.html +1 -1
- package/docs/AdminTask.html +1 -1
- package/docs/AdminUser.html +1 -1
- package/docs/Application.html +1 -1
- package/docs/Chart.html +528 -0
- package/docs/Dashboard.html +349 -0
- package/docs/Datasource.html +1 -1
- package/docs/Dispatch.html +1 -1
- package/docs/Documents.html +1 -1
- package/docs/External.html +1 -1
- package/docs/GeoLocation.html +1 -1
- package/docs/Help.html +1 -1
- package/docs/Login.html +1 -1
- package/docs/MyTasks.html +1 -1
- package/docs/Notification.html +1 -1
- package/docs/Organization.html +1 -1
- package/docs/Page.html +1 -1
- package/docs/Process.html +1 -1
- package/docs/Register.html +1 -1
- package/docs/Session.html +1 -1
- package/docs/Settings.html +1 -1
- package/docs/Task.html +1 -1
- package/docs/TaskAvailable.html +1 -1
- package/docs/Updates.html +1 -1
- package/docs/User.html +1 -1
- package/docs/Users.html +2 -2
- package/docs/admin_doctypes.js.html +1 -1
- package/docs/admin_document.js.html +1 -1
- package/docs/admin_form.js.html +1 -1
- package/docs/admin_index.js.html +1 -1
- package/docs/admin_list.js.html +1 -1
- package/docs/admin_message.js.html +1 -1
- package/docs/admin_notification.js.html +1 -1
- package/docs/admin_organization.js.html +1 -1
- package/docs/admin_plugin.js.html +1 -1
- package/docs/admin_policy.js.html +1 -1
- package/docs/admin_processes.js.html +1 -1
- package/docs/admin_task.js.html +1 -1
- package/docs/admin_user.js.html +1 -1
- package/docs/dispatch.js.html +1 -1
- package/docs/external.js.html +1 -1
- package/docs/general_geoLocation.js.html +1 -1
- package/docs/general_index.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/login.js.html +1 -1
- package/docs/session.js.html +1 -1
- package/docs/user_application.js.html +1 -1
- package/docs/user_dashboard.js.html +267 -0
- package/docs/user_datasource.js.html +1 -1
- package/docs/user_document.js.html +1 -1
- package/docs/user_help.js.html +1 -1
- package/docs/user_index.js.html +3 -1
- package/docs/user_my_tasks.js.html +1 -1
- package/docs/user_notification.js.html +1 -1
- package/docs/user_organization.js.html +1 -1
- package/docs/user_page.js.html +1 -1
- package/docs/user_process.js.html +1 -1
- package/docs/user_register.js.html +1 -1
- package/docs/user_settings.js.html +1 -1
- package/docs/user_task.js.html +1 -1
- package/docs/user_task_available.js.html +1 -1
- package/docs/user_updates.js.html +1 -1
- package/docs/user_user.js.html +1 -1
- package/docs/utils_promises.js.html +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class user access to charts
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class Chart {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
Joi.assert(options, Joi.object().required());
|
|
12
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
13
|
+
|
|
14
|
+
const self = this;
|
|
15
|
+
self.parent = options.parent;
|
|
16
|
+
self._client = self.parent.dispatch.getClient();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
21
|
+
* @description Get the return data and check for errors
|
|
22
|
+
* @param {object} retData Response HTTP
|
|
23
|
+
* @return {*}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
_returnData(retData, def = {}) {
|
|
27
|
+
if (retData.status !== 200) {
|
|
28
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
29
|
+
} else {
|
|
30
|
+
return _.get(retData, 'data', def);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
36
|
+
* @description Set header with new session
|
|
37
|
+
* @param {string} session Session, token JWT
|
|
38
|
+
* @return {object} header with new session
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
_setHeader(session) {
|
|
42
|
+
return {
|
|
43
|
+
headers: {
|
|
44
|
+
authorization: session,
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
51
|
+
* @description Get the data for a chart
|
|
52
|
+
* @param {object} params Params to get helps from topic
|
|
53
|
+
* @param {object} params.type Type of the chart data
|
|
54
|
+
* @param {object} params.query The query if any
|
|
55
|
+
* @param {string} session Session, token JWT
|
|
56
|
+
* @returns {promise}
|
|
57
|
+
* @public
|
|
58
|
+
* @example
|
|
59
|
+
*
|
|
60
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
61
|
+
* const api = new API();
|
|
62
|
+
* const params = {
|
|
63
|
+
* type: 'heatmap_data'
|
|
64
|
+
* };
|
|
65
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
66
|
+
* await api.user.dashboard.chart.getData(params, session);
|
|
67
|
+
*/
|
|
68
|
+
async getData(params, session) {
|
|
69
|
+
const self = this;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
Joi.assert(params, Joi.object().required(), 'Params to helps from a topic');
|
|
73
|
+
Joi.assert(params.type, Joi.string().required(), 'Type of graph');
|
|
74
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
75
|
+
|
|
76
|
+
const { type, query = {} } = params;
|
|
77
|
+
const apiCall = self._client.post(`/organizations/dashboard/chart/data/${type}`, query, self._setHeader(session));
|
|
78
|
+
|
|
79
|
+
return self._returnData(await apiCall);
|
|
80
|
+
} catch (ex) {
|
|
81
|
+
throw ex;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Class user access to dashboards
|
|
88
|
+
* @class
|
|
89
|
+
*/
|
|
90
|
+
class Dashboard {
|
|
91
|
+
|
|
92
|
+
constructor(options) {
|
|
93
|
+
Joi.assert(options, Joi.object().required());
|
|
94
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
95
|
+
|
|
96
|
+
const self = this;
|
|
97
|
+
self.parent = options.parent;
|
|
98
|
+
self._client = self.parent.dispatch.getClient();
|
|
99
|
+
self._chart = new Chart(options);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
104
|
+
* @description Get the return data and check for errors
|
|
105
|
+
* @param {object} retData Response HTTP
|
|
106
|
+
* @return {*}
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
_returnData(retData, def = {}) {
|
|
110
|
+
if (retData.status !== 200) {
|
|
111
|
+
return Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
112
|
+
} else {
|
|
113
|
+
return _.get(retData, 'data', def);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
119
|
+
* @description Set header with new session
|
|
120
|
+
* @param {string} session Session, token JWT
|
|
121
|
+
* @return {object} header with new session
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
_setHeader(session) {
|
|
125
|
+
return {
|
|
126
|
+
headers: {
|
|
127
|
+
authorization: session,
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
134
|
+
* @description return the chart
|
|
135
|
+
* @public
|
|
136
|
+
* @async
|
|
137
|
+
* @example
|
|
138
|
+
*
|
|
139
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
140
|
+
* const api = new API();
|
|
141
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
142
|
+
* await api.user.help.getTopics({}, session);
|
|
143
|
+
*/
|
|
144
|
+
get chart() {
|
|
145
|
+
const self = this;
|
|
146
|
+
return self._chart;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default Help;
|
package/api/user/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import Help from './help.js';
|
|
|
13
13
|
import Datasource from './datasource.js';
|
|
14
14
|
import Application from './application.js';
|
|
15
15
|
import Settings from './settings.js';
|
|
16
|
+
import Dashboard from './dashboard.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @class API request, user permission level
|
|
@@ -41,6 +42,7 @@ class Users {
|
|
|
41
42
|
self.updates = new Updates(options);
|
|
42
43
|
self.help = new Help(options);
|
|
43
44
|
self.application = new Application(options);
|
|
45
|
+
self.dashboard = new Dashboard(options);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
package/dist/bundle.cjs
CHANGED
|
@@ -10446,7 +10446,7 @@ class Updates {
|
|
|
10446
10446
|
* Class for user registration in a user
|
|
10447
10447
|
* @class
|
|
10448
10448
|
*/
|
|
10449
|
-
class Help {
|
|
10449
|
+
class Help$1 {
|
|
10450
10450
|
|
|
10451
10451
|
constructor(options) {
|
|
10452
10452
|
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
@@ -11002,6 +11002,8 @@ class Settings {
|
|
|
11002
11002
|
}
|
|
11003
11003
|
}
|
|
11004
11004
|
|
|
11005
|
+
var Dashboard = Help;
|
|
11006
|
+
|
|
11005
11007
|
/**
|
|
11006
11008
|
* @class API request, user permission level
|
|
11007
11009
|
*/
|
|
@@ -11027,8 +11029,9 @@ class Users {
|
|
|
11027
11029
|
self.register = new Register(options);
|
|
11028
11030
|
self.notification = new Notification(options);
|
|
11029
11031
|
self.updates = new Updates(options);
|
|
11030
|
-
self.help = new Help(options);
|
|
11032
|
+
self.help = new Help$1(options);
|
|
11031
11033
|
self.application = new Application(options);
|
|
11034
|
+
self.dashboard = new Dashboard(options);
|
|
11032
11035
|
}
|
|
11033
11036
|
}
|
|
11034
11037
|
|