Commit c50dd443c625acc380f8e9d4c1ae2f6ada21cf18

Authored by Andrii Shvaika
1 parent ca89a4fc

Dashboard controller

... ... @@ -157,19 +157,25 @@ public abstract class BaseController {
157 157 public static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " +
158 158 "The result is wrapped with PageData object that allows you to iterate over result set using pagination. " +
159 159 "See the 'Model' tab of the Response Class for more details. ";
  160 + public static final String DASHBOARD_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
160 161 public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
161 162 public static final String DEVICE_PROFILE_ID_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
162 163 public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
163 164 public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
164 165 public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'";
  166 + public static final String CUSTOMER_ID = "customerId";
  167 + public static final String TENANT_ID = "tenantId";
165 168
166 169 protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page";
167 170 protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0";
168 171 protected final String DEVICE_TYPE_DESCRIPTION = "Device type as the name of the device profile";
  172 + protected final String DASHBOARD_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the dashboard title.";
169 173 protected final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name.";
170   - protected final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer name.";
  174 + protected final String CUSTOMER_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the customer title.";
171 175 protected final String SORT_PROPERTY_DESCRIPTION = "Property of device to sort by";
172   - protected final String SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, label, type";
  176 + protected final String DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title";
  177 + protected final String CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, title, email, country, city";
  178 + protected final String DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES = "createdTime, name, label, type";
173 179 protected final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESCENDING (DESC)";
174 180 protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC";
175 181 protected final String DEVICE_INFO_DESCRIPTION = "Device Info is an extension of the default Device object that contains information about the assigned customer name and device profile name. ";
... ...
... ... @@ -52,7 +52,6 @@ import java.util.List;
52 52 @RequestMapping("/api")
53 53 public class CustomerController extends BaseController {
54 54
55   - public static final String CUSTOMER_ID = "customerId";
56 55 public static final String IS_PUBLIC = "isPublic";
57 56 public static final String CUSTOMER_SECURITY_CHECK = "If the user has the authority of 'Tenant Administrator', the server checks that the customer is owned by the same tenant. " +
58 57 "If the user has the authority of 'Customer User', the server checks that the user belongs to the customer.";
... ... @@ -120,9 +119,10 @@ public class CustomerController extends BaseController {
120 119 }
121 120
122 121 @ApiOperation(value = "Create or update Customer (saveCustomer)",
123   - notes = "Creates or Updates the Customer. Platform generates random Customer Id during device creation. " +
124   - "The Customer Id will be present in the response. Specify the Customer Id when you would like to update the Customer. " +
125   - "Referencing non-existing Customer Id will cause an error.")
  122 + notes = "Creates or Updates the Customer. When creating customer, platform generates Customer Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address) " +
  123 + "The newly created Customer Id will be present in the response. " +
  124 + "Specify existing Customer Id to update the Customer. " +
  125 + "Referencing non-existing Customer Id will cause 'Not Found' error.")
126 126 @PreAuthorize("hasAuthority('TENANT_ADMIN')")
127 127 @RequestMapping(value = "/customer", method = RequestMethod.POST)
128 128 @ResponseBody
... ... @@ -192,13 +192,13 @@ public class CustomerController extends BaseController {
192 192 @RequestMapping(value = "/customers", params = {"pageSize", "page"}, method = RequestMethod.GET)
193 193 @ResponseBody
194 194 public PageData<Customer> getCustomers(
195   - @ApiParam(value = PAGE_SIZE_DESCRIPTION)
  195 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
196 196 @RequestParam int pageSize,
197   - @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
  197 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
198 198 @RequestParam int page,
199 199 @ApiParam(value = CUSTOMER_TEXT_SEARCH_DESCRIPTION)
200 200 @RequestParam(required = false) String textSearch,
201   - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
  201 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = CUSTOMER_SORT_PROPERTY_ALLOWABLE_VALUES)
202 202 @RequestParam(required = false) String sortProperty,
203 203 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
204 204 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
... ...
... ... @@ -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
... ...
... ... @@ -137,7 +137,7 @@ public class DeviceController extends BaseController {
137 137 }
138 138
139 139 @ApiOperation(value = "Create Or Update Device (saveDevice)",
140   - notes = "Creates or Updates the Device. When creating device, platform generates Device Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)" +
  140 + notes = "Create or update the Device. When creating device, platform generates Device Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address). " +
141 141 "Device credentials are also generated if not provided in the 'accessToken' request parameter. " +
142 142 "The newly created device id will be present in the response. " +
143 143 "Specify existing Device id to update the device. " +
... ... @@ -376,15 +376,15 @@ public class DeviceController extends BaseController {
376 376 @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET)
377 377 @ResponseBody
378 378 public PageData<Device> getTenantDevices(
379   - @ApiParam(value = PAGE_SIZE_DESCRIPTION)
  379 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
380 380 @RequestParam int pageSize,
381   - @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
  381 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
382 382 @RequestParam int page,
383 383 @ApiParam(value = DEVICE_TYPE_DESCRIPTION)
384 384 @RequestParam(required = false) String type,
385 385 @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION)
386 386 @RequestParam(required = false) String textSearch,
387   - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
  387 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES)
388 388 @RequestParam(required = false) String sortProperty,
389 389 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
390 390 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
... ... @@ -408,9 +408,9 @@ public class DeviceController extends BaseController {
408 408 @RequestMapping(value = "/tenant/deviceInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
409 409 @ResponseBody
410 410 public PageData<DeviceInfo> getTenantDeviceInfos(
411   - @ApiParam(value = PAGE_SIZE_DESCRIPTION)
  411 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
412 412 @RequestParam int pageSize,
413   - @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
  413 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
414 414 @RequestParam int page,
415 415 @ApiParam(value = DEVICE_TYPE_DESCRIPTION)
416 416 @RequestParam(required = false) String type,
... ... @@ -418,7 +418,7 @@ public class DeviceController extends BaseController {
418 418 @RequestParam(required = false) String deviceProfileId,
419 419 @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION)
420 420 @RequestParam(required = false) String textSearch,
421   - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
  421 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES)
422 422 @RequestParam(required = false) String sortProperty,
423 423 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
424 424 @RequestParam(required = false) String sortOrder
... ... @@ -462,17 +462,17 @@ public class DeviceController extends BaseController {
462 462 @RequestMapping(value = "/customer/{customerId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET)
463 463 @ResponseBody
464 464 public PageData<Device> getCustomerDevices(
465   - @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
  465 + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
466 466 @PathVariable("customerId") String strCustomerId,
467   - @ApiParam(value = PAGE_SIZE_DESCRIPTION)
  467 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
468 468 @RequestParam int pageSize,
469   - @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
  469 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
470 470 @RequestParam int page,
471 471 @ApiParam(value = DEVICE_TYPE_DESCRIPTION)
472 472 @RequestParam(required = false) String type,
473 473 @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION)
474 474 @RequestParam(required = false) String textSearch,
475   - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
  475 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES)
476 476 @RequestParam(required = false) String sortProperty,
477 477 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
478 478 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
... ... @@ -499,11 +499,11 @@ public class DeviceController extends BaseController {
499 499 @RequestMapping(value = "/customer/{customerId}/deviceInfos", params = {"pageSize", "page"}, method = RequestMethod.GET)
500 500 @ResponseBody
501 501 public PageData<DeviceInfo> getCustomerDeviceInfos(
502   - @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION)
  502 + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true)
503 503 @PathVariable("customerId") String strCustomerId,
504   - @ApiParam(value = PAGE_SIZE_DESCRIPTION)
  504 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
505 505 @RequestParam int pageSize,
506   - @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
  506 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
507 507 @RequestParam int page,
508 508 @ApiParam(value = DEVICE_TYPE_DESCRIPTION)
509 509 @RequestParam(required = false) String type,
... ... @@ -511,7 +511,7 @@ public class DeviceController extends BaseController {
511 511 @RequestParam(required = false) String deviceProfileId,
512 512 @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION)
513 513 @RequestParam(required = false) String textSearch,
514   - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
  514 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES)
515 515 @RequestParam(required = false) String sortProperty,
516 516 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
517 517 @RequestParam(required = false) String sortOrder) throws ThingsboardException {
... ... @@ -863,17 +863,17 @@ public class DeviceController extends BaseController {
863 863 @RequestMapping(value = "/edge/{edgeId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET)
864 864 @ResponseBody
865 865 public PageData<Device> getEdgeDevices(
866   - @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION)
  866 + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true)
867 867 @PathVariable(EDGE_ID) String strEdgeId,
868   - @ApiParam(value = PAGE_SIZE_DESCRIPTION)
  868 + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true)
869 869 @RequestParam int pageSize,
870   - @ApiParam(value = PAGE_NUMBER_DESCRIPTION)
  870 + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true)
871 871 @RequestParam int page,
872 872 @ApiParam(value = DEVICE_TYPE_DESCRIPTION)
873 873 @RequestParam(required = false) String type,
874 874 @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION)
875 875 @RequestParam(required = false) String textSearch,
876   - @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = SORT_PROPERTY_ALLOWABLE_VALUES)
  876 + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DEVICE_SORT_PROPERTY_ALLOWABLE_VALUES)
877 877 @RequestParam(required = false) String sortProperty,
878 878 @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES)
879 879 @RequestParam(required = false) String sortOrder,
... ...
... ... @@ -38,7 +38,6 @@ import org.thingsboard.server.common.data.EntitySubtype;
38 38 import org.thingsboard.server.common.data.EntityType;
39 39 import org.thingsboard.server.common.data.EntityView;
40 40 import org.thingsboard.server.common.data.EntityViewInfo;
41   -import org.thingsboard.server.common.data.asset.Asset;
42 41 import org.thingsboard.server.common.data.audit.ActionType;
43 42 import org.thingsboard.server.common.data.edge.Edge;
44 43 import org.thingsboard.server.common.data.edge.EdgeEventActionType;
... ... @@ -49,7 +48,6 @@ import org.thingsboard.server.common.data.id.EdgeId;
49 48 import org.thingsboard.server.common.data.id.EntityId;
50 49 import org.thingsboard.server.common.data.id.EntityViewId;
51 50 import org.thingsboard.server.common.data.id.TenantId;
52   -import org.thingsboard.server.common.data.id.UUIDBased;
53 51 import org.thingsboard.server.common.data.kv.AttributeKvEntry;
54 52 import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery;
55 53 import org.thingsboard.server.common.data.kv.ReadTsKvQuery;
... ... @@ -74,7 +72,6 @@ import java.util.concurrent.ExecutionException;
74 72 import java.util.stream.Collectors;
75 73
76 74 import static org.apache.commons.lang3.StringUtils.isBlank;
77   -import static org.thingsboard.server.controller.CustomerController.CUSTOMER_ID;
78 75 import static org.thingsboard.server.controller.EdgeController.EDGE_ID;
79 76
80 77 /**
... ...
... ... @@ -57,7 +57,7 @@ public class TenantController extends BaseController {
57 57 @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.GET)
58 58 @ResponseBody
59 59 public Tenant getTenantById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException {
60   - checkParameter("tenantId", strTenantId);
  60 + checkParameter(TENANT_ID, strTenantId);
61 61 try {
62 62 TenantId tenantId = new TenantId(toUUID(strTenantId));
63 63 Tenant tenant = checkTenantId(tenantId, Operation.READ);
... ... @@ -74,7 +74,7 @@ public class TenantController extends BaseController {
74 74 @RequestMapping(value = "/tenant/info/{tenantId}", method = RequestMethod.GET)
75 75 @ResponseBody
76 76 public TenantInfo getTenantInfoById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException {
77   - checkParameter("tenantId", strTenantId);
  77 + checkParameter(TENANT_ID, strTenantId);
78 78 try {
79 79 TenantId tenantId = new TenantId(toUUID(strTenantId));
80 80 return checkTenantInfoId(tenantId, Operation.READ);
... ...
... ... @@ -16,6 +16,7 @@
16 16 package org.thingsboard.server.common.data;
17 17
18 18 import com.fasterxml.jackson.databind.JsonNode;
  19 +import io.swagger.annotations.ApiModelProperty;
19 20 import org.thingsboard.server.common.data.id.DashboardId;
20 21
21 22 public class Dashboard extends DashboardInfo {
... ... @@ -41,6 +42,10 @@ public class Dashboard extends DashboardInfo {
41 42 this.configuration = dashboard.getConfiguration();
42 43 }
43 44
  45 + @ApiModelProperty(position = 9, value = "JSON object with main configuration of the dashboard: layouts, widgets, aliases, etc. " +
  46 + "The JSON structure of the dashboard configuration is quite complex. " +
  47 + "The easiest way to learn it is to export existing dashboard to JSON."
  48 + , dataType = "com.fasterxml.jackson.databind.JsonNode")
44 49 public JsonNode getConfiguration() {
45 50 return configuration;
46 51 }
... ...
... ... @@ -16,6 +16,8 @@
16 16 package org.thingsboard.server.common.data;
17 17
18 18 import com.fasterxml.jackson.annotation.JsonProperty;
  19 +import io.swagger.annotations.ApiModel;
  20 +import io.swagger.annotations.ApiModelProperty;
19 21 import org.thingsboard.server.common.data.id.CustomerId;
20 22 import org.thingsboard.server.common.data.id.DashboardId;
21 23 import org.thingsboard.server.common.data.id.TenantId;
... ... @@ -25,6 +27,7 @@ import javax.validation.Valid;
25 27 import java.util.HashSet;
26 28 import java.util.Set;
27 29
  30 +@ApiModel
28 31 public class DashboardInfo extends SearchTextBased<DashboardId> implements HasName, HasTenantId {
29 32
30 33 private TenantId tenantId;
... ... @@ -54,6 +57,22 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
54 57 this.mobileOrder = dashboardInfo.getMobileOrder();
55 58 }
56 59
  60 + @ApiModelProperty(position = 1, value = "JSON object with the dashboard Id. " +
  61 + "Specify existing dashboard Id to update the dashboard. " +
  62 + "Referencing non-existing dashboard id will cause error. " +
  63 + "Omit this field to create new dashboard." )
  64 + @Override
  65 + public DashboardId getId() {
  66 + return super.getId();
  67 + }
  68 +
  69 + @ApiModelProperty(position = 2, value = "Timestamp of the dashboard creation, in milliseconds", example = "1609459200000", readOnly = true)
  70 + @Override
  71 + public long getCreatedTime() {
  72 + return super.getCreatedTime();
  73 + }
  74 +
  75 + @ApiModelProperty(position = 3, value = "JSON object with Tenant Id. Tenant Id of the dashboard can't be changed.", readOnly = true)
57 76 public TenantId getTenantId() {
58 77 return tenantId;
59 78 }
... ... @@ -62,6 +81,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
62 81 this.tenantId = tenantId;
63 82 }
64 83
  84 + @ApiModelProperty(position = 4, value = "Title of the dashboard.")
65 85 public String getTitle() {
66 86 return title;
67 87 }
... ... @@ -70,6 +90,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
70 90 this.title = title;
71 91 }
72 92
  93 + @ApiModelProperty(position = 8, value = "Thumbnail picture for rendering of the dashboards in a grid view on mobile devices.", readOnly = true)
73 94 public String getImage() {
74 95 return image;
75 96 }
... ... @@ -78,6 +99,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
78 99 this.image = image;
79 100 }
80 101
  102 + @ApiModelProperty(position = 5, value = "List of assigned customers with their info.", readOnly = true)
81 103 public Set<ShortCustomerInfo> getAssignedCustomers() {
82 104 return assignedCustomers;
83 105 }
... ... @@ -86,6 +108,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
86 108 this.assignedCustomers = assignedCustomers;
87 109 }
88 110
  111 + @ApiModelProperty(position = 6, value = "Hide dashboard from mobile devices. Useful if the dashboard is not designed for small screens.", readOnly = true)
89 112 public boolean isMobileHide() {
90 113 return mobileHide;
91 114 }
... ... @@ -94,6 +117,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
94 117 this.mobileHide = mobileHide;
95 118 }
96 119
  120 + @ApiModelProperty(position = 7, value = "Order on mobile devices. Useful to adjust sorting of the dashboards for mobile applications", readOnly = true)
97 121 public Integer getMobileOrder() {
98 122 return mobileOrder;
99 123 }
... ... @@ -152,6 +176,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
152 176 }
153 177 }
154 178
  179 + @ApiModelProperty(position = 4, value = "Same as title of the dashboard. Read-only field. Update the 'title' to change the 'name' of the dashboard.", readOnly = true)
155 180 @Override
156 181 @JsonProperty(access = JsonProperty.Access.READ_ONLY)
157 182 public String getName() {
... ...
... ... @@ -15,11 +15,17 @@
15 15 */
16 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.Data;
19 21
  22 +@ApiModel
20 23 @Data
21 24 public class HomeDashboard extends Dashboard {
22 25
  26 + public static final String HIDE_DASHBOARD_TOOLBAR_DESCRIPTION = "Hide dashboard toolbar flag. Useful for rendering dashboards on mobile.";
  27 +
  28 + @ApiModelProperty(position = 10, value = HIDE_DASHBOARD_TOOLBAR_DESCRIPTION)
23 29 private boolean hideDashboardToolbar;
24 30
25 31 public HomeDashboard(Dashboard dashboard, boolean hideDashboardToolbar) {
... ...
... ... @@ -15,13 +15,18 @@
15 15 */
16 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.AllArgsConstructor;
19 21 import lombok.Data;
20 22 import org.thingsboard.server.common.data.id.DashboardId;
21 23
  24 +@ApiModel
22 25 @Data
23 26 @AllArgsConstructor
24 27 public class HomeDashboardInfo {
  28 + @ApiModelProperty(position = 1, value = "JSON object with the dashboard Id.")
25 29 private DashboardId dashboardId;
  30 + @ApiModelProperty(position = 1, value = HomeDashboard.HIDE_DASHBOARD_TOOLBAR_DESCRIPTION)
26 31 private boolean hideDashboardToolbar;
27 32 }
... ...
... ... @@ -15,6 +15,8 @@
15 15 */
16 16 package org.thingsboard.server.common.data;
17 17
  18 +import io.swagger.annotations.ApiModel;
  19 +import io.swagger.annotations.ApiModelProperty;
18 20 import lombok.AllArgsConstructor;
19 21 import lombok.Getter;
20 22 import lombok.Setter;
... ... @@ -25,16 +27,20 @@ import org.thingsboard.server.common.data.validation.NoXss;
25 27 * Created by igor on 2/27/18.
26 28 */
27 29
  30 +@ApiModel
28 31 @AllArgsConstructor
29 32 public class ShortCustomerInfo {
30 33
  34 + @ApiModelProperty(position = 1, value = "JSON object with the customer Id.")
31 35 @Getter @Setter
32 36 private CustomerId customerId;
33 37
  38 + @ApiModelProperty(position = 2, value = "Title of the customer.")
34 39 @Getter @Setter
35 40 @NoXss
36 41 private String title;
37 42
  43 + @ApiModelProperty(position = 3, value = "Indicates special 'Public' customer used to embed dashboards on public websites.")
38 44 @Getter @Setter
39 45 private boolean isPublic;
40 46
... ...
... ... @@ -48,22 +48,22 @@ public class PageData<T> {
48 48 this.hasNext = hasNext;
49 49 }
50 50
51   - @ApiModelProperty(position = 1, value = "Array of the entities.", readOnly = true)
  51 + @ApiModelProperty(position = 1, value = "Array of the entities", readOnly = true)
52 52 public List<T> getData() {
53 53 return data;
54 54 }
55 55
56   - @ApiModelProperty(position = 2, value = "Total number of available pages. Calculated based on the 'pageSize' request parameter and total number of entities that match search criteria.", readOnly = true)
  56 + @ApiModelProperty(position = 2, value = "Total number of available pages. Calculated based on the 'pageSize' request parameter and total number of entities that match search criteria", readOnly = true)
57 57 public int getTotalPages() {
58 58 return totalPages;
59 59 }
60 60
61   - @ApiModelProperty(position = 3, value = "Total number of elements in all available pages.", readOnly = true)
  61 + @ApiModelProperty(position = 3, value = "Total number of elements in all available pages", readOnly = true)
62 62 public long getTotalElements() {
63 63 return totalElements;
64 64 }
65 65
66   - @ApiModelProperty(position = 4, value = "'false' value indicates the end of the result set.", readOnly = true)
  66 + @ApiModelProperty(position = 4, value = "'false' value indicates the end of the result set", readOnly = true)
67 67 @JsonProperty("hasNext")
68 68 public boolean hasNext() {
69 69 return hasNext;
... ...