Showing
12 changed files
with
263 additions
and
63 deletions
@@ -157,19 +157,25 @@ public abstract class BaseController { | @@ -157,19 +157,25 @@ public abstract class BaseController { | ||
157 | public static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " + | 157 | public static final String PAGE_DATA_PARAMETERS = "You can specify parameters to filter the results. " + |
158 | "The result is wrapped with PageData object that allows you to iterate over result set using pagination. " + | 158 | "The result is wrapped with PageData object that allows you to iterate over result set using pagination. " + |
159 | "See the 'Model' tab of the Response Class for more details. "; | 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 | public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | 161 | public static final String DEVICE_ID_PARAM_DESCRIPTION = "A string value representing the device id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
161 | public static final String DEVICE_PROFILE_ID_DESCRIPTION = "A string value representing the device profile id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | 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 | public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | 163 | public static final String TENANT_ID_PARAM_DESCRIPTION = "A string value representing the tenant id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
163 | public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | 164 | public static final String EDGE_ID_PARAM_DESCRIPTION = "A string value representing the edge id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; |
164 | public static final String CUSTOMER_ID_PARAM_DESCRIPTION = "A string value representing the customer id. For example, '784f394c-42b6-435a-983c-b7beff2784f9'"; | 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 | protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page"; | 169 | protected final String PAGE_SIZE_DESCRIPTION = "Maximum amount of entities in a one page"; |
167 | protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0"; | 170 | protected final String PAGE_NUMBER_DESCRIPTION = "Sequence number of page starting from 0"; |
168 | protected final String DEVICE_TYPE_DESCRIPTION = "Device type as the name of the device profile"; | 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 | protected final String DEVICE_TEXT_SEARCH_DESCRIPTION = "The case insensitive 'startsWith' filter based on the device name."; | 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 | protected final String SORT_PROPERTY_DESCRIPTION = "Property of device to sort by"; | 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 | protected final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESCENDING (DESC)"; | 179 | protected final String SORT_ORDER_DESCRIPTION = "Sort order. ASC (ASCENDING) or DESCENDING (DESC)"; |
174 | protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC"; | 180 | protected final String SORT_ORDER_ALLOWABLE_VALUES = "ASC, DESC"; |
175 | 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. "; | 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,7 +52,6 @@ import java.util.List; | ||
52 | @RequestMapping("/api") | 52 | @RequestMapping("/api") |
53 | public class CustomerController extends BaseController { | 53 | public class CustomerController extends BaseController { |
54 | 54 | ||
55 | - public static final String CUSTOMER_ID = "customerId"; | ||
56 | public static final String IS_PUBLIC = "isPublic"; | 55 | public static final String IS_PUBLIC = "isPublic"; |
57 | 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. " + | 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 | "If the user has the authority of 'Customer User', the server checks that the user belongs to the customer."; | 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,9 +119,10 @@ public class CustomerController extends BaseController { | ||
120 | } | 119 | } |
121 | 120 | ||
122 | @ApiOperation(value = "Create or update Customer (saveCustomer)", | 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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 126 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
127 | @RequestMapping(value = "/customer", method = RequestMethod.POST) | 127 | @RequestMapping(value = "/customer", method = RequestMethod.POST) |
128 | @ResponseBody | 128 | @ResponseBody |
@@ -192,13 +192,13 @@ public class CustomerController extends BaseController { | @@ -192,13 +192,13 @@ public class CustomerController extends BaseController { | ||
192 | @RequestMapping(value = "/customers", params = {"pageSize", "page"}, method = RequestMethod.GET) | 192 | @RequestMapping(value = "/customers", params = {"pageSize", "page"}, method = RequestMethod.GET) |
193 | @ResponseBody | 193 | @ResponseBody |
194 | public PageData<Customer> getCustomers( | 194 | public PageData<Customer> getCustomers( |
195 | - @ApiParam(value = PAGE_SIZE_DESCRIPTION) | 195 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) |
196 | @RequestParam int pageSize, | 196 | @RequestParam int pageSize, |
197 | - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | 197 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) |
198 | @RequestParam int page, | 198 | @RequestParam int page, |
199 | @ApiParam(value = CUSTOMER_TEXT_SEARCH_DESCRIPTION) | 199 | @ApiParam(value = CUSTOMER_TEXT_SEARCH_DESCRIPTION) |
200 | @RequestParam(required = false) String textSearch, | 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 | @RequestParam(required = false) String sortProperty, | 202 | @RequestParam(required = false) String sortProperty, |
203 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | 203 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) |
204 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 204 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
@@ -17,8 +17,11 @@ package org.thingsboard.server.controller; | @@ -17,8 +17,11 @@ package org.thingsboard.server.controller; | ||
17 | 17 | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | import com.fasterxml.jackson.databind.node.ObjectNode; | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
20 | +import io.swagger.annotations.ApiOperation; | ||
21 | +import io.swagger.annotations.ApiParam; | ||
20 | import org.springframework.beans.factory.annotation.Value; | 22 | import org.springframework.beans.factory.annotation.Value; |
21 | import org.springframework.http.HttpStatus; | 23 | import org.springframework.http.HttpStatus; |
24 | +import org.springframework.http.MediaType; | ||
22 | import org.springframework.security.access.prepost.PreAuthorize; | 25 | import org.springframework.security.access.prepost.PreAuthorize; |
23 | import org.springframework.web.bind.annotation.PathVariable; | 26 | import org.springframework.web.bind.annotation.PathVariable; |
24 | import org.springframework.web.bind.annotation.RequestBody; | 27 | import org.springframework.web.bind.annotation.RequestBody; |
@@ -68,11 +71,16 @@ public class DashboardController extends BaseController { | @@ -68,11 +71,16 @@ public class DashboardController extends BaseController { | ||
68 | 71 | ||
69 | private static final String HOME_DASHBOARD_ID = "homeDashboardId"; | 72 | private static final String HOME_DASHBOARD_ID = "homeDashboardId"; |
70 | private static final String HOME_DASHBOARD_HIDE_TOOLBAR = "homeDashboardHideToolbar"; | 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 | @Value("${dashboard.max_datapoints_limit}") | 78 | @Value("${dashboard.max_datapoints_limit}") |
73 | private long maxDatapointsLimit; | 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 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") | 84 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
77 | @RequestMapping(value = "/dashboard/serverTime", method = RequestMethod.GET) | 85 | @RequestMapping(value = "/dashboard/serverTime", method = RequestMethod.GET) |
78 | @ResponseBody | 86 | @ResponseBody |
@@ -80,6 +88,11 @@ public class DashboardController extends BaseController { | @@ -80,6 +88,11 @@ public class DashboardController extends BaseController { | ||
80 | return System.currentTimeMillis(); | 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 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") | 96 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
84 | @RequestMapping(value = "/dashboard/maxDatapointsLimit", method = RequestMethod.GET) | 97 | @RequestMapping(value = "/dashboard/maxDatapointsLimit", method = RequestMethod.GET) |
85 | @ResponseBody | 98 | @ResponseBody |
@@ -87,10 +100,16 @@ public class DashboardController extends BaseController { | @@ -87,10 +100,16 @@ public class DashboardController extends BaseController { | ||
87 | return maxDatapointsLimit; | 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 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") | 107 | @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") |
91 | @RequestMapping(value = "/dashboard/info/{dashboardId}", method = RequestMethod.GET) | 108 | @RequestMapping(value = "/dashboard/info/{dashboardId}", method = RequestMethod.GET) |
92 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 113 | checkParameter(DASHBOARD_ID, strDashboardId); |
95 | try { | 114 | try { |
96 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 115 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -100,10 +119,16 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 126 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
104 | @RequestMapping(value = "/dashboard/{dashboardId}", method = RequestMethod.GET) | 127 | @RequestMapping(value = "/dashboard/{dashboardId}", method = RequestMethod.GET) |
105 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 132 | checkParameter(DASHBOARD_ID, strDashboardId); |
108 | try { | 133 | try { |
109 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 134 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -113,10 +138,20 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 149 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
117 | @RequestMapping(value = "/dashboard", method = RequestMethod.POST) | 150 | @RequestMapping(value = "/dashboard", method = RequestMethod.POST) |
118 | @ResponseBody | 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 | try { | 155 | try { |
121 | dashboard.setTenantId(getCurrentUser().getTenantId()); | 156 | dashboard.setTenantId(getCurrentUser().getTenantId()); |
122 | 157 | ||
@@ -141,10 +176,14 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 181 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
145 | @RequestMapping(value = "/dashboard/{dashboardId}", method = RequestMethod.DELETE) | 182 | @RequestMapping(value = "/dashboard/{dashboardId}", method = RequestMethod.DELETE) |
146 | @ResponseStatus(value = HttpStatus.OK) | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 187 | checkParameter(DASHBOARD_ID, strDashboardId); |
149 | try { | 188 | try { |
150 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 189 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -170,12 +209,19 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 216 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
174 | @RequestMapping(value = "/customer/{customerId}/dashboard/{dashboardId}", method = RequestMethod.POST) | 217 | @RequestMapping(value = "/customer/{customerId}/dashboard/{dashboardId}", method = RequestMethod.POST) |
175 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 225 | checkParameter(DASHBOARD_ID, strDashboardId); |
180 | try { | 226 | try { |
181 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); | 227 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
@@ -203,11 +249,18 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 256 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
207 | @RequestMapping(value = "/customer/{customerId}/dashboard/{dashboardId}", method = RequestMethod.DELETE) | 257 | @RequestMapping(value = "/customer/{customerId}/dashboard/{dashboardId}", method = RequestMethod.DELETE) |
208 | @ResponseBody | 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 | checkParameter("customerId", strCustomerId); | 264 | checkParameter("customerId", strCustomerId); |
212 | checkParameter(DASHBOARD_ID, strDashboardId); | 265 | checkParameter(DASHBOARD_ID, strDashboardId); |
213 | try { | 266 | try { |
@@ -235,11 +288,20 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 297 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
239 | @RequestMapping(value = "/dashboard/{dashboardId}/customers", method = RequestMethod.POST) | 298 | @RequestMapping(value = "/dashboard/{dashboardId}/customers", method = RequestMethod.POST) |
240 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 305 | checkParameter(DASHBOARD_ID, strDashboardId); |
244 | try { | 306 | try { |
245 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 307 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -301,11 +363,19 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 371 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
305 | @RequestMapping(value = "/dashboard/{dashboardId}/customers/add", method = RequestMethod.POST) | 372 | @RequestMapping(value = "/dashboard/{dashboardId}/customers/add", method = RequestMethod.POST) |
306 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 379 | checkParameter(DASHBOARD_ID, strDashboardId); |
310 | try { | 380 | try { |
311 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 381 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -345,11 +415,19 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 423 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
349 | @RequestMapping(value = "/dashboard/{dashboardId}/customers/remove", method = RequestMethod.POST) | 424 | @RequestMapping(value = "/dashboard/{dashboardId}/customers/remove", method = RequestMethod.POST) |
350 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 431 | checkParameter(DASHBOARD_ID, strDashboardId); |
354 | try { | 432 | try { |
355 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 433 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -389,10 +467,20 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 478 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
393 | @RequestMapping(value = "/customer/public/dashboard/{dashboardId}", method = RequestMethod.POST) | 479 | @RequestMapping(value = "/customer/public/dashboard/{dashboardId}", method = RequestMethod.POST) |
394 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 484 | checkParameter(DASHBOARD_ID, strDashboardId); |
397 | try { | 485 | try { |
398 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 486 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -415,10 +503,16 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 510 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
419 | @RequestMapping(value = "/customer/public/dashboard/{dashboardId}", method = RequestMethod.DELETE) | 511 | @RequestMapping(value = "/customer/public/dashboard/{dashboardId}", method = RequestMethod.DELETE) |
420 | @ResponseBody | 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 | checkParameter(DASHBOARD_ID, strDashboardId); | 516 | checkParameter(DASHBOARD_ID, strDashboardId); |
423 | try { | 517 | try { |
424 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); | 518 | DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); |
@@ -442,15 +536,25 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('SYS_ADMIN')") | 543 | @PreAuthorize("hasAuthority('SYS_ADMIN')") |
446 | @RequestMapping(value = "/tenant/{tenantId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) | 544 | @RequestMapping(value = "/tenant/{tenantId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) |
447 | @ResponseBody | 545 | @ResponseBody |
448 | public PageData<DashboardInfo> getTenantDashboards( | 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 | @RequestParam int pageSize, | 550 | @RequestParam int pageSize, |
551 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | ||
451 | @RequestParam int page, | 552 | @RequestParam int page, |
553 | + @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION) | ||
452 | @RequestParam(required = false) String textSearch, | 554 | @RequestParam(required = false) String textSearch, |
555 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES) | ||
453 | @RequestParam(required = false) String sortProperty, | 556 | @RequestParam(required = false) String sortProperty, |
557 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | ||
454 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 558 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
455 | try { | 559 | try { |
456 | TenantId tenantId = new TenantId(toUUID(strTenantId)); | 560 | TenantId tenantId = new TenantId(toUUID(strTenantId)); |
@@ -462,20 +566,30 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 573 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
466 | @RequestMapping(value = "/tenant/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) | 574 | @RequestMapping(value = "/tenant/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) |
467 | @ResponseBody | 575 | @ResponseBody |
468 | public PageData<DashboardInfo> getTenantDashboards( | 576 | public PageData<DashboardInfo> getTenantDashboards( |
577 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) | ||
469 | @RequestParam int pageSize, | 578 | @RequestParam int pageSize, |
579 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | ||
470 | @RequestParam int page, | 580 | @RequestParam int page, |
581 | + @ApiParam(value = HIDDEN_FOR_MOBILE) | ||
471 | @RequestParam(required = false) Boolean mobile, | 582 | @RequestParam(required = false) Boolean mobile, |
583 | + @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION) | ||
472 | @RequestParam(required = false) String textSearch, | 584 | @RequestParam(required = false) String textSearch, |
585 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES) | ||
473 | @RequestParam(required = false) String sortProperty, | 586 | @RequestParam(required = false) String sortProperty, |
587 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | ||
474 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 588 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
475 | try { | 589 | try { |
476 | TenantId tenantId = getCurrentUser().getTenantId(); | 590 | TenantId tenantId = getCurrentUser().getTenantId(); |
477 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | 591 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
478 | - if (mobile != null && mobile.booleanValue()) { | 592 | + if (mobile != null && mobile) { |
479 | return checkNotNull(dashboardService.findMobileDashboardsByTenantId(tenantId, pageLink)); | 593 | return checkNotNull(dashboardService.findMobileDashboardsByTenantId(tenantId, pageLink)); |
480 | } else { | 594 | } else { |
481 | return checkNotNull(dashboardService.findDashboardsByTenantId(tenantId, pageLink)); | 595 | return checkNotNull(dashboardService.findDashboardsByTenantId(tenantId, pageLink)); |
@@ -485,24 +599,35 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") | 606 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
489 | @RequestMapping(value = "/customer/{customerId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) | 607 | @RequestMapping(value = "/customer/{customerId}/dashboards", params = {"pageSize", "page"}, method = RequestMethod.GET) |
490 | @ResponseBody | 608 | @ResponseBody |
491 | public PageData<DashboardInfo> getCustomerDashboards( | 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 | @RequestParam int pageSize, | 613 | @RequestParam int pageSize, |
614 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) | ||
494 | @RequestParam int page, | 615 | @RequestParam int page, |
616 | + @ApiParam(value = HIDDEN_FOR_MOBILE) | ||
495 | @RequestParam(required = false) Boolean mobile, | 617 | @RequestParam(required = false) Boolean mobile, |
618 | + @ApiParam(value = DASHBOARD_TEXT_SEARCH_DESCRIPTION) | ||
496 | @RequestParam(required = false) String textSearch, | 619 | @RequestParam(required = false) String textSearch, |
620 | + @ApiParam(value = SORT_PROPERTY_DESCRIPTION, allowableValues = DASHBOARD_SORT_PROPERTY_ALLOWABLE_VALUES) | ||
497 | @RequestParam(required = false) String sortProperty, | 621 | @RequestParam(required = false) String sortProperty, |
622 | + @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | ||
498 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 623 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
499 | - checkParameter("customerId", strCustomerId); | 624 | + checkParameter(CUSTOMER_ID, strCustomerId); |
500 | try { | 625 | try { |
501 | TenantId tenantId = getCurrentUser().getTenantId(); | 626 | TenantId tenantId = getCurrentUser().getTenantId(); |
502 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); | 627 | CustomerId customerId = new CustomerId(toUUID(strCustomerId)); |
503 | checkCustomerId(customerId, Operation.READ); | 628 | checkCustomerId(customerId, Operation.READ); |
504 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); | 629 | PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
505 | - if (mobile != null && mobile.booleanValue()) { | 630 | + if (mobile != null && mobile) { |
506 | return checkNotNull(dashboardService.findMobileDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink)); | 631 | return checkNotNull(dashboardService.findMobileDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink)); |
507 | } else { | 632 | } else { |
508 | return checkNotNull(dashboardService.findDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink)); | 633 | return checkNotNull(dashboardService.findDashboardsByTenantIdAndCustomerId(tenantId, customerId, pageLink)); |
@@ -512,6 +637,13 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("isAuthenticated()") | 647 | @PreAuthorize("isAuthenticated()") |
516 | @RequestMapping(value = "/dashboard/home", method = RequestMethod.GET) | 648 | @RequestMapping(value = "/dashboard/home", method = RequestMethod.GET) |
517 | @ResponseBody | 649 | @ResponseBody |
@@ -543,6 +675,12 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("isAuthenticated()") | 684 | @PreAuthorize("isAuthenticated()") |
547 | @RequestMapping(value = "/dashboard/home/info", method = RequestMethod.GET) | 685 | @RequestMapping(value = "/dashboard/home/info", method = RequestMethod.GET) |
548 | @ResponseBody | 686 | @ResponseBody |
@@ -574,6 +712,10 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 719 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
578 | @RequestMapping(value = "/tenant/dashboard/home/info", method = RequestMethod.GET) | 720 | @RequestMapping(value = "/tenant/dashboard/home/info", method = RequestMethod.GET) |
579 | @ResponseBody | 721 | @ResponseBody |
@@ -596,10 +738,16 @@ public class DashboardController extends BaseController { | @@ -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 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") | 745 | @PreAuthorize("hasAuthority('TENANT_ADMIN')") |
600 | @RequestMapping(value = "/tenant/dashboard/home/info", method = RequestMethod.POST) | 746 | @RequestMapping(value = "/tenant/dashboard/home/info", method = RequestMethod.POST) |
601 | @ResponseStatus(value = HttpStatus.OK) | 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 | try { | 751 | try { |
604 | if (homeDashboardInfo.getDashboardId() != null) { | 752 | if (homeDashboardInfo.getDashboardId() != null) { |
605 | checkDashboardId(homeDashboardInfo.getDashboardId(), Operation.READ); | 753 | checkDashboardId(homeDashboardInfo.getDashboardId(), Operation.READ); |
@@ -635,7 +783,8 @@ public class DashboardController extends BaseController { | @@ -635,7 +783,8 @@ public class DashboardController extends BaseController { | ||
635 | } | 783 | } |
636 | return new HomeDashboardInfo(dashboardId, hideDashboardToolbar); | 784 | return new HomeDashboardInfo(dashboardId, hideDashboardToolbar); |
637 | } | 785 | } |
638 | - } catch (Exception e) {} | 786 | + } catch (Exception e) { |
787 | + } | ||
639 | return null; | 788 | return null; |
640 | } | 789 | } |
641 | 790 | ||
@@ -651,7 +800,8 @@ public class DashboardController extends BaseController { | @@ -651,7 +800,8 @@ public class DashboardController extends BaseController { | ||
651 | } | 800 | } |
652 | return new HomeDashboard(dashboard, hideDashboardToolbar); | 801 | return new HomeDashboard(dashboard, hideDashboardToolbar); |
653 | } | 802 | } |
654 | - } catch (Exception e) {} | 803 | + } catch (Exception e) { |
804 | + } | ||
655 | return null; | 805 | return null; |
656 | } | 806 | } |
657 | 807 |
@@ -137,7 +137,7 @@ public class DeviceController extends BaseController { | @@ -137,7 +137,7 @@ public class DeviceController extends BaseController { | ||
137 | } | 137 | } |
138 | 138 | ||
139 | @ApiOperation(value = "Create Or Update Device (saveDevice)", | 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 | "Device credentials are also generated if not provided in the 'accessToken' request parameter. " + | 141 | "Device credentials are also generated if not provided in the 'accessToken' request parameter. " + |
142 | "The newly created device id will be present in the response. " + | 142 | "The newly created device id will be present in the response. " + |
143 | "Specify existing Device id to update the device. " + | 143 | "Specify existing Device id to update the device. " + |
@@ -376,15 +376,15 @@ public class DeviceController extends BaseController { | @@ -376,15 +376,15 @@ public class DeviceController extends BaseController { | ||
376 | @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) | 376 | @RequestMapping(value = "/tenant/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) |
377 | @ResponseBody | 377 | @ResponseBody |
378 | public PageData<Device> getTenantDevices( | 378 | public PageData<Device> getTenantDevices( |
379 | - @ApiParam(value = PAGE_SIZE_DESCRIPTION) | 379 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) |
380 | @RequestParam int pageSize, | 380 | @RequestParam int pageSize, |
381 | - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | 381 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) |
382 | @RequestParam int page, | 382 | @RequestParam int page, |
383 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) | 383 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
384 | @RequestParam(required = false) String type, | 384 | @RequestParam(required = false) String type, |
385 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) | 385 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
386 | @RequestParam(required = false) String textSearch, | 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 | @RequestParam(required = false) String sortProperty, | 388 | @RequestParam(required = false) String sortProperty, |
389 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | 389 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) |
390 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 390 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
@@ -408,9 +408,9 @@ public class DeviceController extends BaseController { | @@ -408,9 +408,9 @@ public class DeviceController extends BaseController { | ||
408 | @RequestMapping(value = "/tenant/deviceInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) | 408 | @RequestMapping(value = "/tenant/deviceInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
409 | @ResponseBody | 409 | @ResponseBody |
410 | public PageData<DeviceInfo> getTenantDeviceInfos( | 410 | public PageData<DeviceInfo> getTenantDeviceInfos( |
411 | - @ApiParam(value = PAGE_SIZE_DESCRIPTION) | 411 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) |
412 | @RequestParam int pageSize, | 412 | @RequestParam int pageSize, |
413 | - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | 413 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) |
414 | @RequestParam int page, | 414 | @RequestParam int page, |
415 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) | 415 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
416 | @RequestParam(required = false) String type, | 416 | @RequestParam(required = false) String type, |
@@ -418,7 +418,7 @@ public class DeviceController extends BaseController { | @@ -418,7 +418,7 @@ public class DeviceController extends BaseController { | ||
418 | @RequestParam(required = false) String deviceProfileId, | 418 | @RequestParam(required = false) String deviceProfileId, |
419 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) | 419 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
420 | @RequestParam(required = false) String textSearch, | 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 | @RequestParam(required = false) String sortProperty, | 422 | @RequestParam(required = false) String sortProperty, |
423 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | 423 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) |
424 | @RequestParam(required = false) String sortOrder | 424 | @RequestParam(required = false) String sortOrder |
@@ -462,17 +462,17 @@ public class DeviceController extends BaseController { | @@ -462,17 +462,17 @@ public class DeviceController extends BaseController { | ||
462 | @RequestMapping(value = "/customer/{customerId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) | 462 | @RequestMapping(value = "/customer/{customerId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) |
463 | @ResponseBody | 463 | @ResponseBody |
464 | public PageData<Device> getCustomerDevices( | 464 | public PageData<Device> getCustomerDevices( |
465 | - @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) | 465 | + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true) |
466 | @PathVariable("customerId") String strCustomerId, | 466 | @PathVariable("customerId") String strCustomerId, |
467 | - @ApiParam(value = PAGE_SIZE_DESCRIPTION) | 467 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) |
468 | @RequestParam int pageSize, | 468 | @RequestParam int pageSize, |
469 | - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | 469 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) |
470 | @RequestParam int page, | 470 | @RequestParam int page, |
471 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) | 471 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
472 | @RequestParam(required = false) String type, | 472 | @RequestParam(required = false) String type, |
473 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) | 473 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
474 | @RequestParam(required = false) String textSearch, | 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 | @RequestParam(required = false) String sortProperty, | 476 | @RequestParam(required = false) String sortProperty, |
477 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | 477 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) |
478 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 478 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
@@ -499,11 +499,11 @@ public class DeviceController extends BaseController { | @@ -499,11 +499,11 @@ public class DeviceController extends BaseController { | ||
499 | @RequestMapping(value = "/customer/{customerId}/deviceInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) | 499 | @RequestMapping(value = "/customer/{customerId}/deviceInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
500 | @ResponseBody | 500 | @ResponseBody |
501 | public PageData<DeviceInfo> getCustomerDeviceInfos( | 501 | public PageData<DeviceInfo> getCustomerDeviceInfos( |
502 | - @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION) | 502 | + @ApiParam(value = CUSTOMER_ID_PARAM_DESCRIPTION, required = true) |
503 | @PathVariable("customerId") String strCustomerId, | 503 | @PathVariable("customerId") String strCustomerId, |
504 | - @ApiParam(value = PAGE_SIZE_DESCRIPTION) | 504 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) |
505 | @RequestParam int pageSize, | 505 | @RequestParam int pageSize, |
506 | - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | 506 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) |
507 | @RequestParam int page, | 507 | @RequestParam int page, |
508 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) | 508 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
509 | @RequestParam(required = false) String type, | 509 | @RequestParam(required = false) String type, |
@@ -511,7 +511,7 @@ public class DeviceController extends BaseController { | @@ -511,7 +511,7 @@ public class DeviceController extends BaseController { | ||
511 | @RequestParam(required = false) String deviceProfileId, | 511 | @RequestParam(required = false) String deviceProfileId, |
512 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) | 512 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
513 | @RequestParam(required = false) String textSearch, | 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 | @RequestParam(required = false) String sortProperty, | 515 | @RequestParam(required = false) String sortProperty, |
516 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | 516 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) |
517 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { | 517 | @RequestParam(required = false) String sortOrder) throws ThingsboardException { |
@@ -863,17 +863,17 @@ public class DeviceController extends BaseController { | @@ -863,17 +863,17 @@ public class DeviceController extends BaseController { | ||
863 | @RequestMapping(value = "/edge/{edgeId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) | 863 | @RequestMapping(value = "/edge/{edgeId}/devices", params = {"pageSize", "page"}, method = RequestMethod.GET) |
864 | @ResponseBody | 864 | @ResponseBody |
865 | public PageData<Device> getEdgeDevices( | 865 | public PageData<Device> getEdgeDevices( |
866 | - @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION) | 866 | + @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) |
867 | @PathVariable(EDGE_ID) String strEdgeId, | 867 | @PathVariable(EDGE_ID) String strEdgeId, |
868 | - @ApiParam(value = PAGE_SIZE_DESCRIPTION) | 868 | + @ApiParam(value = PAGE_SIZE_DESCRIPTION, required = true) |
869 | @RequestParam int pageSize, | 869 | @RequestParam int pageSize, |
870 | - @ApiParam(value = PAGE_NUMBER_DESCRIPTION) | 870 | + @ApiParam(value = PAGE_NUMBER_DESCRIPTION, required = true) |
871 | @RequestParam int page, | 871 | @RequestParam int page, |
872 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) | 872 | @ApiParam(value = DEVICE_TYPE_DESCRIPTION) |
873 | @RequestParam(required = false) String type, | 873 | @RequestParam(required = false) String type, |
874 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) | 874 | @ApiParam(value = DEVICE_TEXT_SEARCH_DESCRIPTION) |
875 | @RequestParam(required = false) String textSearch, | 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 | @RequestParam(required = false) String sortProperty, | 877 | @RequestParam(required = false) String sortProperty, |
878 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) | 878 | @ApiParam(value = SORT_ORDER_DESCRIPTION, allowableValues = SORT_ORDER_ALLOWABLE_VALUES) |
879 | @RequestParam(required = false) String sortOrder, | 879 | @RequestParam(required = false) String sortOrder, |
@@ -38,7 +38,6 @@ import org.thingsboard.server.common.data.EntitySubtype; | @@ -38,7 +38,6 @@ import org.thingsboard.server.common.data.EntitySubtype; | ||
38 | import org.thingsboard.server.common.data.EntityType; | 38 | import org.thingsboard.server.common.data.EntityType; |
39 | import org.thingsboard.server.common.data.EntityView; | 39 | import org.thingsboard.server.common.data.EntityView; |
40 | import org.thingsboard.server.common.data.EntityViewInfo; | 40 | import org.thingsboard.server.common.data.EntityViewInfo; |
41 | -import org.thingsboard.server.common.data.asset.Asset; | ||
42 | import org.thingsboard.server.common.data.audit.ActionType; | 41 | import org.thingsboard.server.common.data.audit.ActionType; |
43 | import org.thingsboard.server.common.data.edge.Edge; | 42 | import org.thingsboard.server.common.data.edge.Edge; |
44 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; | 43 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
@@ -49,7 +48,6 @@ import org.thingsboard.server.common.data.id.EdgeId; | @@ -49,7 +48,6 @@ import org.thingsboard.server.common.data.id.EdgeId; | ||
49 | import org.thingsboard.server.common.data.id.EntityId; | 48 | import org.thingsboard.server.common.data.id.EntityId; |
50 | import org.thingsboard.server.common.data.id.EntityViewId; | 49 | import org.thingsboard.server.common.data.id.EntityViewId; |
51 | import org.thingsboard.server.common.data.id.TenantId; | 50 | import org.thingsboard.server.common.data.id.TenantId; |
52 | -import org.thingsboard.server.common.data.id.UUIDBased; | ||
53 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 51 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
54 | import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; | 52 | import org.thingsboard.server.common.data.kv.BaseReadTsKvQuery; |
55 | import org.thingsboard.server.common.data.kv.ReadTsKvQuery; | 53 | import org.thingsboard.server.common.data.kv.ReadTsKvQuery; |
@@ -74,7 +72,6 @@ import java.util.concurrent.ExecutionException; | @@ -74,7 +72,6 @@ import java.util.concurrent.ExecutionException; | ||
74 | import java.util.stream.Collectors; | 72 | import java.util.stream.Collectors; |
75 | 73 | ||
76 | import static org.apache.commons.lang3.StringUtils.isBlank; | 74 | import static org.apache.commons.lang3.StringUtils.isBlank; |
77 | -import static org.thingsboard.server.controller.CustomerController.CUSTOMER_ID; | ||
78 | import static org.thingsboard.server.controller.EdgeController.EDGE_ID; | 75 | import static org.thingsboard.server.controller.EdgeController.EDGE_ID; |
79 | 76 | ||
80 | /** | 77 | /** |
@@ -57,7 +57,7 @@ public class TenantController extends BaseController { | @@ -57,7 +57,7 @@ public class TenantController extends BaseController { | ||
57 | @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.GET) | 57 | @RequestMapping(value = "/tenant/{tenantId}", method = RequestMethod.GET) |
58 | @ResponseBody | 58 | @ResponseBody |
59 | public Tenant getTenantById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException { | 59 | public Tenant getTenantById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException { |
60 | - checkParameter("tenantId", strTenantId); | 60 | + checkParameter(TENANT_ID, strTenantId); |
61 | try { | 61 | try { |
62 | TenantId tenantId = new TenantId(toUUID(strTenantId)); | 62 | TenantId tenantId = new TenantId(toUUID(strTenantId)); |
63 | Tenant tenant = checkTenantId(tenantId, Operation.READ); | 63 | Tenant tenant = checkTenantId(tenantId, Operation.READ); |
@@ -74,7 +74,7 @@ public class TenantController extends BaseController { | @@ -74,7 +74,7 @@ public class TenantController extends BaseController { | ||
74 | @RequestMapping(value = "/tenant/info/{tenantId}", method = RequestMethod.GET) | 74 | @RequestMapping(value = "/tenant/info/{tenantId}", method = RequestMethod.GET) |
75 | @ResponseBody | 75 | @ResponseBody |
76 | public TenantInfo getTenantInfoById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException { | 76 | public TenantInfo getTenantInfoById(@PathVariable("tenantId") String strTenantId) throws ThingsboardException { |
77 | - checkParameter("tenantId", strTenantId); | 77 | + checkParameter(TENANT_ID, strTenantId); |
78 | try { | 78 | try { |
79 | TenantId tenantId = new TenantId(toUUID(strTenantId)); | 79 | TenantId tenantId = new TenantId(toUUID(strTenantId)); |
80 | return checkTenantInfoId(tenantId, Operation.READ); | 80 | return checkTenantInfoId(tenantId, Operation.READ); |
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | package org.thingsboard.server.common.data; | 16 | package org.thingsboard.server.common.data; |
17 | 17 | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
19 | +import io.swagger.annotations.ApiModelProperty; | ||
19 | import org.thingsboard.server.common.data.id.DashboardId; | 20 | import org.thingsboard.server.common.data.id.DashboardId; |
20 | 21 | ||
21 | public class Dashboard extends DashboardInfo { | 22 | public class Dashboard extends DashboardInfo { |
@@ -41,6 +42,10 @@ public class Dashboard extends DashboardInfo { | @@ -41,6 +42,10 @@ public class Dashboard extends DashboardInfo { | ||
41 | this.configuration = dashboard.getConfiguration(); | 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 | public JsonNode getConfiguration() { | 49 | public JsonNode getConfiguration() { |
45 | return configuration; | 50 | return configuration; |
46 | } | 51 | } |
@@ -16,6 +16,8 @@ | @@ -16,6 +16,8 @@ | ||
16 | package org.thingsboard.server.common.data; | 16 | package org.thingsboard.server.common.data; |
17 | 17 | ||
18 | import com.fasterxml.jackson.annotation.JsonProperty; | 18 | import com.fasterxml.jackson.annotation.JsonProperty; |
19 | +import io.swagger.annotations.ApiModel; | ||
20 | +import io.swagger.annotations.ApiModelProperty; | ||
19 | import org.thingsboard.server.common.data.id.CustomerId; | 21 | import org.thingsboard.server.common.data.id.CustomerId; |
20 | import org.thingsboard.server.common.data.id.DashboardId; | 22 | import org.thingsboard.server.common.data.id.DashboardId; |
21 | import org.thingsboard.server.common.data.id.TenantId; | 23 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -25,6 +27,7 @@ import javax.validation.Valid; | @@ -25,6 +27,7 @@ import javax.validation.Valid; | ||
25 | import java.util.HashSet; | 27 | import java.util.HashSet; |
26 | import java.util.Set; | 28 | import java.util.Set; |
27 | 29 | ||
30 | +@ApiModel | ||
28 | public class DashboardInfo extends SearchTextBased<DashboardId> implements HasName, HasTenantId { | 31 | public class DashboardInfo extends SearchTextBased<DashboardId> implements HasName, HasTenantId { |
29 | 32 | ||
30 | private TenantId tenantId; | 33 | private TenantId tenantId; |
@@ -54,6 +57,22 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -54,6 +57,22 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | ||
54 | this.mobileOrder = dashboardInfo.getMobileOrder(); | 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 | public TenantId getTenantId() { | 76 | public TenantId getTenantId() { |
58 | return tenantId; | 77 | return tenantId; |
59 | } | 78 | } |
@@ -62,6 +81,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -62,6 +81,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | ||
62 | this.tenantId = tenantId; | 81 | this.tenantId = tenantId; |
63 | } | 82 | } |
64 | 83 | ||
84 | + @ApiModelProperty(position = 4, value = "Title of the dashboard.") | ||
65 | public String getTitle() { | 85 | public String getTitle() { |
66 | return title; | 86 | return title; |
67 | } | 87 | } |
@@ -70,6 +90,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -70,6 +90,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | ||
70 | this.title = title; | 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 | public String getImage() { | 94 | public String getImage() { |
74 | return image; | 95 | return image; |
75 | } | 96 | } |
@@ -78,6 +99,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -78,6 +99,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | ||
78 | this.image = image; | 99 | this.image = image; |
79 | } | 100 | } |
80 | 101 | ||
102 | + @ApiModelProperty(position = 5, value = "List of assigned customers with their info.", readOnly = true) | ||
81 | public Set<ShortCustomerInfo> getAssignedCustomers() { | 103 | public Set<ShortCustomerInfo> getAssignedCustomers() { |
82 | return assignedCustomers; | 104 | return assignedCustomers; |
83 | } | 105 | } |
@@ -86,6 +108,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -86,6 +108,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | ||
86 | this.assignedCustomers = assignedCustomers; | 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 | public boolean isMobileHide() { | 112 | public boolean isMobileHide() { |
90 | return mobileHide; | 113 | return mobileHide; |
91 | } | 114 | } |
@@ -94,6 +117,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -94,6 +117,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | ||
94 | this.mobileHide = mobileHide; | 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 | public Integer getMobileOrder() { | 121 | public Integer getMobileOrder() { |
98 | return mobileOrder; | 122 | return mobileOrder; |
99 | } | 123 | } |
@@ -152,6 +176,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa | @@ -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 | @Override | 180 | @Override |
156 | @JsonProperty(access = JsonProperty.Access.READ_ONLY) | 181 | @JsonProperty(access = JsonProperty.Access.READ_ONLY) |
157 | public String getName() { | 182 | public String getName() { |
@@ -15,11 +15,17 @@ | @@ -15,11 +15,17 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.data; | 16 | package org.thingsboard.server.common.data; |
17 | 17 | ||
18 | +import io.swagger.annotations.ApiModel; | ||
19 | +import io.swagger.annotations.ApiModelProperty; | ||
18 | import lombok.Data; | 20 | import lombok.Data; |
19 | 21 | ||
22 | +@ApiModel | ||
20 | @Data | 23 | @Data |
21 | public class HomeDashboard extends Dashboard { | 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 | private boolean hideDashboardToolbar; | 29 | private boolean hideDashboardToolbar; |
24 | 30 | ||
25 | public HomeDashboard(Dashboard dashboard, boolean hideDashboardToolbar) { | 31 | public HomeDashboard(Dashboard dashboard, boolean hideDashboardToolbar) { |
@@ -15,13 +15,18 @@ | @@ -15,13 +15,18 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.data; | 16 | package org.thingsboard.server.common.data; |
17 | 17 | ||
18 | +import io.swagger.annotations.ApiModel; | ||
19 | +import io.swagger.annotations.ApiModelProperty; | ||
18 | import lombok.AllArgsConstructor; | 20 | import lombok.AllArgsConstructor; |
19 | import lombok.Data; | 21 | import lombok.Data; |
20 | import org.thingsboard.server.common.data.id.DashboardId; | 22 | import org.thingsboard.server.common.data.id.DashboardId; |
21 | 23 | ||
24 | +@ApiModel | ||
22 | @Data | 25 | @Data |
23 | @AllArgsConstructor | 26 | @AllArgsConstructor |
24 | public class HomeDashboardInfo { | 27 | public class HomeDashboardInfo { |
28 | + @ApiModelProperty(position = 1, value = "JSON object with the dashboard Id.") | ||
25 | private DashboardId dashboardId; | 29 | private DashboardId dashboardId; |
30 | + @ApiModelProperty(position = 1, value = HomeDashboard.HIDE_DASHBOARD_TOOLBAR_DESCRIPTION) | ||
26 | private boolean hideDashboardToolbar; | 31 | private boolean hideDashboardToolbar; |
27 | } | 32 | } |
@@ -15,6 +15,8 @@ | @@ -15,6 +15,8 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.data; | 16 | package org.thingsboard.server.common.data; |
17 | 17 | ||
18 | +import io.swagger.annotations.ApiModel; | ||
19 | +import io.swagger.annotations.ApiModelProperty; | ||
18 | import lombok.AllArgsConstructor; | 20 | import lombok.AllArgsConstructor; |
19 | import lombok.Getter; | 21 | import lombok.Getter; |
20 | import lombok.Setter; | 22 | import lombok.Setter; |
@@ -25,16 +27,20 @@ import org.thingsboard.server.common.data.validation.NoXss; | @@ -25,16 +27,20 @@ import org.thingsboard.server.common.data.validation.NoXss; | ||
25 | * Created by igor on 2/27/18. | 27 | * Created by igor on 2/27/18. |
26 | */ | 28 | */ |
27 | 29 | ||
30 | +@ApiModel | ||
28 | @AllArgsConstructor | 31 | @AllArgsConstructor |
29 | public class ShortCustomerInfo { | 32 | public class ShortCustomerInfo { |
30 | 33 | ||
34 | + @ApiModelProperty(position = 1, value = "JSON object with the customer Id.") | ||
31 | @Getter @Setter | 35 | @Getter @Setter |
32 | private CustomerId customerId; | 36 | private CustomerId customerId; |
33 | 37 | ||
38 | + @ApiModelProperty(position = 2, value = "Title of the customer.") | ||
34 | @Getter @Setter | 39 | @Getter @Setter |
35 | @NoXss | 40 | @NoXss |
36 | private String title; | 41 | private String title; |
37 | 42 | ||
43 | + @ApiModelProperty(position = 3, value = "Indicates special 'Public' customer used to embed dashboards on public websites.") | ||
38 | @Getter @Setter | 44 | @Getter @Setter |
39 | private boolean isPublic; | 45 | private boolean isPublic; |
40 | 46 |
@@ -48,22 +48,22 @@ public class PageData<T> { | @@ -48,22 +48,22 @@ public class PageData<T> { | ||
48 | this.hasNext = hasNext; | 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 | public List<T> getData() { | 52 | public List<T> getData() { |
53 | return data; | 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 | public int getTotalPages() { | 57 | public int getTotalPages() { |
58 | return totalPages; | 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 | public long getTotalElements() { | 62 | public long getTotalElements() { |
63 | return totalElements; | 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 | @JsonProperty("hasNext") | 67 | @JsonProperty("hasNext") |
68 | public boolean hasNext() { | 68 | public boolean hasNext() { |
69 | return hasNext; | 69 | return hasNext; |