Initial Commit : Network Map
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../models/network/network_site.dart';
|
||||
import '../../models/network/topology_graph.dart';
|
||||
import 'network_devices_provider.dart';
|
||||
import 'network_sites_provider.dart';
|
||||
|
||||
/// Aggregate topology for a specific site (or null for orphan devices).
|
||||
///
|
||||
/// This rebuilds whenever any of the underlying tables changes — invalidation
|
||||
/// flows from the granular providers (sites, locations, devices, ports, links,
|
||||
/// vlans) up through this aggregate.
|
||||
final topologyForSiteProvider =
|
||||
FutureProvider.family<TopologyGraph, String?>((ref, siteId) async {
|
||||
final sites = await ref.watch(networkSitesProvider.future);
|
||||
final locations = await ref.watch(networkLocationsProvider.future);
|
||||
final devices = await ref.watch(networkDevicesProvider.future);
|
||||
final ports = await ref.watch(networkPortsProvider.future);
|
||||
final links = await ref.watch(networkLinksProvider.future);
|
||||
final vlans = await ref.watch(networkVlansProvider.future);
|
||||
|
||||
NetworkSite? site;
|
||||
if (siteId != null) {
|
||||
for (final s in sites) {
|
||||
if (s.id == siteId) {
|
||||
site = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TopologyGraph.build(
|
||||
site: site,
|
||||
allLocations: locations,
|
||||
allDevices: devices,
|
||||
allPorts: ports,
|
||||
allLinks: links,
|
||||
allVlans: vlans,
|
||||
);
|
||||
});
|
||||
|
||||
final topologyViewModeProvider =
|
||||
StateProvider<TopologyViewMode>((ref) => TopologyViewMode.physical);
|
||||
Reference in New Issue
Block a user