Permalink
Browse files

Fixed the undefined check.

  • Loading branch information...
1 parent e38009a commit 151610483dc9379915b089a1b2f25835ccac13c2 @jeffyu jeffyu committed Nov 9, 2012
View
17 gadget-web/src/main/java/org/overlord/gadgets/web/client/widgets/Portlet.java
@@ -36,6 +36,7 @@
import com.google.gwt.http.client.Response;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
@@ -95,13 +96,15 @@ public void onClick(ClickEvent clickEvent) {
removeBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- String theURL = URLBuilder.getRemoveWidgetURL(Long.valueOf(widgetId));
- RestfulInvoker.invoke(RequestBuilder.POST, theURL,
- null, new RestfulInvoker.Response() {
- public void onResponseReceived(Request request, Response response) {
- remove(id);
- }
- });
+ if (Window.confirm("Are you sure to delete this widget?")) {
+ String theURL = URLBuilder.getRemoveWidgetURL(Long.valueOf(widgetId));
+ RestfulInvoker.invoke(RequestBuilder.POST, theURL,
+ null, new RestfulInvoker.Response() {
+ public void onResponseReceived(Request request, Response response) {
+ remove(id);
+ }
+ });
+ }
}
});
View
2 gadget-web/src/main/java/org/overlord/gadgets/web/client/widgets/TabLayout.java
@@ -260,7 +260,7 @@ private static native void registerCloseEvent(final TabLayout layout, String id)
$wnd.$('#'+id + ' span.ui-icon-close').live('click', function(){
var theTabs = $wnd.$('#'+id).tabs();
var index = $wnd.$(this).parent().index();
- if (index > -1) {
+ if (index > -1 && confirm('Are you sure to delete the page?')) {
layout.@org.overlord.gadgets.web.client.widgets.TabLayout::removePage(Ljava/lang/Long;)(index);
theTabs.tabs('remove', index);
}
View
16 gadget-web/src/main/java/org/overlord/gadgets/web/server/UserController.java
@@ -28,6 +28,7 @@
import org.overlord.gadgets.server.service.UserManager;
import org.overlord.gadgets.web.shared.dto.PageModel;
import org.overlord.gadgets.web.shared.dto.UserModel;
+import org.overlord.gadgets.web.shared.dto.UserPreference.UserPreferenceSetting;
import org.overlord.gadgets.web.shared.dto.WidgetModel;
import javax.servlet.http.HttpServletRequest;
@@ -125,6 +126,9 @@ public Response checkUsername(@PathParam("username") String username) {
WidgetModel widgetModel = metadataService.getGadgetMetadata(widget.getAppUrl());
widgetModel.setWidgetId(widget.getId());
widgetModel.setOrder(widget.getOrder());
+
+ populateWidgetsDefaultValue(widget, widgetModel);
+
pageModel.addModel(widgetModel);
}
@@ -133,6 +137,18 @@ public Response checkUsername(@PathParam("username") String username) {
return pageModels;
}
+
+ private void populateWidgetsDefaultValue(Widget widget, WidgetModel widgetModel) {
+ if (widget.getPrefs() != null && widget.getPrefs().size() > 0) {
+ for(UserPreferenceSetting ups : widgetModel.getUserPreference().getData()) {
+ for(WidgetPreference wp: widget.getPrefs()) {
+ if (ups.getName().equals(wp.getName())) {
+ ups.setDefaultValue(wp.getValue());
+ }
+ }
+ }
+ }
+ }
@POST
@Path("widget/{widgetId}/remove")
View
14 gadgets/src/main/webapp/rt-gadget/gadget.xml
@@ -109,12 +109,14 @@
var min = [], max = [], duration = [];
var jsondata, rtResult, i, ts;
jsondata = response.data;
- for (i = 0; i < jsondata.length; i++) {
- rtResult = jsondata[i];
- ts = getDateTime(new Date(rtResult.timestamp));
- min.push([i, rtResult.min, rtResult.serviceType, rtResult.operation, ts]);
- max.push([i, rtResult.max, rtResult.serviceType, rtResult.operation, ts]);
- duration.push([i, rtResult.average, rtResult.serviceType, rtResult.operation, ts]);
+ if (jsondata != undefined) {
+ for (i = 0; i < jsondata.length; i++) {
+ rtResult = jsondata[i];
+ ts = getDateTime(new Date(rtResult.timestamp));
+ min.push([i, rtResult.min, rtResult.serviceType, rtResult.operation, ts]);
+ max.push([i, rtResult.max, rtResult.serviceType, rtResult.operation, ts]);
+ duration.push([i, rtResult.average, rtResult.serviceType, rtResult.operation, ts]);
+ }
}
return [{data:min, label:"Min"},
View
2 gadgets/src/main/webapp/situation-gadget/gadget.xml
@@ -48,7 +48,7 @@
function updateResponse(result) {
var jsondata, slaResult, i, rowData, theUpdatedTime;
- if (result.data == "undefined") {
+ if (result.data == undefined) {
return;
}
theUpdatedTime = new Date();

0 comments on commit 1516104

Please sign in to comment.