Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-coppola committed Dec 17, 2024
1 parent b221235 commit 298b9ae
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 170 deletions.
2 changes: 2 additions & 0 deletions kura/org.eclipse.kura.web2/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ output.. = target/classes/
source.. = src/main/java/,\
src/main/resources/,\
target/generated-sources/gwt
jars.extra.classpath = lib/gwtbootstrap3.jar,\
lib/gwt-user.jar
Binary file added kura/org.eclipse.kura.web2/lib/gwt-user.jar
Binary file not shown.
Binary file added kura/org.eclipse.kura.web2/lib/gwtbootstrap3.jar
Binary file not shown.
38 changes: 34 additions & 4 deletions kura/org.eclipse.kura.web2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@
<gwtVersion>2.10.0</gwtVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.gwtbootstrap3</groupId>
<artifactId>gwtbootstrap3</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gwtproject</groupId>
<artifactId>gwt-user</artifactId>
<version>2.12.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<extensions>
Expand All @@ -69,6 +67,35 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>validate</phase>
<configuration>
<outputDirectory>${project.basedir}/lib</outputDirectory>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>org.gwtbootstrap3</groupId>
<artifactId>gwtbootstrap3</artifactId>
<version>1.0.1</version>
</artifactItem>
<artifactItem>
<groupId>org.gwtproject</groupId>
<artifactId>gwt-user</artifactId>
<version>2.12.1</version>
</artifactItem>
</artifactItems>
</configuration>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Remove CSS on clean -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -82,6 +109,9 @@
<fileset>
<directory>src/main/webapp/WEB-INF</directory>
</fileset>
<fileset>
<directory>lib</directory>
</fileset>
</filesets>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
import static org.eclipse.kura.web.client.util.FilterBuilder.not;
import static org.eclipse.kura.web.client.util.FilterBuilder.or;

import java.awt.Button;
import java.awt.Container;
import java.awt.Panel;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

import javax.naming.Context;

import org.eclipse.kura.core.configuration.ConfigurationChangeEvent;
import org.eclipse.kura.web.client.messages.Messages;
Expand Down Expand Up @@ -71,11 +65,15 @@
import org.eclipse.kura.web.shared.service.GwtSessionService;
import org.eclipse.kura.web.shared.service.GwtSessionServiceAsync;
import org.gwtbootstrap3.client.ui.AnchorListItem;
import org.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.Column;
import org.gwtbootstrap3.client.ui.Container;
import org.gwtbootstrap3.client.ui.FormLabel;
import org.gwtbootstrap3.client.ui.Icon;
import org.gwtbootstrap3.client.ui.ListBox;
import org.gwtbootstrap3.client.ui.Modal;
import org.gwtbootstrap3.client.ui.NavPills;
import org.gwtbootstrap3.client.ui.Panel;
import org.gwtbootstrap3.client.ui.PanelBody;
import org.gwtbootstrap3.client.ui.PanelHeader;
import org.gwtbootstrap3.client.ui.Row;
Expand All @@ -101,7 +99,7 @@
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;

public class EntryClassUi extends Composite implements Context, ServicesUi.Listener {
public class EntryClassUi extends Composite implements ServicesUi.Listener {

interface EntryClassUIUiBinder extends UiBinder<Widget, EntryClassUi> {
}
Expand Down Expand Up @@ -322,15 +320,6 @@ public EntryClassUi(final GwtUserData gwtUserData, final GwtSecurityCapabilities

initDropdownMenu();
initServicesTree();
initExtensions();
}

private void initExtensions() {

ExtensionRegistry.get().addExtensionConsumer(e -> {
e.onLoad(this);
});

}

private void initExceptionReportModal() {
Expand Down Expand Up @@ -1150,7 +1139,7 @@ public void init() {

private void handleConcurrencyEvent(GwtEventInfo eventInfo) {
String eventPid = (String) eventInfo.getProperties().get(ConfigurationChangeEvent.CONF_CHANGE_EVENT_PID_PROP);
if (eventPid.length() == 0) {
if (eventPid.isEmpty()) {
this.dropdownNotification.show(MSGS.configurationChangeEventNotificationGeneric());
} else {
this.dropdownNotification.show(MSGS.configurationChangeEventNotification(eventPid));
Expand All @@ -1168,62 +1157,6 @@ private void showStatusPanel() {
this.statusBinder.loadStatusData(false);
}

@Override
public void addSidenavComponent(final String name, final String icon, final WidgetFactory widgetFactory) {
final AnchorListItem item = new AnchorListItem(name);

try {
item.setIcon(IconType.valueOf(icon));
} catch (final Exception e) {
// do nothing
}

item.addClickHandler(evt -> confirmIfUiDirty(() -> {
EntryClassUi.this.contentPanelBody.clear();

forceTabsCleaning();
EntryClassUi.this.setSelectedAnchorListItem(item);
EntryClassUi.this.contentPanel.setVisible(true);
setHeader(name, null);
EntryClassUi.this.contentPanelBody.clear();

EntryClassUi.this.contentPanelBody.add(widgetFactory.buildWidget());

EntryClassUi.this.deviceBinder.setSession(EntryClassUi.this.currentSession);
EntryClassUi.this.deviceBinder.initDevicePanel();
}));

this.sidenavPills.add(item);
}

@Override
public void addSettingsComponent(final String name, final WidgetFactory factory) {
this.settingsBinder.addTab(name, factory);
}

@Override
public void addAuthenticationHandler(final AuthenticationHandler authenticationHandler) {
// unsupported
}

@Override
public void getXSRFToken(Callback<String, String> callback) {
this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

@Override
public void onSuccess(GwtXSRFToken result) {
callback.onSuccess(result.getToken());
}

@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught.getMessage());
}

});

}

private class WrapperRequest implements Callback<Void, String>, Request {

private AsyncCallback<Void> wrapped;
Expand All @@ -1245,24 +1178,6 @@ public void run(RequestContext context) {

}

@Override
public Callback<Void, String> startLongRunningOperation() {

final WrapperRequest callback = new WrapperRequest();

RequestQueue.submit(callback);

return callback;

}

@Override
public void showAlertDialog(final String message, final AlertSeverity severity, final Consumer<Boolean> callback) {
this.alertDialog.show(message,
severity == AlertSeverity.INFO ? AlertDialog.Severity.INFO : AlertDialog.Severity.ALERT,
callback::accept);
}

@Override
public void onConfigurationChanged() {
fetchAvailableServices();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2024 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
*******************************************************************************/

package org.eclipse.kura.web.client.ui.login;

import java.util.function.Supplier;

import com.google.gwt.core.client.Callback;
import com.google.gwt.user.client.ui.Widget;

public interface AuthenticationHandler {

public String getName();

public Supplier<Widget> getLoginDialogElement();

public void authenticate(final Callback<String, String> callback);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
*******************************************************************************/
package org.eclipse.kura.web.client.ui.login;

import java.awt.Button;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

import javax.naming.Context;
import java.util.function.Supplier;

import org.eclipse.kura.web.client.messages.Messages;
import org.eclipse.kura.web.client.ui.AlertDialog;
Expand All @@ -37,7 +35,9 @@
import org.eclipse.kura.web.shared.service.GwtSecurityTokenServiceAsync;
import org.eclipse.kura.web.shared.service.GwtSessionService;
import org.eclipse.kura.web.shared.service.GwtSessionServiceAsync;
import org.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.FormGroup;
import org.gwtbootstrap3.client.ui.Icon;
import org.gwtbootstrap3.client.ui.Input;
import org.gwtbootstrap3.client.ui.InputGroup;
import org.gwtbootstrap3.client.ui.InputGroupAddon;
Expand All @@ -63,7 +63,7 @@
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

public class LoginUi extends Composite implements Context {
public class LoginUi extends Composite {

private final GwtPasswordAuthenticationServiceAsync pwdAutenticationService = GWT
.create(GwtPasswordAuthenticationService.class);
Expand Down Expand Up @@ -136,8 +136,6 @@ private void initAuthenticationHandlers(final GwtLoginInfo loginInfo) {

authenticationMethod.addChangeHandler(e -> setAuthenticationMethod(authenticationMethod.getSelectedItemText()));

ExtensionRegistry.get().addExtensionConsumer(e -> e.onLoad(LoginUi.this));

}

@Override
Expand Down Expand Up @@ -188,13 +186,13 @@ private void setAuthenticationMethod(final String authenticationMethod) {
this.authenticationMethodWidget = null;
}

final WidgetFactory factory = this.authenticationHandler.getLoginDialogElement();
final Supplier<Widget> factory = this.authenticationHandler.getLoginDialogElement();

if (factory == null) {
return;
}

this.authenticationMethodWidget = factory.buildWidget();
this.authenticationMethodWidget = factory.get();

if (this.authenticationMethodWidget != null) {
this.loginModalBody.add(this.authenticationMethodWidget);
Expand All @@ -215,17 +213,6 @@ private void initWaitModal() {
this.waitModal.hide();
}

@Override
public void addSidenavComponent(String name, String icon, WidgetFactory element) {
// not supported
}

@Override
public void addSettingsComponent(String name, WidgetFactory element) {
// not supported
}

@Override
public void addAuthenticationHandler(final AuthenticationHandler authenticationHandler) {
final String name = authenticationHandler.getName();

Expand All @@ -248,12 +235,6 @@ public void addAuthenticationHandler(final AuthenticationHandler authenticationH
this.authenticationMethodGroup.setVisible(this.authenticationHandlers.size() >= 2);
}

@Override
public void getXSRFToken(Callback<String, String> callback) {
callback.onFailure("not supported");
}

@Override
public Callback<Void, String> startLongRunningOperation() {
this.waitModal.show();
return new Callback<Void, String>() {
Expand All @@ -273,13 +254,6 @@ public void onSuccess(Void result) {
};
}

@Override
public void showAlertDialog(String message, AlertSeverity severity, Consumer<Boolean> callback) {
this.alertDialog.show(message,
severity == AlertSeverity.INFO ? AlertDialog.Severity.INFO : AlertDialog.Severity.ALERT,
callback::accept);
}

private class PasswordAuthenticationHandler implements AuthenticationHandler {

private final FormGroup group = new FormGroup();
Expand Down Expand Up @@ -336,7 +310,7 @@ public String getName() {
}

@Override
public WidgetFactory getLoginDialogElement() {
public Supplier<Widget> getLoginDialogElement() {
return () -> {
this.passwordInput.setValue("");
return this.group;
Expand Down Expand Up @@ -436,7 +410,7 @@ public String getName() {
}

@Override
public WidgetFactory getLoginDialogElement() {
public Supplier<Widget> getLoginDialogElement() {
return () -> {
final Paragraph paragraph = new Paragraph();
paragraph.setText(MSGS.loginCertificateDescription());
Expand Down
Loading

0 comments on commit 298b9ae

Please sign in to comment.