Create management portal in Flutter #39
This commit is contained in:
parent
72a2567c83
commit
eb8f66ebe9
@ -26,4 +26,36 @@ String initialCaps(String txt) {
|
|||||||
return txt[0].toUpperCase() + txt.substring(1).toLowerCase();
|
return txt[0].toUpperCase() + txt.substring(1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> createDefaultSettings() => {'EventLevel': 'info'};
|
Map<String, dynamic> createDefaultSettings(String mountType) {
|
||||||
|
switch (mountType) {
|
||||||
|
case 'Encrypt':
|
||||||
|
return {
|
||||||
|
'EncryptConfig': {'EncryptionToken': '', 'Path': ''},
|
||||||
|
};
|
||||||
|
case 'Remote':
|
||||||
|
return {'EventLevel': 'info'};
|
||||||
|
case 'S3':
|
||||||
|
return {
|
||||||
|
'S3Config': {
|
||||||
|
'AccessKey': '',
|
||||||
|
'Bucket': '',
|
||||||
|
'Region': 'any',
|
||||||
|
'SecretKey': '',
|
||||||
|
'URL': '',
|
||||||
|
'UsePathStyle': false,
|
||||||
|
'UseRegionInURL': false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case 'Sia':
|
||||||
|
return {
|
||||||
|
'HostConfig': {
|
||||||
|
'ApiPassword': '',
|
||||||
|
'ApiPort': '9980',
|
||||||
|
'HostNameOrIp': 'localhost',
|
||||||
|
},
|
||||||
|
'SiaConfig': {'Bucket': 'default'},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
@ -19,7 +19,13 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
Mount? _mount;
|
Mount? _mount;
|
||||||
final _mountNameController = TextEditingController();
|
final _mountNameController = TextEditingController();
|
||||||
String _mountType = "";
|
String _mountType = "";
|
||||||
var _settings = createDefaultSettings();
|
final Map<String, Map<String, dynamic>> _settings = {
|
||||||
|
"": {},
|
||||||
|
"Encrypt": createDefaultSettings("Encrypt"),
|
||||||
|
"Remote": createDefaultSettings("Remote"),
|
||||||
|
"S3": createDefaultSettings("S3"),
|
||||||
|
"Sia": createDefaultSettings("Sia"),
|
||||||
|
};
|
||||||
bool _showAdvanced = false;
|
bool _showAdvanced = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -45,77 +51,87 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Card(
|
Card(
|
||||||
margin: EdgeInsets.all(_padding),
|
child: Padding(
|
||||||
child: Row(
|
padding: const EdgeInsets.all(_padding),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
const Text('Provider Type'),
|
children: [
|
||||||
const SizedBox(width: _padding),
|
const Text('Provider Type'),
|
||||||
DropdownButton<String>(
|
const SizedBox(width: _padding),
|
||||||
value: _mountType,
|
DropdownButton<String>(
|
||||||
onChanged: (newValue) {
|
value: _mountType,
|
||||||
setState(() {
|
onChanged: (newValue) {
|
||||||
_mountType = newValue ?? "";
|
setState(() {
|
||||||
});
|
_mountType = newValue ?? "";
|
||||||
},
|
});
|
||||||
items:
|
},
|
||||||
providerTypeList.map<DropdownMenuItem<String>>((item) {
|
items:
|
||||||
return DropdownMenuItem<String>(
|
providerTypeList.map<DropdownMenuItem<String>>((
|
||||||
value: item,
|
item,
|
||||||
child: Text(item),
|
) {
|
||||||
);
|
return DropdownMenuItem<String>(
|
||||||
}).toList(),
|
value: item,
|
||||||
),
|
child: Text(item),
|
||||||
],
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_mountType.isNotEmpty) const SizedBox(height: _padding),
|
if (_mountType.isNotEmpty) const SizedBox(height: _padding),
|
||||||
if (_mountType.isNotEmpty)
|
if (_mountType.isNotEmpty)
|
||||||
Card(
|
Card(
|
||||||
margin: EdgeInsets.all(_padding),
|
child: Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.all(_padding),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
mainAxisSize: MainAxisSize.min,
|
||||||
const Text('Configuration Name'),
|
children: [
|
||||||
const SizedBox(width: _padding),
|
const Text('Configuration Name'),
|
||||||
TextField(
|
const SizedBox(width: _padding),
|
||||||
autofocus: true,
|
TextField(
|
||||||
controller: _mountNameController,
|
autofocus: true,
|
||||||
keyboardType: TextInputType.text,
|
controller: _mountNameController,
|
||||||
onChanged: (_) {
|
keyboardType: TextInputType.text,
|
||||||
setState(() {
|
onChanged: (_) {
|
||||||
_mount =
|
setState(() {
|
||||||
(_mountNameController.text.isEmpty)
|
_mount =
|
||||||
? null
|
(_mountNameController.text.isEmpty)
|
||||||
: Mount(
|
? null
|
||||||
MountConfig(
|
: Mount(
|
||||||
name: _mountNameController.text,
|
MountConfig(
|
||||||
settings: _settings,
|
name: _mountNameController.text,
|
||||||
type: _mountType,
|
settings: _settings[_mountType],
|
||||||
),
|
type: _mountType,
|
||||||
isAdd: true,
|
),
|
||||||
);
|
isAdd: true,
|
||||||
});
|
);
|
||||||
},
|
});
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_mount != null)
|
if (_mount != null)
|
||||||
Card(
|
Expanded(
|
||||||
margin: EdgeInsets.all(_padding),
|
child: Card(
|
||||||
child: MountSettingsWidget(
|
child: Padding(
|
||||||
isAdd: true,
|
padding: const EdgeInsets.all(_padding),
|
||||||
mount: _mount!,
|
child: MountSettingsWidget(
|
||||||
onChanged: (settings) => _settings = settings,
|
isAdd: true,
|
||||||
showAdvanced: _showAdvanced,
|
mount: _mount!,
|
||||||
|
onChanged: (settings) => _settings[_mountType] = settings,
|
||||||
|
showAdvanced: _showAdvanced,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user