Skip to content

Commit

Permalink
feat(web2): added 'Advanced' tab for MTUs and Promiscuous mode (#5087)
Browse files Browse the repository at this point in the history
* feat(web2): added 'Advanced' tab for MTUs and Promiscuous mode

* fix(web2): fixed mtu fields validation, grouped advanced network labels

* chore(web2): fixed copyright headers

* fix(web2): fixed unprintable char

* feat(web2): japanese labels in advanced network configuration tab
  • Loading branch information
fdizazzo authored Jan 17, 2024
1 parent 83b8591 commit 1063893
Show file tree
Hide file tree
Showing 14 changed files with 620 additions and 192 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Eurotech and/or its affiliates and others
* Copyright (c) 2011, 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
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* Eurotech
* Areti
*******************************************************************************/
package org.eclipse.kura.web.client.ui.network;

Expand Down Expand Up @@ -70,6 +71,7 @@ interface NetworkTabsUiUiBinder extends UiBinder<Widget, NetworkTabsUi> {
AnchorListItem modemGpsTabAnchorItem;
AnchorListItem modemAntennaTabAnchorItem;
AnchorListItem hardwareTabAnchorItem;
AnchorListItem advancedTabAnchorItem;
List<AnchorListItem> visibleTabs;

NetworkTab selectedTab;
Expand All @@ -82,6 +84,7 @@ interface NetworkTabsUiUiBinder extends UiBinder<Widget, NetworkTabsUi> {
TabModemUi modemTab;
TabModemGpsUi modemGpsTab;
TabModemAntennaUi modemAntennaTab;
TabAdvancedUi advancedTab;

GwtNetInterfaceConfig netIfConfig;
NetworkButtonBarUi buttons;
Expand Down Expand Up @@ -118,6 +121,7 @@ private void initTabs(final boolean isNet2) {
initModemAntennaTab();
initDhcp4NatTab();
initHardwareTab();
initAdvancedTab();

setSelected(this.ip4TabAnchorItem);
this.selectedTab = this.ip4Tab;
Expand Down Expand Up @@ -234,6 +238,18 @@ private void initHardwareTab() {
});
}

private void initAdvancedTab() {
this.advancedTabAnchorItem = new AnchorListItem(MSGS.netAdvanced());
this.advancedTab = new TabAdvancedUi(this.session, this);

this.advancedTabAnchorItem.addClickHandler(event -> {
setSelected(NetworkTabsUi.this.advancedTabAnchorItem);
NetworkTabsUi.this.selectedTab = NetworkTabsUi.this.advancedTab;
NetworkTabsUi.this.content.clear();
NetworkTabsUi.this.content.add(NetworkTabsUi.this.advancedTab);
});
}

public void setButtons(NetworkButtonBarUi buttons) {
this.buttons = buttons;
}
Expand All @@ -258,6 +274,7 @@ public void setNetInterface(GwtNetInterfaceConfig selection) {
this.modemGpsTab.setNetInterface(selection);
this.modemAntennaTab.setNetInterface(selection);
this.hardwareTab.setNetInterface(selection);
this.advancedTab.setNetInterface(selection);

updateTabs();
refreshAllVisibleTabs();
Expand All @@ -270,6 +287,7 @@ public void updateTabs() {

if (this.isNet2) {
insertTab(this.ip6TabAnchorItem);
insertTab(this.advancedTabAnchorItem);
}

arrangeOptionalTabs();
Expand All @@ -287,6 +305,7 @@ private void removeAllTabs() {
removeTab(this.modemGpsTabAnchorItem);
removeTab(this.modemAntennaTabAnchorItem);
removeTab(this.hardwareTabAnchorItem);
removeTab(this.advancedTabAnchorItem);
}

private void arrangeOptionalTabs() {
Expand Down Expand Up @@ -418,6 +437,9 @@ private void refreshAllVisibleTabs() {
if (this.visibleTabs.contains(this.net8021xTabAnchorItem)) {
this.set8021xTab.refresh();
}
if(this.visibleTabs.contains(this.advancedTabAnchorItem)) {
this.advancedTab.refresh();
}
}

/*
Expand Down Expand Up @@ -457,6 +479,10 @@ public boolean isDirty() {
if (this.visibleTabs.contains(this.net8021xTabAnchorItem) && this.set8021xTab.isDirty()) {
return true;
}

if (this.visibleTabs.contains(this.advancedTabAnchorItem) && this.advancedTab.isDirty()) {
return true;
}

return false;
}
Expand All @@ -471,6 +497,7 @@ public void setDirty(boolean isDirty) {
this.modemTab.setDirty(isDirty);
this.modemGpsTab.setDirty(isDirty);
this.modemAntennaTab.setDirty(isDirty);
this.advancedTab.setDirty(isDirty);
}

public void refresh() {
Expand All @@ -483,6 +510,7 @@ public void refresh() {
this.modemTab.refresh();
this.modemGpsTab.refresh();
this.modemAntennaTab.refresh();
this.advancedTab.refresh();
}

public GwtNetInterfaceConfig getUpdatedInterface() {
Expand Down Expand Up @@ -523,6 +551,9 @@ public GwtNetInterfaceConfig getUpdatedInterface() {
if (this.visibleTabs.contains(this.net8021xTabAnchorItem)) {
this.set8021xTab.getUpdatedNetInterface(updatedNetIf);
}
if (this.visibleTabs.contains(this.advancedTabAnchorItem)) {
this.advancedTab.getUpdatedNetInterface(updatedNetIf);
}

return updatedNetIf;
}
Expand All @@ -542,6 +573,7 @@ public boolean isValid() {
clearErrorTab(this.modemGpsTabAnchorItem);
clearErrorTab(this.modemAntennaTabAnchorItem);
clearErrorTab(this.net8021xTabAnchorItem);
clearErrorTab(this.advancedTabAnchorItem);

if (this.visibleTabs.contains(this.ip4TabAnchorItem) && !this.ip4Tab.isValid()) {
errorTab(this.ip4TabAnchorItem);
Expand Down Expand Up @@ -589,6 +621,12 @@ public boolean isValid() {
errorTab(this.net8021xTabAnchorItem);
return false;
}

if (this.visibleTabs.contains(this.advancedTabAnchorItem) && this.advancedTabAnchorItem.isEnabled()
&& !this.advancedTab.isValid()) {
errorTab(this.advancedTabAnchorItem);
return false;
}

return true;
}
Expand Down Expand Up @@ -634,6 +672,7 @@ private void setSelected(AnchorListItem item) {
this.modemTabAnchorItem.setActive(false);
this.modemGpsTabAnchorItem.setActive(false);
this.modemAntennaTabAnchorItem.setActive(false);
this.advancedTabAnchorItem.setActive(false);
item.setActive(true);
}

Expand Down
Loading

0 comments on commit 1063893

Please sign in to comment.