...
|
...
|
@@ -17,8 +17,11 @@ package org.thingsboard.server.controller; |
17
|
17
|
|
18
|
18
|
import com.fasterxml.jackson.databind.JsonNode;
|
19
|
19
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
20
|
+import io.swagger.annotations.ApiOperation;
|
|
21
|
+import io.swagger.annotations.ApiParam;
|
20
|
22
|
import org.springframework.beans.factory.annotation.Value;
|
21
|
23
|
import org.springframework.http.HttpStatus;
|
|
24
|
+import org.springframework.http.MediaType;
|
22
|
25
|
import org.springframework.security.access.prepost.PreAuthorize;
|
23
|
26
|
import org.springframework.web.bind.annotation.PathVariable;
|
24
|
27
|
import org.springframework.web.bind.annotation.RequestBody;
|
...
|
...
|
@@ -68,11 +71,16 @@ public class DashboardController extends BaseController { |
68
|
71
|
|
69
|
72
|
private static final String HOME_DASHBOARD_ID = "homeDashboardId";
|
70
|
73
|
private static final String HOME_DASHBOARD_HIDE_TOOLBAR = "homeDashboardHideToolbar";
|
|
74
|
+ public static final String DASHBOARD_INFO_DEFINITION = "The Dashboard Info object contains lightweight information about the dashboard (e.g. title, image, assigned customers) but does not contain the heavyweight configuration JSON.";
|
|
75
|
+ public static final String DASHBOARD_DEFINITION = "The Dashboard object is a heavyweight object that contains information about the dashboard (e.g. title, image, assigned customers) and also configuration JSON (e.g. layouts, widgets, entity aliases).";
|
|
76
|
+ public static final String HIDDEN_FOR_MOBILE = "Exclude dashboards that are hidden for mobile";
|
71
|
77
|
|
72
|
78
|
@Value("${dashboard.max_datapoints_limit}")
|
73
|
79
|
private long maxDatapointsLimit;
|
74
|
80
|
|
75
|
|
-
|
|
81
|
+ @ApiOperation(value = "Get server time (getServerTime)",
|
|
82
|
+ notes = "Get the server time (milliseconds since January 1, 1970 UTC). " +
|
|
83
|
+ "Used to adjust view of the dashboards according to the difference between browser and server time.")
|
76
|
84
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
77
|
85
|
@RequestMapping(value = "/dashboard/serverTime", method = RequestMethod.GET)
|
78
|
86
|
@ResponseBody
|
...
|
...
|
@@ -80,6 +88,11 @@ public class DashboardController extends BaseController { |
80
|
88
|
return System.currentTimeMillis();
|
81
|
89
|
}
|
82
|
90
|
|
|
91
|
+ @ApiOperation(value = "Get max data points limit (getMaxDatapointsLimit)",
|
|
92
|
+ notes = "Get the maximum number of data points that dashboard may request from the server per in a single subscription command. " +
|
|
93
|
+ "This value impacts the time window behavior. It impacts 'Max values' parameter in case user selects 'None' as 'Data aggregation function'. " +
|
|
94
|
+ "It also impacts the 'Grouping interval' in case of any other 'Data aggregation function' is selected. " +
|
|
95
|
+ "The actual value of the limit is configurable in the system configuration file.")
|
83
|
96
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
84
|
97
|
@RequestMapping(value = "/dashboard/maxDatapointsLimit", method = RequestMethod.GET)
|
85
|
98
|
@ResponseBody
|
...
|
...
|
@@ -87,10 +100,16 @@ public class DashboardController extends BaseController { |
87
|
100
|
return maxDatapointsLimit;
|
88
|
101
|
}
|
89
|
102
|
|
|
103
|
+ @ApiOperation(value = "Get Dashboard Info (getDashboardInfoById)",
|
|
104
|
+ notes = "Get the information about the dashboard based on 'dashboardId' parameter. " + DASHBOARD_INFO_DEFINITION,
|
|
105
|
+ produces = MediaType.APPLICATION_JSON_VALUE
|
|
106
|
+ )
|
90
|
107
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
91
|
108
|
@RequestMapping(value = "/dashboard/info/{dashboardId}", method = RequestMethod.GET)
|
92
|
109
|
@ResponseBody
|
93
|
|
- public DashboardInfo getDashboardInfoById(@PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
110
|
+ public DashboardInfo getDashboardInfoById(
|
|
111
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
112
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
94
|
113
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
95
|
114
|
try {
|
96
|
115
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -100,10 +119,16 @@ public class DashboardController extends BaseController { |
100
|
119
|
}
|
101
|
120
|
}
|
102
|
121
|
|
|
122
|
+ @ApiOperation(value = "Get Dashboard (getDashboardById)",
|
|
123
|
+ notes = "Get the dashboard based on 'dashboardId' parameter. " + DASHBOARD_DEFINITION,
|
|
124
|
+ produces = MediaType.APPLICATION_JSON_VALUE
|
|
125
|
+ )
|
103
|
126
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
104
|
127
|
@RequestMapping(value = "/dashboard/{dashboardId}", method = RequestMethod.GET)
|
105
|
128
|
@ResponseBody
|
106
|
|
- public Dashboard getDashboardById(@PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
129
|
+ public Dashboard getDashboardById(
|
|
130
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
131
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
107
|
132
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
108
|
133
|
try {
|
109
|
134
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -113,10 +138,20 @@ public class DashboardController extends BaseController { |
113
|
138
|
}
|
114
|
139
|
}
|
115
|
140
|
|
|
141
|
+ @ApiOperation(value = "Create Or Update Dashboard (saveDashboard)",
|
|
142
|
+ notes = "Create or update the Dashboard. When creating dashboard, platform generates Dashboard Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)." +
|
|
143
|
+ "The newly created Dashboard id will be present in the response. " +
|
|
144
|
+ "Specify existing Dashboard id to update the dashboard. " +
|
|
145
|
+ "Referencing non-existing dashboard Id will cause 'Not Found' error. " +
|
|
146
|
+ "Only users with 'TENANT_ADMIN') authority may create the dashboards.",
|
|
147
|
+ produces = MediaType.APPLICATION_JSON_VALUE,
|
|
148
|
+ consumes = MediaType.APPLICATION_JSON_VALUE)
|
116
|
149
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
117
|
150
|
@RequestMapping(value = "/dashboard", method = RequestMethod.POST)
|
118
|
151
|
@ResponseBody
|
119
|
|
- public Dashboard saveDashboard(@RequestBody Dashboard dashboard) throws ThingsboardException {
|
|
152
|
+ public Dashboard saveDashboard(
|
|
153
|
+ @ApiParam(value = "A JSON value representing the dashboard.")
|
|
154
|
+ @RequestBody Dashboard dashboard) throws ThingsboardException {
|
120
|
155
|
try {
|
121
|
156
|
dashboard.setTenantId(getCurrentUser().getTenantId());
|
122
|
157
|
|
...
|
...
|
@@ -141,10 +176,14 @@ public class DashboardController extends BaseController { |
141
|
176
|
}
|
142
|
177
|
}
|
143
|
178
|
|
|
179
|
+ @ApiOperation(value = "Delete the Dashboard (deleteDashboard)",
|
|
180
|
+ notes = "Delete the Dashboard. Only users with 'TENANT_ADMIN') authority may delete the dashboards.")
|
144
|
181
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
145
|
182
|
@RequestMapping(value = "/dashboard/{dashboardId}", method = RequestMethod.DELETE)
|
146
|
183
|
@ResponseStatus(value = HttpStatus.OK)
|
147
|
|
- public void deleteDashboard(@PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
184
|
+ public void deleteDashboard(
|
|
185
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
186
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
148
|
187
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
149
|
188
|
try {
|
150
|
189
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -170,12 +209,19 @@ public class DashboardController extends BaseController { |
170
|
209
|
}
|
171
|
210
|
}
|
172
|
211
|
|
|
212
|
+ @ApiOperation(value = "Assign the Dashboard (assignDashboardToCustomer)",
|
|
213
|
+ notes = "Assign the Dashboard to specified Customer or do nothing if the Dashboard is already assigned to that Customer. " +
|
|
214
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may assign the dashboards to customers.",
|
|
215
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
173
|
216
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
174
|
217
|
@RequestMapping(value = "/customer/{customerId}/dashboard/{dashboardId}", method = RequestMethod.POST)
|
175
|
218
|
@ResponseBody
|
176
|
|
- public Dashboard assignDashboardToCustomer(@PathVariable("customerId") String strCustomerId,
|
177
|
|
- @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
178
|
|
- checkParameter("customerId", strCustomerId);
|
|
219
|
+ public Dashboard assignDashboardToCustomer(
|
|
220
|
+ @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
|
221
|
+ @PathVariable(CUSTOMER_ID) String strCustomerId,
|
|
222
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
223
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
224
|
+ checkParameter(CUSTOMER_ID, strCustomerId);
|
179
|
225
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
180
|
226
|
try {
|
181
|
227
|
CustomerId customerId = new CustomerId(toUUID(strCustomerId));
|
...
|
...
|
@@ -203,11 +249,18 @@ public class DashboardController extends BaseController { |
203
|
249
|
}
|
204
|
250
|
}
|
205
|
251
|
|
|
252
|
+ @ApiOperation(value = "Unassign the Dashboard (unassignDashboardFromCustomer)",
|
|
253
|
+ notes = "Unassign the Dashboard from specified Customer or do nothing if the Dashboard is already assigned to that Customer. " +
|
|
254
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may unassign the dashboards from customers.",
|
|
255
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
206
|
256
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
207
|
257
|
@RequestMapping(value = "/customer/{customerId}/dashboard/{dashboardId}", method = RequestMethod.DELETE)
|
208
|
258
|
@ResponseBody
|
209
|
|
- public Dashboard unassignDashboardFromCustomer(@PathVariable("customerId") String strCustomerId,
|
210
|
|
- @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
259
|
+ public Dashboard unassignDashboardFromCustomer(
|
|
260
|
+ @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
|
|
261
|
+ @PathVariable(CUSTOMER_ID) String strCustomerId,
|
|
262
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
263
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
211
|
264
|
checkParameter("customerId", strCustomerId);
|
212
|
265
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
213
|
266
|
try {
|
...
|
...
|
@@ -235,11 +288,20 @@ public class DashboardController extends BaseController { |
235
|
288
|
}
|
236
|
289
|
}
|
237
|
290
|
|
|
291
|
+ @ApiOperation(value = "Update the Dashboard Customers (updateDashboardCustomers)",
|
|
292
|
+ notes = "Updates the list of Customers that this Dashboard is assigned to. Removes previous assignments to customers that are not in the provided list. " +
|
|
293
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may assign the dashboards to customers.",
|
|
294
|
+ produces = MediaType.APPLICATION_JSON_VALUE,
|
|
295
|
+ consumes = MediaType.APPLICATION_JSON_VALUE)
|
|
296
|
+
|
238
|
297
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
239
|
298
|
@RequestMapping(value = "/dashboard/{dashboardId}/customers", method = RequestMethod.POST)
|
240
|
299
|
@ResponseBody
|
241
|
|
- public Dashboard updateDashboardCustomers(@PathVariable(DASHBOARD_ID) String strDashboardId,
|
242
|
|
- @RequestBody(required = false) String[] strCustomerIds) throws ThingsboardException {
|
|
300
|
+ public Dashboard updateDashboardCustomers(
|
|
301
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
302
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId,
|
|
303
|
+ @ApiParam(value = "JSON array with the list of customer ids, or empty to remove all customers")
|
|
304
|
+ @RequestBody(required = false) String[] strCustomerIds) throws ThingsboardException {
|
243
|
305
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
244
|
306
|
try {
|
245
|
307
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -301,11 +363,19 @@ public class DashboardController extends BaseController { |
301
|
363
|
}
|
302
|
364
|
}
|
303
|
365
|
|
|
366
|
+ @ApiOperation(value = "Adds the Dashboard Customers (addDashboardCustomers)",
|
|
367
|
+ notes = "Adds the list of Customers to the existing list of assignments for the Dashboard. Keeps previous assignments to customers that are not in the provided list. " +
|
|
368
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may assign the dashboards to customers.",
|
|
369
|
+ produces = MediaType.APPLICATION_JSON_VALUE,
|
|
370
|
+ consumes = MediaType.APPLICATION_JSON_VALUE)
|
304
|
371
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
305
|
372
|
@RequestMapping(value = "/dashboard/{dashboardId}/customers/add", method = RequestMethod.POST)
|
306
|
373
|
@ResponseBody
|
307
|
|
- public Dashboard addDashboardCustomers(@PathVariable(DASHBOARD_ID) String strDashboardId,
|
308
|
|
- @RequestBody String[] strCustomerIds) throws ThingsboardException {
|
|
374
|
+ public Dashboard addDashboardCustomers(
|
|
375
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
376
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId,
|
|
377
|
+ @ApiParam(value = "JSON array with the list of customer ids")
|
|
378
|
+ @RequestBody String[] strCustomerIds) throws ThingsboardException {
|
309
|
379
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
310
|
380
|
try {
|
311
|
381
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -345,11 +415,19 @@ public class DashboardController extends BaseController { |
345
|
415
|
}
|
346
|
416
|
}
|
347
|
417
|
|
|
418
|
+ @ApiOperation(value = "Remove the Dashboard Customers (removeDashboardCustomers)",
|
|
419
|
+ notes = "Removes the list of Customers from the existing list of assignments for the Dashboard. Keeps other assignments to customers that are not in the provided list. " +
|
|
420
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may assign the dashboards to customers.",
|
|
421
|
+ produces = MediaType.APPLICATION_JSON_VALUE,
|
|
422
|
+ consumes = MediaType.APPLICATION_JSON_VALUE)
|
348
|
423
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
349
|
424
|
@RequestMapping(value = "/dashboard/{dashboardId}/customers/remove", method = RequestMethod.POST)
|
350
|
425
|
@ResponseBody
|
351
|
|
- public Dashboard removeDashboardCustomers(@PathVariable(DASHBOARD_ID) String strDashboardId,
|
352
|
|
- @RequestBody String[] strCustomerIds) throws ThingsboardException {
|
|
426
|
+ public Dashboard removeDashboardCustomers(
|
|
427
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
428
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId,
|
|
429
|
+ @ApiParam(value = "JSON array with the list of customer ids")
|
|
430
|
+ @RequestBody String[] strCustomerIds) throws ThingsboardException {
|
353
|
431
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
354
|
432
|
try {
|
355
|
433
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -389,10 +467,20 @@ public class DashboardController extends BaseController { |
389
|
467
|
}
|
390
|
468
|
}
|
391
|
469
|
|
|
470
|
+ @ApiOperation(value = "Assign the Dashboard to Public Customer (assignDashboardToPublicCustomer)",
|
|
471
|
+ notes = "Assigns the dashboard to a special, auto-generated 'Public' Customer. Once assigned, unauthenticated users may browse the dashboard. " +
|
|
472
|
+ "This method is useful if you like to embed the dashboard on public web pages to be available for users that are not logged in. " +
|
|
473
|
+ "Be aware that making the dashboard public does not mean that it automatically makes all devices and assets you use in the dashboard to be public." +
|
|
474
|
+ "Use [assign Asset to Public Customer](#!/asset-controller/assignAssetToPublicCustomerUsingPOST) and " +
|
|
475
|
+ "[assign Device to Public Customer](#!/device-controller/assignDeviceToPublicCustomerUsingPOST) for this purpose. " +
|
|
476
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may assign the dashboards to customers.",
|
|
477
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
392
|
478
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
393
|
479
|
@RequestMapping(value = "/customer/public/dashboard/{dashboardId}", method = RequestMethod.POST)
|
394
|
480
|
@ResponseBody
|
395
|
|
- public Dashboard assignDashboardToPublicCustomer(@PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
481
|
+ public Dashboard assignDashboardToPublicCustomer(
|
|
482
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
483
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
396
|
484
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
397
|
485
|
try {
|
398
|
486
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -415,10 +503,16 @@ public class DashboardController extends BaseController { |
415
|
503
|
}
|
416
|
504
|
}
|
417
|
505
|
|
|
506
|
+ @ApiOperation(value = "Unassign the Dashboard from Public Customer (unassignDashboardFromPublicCustomer)",
|
|
507
|
+ notes = "Unassigns the dashboard from a special, auto-generated 'Public' Customer. Once unassigned, unauthenticated users may no longer browse the dashboard. " +
|
|
508
|
+ "Returns the Dashboard object. Only users with 'TENANT_ADMIN') authority may assign the dashboards to customers.",
|
|
509
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
418
|
510
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
419
|
511
|
@RequestMapping(value = "/customer/public/dashboard/{dashboardId}", method = RequestMethod.DELETE)
|
420
|
512
|
@ResponseBody
|
421
|
|
- public Dashboard unassignDashboardFromPublicCustomer(@PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
|
513
|
+ public Dashboard unassignDashboardFromPublicCustomer(
|
|
514
|
+ @ApiParam(value = DASHBOARD_ID_PARAM_DESCRIPTION)
|
|
515
|
+ @PathVariable(DASHBOARD_ID) String strDashboardId) throws ThingsboardException {
|
422
|
516
|
checkParameter(DASHBOARD_ID, strDashboardId);
|
423
|
517
|
try {
|
424
|
518
|
DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
|
...
|
...
|
@@ -442,15 +536,25 @@ public class DashboardController extends BaseController { |
442
|
536
|
}
|
443
|
537
|
}
|
444
|
538
|
|
|
539
|
+ @ApiOperation(value = "Get Tenant Dashboards by System Administrator (getTenantDashboards)",
|
|
540
|
+ notes = "Returns a page of dashboard info objects owned by tenant. " + DASHBOARD_INFO_DEFINITION + " " + PAGE_DATA_PARAMETERS +
|
|
541
|
+ "Only users with 'SYS_ADMIN' authority may use this method.",
|
|
542
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
445
|
543
|
@PreAuthorize("hasAuthority('SYS_ADMIN')")
|
446
|
544
|
@RequestMapping(value = "/tenant/{tenantId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
447
|
545
|
@ResponseBody
|
448
|
546
|
public PageData<DashboardInfo> getTenantDashboards(
|
449
|
|
- @PathVariable("tenantId") String strTenantId,
|
|
547
|
+ @ApiParam(value = TENANT_ID_PARAM_DESCRIPTION, required = true)
|
|
548
|
+ @PathVariable(TENANT_ID) String strTenantId,
|
|
549
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
450
|
550
|
@RequestParam int pageSize,
|
|
551
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
451
|
552
|
@RequestParam int page,
|
|
553
|
+ @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION)
|
452
|
554
|
@RequestParam(required = false) String textSearch,
|
|
555
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES)
|
453
|
556
|
@RequestParam(required = false) String sortProperty,
|
|
557
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
454
|
558
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
455
|
559
|
try {
|
456
|
560
|
TenantId tenantId = new TenantId(toUUID(strTenantId));
|
...
|
...
|
@@ -462,20 +566,30 @@ public class DashboardController extends BaseController { |
462
|
566
|
}
|
463
|
567
|
}
|
464
|
568
|
|
|
569
|
+ @ApiOperation(value = "Get Tenant Dashboards (getTenantDashboards)",
|
|
570
|
+ notes = "Returns a page of dashboard info objects owned by the tenant of a current user. " + DASHBOARD_INFO_DEFINITION + " " + PAGE_DATA_PARAMETERS +
|
|
571
|
+ "Only users with 'TENANT_ADMIN' authority may use this method.",
|
|
572
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
465
|
573
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
466
|
574
|
@RequestMapping(value = "/tenant/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
467
|
575
|
@ResponseBody
|
468
|
576
|
public PageData<DashboardInfo> getTenantDashboards(
|
|
577
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
469
|
578
|
@RequestParam int pageSize,
|
|
579
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
470
|
580
|
@RequestParam int page,
|
|
581
|
+ @ApiParam(value = HIDDEN_FOR_MOBILE)
|
471
|
582
|
@RequestParam(required = false) Boolean mobile,
|
|
583
|
+ @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION)
|
472
|
584
|
@RequestParam(required = false) String textSearch,
|
|
585
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES)
|
473
|
586
|
@RequestParam(required = false) String sortProperty,
|
|
587
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
474
|
588
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
475
|
589
|
try {
|
476
|
590
|
TenantId tenantId = getCurrentUser().getTenantId();
|
477
|
591
|
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
478
|
|
- if (mobile != null && mobile.booleanValue()) {
|
|
592
|
+ if (mobile != null && mobile) {
|
479
|
593
|
return checkNotNull(dashboardService.findMobileDashboardsByTenantId(tenantId, pageLink));
|
480
|
594
|
} else {
|
481
|
595
|
return checkNotNull(dashboardService.findDashboardsByTenantId(tenantId, pageLink));
|
...
|
...
|
@@ -485,24 +599,35 @@ public class DashboardController extends BaseController { |
485
|
599
|
}
|
486
|
600
|
}
|
487
|
601
|
|
|
602
|
+ @ApiOperation(value = "Get Customer Dashboards (getCustomerDashboards)",
|
|
603
|
+ notes = "Returns a page of dashboard info objects owned by the specified customer. " + DASHBOARD_INFO_DEFINITION + " " + PAGE_DATA_PARAMETERS +
|
|
604
|
+ "Only users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority may use this method.",
|
|
605
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
488
|
606
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
489
|
607
|
@RequestMapping(value = "/customer/{customerId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET)
|
490
|
608
|
@ResponseBody
|
491
|
609
|
public PageData<DashboardInfo> getCustomerDashboards(
|
492
|
|
- @PathVariable("customerId") String strCustomerId,
|
|
610
|
+ @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
|
|
611
|
+ @PathVariable(CUSTOMER_ID) String strCustomerId,
|
|
612
|
+ @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
|
493
|
613
|
@RequestParam int pageSize,
|
|
614
|
+ @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
|
494
|
615
|
@RequestParam int page,
|
|
616
|
+ @ApiParam(value = HIDDEN_FOR_MOBILE)
|
495
|
617
|
@RequestParam(required = false) Boolean mobile,
|
|
618
|
+ @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION)
|
496
|
619
|
@RequestParam(required = false) String textSearch,
|
|
620
|
+ @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES)
|
497
|
621
|
@RequestParam(required = false) String sortProperty,
|
|
622
|
+ @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
|
498
|
623
|
@RequestParam(required = false) String sortOrder) throws ThingsboardException {
|
499
|
|
- checkParameter("customerId", strCustomerId);
|
|
624
|
+ checkParameter(CUSTOMER_ID, strCustomerId);
|
500
|
625
|
try {
|
501
|
626
|
TenantId tenantId = getCurrentUser().getTenantId();
|
502
|
627
|
CustomerId customerId = new CustomerId(toUUID(strCustomerId));
|
503
|
628
|
checkCustomerId(customerId, Operation.READ);
|
504
|
629
|
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder);
|
505
|
|
- if (mobile != null && mobile.booleanValue()) {
|
|
630
|
+ if (mobile != null && mobile) {
|
506
|
631
|
return checkNotNull(dashboardService.findMobileDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink));
|
507
|
632
|
} else {
|
508
|
633
|
return checkNotNull(dashboardService.findDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink));
|
...
|
...
|
@@ -512,6 +637,13 @@ public class DashboardController extends BaseController { |
512
|
637
|
}
|
513
|
638
|
}
|
514
|
639
|
|
|
640
|
+ @ApiOperation(value = "Get Home Dashboard (getHomeDashboard)",
|
|
641
|
+ notes = "Returns the home dashboard object that is configured as 'homeDashboardId' parameter in the 'additionalInfo' of the User. " +
|
|
642
|
+ "If 'homeDashboardId' parameter is not set on the User level and the User has authority 'CUSTOMER_USER', check the same parameter for the corresponding Customer. " +
|
|
643
|
+ "If 'homeDashboardId' parameter is not set on the User and Customer levels then checks the same parameter for the Tenant that owns the user. "
|
|
644
|
+ + DASHBOARD_DEFINITION + " " +
|
|
645
|
+ "Only users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority should use this method.",
|
|
646
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
515
|
647
|
@PreAuthorize("isAuthenticated()")
|
516
|
648
|
@RequestMapping(value = "/dashboard/home", method = RequestMethod.GET)
|
517
|
649
|
@ResponseBody
|
...
|
...
|
@@ -543,6 +675,12 @@ public class DashboardController extends BaseController { |
543
|
675
|
}
|
544
|
676
|
}
|
545
|
677
|
|
|
678
|
+ @ApiOperation(value = "Get Home Dashboard Info (getHomeDashboardInfo)",
|
|
679
|
+ notes = "Returns the home dashboard info object that is configured as 'homeDashboardId' parameter in the 'additionalInfo' of the User. " +
|
|
680
|
+ "If 'homeDashboardId' parameter is not set on the User level and the User has authority 'CUSTOMER_USER', check the same parameter for the corresponding Customer. " +
|
|
681
|
+ "If 'homeDashboardId' parameter is not set on the User and Customer levels then checks the same parameter for the Tenant that owns the user. " +
|
|
682
|
+ "Only users with 'TENANT_ADMIN' or 'CUSTOMER_USER' authority should use this method.",
|
|
683
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
546
|
684
|
@PreAuthorize("isAuthenticated()")
|
547
|
685
|
@RequestMapping(value = "/dashboard/home/info", method = RequestMethod.GET)
|
548
|
686
|
@ResponseBody
|
...
|
...
|
@@ -574,6 +712,10 @@ public class DashboardController extends BaseController { |
574
|
712
|
}
|
575
|
713
|
}
|
576
|
714
|
|
|
715
|
+ @ApiOperation(value = "Get Tenant Home Dashboard Info (getTenantHomeDashboardInfo)",
|
|
716
|
+ notes = "Returns the home dashboard info object that is configured as 'homeDashboardId' parameter in the 'additionalInfo' of the corresponding tenant. " +
|
|
717
|
+ "Only users with 'TENANT_ADMIN' authority may use this method.",
|
|
718
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
577
|
719
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
578
|
720
|
@RequestMapping(value = "/tenant/dashboard/home/info", method = RequestMethod.GET)
|
579
|
721
|
@ResponseBody
|
...
|
...
|
@@ -596,10 +738,16 @@ public class DashboardController extends BaseController { |
596
|
738
|
}
|
597
|
739
|
}
|
598
|
740
|
|
|
741
|
+ @ApiOperation(value = "Update Tenant Home Dashboard Info (getTenantHomeDashboardInfo)",
|
|
742
|
+ notes = "Update the home dashboard assignment for the current tenant. " +
|
|
743
|
+ "Only users with 'TENANT_ADMIN' authority may use this method.",
|
|
744
|
+ produces = MediaType.APPLICATION_JSON_VALUE)
|
599
|
745
|
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
600
|
746
|
@RequestMapping(value = "/tenant/dashboard/home/info", method = RequestMethod.POST)
|
601
|
747
|
@ResponseStatus(value = HttpStatus.OK)
|
602
|
|
- public void setTenantHomeDashboardInfo(@RequestBody HomeDashboardInfo homeDashboardInfo) throws ThingsboardException {
|
|
748
|
+ public void setTenantHomeDashboardInfo(
|
|
749
|
+ @ApiParam(value = "A JSON object that represents home dashboard id and other parameters", required = true)
|
|
750
|
+ @RequestBody HomeDashboardInfo homeDashboardInfo) throws ThingsboardException {
|
603
|
751
|
try {
|
604
|
752
|
if (homeDashboardInfo.getDashboardId() != null) {
|
605
|
753
|
checkDashboardId(homeDashboardInfo.getDashboardId(), Operation.READ);
|
...
|
...
|
@@ -635,7 +783,8 @@ public class DashboardController extends BaseController { |
635
|
783
|
}
|
636
|
784
|
return new HomeDashboardInfo(dashboardId, hideDashboardToolbar);
|
637
|
785
|
}
|
638
|
|
- } catch (Exception e) {}
|
|
786
|
+ } catch (Exception e) {
|
|
787
|
+ }
|
639
|
788
|
return null;
|
640
|
789
|
}
|
641
|
790
|
|
...
|
...
|
@@ -651,7 +800,8 @@ public class DashboardController extends BaseController { |
651
|
800
|
}
|
652
|
801
|
return new HomeDashboard(dashboard, hideDashboardToolbar);
|
653
|
802
|
}
|
654
|
|
- } catch (Exception e) {}
|
|
803
|
+ } catch (Exception e) {
|
|
804
|
+ }
|
655
|
805
|
return null;
|
656
|
806
|
}
|
657
|
807
|
|
...
|
...
|
|