mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
added incoming and outgoing connections
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import 'dart:ui';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart';
|
||||
|
||||
class SpaceModel {
|
||||
final String? uuid;
|
||||
@ -8,12 +9,15 @@ class SpaceModel {
|
||||
final String name;
|
||||
final bool isPrivate;
|
||||
final String? invitationCode;
|
||||
final SpaceModel? parent;
|
||||
SpaceModel? parent;
|
||||
final CommunityModel? community;
|
||||
final List<SpaceModel> children;
|
||||
List<SpaceModel> children;
|
||||
Offset position;
|
||||
bool isHovered;
|
||||
|
||||
List<Connection> outgoingConnections = []; // Connections from this space
|
||||
List<Connection> incomingConnections = []; // Connections to this space
|
||||
|
||||
SpaceModel({
|
||||
this.uuid,
|
||||
this.spaceTuyaUuid,
|
||||
@ -35,15 +39,10 @@ class SpaceModel {
|
||||
name: json['spaceName'],
|
||||
isPrivate: json['isPrivate'] ?? false,
|
||||
invitationCode: json['invitationCode'],
|
||||
parent:
|
||||
json['parent'] != null ? SpaceModel.fromJson(json['parent']) : null,
|
||||
community: json['community'] != null
|
||||
? CommunityModel.fromJson(json['community'])
|
||||
: null,
|
||||
parent: json['parent'] != null ? SpaceModel.fromJson(json['parent']) : null,
|
||||
community: json['community'] != null ? CommunityModel.fromJson(json['community']) : null,
|
||||
children: json['children'] != null
|
||||
? (json['children'] as List)
|
||||
.map((child) => SpaceModel.fromJson(child))
|
||||
.toList()
|
||||
? (json['children'] as List).map((child) => SpaceModel.fromJson(child)).toList()
|
||||
: [],
|
||||
icon: json['icon'] as String?,
|
||||
position: json['position'] != null
|
||||
@ -60,12 +59,22 @@ class SpaceModel {
|
||||
'name': name,
|
||||
'isPrivate': isPrivate,
|
||||
'invitationCode': invitationCode,
|
||||
'parent': parent?.toMap(),
|
||||
'parent': parent?.uuid,
|
||||
'community': community?.toMap(),
|
||||
'children': children.map((child) => child.toMap()).toList(),
|
||||
'icon': icon,
|
||||
'position': {'dx': position.dx, 'dy': position.dy},
|
||||
'isHovered': isHovered,
|
||||
'outgoingConnections': outgoingConnections.map((c) => c.toMap()).toList(),
|
||||
'incomingConnections': incomingConnections.map((c) => c.toMap()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
void addOutgoingConnection(Connection connection) {
|
||||
outgoingConnections.add(connection);
|
||||
}
|
||||
|
||||
void addIncomingConnection(Connection connection) {
|
||||
incomingConnections.add(connection);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user