mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
new: auto refresh container page
This commit is contained in:
@@ -73,8 +73,6 @@ extension SSHClientX on SSHClient {
|
|||||||
cmd,
|
cmd,
|
||||||
redirectToBash: redirectToBash,
|
redirectToBash: redirectToBash,
|
||||||
onStderr: (data, session) async {
|
onStderr: (data, session) async {
|
||||||
debugPrint(
|
|
||||||
" --- execWithPwd stderr (reqPwd = $isRequestingPwd) --- $data");
|
|
||||||
onStderr?.call(data, session);
|
onStderr?.call(data, session);
|
||||||
if (isRequestingPwd) return;
|
if (isRequestingPwd) return;
|
||||||
|
|
||||||
@@ -84,7 +82,6 @@ extension SSHClientX on SSHClient {
|
|||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
final pwd = await context.showPwdDialog(user);
|
final pwd = await context.showPwdDialog(user);
|
||||||
if (pwd == null || pwd.isEmpty) {
|
if (pwd == null || pwd.isEmpty) {
|
||||||
debugPrint("Empty pwd. Exiting");
|
|
||||||
session.kill(SSHSignal.INT);
|
session.kill(SSHSignal.INT);
|
||||||
} else {
|
} else {
|
||||||
session.stdin.add('$pwd\n'.uint8List);
|
session.stdin.add('$pwd\n'.uint8List);
|
||||||
@@ -94,7 +91,6 @@ extension SSHClientX on SSHClient {
|
|||||||
},
|
},
|
||||||
onStdout: (data, sink) async {
|
onStdout: (data, sink) async {
|
||||||
onStdout?.call(data, sink);
|
onStdout?.call(data, sink);
|
||||||
debugPrint(" --- execWithPwd stdout --- $data");
|
|
||||||
},
|
},
|
||||||
stdin: stdin,
|
stdin: stdin,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -236,6 +236,9 @@ class SettingStore extends PersistentStore {
|
|||||||
/// Parse container stat
|
/// Parse container stat
|
||||||
late final containerParseStat = property('containerParseStat', true);
|
late final containerParseStat = property('containerParseStat', true);
|
||||||
|
|
||||||
|
/// Auto refresh container status
|
||||||
|
late final contaienrAutoRefresh = property('contaienrAutoRefresh', true);
|
||||||
|
|
||||||
// Never show these settings for users
|
// Never show these settings for users
|
||||||
//
|
//
|
||||||
// ------BEGIN------
|
// ------BEGIN------
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:toolbox/core/extension/context/common.dart';
|
import 'package:toolbox/core/extension/context/common.dart';
|
||||||
@@ -49,6 +51,7 @@ class _ContainerPageState extends State<ContainerPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_initAutoRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -300,7 +303,8 @@ class _ContainerPageState extends State<ContainerPage> {
|
|||||||
child: Text(l10n.dockerEditHost),
|
child: Text(l10n.dockerEditHost),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return CardX(child: Column(
|
return CardX(
|
||||||
|
child: Column(
|
||||||
children: children,
|
children: children,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -582,4 +586,19 @@ class _ContainerPageState extends State<ContainerPage> {
|
|||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _initAutoRefresh() {
|
||||||
|
if (Stores.setting.contaienrAutoRefresh.fetch()) {
|
||||||
|
Timer.periodic(
|
||||||
|
Duration(seconds: Stores.setting.serverStatusUpdateInterval.fetch()),
|
||||||
|
(timer) {
|
||||||
|
if (mounted) {
|
||||||
|
_container.refresh();
|
||||||
|
} else {
|
||||||
|
timer.cancel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user