Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
BasicUI: WebAppServlet: add onlyUpdateLocation request parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Ivanov committed Sep 2, 2016
1 parent aec4037 commit 39c1c8d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class WebAppServlet extends BaseServlet {
public static final String SERVLET_NAME = "app";

private static final String CONTENT_TYPE_ASYNC = "application/xml;charset=UTF-8";
private static final String CONTENT_TYPE_TEXT = "text/plain;charset=UTF-8";
private static final String CONTENT_TYPE = "text/html;charset=UTF-8";

private PageRenderer renderer;
Expand Down Expand Up @@ -118,6 +119,7 @@ public void service(ServletRequest req, ServletResponse res) throws ServletExcep
String sitemapName = req.getParameter("sitemap");
String widgetId = req.getParameter("w");
String subscriptionId = req.getParameter("subscriptionId");
boolean onlyUpdateLocation = "true".equalsIgnoreCase(req.getParameter("onlyUpdateLocation"));
boolean async = "true".equalsIgnoreCase(req.getParameter("__async"));

if (sitemapName == null) {
Expand All @@ -134,6 +136,17 @@ public void service(ServletRequest req, ServletResponse res) throws ServletExcep
}
}

if (onlyUpdateLocation && sitemap != null) {
if (widgetId == null || widgetId.isEmpty()) {
subscriptions.setPageId(subscriptionId, sitemap.getName(), sitemapName);
} else {
subscriptions.setPageId(subscriptionId, sitemap.getName(), widgetId);
}

res.setContentType(CONTENT_TYPE_TEXT);
return;
}

try {
if (sitemap == null) {
showSitemapList(res);
Expand Down
24 changes: 20 additions & 4 deletions extensions/ui/org.eclipse.smarthome.ui.basic/web-src/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -1419,9 +1419,9 @@
_t.navigate = function(){};
_t.source = new EventSource(subscribeLocation);
_t.source.addEventListener("message", function(payload) {
if (_t.paused) {
return;
}
// if (_t.paused) {
// return;
// }

var
data = JSON.parse(payload.data);
Expand Down Expand Up @@ -1539,7 +1539,10 @@
var
responseJSON,
subscribeLocation,
c = console;
subscribeLocationArray,
sitemap,
subscriptionId,
page;

try {
responseJSON = JSON.parse(response.responseText);
Expand All @@ -1557,6 +1560,19 @@
return;
}

subscribeLocationArray = subscribeLocation.split("/");
subscriptionId = subscribeLocationArray[subscribeLocationArray.length - 1];

sitemap = document.body.getAttribute("data-sitemap");
page = document.body.getAttribute("data-page-id");

ajax({
url: "/basicui/app?sitemap=" + sitemap +
"&subscriptionId=" + subscriptionId +
"&w=" + page +
"&onlyUpdateLocation=" + "true"
});

if (featureSupport.eventSource) {
ChangeListenerEventsource.call(_t, subscribeLocation);
} else {
Expand Down
Loading

0 comments on commit 39c1c8d

Please sign in to comment.