Compare commits

..

11 Commits

Author SHA1 Message Date
de65f79ccf Merge branch 'dev' of https://github.com/SyncrowIOT/web into bugfix/empty-space-model 2025-03-09 17:32:06 +04:00
eb0490fb16 fixed issue in update 2025-03-09 17:31:36 +04:00
a73fc04712 Merge pull request #110 from SyncrowIOT/SP-1297
fix model and SpaceModelCardWidget and LinkSpaceModelSpacesDialog
2025-03-09 16:11:18 +03:00
dee07ebb06 fix LinkingSuccessful 2025-03-09 16:01:04 +03:00
5237f3ae5b Merge pull request #111 from SyncrowIOT/bugfix/empty-space-model
fix the circular progress on empty space model
2025-03-09 16:49:36 +04:00
e017633b9b fixed space model 2025-03-09 16:48:42 +04:00
e8e5e9bcb7 fix LoadedSpaceView 2025-03-09 14:54:13 +03:00
a1d15c9cea fix the circular progress on empty space model 2025-03-09 15:53:55 +04:00
16c006e7a9 Merge pull request #109 from SyncrowIOT/feat/fix-update-on-community-tree
Feat/fix-update-on-community-tree
2025-03-09 14:06:48 +04:00
8359642a1a Merge branch 'dev' into SP-1297 2025-03-09 12:03:34 +03:00
8af24e575c fix model and SpaceModelCardWidget and LinkSpaceModelSpacesDialog 2025-03-08 09:57:35 +03:00
6 changed files with 181 additions and 175 deletions

View File

@ -52,14 +52,24 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
Future<void> _updateSpaceModelCache( Future<void> _updateSpaceModelCache(
UpdateSpaceModelCache event, Emitter<SpaceManagementState> emit) async { UpdateSpaceModelCache event, Emitter<SpaceManagementState> emit) async {
if (_cachedSpaceModels != null) { final projectUuid = await ProjectManager.getProjectUUID() ?? '';
_cachedSpaceModels = _cachedSpaceModels!.map((model) {
return model.uuid == event.updatedModel.uuid ? event.updatedModel : model; List<SpaceTemplateModel> allSpaceModels = [];
}).toList();
} else { bool hasNext = true;
_cachedSpaceModels = await fetchSpaceModels(); int page = 1;
while (hasNext) {
final spaceModels = await _spaceModelApi.listSpaceModels(page: page, projectId: projectUuid);
if (spaceModels.isNotEmpty) {
allSpaceModels.addAll(spaceModels);
page++;
} else {
hasNext = false;
}
} }
_cachedSpaceModels = allSpaceModels;
await fetchTags(); await fetchTags();
emit(SpaceModelLoaded( emit(SpaceModelLoaded(

View File

@ -81,33 +81,32 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: [ children: [
widget.shouldNavigateToSpaceModelPage widget.shouldNavigateToSpaceModelPage
? _spaceModels.isNotEmpty ? Row(
? Row( children: [
children: [ SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})), Expanded(
Expanded( child: BlocProvider(
child: BlocProvider( create: (context) => SpaceModelBloc(
create: (context) => SpaceModelBloc( BlocProvider.of<SpaceTreeBloc>(context),
BlocProvider.of<SpaceTreeBloc>(context), api: SpaceModelManagementApi(),
api: SpaceModelManagementApi(), initialSpaceModels: widget.spaceModels ?? [],
initialSpaceModels: _spaceModels,
),
child: SpaceModelPage(
products: widget.products,
onSpaceModelsUpdated: _onSpaceModelsUpdated,
projectTags: widget.projectTags,
),
),
), ),
], child: SpaceModelPage(
) products: widget.products,
: const Center(child: CircularProgressIndicator()) onSpaceModelsUpdated: _onSpaceModelsUpdated,
projectTags: widget.projectTags,
),
),
),
],
)
: Row( : Row(
children: [ children: [
SidebarWidget( SidebarWidget(
communities: widget.communities, communities: widget.communities,
selectedSpaceUuid: selectedSpaceUuid: widget.selectedSpace?.uuid ??
widget.selectedSpace?.uuid ?? widget.selectedCommunity?.uuid ?? '', widget.selectedCommunity?.uuid ??
'',
), ),
CommunityStructureArea( CommunityStructureArea(
selectedCommunity: widget.selectedCommunity, selectedCommunity: widget.selectedCommunity,

View File

@ -5,6 +5,8 @@ abstract class LinkSpaceToModelState {
class SpaceModelInitial extends LinkSpaceToModelState {} class SpaceModelInitial extends LinkSpaceToModelState {}
class SpaceModelLoading extends LinkSpaceToModelState {} class SpaceModelLoading extends LinkSpaceToModelState {}
class LinkSpaceModelLoading extends LinkSpaceToModelState {}
class SpaceModelSelectedState extends LinkSpaceToModelState { class SpaceModelSelectedState extends LinkSpaceToModelState {
final int selectedIndex; final int selectedIndex;

View File

@ -11,7 +11,7 @@ class SpaceTemplateModel extends Equatable {
List<SubspaceTemplateModel>? subspaceModels; List<SubspaceTemplateModel>? subspaceModels;
final List<Tag>? tags; final List<Tag>? tags;
String internalId; String internalId;
String? createdAt; DateTime? createdAt;
@override @override
List<Object?> get props => [modelName, subspaceModels, tags]; List<Object?> get props => [modelName, subspaceModels, tags];
@ -24,17 +24,18 @@ class SpaceTemplateModel extends Equatable {
this.tags, this.tags,
this.createdAt, this.createdAt,
}) : internalId = internalId ?? const Uuid().v4(); }) : internalId = internalId ?? const Uuid().v4();
factory SpaceTemplateModel.fromJson(Map<String, dynamic> json) { factory SpaceTemplateModel.fromJson(Map<String, dynamic> json) {
final String internalId = json['internalId'] ?? const Uuid().v4(); final String internalId = json['internalId'] ?? const Uuid().v4();
return SpaceTemplateModel( return SpaceTemplateModel(
uuid: json['uuid'] ?? '', uuid: json['uuid'] ?? '',
createdAt: json['createdAt'] ?? '', createdAt: json['createdAt'] != null
? DateTime.tryParse(json['createdAt'])
: null,
internalId: internalId, internalId: internalId,
modelName: json['modelName'] ?? '', modelName: json['modelName'] ?? '',
subspaceModels: (json['subspaceModels'] as List<dynamic>?) subspaceModels: (json['subspaceModels'] as List<dynamic>?)
?.where((e) => e is Map<String, dynamic>) // Validate type ?.where((e) => e is Map<String, dynamic>)
.map((e) => .map((e) =>
SubspaceTemplateModel.fromJson(e as Map<String, dynamic>)) SubspaceTemplateModel.fromJson(e as Map<String, dynamic>))
.toList() ?? .toList() ??

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:intl/intl.dart';
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart'; import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_bloc.dart'; import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_event.dart'; import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_event.dart';
@ -45,6 +46,12 @@ class _LinkSpaceModelSpacesDialogState
} }
Widget _buildDialogContent() { Widget _buildDialogContent() {
widget.spaceModel.createdAt.toString();
String formattedDate =
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
String formattedTime =
DateFormat('HH:mm:ss').format(widget.spaceModel.createdAt!);
return Expanded( return Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.all(15.0), padding: const EdgeInsets.all(15.0),
@ -75,8 +82,31 @@ class _LinkSpaceModelSpacesDialogState
const SizedBox(height: 16), const SizedBox(height: 16),
_buildDetailRow( _buildDetailRow(
"Space model name:", widget.spaceModel.modelName), "Space model name:", widget.spaceModel.modelName),
_buildDetailRow("Creation date and time:", Padding(
widget.spaceModel.createdAt.toString()), padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
const Expanded(
child: Text(
"Creation date and time:",
style: const TextStyle(
fontWeight: FontWeight.bold),
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
"$formattedDate $formattedTime",
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black),
),
),
],
),
),
// _buildDetailRow("Creation date and time:",
// widget.spaceModel.createdAt.toString()),
_buildDetailRow("Created by:", "Admin"), _buildDetailRow("Created by:", "Admin"),
const SizedBox(height: 12), const SizedBox(height: 12),
const Text( const Text(

View File

@ -85,111 +85,116 @@ class SpaceModelCardWidget extends StatelessWidget {
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
Row( if (!topActionsDisabled)
children: [ Row(
InkWell( children: [
onTap: () { InkWell(
showDialog( onTap: () {
context: context, showDialog(
builder: (BuildContext dialogContext) { context: context,
return BlocProvider<LinkSpaceToModelBloc>( builder: (BuildContext dialogContext) {
create: (_) => LinkSpaceToModelBloc(), return BlocProvider<LinkSpaceToModelBloc>(
child: BlocListener<LinkSpaceToModelBloc, create: (_) => LinkSpaceToModelBloc(),
LinkSpaceToModelState>( child: BlocListener<LinkSpaceToModelBloc,
listener: (context, state) { LinkSpaceToModelState>(
final _bloc = listenWhen: (previous, current) {
BlocProvider.of<LinkSpaceToModelBloc>( return previous != current;
context); },
if (state is SpaceModelLoading) { listener: (context, state) {
showDialog( final _bloc =
context: context, BlocProvider.of<LinkSpaceToModelBloc>(
barrierDismissible: false, context);
builder: (BuildContext context) { if (state is SpaceModelLoading) {
return Dialog( showDialog(
shape: RoundedRectangleBorder( context: context,
borderRadius: barrierDismissible: false,
BorderRadius.circular(20)), builder: (BuildContext context) {
elevation: 10, return Dialog(
backgroundColor: Colors.white, shape: RoundedRectangleBorder(
child: Padding( borderRadius:
padding: BorderRadius.circular(
const EdgeInsets.symmetric( 20)),
vertical: 30, elevation: 10,
horizontal: 50), backgroundColor: Colors.white,
child: Column( child: Padding(
mainAxisSize: MainAxisSize.min, padding:
children: [ const EdgeInsets.symmetric(
CustomLoadingIndicator(), vertical: 30,
const SizedBox(height: 20), horizontal: 50),
const Text( child: Column(
"Linking in progress", mainAxisSize:
style: TextStyle( MainAxisSize.min,
fontSize: 16, children: [
fontWeight: CustomLoadingIndicator(),
FontWeight.w500, ],
color: Colors.black87, ),
),
),
],
), ),
), );
); },
}, );
); } else if (state
} else if (state is AlreadyHaveLinkedState) {
is AlreadyHaveLinkedState) { Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop(); showOverwriteDialog(
showOverwriteDialog( context, _bloc, model);
context, _bloc, model); } else if (state
} else if (state is SpaceValidationSuccess) {
is SpaceValidationSuccess) { _bloc.add(LinkSpaceModelEvent(
_bloc.add(LinkSpaceModelEvent( isOverWrite: false,
isOverWrite: false, selectedSpaceMode: model.uuid));
selectedSpaceMode: model.uuid));
Future.delayed(const Duration(seconds: 1),
() {
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
});
showDialog(
context: context,
builder: (BuildContext dialogContext) {
return const LinkingSuccessful();
},
).then((v) {
Future.delayed( Future.delayed(
const Duration(seconds: 2), () { const Duration(seconds: 1), () {
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop(); Navigator.of(dialogContext).pop();
}); });
});
} else if (state is SpaceModelLinkSuccess) { showDialog(
Navigator.of(dialogContext).pop(); context: context,
Navigator.of(dialogContext).pop(); builder:
showDialog( (BuildContext dialogContext) {
context: context, return const LinkingSuccessful();
builder: (BuildContext dialogContext) { },
return const LinkingSuccessful(); ).then((v) {
}, Future.delayed(
); const Duration(seconds: 2), () {
} Navigator.of(dialogContext).pop();
}, });
child: LinkSpaceModelSpacesDialog( });
spaceModel: model, } else if (state
is SpaceModelLinkSuccess) {
Navigator.of(dialogContext).pop();
Navigator.of(dialogContext).pop();
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext
successDialogContext) {
Future.delayed(
const Duration(seconds: 2), () {
Navigator.of(successDialogContext)
.pop();
});
return const LinkingSuccessful();
},
);
}
},
child: LinkSpaceModelSpacesDialog(
spaceModel: model,
),
), ),
), );
); },
}, );
); },
}, child: SvgPicture.asset(
child: SvgPicture.asset( Assets.spaceLinkIcon,
Assets.spaceLinkIcon, fit: BoxFit.contain,
fit: BoxFit.contain, ),
), ),
),
if (!topActionsDisabled)
InkWell( InkWell(
onTap: () { onTap: () {
_showDeleteDialog(context); _showDeleteDialog(context);
@ -199,49 +204,8 @@ class SpaceModelCardWidget extends StatelessWidget {
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
), ),
], ],
), ),
// Expanded(
// child: Text(
// model.modelName,
// style:
// Theme.of(context).textTheme.headlineMedium?.copyWith(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// ),
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// ),
// ),
// if (!topActionsDisabled)
// GestureDetector(
// onTap: () => _showDeleteDialog(context),
// child: Container(
// width: 36, // Adjust size as needed
// height: 36,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.white,
// boxShadow: [
// BoxShadow(
// color: Colors.black.withOpacity(0.1),
// spreadRadius: 2,
// blurRadius: 5,
// offset: const Offset(0, 2),
// ),
// ],
// ),
// child: Center(
// child: SvgPicture.asset(
// Assets.deleteSpaceModel, // Your actual SVG path
// width: 20,
// height: 20,
// colorFilter: const ColorFilter.mode(
// Colors.grey, BlendMode.srcIn),
// ),
// ),
// ),
// ),
], ],
), ),
if (!showOnlyName) ...[ if (!showOnlyName) ...[