add: refresh btn on desktop

This commit is contained in:
lollipopkit
2023-08-10 18:39:58 +08:00
parent 4788f1dddc
commit 9ca096094f
6 changed files with 46 additions and 35 deletions

View File

@@ -65,6 +65,7 @@ class DockerProvider extends ChangeNotifier {
if (raw.contains(_dockerNotFound)) {
error = DockerErr(type: DockerErrType.notInstalled);
_logger.warning('Docker not installed: $raw');
notifyListeners();
return;
}
@@ -73,6 +74,7 @@ class DockerProvider extends ChangeNotifier {
final segments = raw.split(seperator);
if (segments.length != dockerCmds.length) {
error = DockerErr(type: DockerErrType.segmentsNotMatch);
_logger.warning('Docker segments not match: ${segments.length}');
notifyListeners();
return;
}
@@ -94,7 +96,7 @@ class DockerProvider extends ChangeNotifier {
type: DockerErrType.parsePsItem,
message: '$psRaw\n-\n$e',
);
_logger.warning('parse docker ps: $psRaw', e);
_logger.warning('Parse docker ps: $psRaw', e);
} finally {
notifyListeners();
}
@@ -106,12 +108,12 @@ class DockerProvider extends ChangeNotifier {
imageLines.removeWhere((element) => element.isEmpty);
if (imageLines.isNotEmpty) imageLines.removeAt(0);
images = imageLines.map((e) => DockerImage.fromRawStr(e)).toList();
} catch (e) {
} catch (e, trace) {
error = DockerErr(
type: DockerErrType.parseImages,
message: '$imageRaw\n-\n$e',
);
_logger.warning('parse docker images: $imageRaw', e);
_logger.warning('Parse docker images: $imageRaw', e, trace);
} finally {
notifyListeners();
}
@@ -130,12 +132,12 @@ class DockerProvider extends ChangeNotifier {
if (statsLine.isEmpty) continue;
item.parseStats(statsLine);
}
} catch (e) {
} catch (e, trace) {
error = DockerErr(
type: DockerErrType.parseStats,
message: '$statsRaw\n-\n$e',
);
_logger.warning('parse docker stats: $statsRaw', e);
_logger.warning('Parse docker stats: $statsRaw', e, trace);
} finally {
notifyListeners();
}

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 459;
static const int build = 460;
static const String engine = "3.10.6";
static const String buildAt = "2023-08-10 00:38:01.678410";
static const int modifications = 3;
static const String buildAt = "2023-08-10 18:10:04.385080";
static const int modifications = 5;
}

View File

@@ -535,8 +535,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
Future<void> _showEditHostDialog() async {
final id = widget.spi.id;
final host =
_store.fetch(id) ?? 'unix:///run/user/1000/docker.sock';
final host = _store.fetch(id) ?? 'unix:///run/user/1000/docker.sock';
final ctrl = TextEditingController(text: host);
await showRoundDialog(
context: context,

View File

@@ -109,12 +109,8 @@ class _HomePageState extends State<HomePage>
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
drawer: _buildDrawer(),
appBar: AppBar(
title: const Text(BuildData.name),
actions: [
IconButton(
final actions = <Widget>[
IconButton(
icon: const Icon(Icons.developer_mode, size: 23),
tooltip: _s.debug,
onPressed: () => AppRoute(
@@ -122,7 +118,21 @@ class _HomePageState extends State<HomePage>
'Debug Page',
).go(context),
),
],
];
if (isDesktop && _selectIndex.value == AppTab.server.index) {
actions.add(
IconButton(
icon: const Icon(Icons.refresh, size: 23),
tooltip: 'Refresh',
onPressed: () => _serverProvider.refreshData(),
),
);
}
return Scaffold(
drawer: _buildDrawer(),
appBar: AppBar(
title: const Text(BuildData.name),
actions: actions,
),
body: PageView.builder(
controller: _pageController,