Skip to content

Commit

Permalink
loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Feb 22, 2024
1 parent 98ecabf commit 6aac91f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/components/info_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ class InfoCell extends StatelessWidget {
saveInState(context, snapshot.data);
} else {
children = buildError(snapshot.data);
saveInState(context, "ERROR");
}
} else if (snapshot.hasError) {
children = buildError(snapshot.error);
saveInState(context, "ERROR");
} else {
children = buildLoading();
saveInState(context, "LOADING");
}
return Center(
child: Padding(
Expand Down
43 changes: 34 additions & 9 deletions lib/pages/status_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,47 @@ class StatusPageState extends State<StatusPage> {
return list;
}

Icon buildIcon(state, String env, List<dynamic> elements) {
bool isOk = true;
Icon buildIcon(AppState state, String env, List<dynamic> elements) {
String status = "OK";
for (var microservice in elements) {
String value = "";
if (env == "DEV") {
isOk &= state.devVersion.containsKey(microservice['product']);
value = state.devVersion.keys.firstWhere(
(elem) => elem == microservice['product'],
orElse: () => "LOADING");
}
if (env == "UAT") {
isOk &= state.uatVersion.containsKey(microservice['product']);
value = state.devVersion.keys.firstWhere(
(elem) => elem == microservice['product'],
orElse: () => "");
}
if (env == "PROD") {
isOk &= state.prodVersion.containsKey(microservice['product']);
value = state.devVersion.keys.firstWhere(
(elem) => elem == microservice['product'],
orElse: () => "");
}
if (value == "LOADING" && status != "ERROR") {
status = value;
}
if (value == "ERROR") {
status = value;
}
}
return Icon(
isOk ? Icons.check : Icons.priority_high,
color: isOk ? Colors.green : Colors.red,
);
if (status == "OK") {
return const Icon(
Icons.check,
color: Colors.green,
);
} else if (status == "ERROR") {
return const Icon(
Icons.priority_high,
color: Colors.red,
);
} else {
return const Icon(
Icons.downloading,
color: Colors.blue,
);
}
}
}

0 comments on commit 6aac91f

Please sign in to comment.