Skip to content

Commit

Permalink
feat(app) add graph view
Browse files Browse the repository at this point in the history
  • Loading branch information
helderbetiol committed Jun 17, 2024
1 parent 23b798b commit 7d68044
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
21 changes: 18 additions & 3 deletions APP/lib/common/api_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,24 @@ Future<Result<Map<String, dynamic>, Exception>> fetchObject(String id,
}
}

Future<Result<Map<String, dynamic>, Exception>> fetchObjectChildren(
String id) async {
print("API fetch Object /all");
try {
Uri url = Uri.parse('$apiUrl/api/hierarchy_objects/$id/all');
final response = await http.get(url, headers: getHeader(token));
if (response.statusCode == 200 || response.statusCode == 201) {
Map<String, dynamic> data = json.decode(response.body);
return Success(Map<String, dynamic>.from(data["data"]));
} else {
final Map<String, dynamic> data = json.decode(response.body);
return Failure(Exception(data["message"].toString()));
}
} on Exception catch (e) {
return Failure(e);
}
}

Future<Result<void, Exception>> updateObject(
String objId, String category, Map<String, dynamic> object) async {
print("API update object");
Expand Down Expand Up @@ -527,7 +545,6 @@ Future<Result<List<String>, Exception>> fetchGroupContent(
print("API fetch GR content");
try {
Uri url = Uri.parse('$apiUrl/api/objects?id=$id.*&category=$category');
print('$apiUrl/api/objects?$id=$id.*&category=$category');
final response = await http.get(url, headers: getHeader(token));
if (response.statusCode == 200 || response.statusCode == 201) {
Map<String, dynamic> data = json.decode(response.body);
Expand All @@ -537,11 +554,9 @@ Future<Result<List<String>, Exception>> fetchGroupContent(
return Failure(Exception("No object found for to this request"));
} else {
List<String> content = [];
print("hey ya");
for (var item in list) {
content.add(item["name"].toString());
}
print(content);
return Success(content);
}
} else {
Expand Down
1 change: 1 addition & 0 deletions APP/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"example": "Example:",
"viewEditNode": "View and edit this node",
"viewJSON": "View as JSON",
"viewGraph": "View as graph",

"selectColor": "Select color",
"colorPrimary": "Primary",
Expand Down
1 change: 1 addition & 0 deletions APP/lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"example": "Ejemplo:",
"viewEditNode": "Ver y editar este nodo",
"viewJSON": "Ver en JSON",
"viewGraph": "Ver como grafo",

"selectColor": "Seleccionar color",
"colorPrimary": "Primarios",
Expand Down
1 change: 1 addition & 0 deletions APP/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"example": "Exemple :",
"viewEditNode": "Visualiser et modifier ce noeud",
"viewJSON": "Afficher en JSON",
"viewGraph": "Afficher en graphe",

"selectColor": "Choisir couleur",
"colorPrimary": "Palette",
Expand Down
3 changes: 2 additions & 1 deletion APP/lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
"filter": "Filtro",
"example": "Exemplo:",
"viewEditNode": "Visualizar e editar este nó",
"viewJSON": "Visualizar JSON",
"viewJSON": "Ver como JSON",
"viewGraph": "Ver como grafo",

"selectColor": "Selecione a cor",
"colorPrimary": "Primárias",
Expand Down
20 changes: 19 additions & 1 deletion APP/lib/widgets/select_objects/tree_view/_node_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ class _NodeActionsChipState extends State<_NodeActionsChip> {
}
}

if (namespace == Namespace.Physical &&
'.'.allMatches(widget.node.id).length >= 4) {
menuEntries.add(
PopupMenuItem(
value: 4,
child: ListTile(
dense: true,
title: Text(AppLocalizations.of(context)!.viewGraph),
contentPadding: const EdgeInsets.symmetric(horizontal: 4),
leading: const Icon(Icons.auto_graph, color: _kDarkBlue),
),
),
);
}

return PopupMenuButton<int>(
key: _popupMenuKey,
tooltip: AppLocalizations.of(context)!.selectionOptions,
Expand Down Expand Up @@ -91,10 +106,13 @@ class _NodeActionsChipState extends State<_NodeActionsChip> {
objId: widget.node.id,
),
isDismissible: true);
} else {
} else if (selected == 3) {
showCustomPopup(context,
ViewObjectPopup(namespace: namespace, objId: widget.node.id),
isDismissible: true);
} else {
showCustomPopup(context, ObjectGraphView(widget.node.id),
isDismissible: true);
}
},
child: RawChip(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:ogree_app/common/definitions.dart';
import 'package:ogree_app/common/popup_dialog.dart';
import 'package:ogree_app/common/snackbar.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:ogree_app/pages/layer_graph.dart';
import 'package:ogree_app/pages/tenant_page.dart';
import 'package:ogree_app/widgets/select_objects/view_object_popup.dart';
import 'package:ogree_app/widgets/select_objects/object_popup.dart';
Expand Down

0 comments on commit 7d68044

Please sign in to comment.