Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
- Loading branch information
Showing
39 changed files
with
965 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../main/java/org/eclipse/kapua/app/console/module/account/client/AccountDetailsTabCors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.console.module.account.client; | ||
|
||
import org.eclipse.kapua.app.console.module.account.client.cors.CorsView; | ||
import org.eclipse.kapua.app.console.module.account.shared.model.GwtAccount; | ||
import org.eclipse.kapua.app.console.module.api.client.resources.icons.IconSet; | ||
import org.eclipse.kapua.app.console.module.api.client.resources.icons.KapuaIcon; | ||
import org.eclipse.kapua.app.console.module.api.client.ui.tab.KapuaTabItem; | ||
import org.eclipse.kapua.app.console.module.api.shared.model.session.GwtSession; | ||
|
||
import com.google.gwt.user.client.Element; | ||
|
||
public class AccountDetailsTabCors extends KapuaTabItem<GwtAccount> { | ||
|
||
private final AccountDetailsView accountDetailsView; | ||
|
||
public AccountDetailsTabCors(GwtSession currentSession, AccountDetailsView accountDetailsView) { | ||
super(currentSession, "CORS", new KapuaIcon(IconSet.EXTERNAL_LINK)); | ||
this.accountDetailsView = accountDetailsView; | ||
} | ||
|
||
@Override | ||
protected void doRefresh() { | ||
|
||
} | ||
|
||
@Override | ||
protected void onRender(Element parent, int index) { | ||
super.onRender(parent, index); | ||
CorsView corsView = new CorsView(currentSession); | ||
add(corsView); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
...src/main/java/org/eclipse/kapua/app/console/module/account/client/cors/CorsAddDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018, 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.console.module.account.client.cors; | ||
|
||
import org.eclipse.kapua.app.console.module.api.client.messages.ConsoleMessages; | ||
import org.eclipse.kapua.app.console.module.api.client.messages.ValidationMessages; | ||
import org.eclipse.kapua.app.console.module.api.client.ui.dialog.entity.EntityAddEditDialog; | ||
import org.eclipse.kapua.app.console.module.api.client.ui.panel.FormPanel; | ||
import org.eclipse.kapua.app.console.module.api.client.ui.widget.KapuaTextField; | ||
import org.eclipse.kapua.app.console.module.api.client.util.ConsoleInfo; | ||
import org.eclipse.kapua.app.console.module.api.client.util.DialogUtils; | ||
import org.eclipse.kapua.app.console.module.api.client.util.FailureHandler; | ||
import org.eclipse.kapua.app.console.module.api.shared.model.session.GwtSession; | ||
import org.eclipse.kapua.app.console.module.endpoint.client.EndpointModel; | ||
import org.eclipse.kapua.app.console.module.endpoint.client.messages.ConsoleEndpointMessages; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.model.GwtEndpoint; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.model.GwtEndpointCreator; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.service.GwtEndpointService; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.service.GwtEndpointServiceAsync; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.user.client.rpc.AsyncCallback; | ||
|
||
public class CorsAddDialog extends EntityAddEditDialog { | ||
|
||
private static final GwtEndpointServiceAsync GWT_ENDPOINT_SERVICE = GWT.create(GwtEndpointService.class); | ||
protected static final ConsoleEndpointMessages MSGS = GWT.create(ConsoleEndpointMessages.class); | ||
protected static final ConsoleMessages CMSGS = GWT.create(ConsoleMessages.class); | ||
protected static final ValidationMessages VAL_MSGS = GWT.create(ValidationMessages.class); | ||
|
||
protected KapuaTextField<String> corsOriginField; | ||
|
||
public CorsAddDialog(GwtSession currentSession) { | ||
super(currentSession); | ||
DialogUtils.resizeDialog(this, 400, 150); | ||
} | ||
|
||
@Override | ||
public void createBody() { | ||
submitButton.disable(); | ||
FormPanel endpointFormPanel = new FormPanel(FORM_LABEL_WIDTH); | ||
|
||
corsOriginField = new KapuaTextField<String>(); | ||
corsOriginField.setAllowBlank(false); | ||
corsOriginField.setFieldLabel("* " + MSGS.corsDialogAddFieldOrigin()); | ||
corsOriginField.setToolTip(MSGS.corsDialogAddFieldOriginTooltip()); | ||
corsOriginField.setMaxLength(64); | ||
endpointFormPanel.add(corsOriginField); | ||
|
||
bodyPanel.add(endpointFormPanel); | ||
} | ||
|
||
@Override | ||
public void submit() { | ||
GwtEndpointCreator gwtEndpointCreator = new GwtEndpointCreator(); | ||
gwtEndpointCreator.setScopeId(currentSession.getSelectedAccountId()); | ||
|
||
GWT_ENDPOINT_SERVICE.parseEndpointModel(gwtEndpointCreator, corsOriginField.getValue(), new AsyncCallback<EndpointModel>() { | ||
|
||
@Override | ||
public void onFailure(Throwable throwable) { | ||
exitStatus = false; | ||
status.hide(); | ||
formPanel.getButtonBar().enable(); | ||
unmask(); | ||
submitButton.enable(); | ||
cancelButton.enable(); | ||
ConsoleInfo.display(CMSGS.error(), MSGS.corsDialogUnableToParse()); | ||
corsOriginField.markInvalid(MSGS.corsDialogUnableToParse()); | ||
} | ||
|
||
@Override | ||
public void onSuccess(EndpointModel gwtEndpointCreator) { | ||
GWT_ENDPOINT_SERVICE.create((GwtEndpointCreator) gwtEndpointCreator, new AsyncCallback<GwtEndpoint>() { | ||
|
||
@Override | ||
public void onSuccess(GwtEndpoint gwtEndpoint) { | ||
exitStatus = true; | ||
exitMessage = MSGS.corsDialogAddConfirmation(); | ||
hide(); | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable cause) { | ||
exitStatus = false; | ||
status.hide(); | ||
formPanel.getButtonBar().enable(); | ||
unmask(); | ||
submitButton.enable(); | ||
cancelButton.enable(); | ||
if (!isPermissionErrorMessage(cause)) { | ||
FailureHandler.handleFormException(formPanel, cause); | ||
corsOriginField.markInvalid(VAL_MSGS.DUPLICATE_NAME()); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public String getHeaderMessage() { | ||
return MSGS.corsDialogAddHeader(); | ||
} | ||
|
||
@Override | ||
public String getInfoMessage() { | ||
return MSGS.corsDialogAddInfo(); | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
.../main/java/org/eclipse/kapua/app/console/module/account/client/cors/CorsDeleteDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018, 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.console.module.account.client.cors; | ||
|
||
import org.eclipse.kapua.app.console.module.api.client.ui.dialog.entity.EntityDeleteDialog; | ||
import org.eclipse.kapua.app.console.module.api.client.util.DialogUtils; | ||
import org.eclipse.kapua.app.console.module.api.client.util.FailureHandler; | ||
import org.eclipse.kapua.app.console.module.endpoint.client.messages.ConsoleEndpointMessages; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.model.GwtEndpoint; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.service.GwtEndpointService; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.service.GwtEndpointServiceAsync; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.user.client.rpc.AsyncCallback; | ||
|
||
public class CorsDeleteDialog extends EntityDeleteDialog { | ||
|
||
private static final ConsoleEndpointMessages MSGS = GWT.create(ConsoleEndpointMessages.class); | ||
|
||
private static final GwtEndpointServiceAsync GWT_ENDPOINT_SERVICE = GWT.create(GwtEndpointService.class); | ||
|
||
private GwtEndpoint gwtEndpoint; | ||
|
||
public CorsDeleteDialog(GwtEndpoint gwtEndpoint) { | ||
this.gwtEndpoint = gwtEndpoint; | ||
DialogUtils.resizeDialog(this, 300, 135); | ||
setDisabledFormPanelEvents(true); | ||
} | ||
|
||
@Override | ||
public void submit() { | ||
GWT_ENDPOINT_SERVICE.delete(gwtEndpoint.getScopeId(), gwtEndpoint.getId(), new AsyncCallback<Void>() { | ||
|
||
@Override | ||
public void onFailure(Throwable cause) { | ||
exitStatus = false; | ||
if (!isPermissionErrorMessage(cause)) { | ||
FailureHandler.handle(cause); | ||
exitMessage = MSGS.dialogDeleteError(cause.getLocalizedMessage()); | ||
} | ||
hide(); | ||
|
||
} | ||
|
||
@Override | ||
public void onSuccess(Void arg0) { | ||
exitStatus = true; | ||
exitMessage = MSGS.dialogDeleteConfirmation(); | ||
hide(); | ||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public String getHeaderMessage() { | ||
return MSGS.dialogDeleteHeader(gwtEndpoint.toString()); | ||
} | ||
|
||
@Override | ||
public String getInfoMessage() { | ||
return MSGS.dialogDeleteInfo(); | ||
} | ||
|
||
} |
104 changes: 104 additions & 0 deletions
104
...rc/main/java/org/eclipse/kapua/app/console/module/account/client/cors/CorsEditDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018, 2021 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.console.module.account.client.cors; | ||
|
||
import org.eclipse.kapua.app.console.module.api.client.util.ConsoleInfo; | ||
import org.eclipse.kapua.app.console.module.api.client.util.FailureHandler; | ||
import org.eclipse.kapua.app.console.module.api.shared.model.session.GwtSession; | ||
import org.eclipse.kapua.app.console.module.endpoint.client.EndpointModel; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.model.GwtEndpoint; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.service.GwtEndpointService; | ||
import org.eclipse.kapua.app.console.module.endpoint.shared.service.GwtEndpointServiceAsync; | ||
|
||
import com.google.gwt.core.client.GWT; | ||
import com.google.gwt.user.client.rpc.AsyncCallback; | ||
|
||
public class CorsEditDialog extends CorsAddDialog { | ||
|
||
private static final GwtEndpointServiceAsync GWT_ENDPOINT_SERVICE = GWT.create(GwtEndpointService.class); | ||
private final GwtEndpoint selectedEndpoint; | ||
|
||
public CorsEditDialog(GwtSession currentSession, GwtEndpoint selectedEndpoint) { | ||
super(currentSession); | ||
this.selectedEndpoint = selectedEndpoint; | ||
} | ||
|
||
@Override | ||
public void createBody() { | ||
|
||
super.createBody(); | ||
populateEditDialog(selectedEndpoint); | ||
} | ||
|
||
@Override | ||
public void submit() { | ||
GWT_ENDPOINT_SERVICE.parseEndpointModel(selectedEndpoint, corsOriginField.getValue(), new AsyncCallback<EndpointModel>() { | ||
|
||
@Override | ||
public void onFailure(Throwable throwable) { | ||
exitStatus = false; | ||
status.hide(); | ||
formPanel.getButtonBar().enable(); | ||
unmask(); | ||
submitButton.enable(); | ||
cancelButton.enable(); | ||
ConsoleInfo.display(CMSGS.error(), MSGS.corsDialogUnableToParse()); | ||
corsOriginField.markInvalid(MSGS.corsDialogUnableToParse()); | ||
} | ||
|
||
@Override | ||
public void onSuccess(EndpointModel gwtEndpoint) { | ||
|
||
GWT_ENDPOINT_SERVICE.update((GwtEndpoint) gwtEndpoint, new AsyncCallback<GwtEndpoint>() { | ||
|
||
@Override | ||
public void onFailure(Throwable cause) { | ||
exitStatus = false; | ||
status.hide(); | ||
formPanel.getButtonBar().enable(); | ||
unmask(); | ||
submitButton.enable(); | ||
cancelButton.enable(); | ||
if (!isPermissionErrorMessage(cause)) { | ||
FailureHandler.handleFormException(formPanel, cause); | ||
corsOriginField.markInvalid(VAL_MSGS.DUPLICATE_NAME()); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void onSuccess(GwtEndpoint arg0) { | ||
exitStatus = true; | ||
exitMessage = MSGS.corsDialogEditConfirmation(); | ||
hide(); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public String getHeaderMessage() { | ||
return MSGS.corsDialogEditHeader(selectedEndpoint.toString()); | ||
} | ||
|
||
@Override | ||
public String getInfoMessage() { | ||
return MSGS.corsDialogEditInfo(); | ||
} | ||
|
||
private void populateEditDialog(GwtEndpoint gwtEndpoint) { | ||
corsOriginField.setValue(gwtEndpoint.toString()); | ||
} | ||
|
||
} |
Oops, something went wrong.