mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: settings of containerTrySudo usePodman
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import 'package:toolbox/core/extension/listx.dart';
|
||||
import 'package:toolbox/data/model/container/type.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
|
||||
import '../../core/persistant_store.dart';
|
||||
|
||||
const _keyConfig = 'providerConfig';
|
||||
|
||||
class DockerStore extends PersistentStore {
|
||||
DockerStore() : super('docker');
|
||||
class ContainerStore extends PersistentStore {
|
||||
ContainerStore() : super('docker');
|
||||
|
||||
String? fetch(String? id) {
|
||||
return box.get(id);
|
||||
@@ -16,17 +18,28 @@ class DockerStore extends PersistentStore {
|
||||
box.updateLastModified();
|
||||
}
|
||||
|
||||
ContainerType getType([String? id]) {
|
||||
final cfg = box.get(_keyConfig + (id ?? ''));
|
||||
if (cfg == null) {
|
||||
return ContainerType.docker;
|
||||
} else {
|
||||
return ContainerType.values.firstWhere((e) => e.toString() == cfg);
|
||||
ContainerType getType([String id = '']) {
|
||||
final cfg = box.get(_keyConfig + id);
|
||||
if (cfg != null) {
|
||||
final type =
|
||||
ContainerType.values.firstWhereOrNull((e) => e.toString() == cfg);
|
||||
if (type != null) return type;
|
||||
}
|
||||
|
||||
return defaultType;
|
||||
}
|
||||
|
||||
void setType(String? id, ContainerType type) {
|
||||
box.put(_keyConfig + (id ?? ''), type.toString());
|
||||
ContainerType get defaultType {
|
||||
if (Stores.setting.usePodman.fetch()) return ContainerType.podman;
|
||||
return ContainerType.docker;
|
||||
}
|
||||
|
||||
void setType(ContainerType type, [String id = '']) {
|
||||
if (type == defaultType) {
|
||||
box.delete(_keyConfig + id);
|
||||
} else {
|
||||
box.put(_keyConfig + id, type.toString());
|
||||
}
|
||||
box.updateLastModified();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user