From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-flutter-frontend 4/5] nove overview: add power settings menu
Date: Mon, 15 Apr 2024 12:30:26 +0200 [thread overview]
Message-ID: <20240415103027.3000412-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240415103027.3000412-1-d.csapak@proxmox.com>
similar to how it works for qemu
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
this depends on the dart-api-client patch, otherwise the url is wrong
lib/bloc/pve_node_overview_bloc.dart | 11 ++++
lib/widgets/pve_node_overview.dart | 24 ++++++++
.../pve_node_power_settings_widget.dart | 59 +++++++++++++++++++
3 files changed, 94 insertions(+)
create mode 100644 lib/widgets/pve_node_power_settings_widget.dart
diff --git a/lib/bloc/pve_node_overview_bloc.dart b/lib/bloc/pve_node_overview_bloc.dart
index caeb1c4..2f07ef9 100644
--- a/lib/bloc/pve_node_overview_bloc.dart
+++ b/lib/bloc/pve_node_overview_bloc.dart
@@ -52,9 +52,20 @@ class PveNodeOverviewBloc
final disks = await apiClient.getNodeDisksList(nodeID);
yield latestState.rebuild((b) => b..disks.replace(disks));
}
+ if (event is PerformNodeAction) {
+ await apiClient.doResourceAction(nodeID, '', 'node', event.action,
+ parameters: <String, String>{});
+ yield latestState;
+ }
}
}
abstract class PveNodeOverviewEvent {}
class UpdateNodeStatus extends PveNodeOverviewEvent {}
+
+class PerformNodeAction extends PveNodeOverviewEvent {
+ final PveClusterResourceAction action;
+
+ PerformNodeAction(this.action);
+}
diff --git a/lib/widgets/pve_node_overview.dart b/lib/widgets/pve_node_overview.dart
index 219d498..a5d79a3 100644
--- a/lib/widgets/pve_node_overview.dart
+++ b/lib/widgets/pve_node_overview.dart
@@ -8,6 +8,7 @@ import 'package:pve_flutter_frontend/states/pve_node_overview_state.dart';
import 'package:pve_flutter_frontend/states/pve_task_log_state.dart';
import 'package:pve_flutter_frontend/utils/renderers.dart';
import 'package:pve_flutter_frontend/utils/utils.dart';
+import 'package:pve_flutter_frontend/widgets/pve_node_power_settings_widget.dart';
import 'package:pve_flutter_frontend/widgets/proxmox_capacity_indicator.dart';
import 'package:pve_flutter_frontend/widgets/proxmox_stream_builder_widget.dart';
import 'package:pve_flutter_frontend/widgets/pve_action_card_widget.dart';
@@ -189,6 +190,16 @@ class PveNodeOverview extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
+ ActionCard(
+ icon: const Icon(
+ Icons.power_settings_new,
+ size: 55,
+ color: Colors.white24,
+ ),
+ title: 'Power Settings',
+ onTap: () =>
+ showPowerMenuBottomSheet(context, nBloc),
+ ),
ActionCard(
icon: const Icon(
Icons.queue_play_next,
@@ -439,4 +450,17 @@ class PveNodeOverview extends StatelessWidget {
},
);
}
+
+ Future<T?> showPowerMenuBottomSheet<T>(
+ BuildContext context, PveNodeOverviewBloc nodeBloc) async {
+ return showModalBottomSheet(
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(10))),
+ context: context,
+ builder: (context) => Provider.value(
+ value: nodeBloc,
+ child: const PveNodePowerSettings(),
+ ),
+ );
+ }
}
diff --git a/lib/widgets/pve_node_power_settings_widget.dart b/lib/widgets/pve_node_power_settings_widget.dart
new file mode 100644
index 0000000..f8d35d1
--- /dev/null
+++ b/lib/widgets/pve_node_power_settings_widget.dart
@@ -0,0 +1,59 @@
+import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
+import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart';
+import 'package:pve_flutter_frontend/bloc/pve_node_overview_bloc.dart';
+import 'package:pve_flutter_frontend/states/pve_node_overview_state.dart';
+import 'package:pve_flutter_frontend/widgets/proxmox_stream_builder_widget.dart';
+
+class PveNodePowerSettings extends StatelessWidget {
+ const PveNodePowerSettings({
+ super.key,
+ });
+ @override
+ Widget build(BuildContext context) {
+ final bloc = Provider.of<PveNodeOverviewBloc>(context);
+ return ProxmoxStreamBuilder<PveNodeOverviewBloc, PveNodeOverviewState>(
+ bloc: bloc,
+ builder: (context, state) {
+ return SafeArea(
+ child: SingleChildScrollView(
+ child: Container(
+ constraints: BoxConstraints(
+ minHeight: MediaQuery.of(context).size.height / 3),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: <Widget>[
+ ListTile(
+ leading: const Icon(Icons.autorenew),
+ title: const Text(
+ "Reboot",
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ subtitle: const Text("Reboot Node"),
+ onTap: () => action(
+ context, PveClusterResourceAction.reboot, bloc),
+ ),
+ ListTile(
+ leading: const Icon(Icons.power_settings_new),
+ title: const Text(
+ "Shutdown",
+ style: TextStyle(fontWeight: FontWeight.bold),
+ ),
+ subtitle: const Text("Shutdown Node"),
+ onTap: () => action(
+ context, PveClusterResourceAction.shutdown, bloc),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ });
+ }
+
+ void action(BuildContext context, PveClusterResourceAction action,
+ PveNodeOverviewBloc bloc) {
+ bloc.events.add(PerformNodeAction(action));
+ Navigator.of(context).pop();
+ }
+}
--
2.39.2
next prev parent reply other threads:[~2024-04-15 10:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-15 10:30 [pve-devel] [PATCH flutter-repositories] some improvements/fixes for the app Dominik Csapak
2024-04-15 10:30 ` [pve-devel] [PATCH proxmox-dart-api-client 1/1] client: correctly set parameter for node actions Dominik Csapak
2024-04-16 15:07 ` [pve-devel] applied: " Thomas Lamprecht
2024-04-15 10:30 ` [pve-devel] [PATCH proxmox-login-manager 1/2] login: show custom alert dialog for password saving errors Dominik Csapak
2024-04-16 15:08 ` [pve-devel] applied: " Thomas Lamprecht
2024-04-15 10:30 ` [pve-devel] [PATCH proxmox-login-manager 2/2] general settings: add trustedFingerprints list Dominik Csapak
2024-04-15 10:30 ` [pve-devel] [PATCH pve-flutter-frontend 1/5] console: use flutter inappwebview as webview Dominik Csapak
2024-04-15 10:30 ` [pve-devel] [PATCH pve-flutter-frontend 2/5] console: wrap console with appbar Dominik Csapak
2024-04-15 10:30 ` [pve-devel] [PATCH pve-flutter-frontend 3/5] node overview: use correct color for rrd icons Dominik Csapak
2024-04-15 10:30 ` Dominik Csapak [this message]
2024-04-16 15:11 ` [pve-devel] [PATCH pve-flutter-frontend 4/5] nove overview: add power settings menu Thomas Lamprecht
2024-04-15 10:30 ` [pve-devel] [PATCH pve-flutter-frontend 5/5] improve back button behavior Dominik Csapak
2024-04-16 15:11 ` [pve-devel] applied: [PATCH flutter-repositories] some improvements/fixes for the app Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240415103027.3000412-8-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox