Compare commits
No commits in common. "d6b30e11b24b123195ba35ef3a790819ac10a6db" and "462ea165f72a9356e03e8f010857d0d0f5be0b31" have entirely different histories.
d6b30e11b2
...
462ea165f7
@ -11,8 +11,7 @@ class MountConfig {
|
|||||||
|
|
||||||
String get name => _name;
|
String get name => _name;
|
||||||
String get path => _path;
|
String get path => _path;
|
||||||
UnmodifiableMapView<String, dynamic> get settings =>
|
UnmodifiableMapView get settings => UnmodifiableMapView(_settings);
|
||||||
UnmodifiableMapView<String, dynamic>(_settings);
|
|
||||||
IconData get state => _state;
|
IconData get state => _state;
|
||||||
String get type => _type;
|
String get type => _type;
|
||||||
|
|
||||||
|
@ -16,299 +16,44 @@ class MountSettingsWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
||||||
Map<String, dynamic>? _settings;
|
MountConfig? config;
|
||||||
|
|
||||||
void _addBooleanSetting(list, root, key, value) {
|
|
||||||
list.add(
|
|
||||||
SettingsTile.switchTile(
|
|
||||||
leading: Icon(Icons.check),
|
|
||||||
title: Text(key),
|
|
||||||
initialValue: (value as bool),
|
|
||||||
onPressed: (_) {
|
|
||||||
setState(() {
|
|
||||||
root?[key] = !value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onToggle: (bool nextValue) {
|
|
||||||
setState(() {
|
|
||||||
root?[key] = nextValue;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addIntSetting(list, root, key, value) {
|
|
||||||
list.add(
|
|
||||||
SettingsTile.navigation(
|
|
||||||
leading: Icon(Icons.onetwothree),
|
|
||||||
title: Text(key),
|
|
||||||
value: Text((value as int).toString()),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addPasswordSetting(list, root, key, value) {
|
|
||||||
list.add(
|
|
||||||
SettingsTile.navigation(
|
|
||||||
leading: Icon(Icons.password),
|
|
||||||
title: Text(key),
|
|
||||||
value: Text('*' * (value as String).length),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _addStringSetting(list, root, key, value, icon) {
|
|
||||||
list.add(
|
|
||||||
SettingsTile.navigation(
|
|
||||||
leading: Icon(icon),
|
|
||||||
title: Text(key),
|
|
||||||
value: Text(value),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<SettingsTile> commonSettings = [];
|
List<SettingsTile> commonSettings = [];
|
||||||
List<SettingsTile> encryptConfigSettings = [];
|
config?.settings.forEach((key, value) {
|
||||||
List<SettingsTile> hostConfigSettings = [];
|
|
||||||
List<SettingsTile> remoteMountSettings = [];
|
|
||||||
List<SettingsTile> s3ConfigSettings = [];
|
|
||||||
List<SettingsTile> siaConfigSettings = [];
|
|
||||||
|
|
||||||
_settings?.forEach((key, value) {
|
|
||||||
if (key == "ApiAuth") {
|
if (key == "ApiAuth") {
|
||||||
_addPasswordSetting(commonSettings, _settings, key, value);
|
commonSettings.add(
|
||||||
} else if (key == "ApiPort") {
|
SettingsTile.navigation(
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
leading: Icon(Icons.password),
|
||||||
} else if (key == "ApiUser") {
|
title: Text(key),
|
||||||
_addStringSetting(commonSettings, _settings, key, value, Icons.person);
|
value: Text('*' * (value as String).length),
|
||||||
} else if (key == "DatabaseType") {
|
),
|
||||||
_addStringSetting(commonSettings, _settings, key, value, Icons.dataset);
|
);
|
||||||
} else if (key == "DownloadTimeoutSeconds") {
|
} else if (key == "ApiPort") {
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
commonSettings.add(
|
||||||
} else if (key == "EnableDownloadTimeout") {
|
SettingsTile.navigation(
|
||||||
_addBooleanSetting(commonSettings, _settings, key, value);
|
leading: Icon(Icons.onetwothree),
|
||||||
} else if (key == "EnableDriveEvents") {
|
title: Text(key),
|
||||||
_addBooleanSetting(commonSettings, _settings, key, value);
|
value: Text((value as int).toString()),
|
||||||
} else if (key == "EventLevel") {
|
),
|
||||||
_addStringSetting(commonSettings, _settings, key, value, Icons.event);
|
);
|
||||||
} else if (key == "EvictionDelayMinutes") {
|
} else if (key == "ApiUser") {
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
commonSettings.add(
|
||||||
} else if (key == "EvictionUseAccessedTime") {
|
SettingsTile.navigation(
|
||||||
_addBooleanSetting(commonSettings, _settings, key, value);
|
leading: Icon(Icons.person),
|
||||||
} else if (key == "MaxCacheSizeBytes") {
|
title: Text(key),
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
value: Text(value),
|
||||||
} else if (key == "MaxUploadCount") {
|
),
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
);
|
||||||
} else if (key == "OnlineCheckRetrySeconds") {
|
} else if (key == "DatabaseType") {
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
commonSettings.add(
|
||||||
} else if (key == "PreferredDownloadType") {
|
SettingsTile.navigation(
|
||||||
_addStringSetting(
|
leading: Icon(Icons.dataset),
|
||||||
commonSettings,
|
title: Text(key),
|
||||||
_settings,
|
value: Text(value),
|
||||||
key,
|
),
|
||||||
value,
|
|
||||||
Icons.download,
|
|
||||||
);
|
);
|
||||||
} else if (key == "RetryReadCount") {
|
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
|
||||||
} else if (key == "RingBufferFileSize") {
|
|
||||||
_addIntSetting(commonSettings, _settings, key, value);
|
|
||||||
} else if (key == "EncryptConfig") {
|
|
||||||
value.forEach((subKey, subValue) {
|
|
||||||
if (subKey == "EncryptionToken") {
|
|
||||||
_addPasswordSetting(
|
|
||||||
encryptConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "Path") {
|
|
||||||
_addStringSetting(
|
|
||||||
encryptConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.folder,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (key == "HostConfig") {
|
|
||||||
value.forEach((subKey, subValue) {
|
|
||||||
if (subKey == "AgentString") {
|
|
||||||
_addStringSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.support_agent,
|
|
||||||
);
|
|
||||||
} else if (subKey == "ApiPassword") {
|
|
||||||
_addPasswordSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "ApiPort") {
|
|
||||||
_addIntSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "ApiUser") {
|
|
||||||
_addStringSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.person,
|
|
||||||
);
|
|
||||||
} else if (subKey == "HostNameOrIp") {
|
|
||||||
_addStringSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.computer,
|
|
||||||
);
|
|
||||||
} else if (subKey == "Path") {
|
|
||||||
_addStringSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.route,
|
|
||||||
);
|
|
||||||
} else if (subKey == "Protocol") {
|
|
||||||
_addStringSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.http,
|
|
||||||
);
|
|
||||||
} else if (subKey == "TimeoutMs") {
|
|
||||||
_addIntSetting(
|
|
||||||
hostConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (key == "RemoteMount") {
|
|
||||||
value.forEach((subKey, subValue) {
|
|
||||||
if (subKey == "ApiPort") {
|
|
||||||
_addIntSetting(
|
|
||||||
remoteMountSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "ClientPoolSize") {
|
|
||||||
_addIntSetting(
|
|
||||||
remoteMountSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "Enable") {
|
|
||||||
_addBooleanSetting(
|
|
||||||
remoteMountSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "EncryptionToken") {
|
|
||||||
_addPasswordSetting(
|
|
||||||
remoteMountSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (key == "S3Config") {
|
|
||||||
value.forEach((subKey, subValue) {
|
|
||||||
if (subKey == "AccessKey") {
|
|
||||||
_addPasswordSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "Bucket") {
|
|
||||||
_addStringSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.folder,
|
|
||||||
);
|
|
||||||
} else if (subKey == "EncryptionToken") {
|
|
||||||
_addPasswordSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "Region") {
|
|
||||||
_addStringSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.map,
|
|
||||||
);
|
|
||||||
} else if (subKey == "SecretKey") {
|
|
||||||
_addPasswordSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "TimeoutMs") {
|
|
||||||
_addIntSetting(s3ConfigSettings, _settings?[key], subKey, subValue);
|
|
||||||
} else if (subKey == "URL") {
|
|
||||||
_addStringSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.http,
|
|
||||||
);
|
|
||||||
} else if (subKey == "UsePathStyle") {
|
|
||||||
_addBooleanSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
} else if (subKey == "UseRegionInURL") {
|
|
||||||
_addBooleanSetting(
|
|
||||||
s3ConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (key == "SiaConfig") {
|
|
||||||
value.forEach((subKey, subValue) {
|
|
||||||
if (subKey == "Bucket") {
|
|
||||||
_addStringSetting(
|
|
||||||
siaConfigSettings,
|
|
||||||
_settings?[key],
|
|
||||||
subKey,
|
|
||||||
subValue,
|
|
||||||
Icons.folder,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -320,32 +65,10 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
body: SettingsList(
|
body: SettingsList(
|
||||||
shrinkWrap: false,
|
shrinkWrap: false,
|
||||||
sections: [
|
sections: [
|
||||||
if (encryptConfigSettings.isNotEmpty)
|
SettingsSection(
|
||||||
SettingsSection(
|
title: Text('Common Settings'),
|
||||||
title: const Text('Encrypt Config'),
|
tiles: commonSettings.toList(),
|
||||||
tiles: encryptConfigSettings,
|
),
|
||||||
),
|
|
||||||
if (hostConfigSettings.isNotEmpty)
|
|
||||||
SettingsSection(
|
|
||||||
title: const Text('Host Config'),
|
|
||||||
tiles: hostConfigSettings,
|
|
||||||
),
|
|
||||||
if (remoteMountSettings.isNotEmpty)
|
|
||||||
SettingsSection(
|
|
||||||
title: const Text('Remote Mount'),
|
|
||||||
tiles: remoteMountSettings,
|
|
||||||
),
|
|
||||||
if (s3ConfigSettings.isNotEmpty)
|
|
||||||
SettingsSection(
|
|
||||||
title: const Text('S3 Config'),
|
|
||||||
tiles: s3ConfigSettings,
|
|
||||||
),
|
|
||||||
if (siaConfigSettings.isNotEmpty)
|
|
||||||
SettingsSection(
|
|
||||||
title: const Text('Sia Config'),
|
|
||||||
tiles: siaConfigSettings,
|
|
||||||
),
|
|
||||||
SettingsSection(title: const Text('Settings'), tiles: commonSettings),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -353,7 +76,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_settings = Map.from(widget.config.settings);
|
config = widget.config;
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user