mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Fix PR notes.
This commit is contained in:
@ -13,12 +13,12 @@ class CommunitiesBloc extends Bloc<CommunitiesEvent, CommunitiesState> {
|
|||||||
required CommunitiesService communitiesService,
|
required CommunitiesService communitiesService,
|
||||||
}) : _communitiesService = communitiesService,
|
}) : _communitiesService = communitiesService,
|
||||||
super(const CommunitiesState()) {
|
super(const CommunitiesState()) {
|
||||||
on<LoadCommunities>(_onGetCommunity);
|
on<LoadCommunities>(_onLoadCommunities);
|
||||||
}
|
}
|
||||||
|
|
||||||
final CommunitiesService _communitiesService;
|
final CommunitiesService _communitiesService;
|
||||||
|
|
||||||
Future<void> _onGetCommunity(
|
Future<void> _onLoadCommunities(
|
||||||
LoadCommunities event,
|
LoadCommunities event,
|
||||||
Emitter<CommunitiesState> emit,
|
Emitter<CommunitiesState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/params/load_products_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/params/load_products_param.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/services/products_service.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/services/products_service.dart';
|
||||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||||
@ -13,7 +13,7 @@ class RemoteProductsService implements ProductsService {
|
|||||||
static const _defaultErrorMessage = 'Failed to load devices';
|
static const _defaultErrorMessage = 'Failed to load devices';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<ProductModel>> getProducts(LoadProductsParam param) async {
|
Future<List<Product>> getProducts(LoadProductsParam param) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: 'devices',
|
path: 'devices',
|
||||||
@ -24,7 +24,7 @@ class RemoteProductsService implements ProductsService {
|
|||||||
},
|
},
|
||||||
expectedResponseModel: (data) {
|
expectedResponseModel: (data) {
|
||||||
return (data as List)
|
return (data as List)
|
||||||
.map((e) => ProductModel.fromJson(e as Map<String, dynamic>))
|
.map((e) => Product.fromJson(e as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
class ProductModel extends Equatable {
|
class Product extends Equatable {
|
||||||
final String uuid;
|
final String uuid;
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
const ProductModel({
|
const Product({
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
required this.name,
|
required this.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ProductModel.fromJson(Map<String, dynamic> json) {
|
factory Product.fromJson(Map<String, dynamic> json) {
|
||||||
return ProductModel(
|
return Product(
|
||||||
uuid: json['uuid'] as String,
|
uuid: json['uuid'] as String,
|
||||||
name: json['name'] as String,
|
name: json['name'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'uuid': uuid,
|
||||||
|
'name': name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [uuid, name];
|
List<Object?> get props => [uuid, name];
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/params/load_products_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/params/load_products_param.dart';
|
||||||
|
|
||||||
abstract class ProductsService {
|
abstract class ProductsService {
|
||||||
Future<List<ProductModel>> getProducts(LoadProductsParam param);
|
Future<List<Product>> getProducts(LoadProductsParam param);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/params/load_products_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/params/load_products_param.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/services/products_service.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/services/products_service.dart';
|
||||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||||
@ -12,10 +12,10 @@ class ProductsBloc extends Bloc<ProductsEvent, ProductsState> {
|
|||||||
final ProductsService _deviceService;
|
final ProductsService _deviceService;
|
||||||
|
|
||||||
ProductsBloc(this._deviceService) : super(ProductsInitial()) {
|
ProductsBloc(this._deviceService) : super(ProductsInitial()) {
|
||||||
on<LoadProducts>(_onLoadDevices);
|
on<LoadProducts>(_onLoadProducts);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadDevices(
|
Future<void> _onLoadProducts(
|
||||||
LoadProducts event,
|
LoadProducts event,
|
||||||
Emitter<ProductsState> emit,
|
Emitter<ProductsState> emit,
|
||||||
) async {
|
) async {
|
||||||
|
@ -12,12 +12,12 @@ final class ProductsInitial extends ProductsState {}
|
|||||||
final class ProductsLoading extends ProductsState {}
|
final class ProductsLoading extends ProductsState {}
|
||||||
|
|
||||||
final class ProductsLoaded extends ProductsState {
|
final class ProductsLoaded extends ProductsState {
|
||||||
final List<ProductModel> devices;
|
final List<Product> products;
|
||||||
|
|
||||||
const ProductsLoaded(this.devices);
|
const ProductsLoaded(this.products);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [devices];
|
List<Object> get props => [products];
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ProductsFailure extends ProductsState {
|
final class ProductsFailure extends ProductsState {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_management_v2/modules/products/domain/models/product.dart';
|
||||||
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag.dart';
|
||||||
|
|
||||||
class SpaceDetailsModel extends Equatable {
|
class SpaceDetailsModel extends Equatable {
|
||||||
final String uuid;
|
final String uuid;
|
||||||
@ -46,10 +48,12 @@ class SpaceDetailsModel extends Equatable {
|
|||||||
class ProductAllocation extends Equatable {
|
class ProductAllocation extends Equatable {
|
||||||
final Product product;
|
final Product product;
|
||||||
final Tag tag;
|
final Tag tag;
|
||||||
|
final String? location;
|
||||||
|
|
||||||
const ProductAllocation({
|
const ProductAllocation({
|
||||||
required this.product,
|
required this.product,
|
||||||
required this.tag,
|
required this.tag,
|
||||||
|
this.location,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ProductAllocation.fromJson(Map<String, dynamic> json) {
|
factory ProductAllocation.fromJson(Map<String, dynamic> json) {
|
||||||
@ -70,68 +74,6 @@ class ProductAllocation extends Equatable {
|
|||||||
List<Object?> get props => [product, tag];
|
List<Object?> get props => [product, tag];
|
||||||
}
|
}
|
||||||
|
|
||||||
class Product extends Equatable {
|
|
||||||
final String uuid;
|
|
||||||
final String name;
|
|
||||||
|
|
||||||
const Product({
|
|
||||||
required this.uuid,
|
|
||||||
required this.name,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Product.fromJson(Map<String, dynamic> json) {
|
|
||||||
return Product(
|
|
||||||
uuid: json['uuid'] as String,
|
|
||||||
name: json['name'] as String,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'uuid': uuid,
|
|
||||||
'name': name,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [uuid, name];
|
|
||||||
}
|
|
||||||
|
|
||||||
class Tag extends Equatable {
|
|
||||||
final String uuid;
|
|
||||||
final String name;
|
|
||||||
final String createdAt;
|
|
||||||
final String updatedAt;
|
|
||||||
|
|
||||||
const Tag({
|
|
||||||
required this.uuid,
|
|
||||||
required this.name,
|
|
||||||
required this.createdAt,
|
|
||||||
required this.updatedAt,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Tag.fromJson(Map<String, dynamic> json) {
|
|
||||||
return Tag(
|
|
||||||
uuid: json['uuid'] as String,
|
|
||||||
name: json['name'] as String,
|
|
||||||
createdAt: json['createdAt'] as String,
|
|
||||||
updatedAt: json['updatedAt'] as String,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'uuid': uuid,
|
|
||||||
'name': name,
|
|
||||||
'createdAt': createdAt,
|
|
||||||
'updatedAt': updatedAt,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [uuid, name, createdAt, updatedAt];
|
|
||||||
}
|
|
||||||
|
|
||||||
class Subspace extends Equatable {
|
class Subspace extends Equatable {
|
||||||
final String uuid;
|
final String uuid;
|
||||||
final String name;
|
final String name;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/params/load_tags_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/params/load_tags_param.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/services/tags_service.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/services/tags_service.dart';
|
||||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||||
@ -14,7 +14,7 @@ final class RemoteTagsService implements TagsService {
|
|||||||
static const _defaultErrorMessage = 'Failed to load tags';
|
static const _defaultErrorMessage = 'Failed to load tags';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<TagModel>> loadTags(LoadTagsParam param) async {
|
Future<List<Tag>> loadTags(LoadTagsParam param) async {
|
||||||
if (param.projectUuid == null) {
|
if (param.projectUuid == null) {
|
||||||
throw Exception('Project UUID is required');
|
throw Exception('Project UUID is required');
|
||||||
}
|
}
|
||||||
@ -28,9 +28,7 @@ final class RemoteTagsService implements TagsService {
|
|||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
final result = json as Map<String, dynamic>;
|
final result = json as Map<String, dynamic>;
|
||||||
final data = result['data'] as List<dynamic>;
|
final data = result['data'] as List<dynamic>;
|
||||||
return data
|
return data.map((e) => Tag.fromJson(e as Map<String, dynamic>)).toList();
|
||||||
.map((e) => TagModel.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList();
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
class Tag extends Equatable {
|
||||||
|
final String uuid;
|
||||||
|
final String name;
|
||||||
|
final String createdAt;
|
||||||
|
final String updatedAt;
|
||||||
|
|
||||||
|
const Tag({
|
||||||
|
required this.uuid,
|
||||||
|
required this.name,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.updatedAt,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Tag.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Tag(
|
||||||
|
uuid: json['uuid'] as String,
|
||||||
|
name: json['name'] as String,
|
||||||
|
createdAt: json['createdAt'] as String,
|
||||||
|
updatedAt: json['updatedAt'] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'uuid': uuid,
|
||||||
|
'name': name,
|
||||||
|
'createdAt': createdAt,
|
||||||
|
'updatedAt': updatedAt,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [uuid, name, createdAt, updatedAt];
|
||||||
|
}
|
@ -1,53 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:uuid/uuid.dart';
|
|
||||||
|
|
||||||
class TagModel extends Equatable {
|
|
||||||
const TagModel({
|
|
||||||
required this.uuid,
|
|
||||||
required this.tag,
|
|
||||||
required this.internalId,
|
|
||||||
required this.location,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String? uuid;
|
|
||||||
final String? tag;
|
|
||||||
final String? internalId;
|
|
||||||
final String? location;
|
|
||||||
|
|
||||||
factory TagModel.fromJson(Map<String, dynamic> json) {
|
|
||||||
final internalId = json['internalId'] as String? ?? const Uuid().v4();
|
|
||||||
final tag = json['tag'] as Map<String, dynamic>?;
|
|
||||||
final name = json['name'] as String?;
|
|
||||||
|
|
||||||
return TagModel(
|
|
||||||
uuid: name != null ? json['uuid'] as String? : tag?['uuid'] as String?,
|
|
||||||
internalId: internalId,
|
|
||||||
tag: name ?? tag?['name'] as String?,
|
|
||||||
location: json['location'] as String?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TagModel copyWith({
|
|
||||||
String? uuid,
|
|
||||||
String? tag,
|
|
||||||
String? location,
|
|
||||||
String? internalId,
|
|
||||||
}) {
|
|
||||||
return TagModel(
|
|
||||||
uuid: uuid ?? this.uuid,
|
|
||||||
tag: tag ?? this.tag,
|
|
||||||
location: location ?? this.location,
|
|
||||||
internalId: internalId ?? this.internalId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
if (uuid != null) 'uuid': uuid,
|
|
||||||
'name': tag,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [uuid, tag, internalId, location];
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/params/load_tags_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/params/load_tags_param.dart';
|
||||||
|
|
||||||
abstract interface class TagsService {
|
abstract interface class TagsService {
|
||||||
Future<List<TagModel>> loadTags(LoadTagsParam param);
|
Future<List<Tag>> loadTags(LoadTagsParam param);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag_model.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/models/tag.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/params/load_tags_param.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/params/load_tags_param.dart';
|
||||||
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/services/tags_service.dart';
|
import 'package:syncrow_web/pages/space_management_v2/modules/tags/domain/services/tags_service.dart';
|
||||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||||
|
@ -12,7 +12,7 @@ class TagsInitial extends TagsState {}
|
|||||||
class TagsLoading extends TagsState {}
|
class TagsLoading extends TagsState {}
|
||||||
|
|
||||||
class TagsLoaded extends TagsState {
|
class TagsLoaded extends TagsState {
|
||||||
final List<TagModel> tags;
|
final List<Tag> tags;
|
||||||
|
|
||||||
const TagsLoaded(this.tags);
|
const TagsLoaded(this.tags);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user