Skip to content

Commit

Permalink
Fix cv-select, and only show active interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Aug 31, 2023
1 parent ece130b commit f36de41
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion photon-client/src/components/app/photon-sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const mdAndUp = computed<boolean>(() => getCurrentInstance()?.proxy.$vuetify.bre
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title class="text-wrap">
{{ useStateStore().backendConnected ? "Backend Connected" : "Trying to connect to Backend" }}
{{ useStateStore().backendConnected ? "Backend connected" : "Trying to connect to backend" }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
Expand Down
5 changes: 5 additions & 0 deletions photon-client/src/components/common/cv-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const localValue = computed({
// Computed in case items changes
const items = computed<SelectItem[]>(() => {
// Trivial case for empty list; we have no data
if (!props.items.length) {
return [];
}
// Check if the prop exists on the object to infer object type
if((props.items[0] as SelectItem).name) {
return props.items as SelectItem[];
Expand Down
11 changes: 10 additions & 1 deletion photon-client/src/components/settings/NetworkingCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,17 @@ const currentNetworkInterfaceIndex = computed<number>({
:disabled="!(useSettingsStore().network.shouldManage && useSettingsStore().network.canManage)"
:select-cols="12-4"
tooltip="Name of the interface PhotonVision should manage the IP address of"
:items="useSettingsStore().networkInterfaceNames.map((v, i) => ({name: v, value: i, disabled: false}))"
:items="useSettingsStore().networkInterfaceNames"
/>
<v-banner
v-show="!useSettingsStore().networkInterfaceNames.length && useSettingsStore().network.shouldManage && useSettingsStore().network.canManage"
rounded
color="red"
text-color="white"
icon="mdi-information-outline"
>
Photon cannot detect any wired connections! Please send program logs to the developers for help
</v-banner>
<cv-switch
v-model="useSettingsStore().network.runNTServer"
label="Run NetworkTables Server (Debugging Only)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public String toString() {
}
}

public static ArrayList<NMDeviceInfo> getAllActiveInterfaces() {
public static ArrayList<NMDeviceInfo> getAllInterfaces() {
var ret = new ArrayList<NMDeviceInfo>();

if (!Platform.isLinux()) {
Expand Down Expand Up @@ -106,6 +106,14 @@ public static ArrayList<NMDeviceInfo> getAllActiveInterfaces() {
return ret;
}

public static List<NMDeviceInfo> getAllActiveInterfaces() {
// Seems like if a interface exists but isn't actually connected, the connection name will be an
// empty string. Check here and only return connections with non-empty names
return getAllInterfaces().stream()
.filter(it -> !it.connName.trim().isEmpty())
.collect(Collectors.toList());
}

public static List<NMDeviceInfo> getAllWiredInterfaces() {
return getAllActiveInterfaces().stream()
.filter(it -> it.nmType == NMType.NMTYPE_ETHERNET)
Expand Down

0 comments on commit f36de41

Please sign in to comment.