mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 13:25:10 +01:00
#116 fix
This commit is contained in:
@@ -198,7 +198,7 @@ class DockerProvider extends ChangeNotifier {
|
||||
|
||||
// judge whether to use DOCKER_HOST
|
||||
String _wrap(String cmd) {
|
||||
final dockerHost = _dockerStore.getDockerHost(hostId!);
|
||||
final dockerHost = _dockerStore.fetch(hostId!);
|
||||
if (dockerHost == null || dockerHost.isEmpty) {
|
||||
return cmd.withLangExport;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 458;
|
||||
static const int build = 459;
|
||||
static const String engine = "3.10.6";
|
||||
static const String buildAt = "2023-08-10 00:04:32.937108";
|
||||
static const int modifications = 5;
|
||||
static const String buildAt = "2023-08-10 00:38:01.678410";
|
||||
static const int modifications = 3;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
|
||||
class DockerStore extends PersistentStore {
|
||||
String? getDockerHost(String id) {
|
||||
String? fetch(String id) {
|
||||
return box.get(id);
|
||||
}
|
||||
|
||||
void setDockerHost(String id, String host) {
|
||||
void put(String id, String host) {
|
||||
box.put(id, host);
|
||||
}
|
||||
|
||||
Map<String, String> fetch() {
|
||||
Map<String, String> fetchAll() {
|
||||
return box.toMap().cast<String, String>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class BackupPage extends StatelessWidget {
|
||||
spis: _server.fetch(),
|
||||
snippets: _snippet.fetch(),
|
||||
keys: _privateKey.fetch(),
|
||||
dockerHosts: _dockerHosts.fetch(),
|
||||
dockerHosts: _dockerHosts.fetchAll(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -170,7 +170,7 @@ class BackupPage extends StatelessWidget {
|
||||
_privateKey.put(s);
|
||||
}
|
||||
for (final k in backup.dockerHosts.keys) {
|
||||
_dockerHosts.setDockerHost(k, backup.dockerHosts[k]!);
|
||||
_dockerHosts.put(k, backup.dockerHosts[k]!);
|
||||
}
|
||||
context.pop();
|
||||
showRoundDialog(
|
||||
|
||||
@@ -34,6 +34,7 @@ class DockerManagePage extends StatefulWidget {
|
||||
|
||||
class _DockerManagePageState extends State<DockerManagePage> {
|
||||
final _docker = locator<DockerProvider>();
|
||||
final _store = locator<DockerStore>();
|
||||
final _textController = TextEditingController();
|
||||
late S _s;
|
||||
|
||||
@@ -533,25 +534,30 @@ 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 ctrl = TextEditingController(text: host);
|
||||
await showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.dockerEditHost),
|
||||
child: Input(
|
||||
maxLines: 1,
|
||||
controller:
|
||||
TextEditingController(text: 'unix:///run/user/1000/docker.sock'),
|
||||
onSubmitted: (value) {
|
||||
locator<DockerStore>().setDockerHost(widget.spi.id, value.trim());
|
||||
_docker.refresh();
|
||||
context.pop();
|
||||
},
|
||||
controller: ctrl,
|
||||
onSubmitted: _onSaveDockerHost,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
onPressed: () => _onSaveDockerHost(ctrl.text),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _onSaveDockerHost(String val) {
|
||||
context.pop();
|
||||
_store.put(widget.spi.id, val.trim());
|
||||
_docker.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,18 +663,21 @@ class _SftpPageState extends State<SftpPage> {
|
||||
}
|
||||
} catch (e, trace) {
|
||||
_logger.warning('list dir failed', e, trace);
|
||||
Future.delayed(const Duration(milliseconds: 177), () => showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.error),
|
||||
child: Text(e.toString()),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
));
|
||||
await _backward();
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 177),
|
||||
() => showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.error),
|
||||
child: Text(e.toString()),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user