Create management portal in Flutter #39
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
parent
865ed5f0c1
commit
71f3567375
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
String formatMountName(String type, String name) {
|
String formatMountName(String type, String name) {
|
||||||
if (type == "remote") {
|
if (type == "remote") {
|
||||||
return name.replaceAll("_", ":");
|
return name.replaceAll("_", ":");
|
||||||
@ -5,6 +7,13 @@ String formatMountName(String type, String name) {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getBaseUri() {
|
||||||
|
if (kDebugMode) {
|
||||||
|
return "http://127.0.0.1:30000";
|
||||||
|
}
|
||||||
|
return Uri.base.origin;
|
||||||
|
}
|
||||||
|
|
||||||
String initialCaps(String txt) {
|
String initialCaps(String txt) {
|
||||||
if (txt.isEmpty) {
|
if (txt.isEmpty) {
|
||||||
return txt;
|
return txt;
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:repertory/helpers.dart';
|
||||||
import 'package:repertory/types/mount_config.dart';
|
import 'package:repertory/types/mount_config.dart';
|
||||||
|
|
||||||
class Mount with ChangeNotifier {
|
class Mount with ChangeNotifier {
|
||||||
@ -18,7 +19,7 @@ class Mount with ChangeNotifier {
|
|||||||
Future<void> _fetch() async {
|
Future<void> _fetch() async {
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull('${Uri.base.origin}/api/v1/mount?name=$name&type=$type'),
|
Uri.encodeFull('${getBaseUri()}/api/v1/mount?name=$name&type=$type'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ class Mount with ChangeNotifier {
|
|||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull(
|
Uri.encodeFull(
|
||||||
'${Uri.base.origin}/api/v1/mount_status?name=$name&type=$type',
|
'${getBaseUri()}/api/v1/mount_status?name=$name&type=$type',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -52,7 +53,7 @@ class Mount with ChangeNotifier {
|
|||||||
await http.post(
|
await http.post(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull(
|
Uri.encodeFull(
|
||||||
'${Uri.base.origin}/api/v1/mount?unmount=$unmount&name=$name&type=$type&location=$location',
|
'${getBaseUri()}/api/v1/mount?unmount=$unmount&name=$name&type=$type&location=$location',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -69,7 +70,7 @@ class Mount with ChangeNotifier {
|
|||||||
await http.put(
|
await http.put(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull(
|
Uri.encodeFull(
|
||||||
'${Uri.base.origin}/api/v1/set_value_by_name?name=$name&type=$type&key=$key&value=$value',
|
'${getBaseUri()}/api/v1/set_value_by_name?name=$name&type=$type&key=$key&value=$value',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:repertory/helpers.dart';
|
||||||
import 'package:repertory/types/mount_config.dart';
|
import 'package:repertory/types/mount_config.dart';
|
||||||
|
|
||||||
class MountList with ChangeNotifier {
|
class MountList with ChangeNotifier {
|
||||||
@ -16,7 +17,7 @@ class MountList with ChangeNotifier {
|
|||||||
|
|
||||||
Future<void> _fetch() async {
|
Future<void> _fetch() async {
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse('${Uri.base.origin}/api/v1/mount_list'),
|
Uri.parse('${getBaseUri()}/api/v1/mount_list'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@ -50,7 +51,7 @@ class MountList with ChangeNotifier {
|
|||||||
await http.post(
|
await http.post(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
Uri.encodeFull(
|
Uri.encodeFull(
|
||||||
'${Uri.base.origin}/api/v1/add_mount?name=$name&type=$type',
|
'${getBaseUri()}/api/v1/add_mount?name=$name&type=$type',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -6,33 +6,35 @@ class AddMountWidget extends StatelessWidget {
|
|||||||
final String mountType;
|
final String mountType;
|
||||||
final void Function(String? newName) onNameChanged;
|
final void Function(String? newName) onNameChanged;
|
||||||
final void Function(String? newType) onTypeChanged;
|
final void Function(String? newType) onTypeChanged;
|
||||||
const AddMountWidget({
|
|
||||||
|
final _items = <String>["S3", "Sia"];
|
||||||
|
|
||||||
|
AddMountWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.allowEncrypt,
|
required this.allowEncrypt,
|
||||||
required this.mountName,
|
required this.mountName,
|
||||||
required this.mountType,
|
required this.mountType,
|
||||||
required this.onNameChanged,
|
required this.onNameChanged,
|
||||||
required this.onTypeChanged,
|
required this.onTypeChanged,
|
||||||
});
|
}) {
|
||||||
|
if (allowEncrypt) {
|
||||||
|
_items.insert(0, "Encrypt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var items = ["S3", "Sia"];
|
|
||||||
if (allowEncrypt) {
|
|
||||||
items.insert(0, "Encrypt");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
DropdownButton<String>(
|
// DropdownButton<String>(
|
||||||
value: mountType,
|
// value: mountType,
|
||||||
onChanged: onTypeChanged,
|
// onChanged: onTypeChanged,
|
||||||
items:
|
// items:
|
||||||
items.map<DropdownMenuItem<String>>((item) {
|
// _items.map<DropdownMenuItem<String>>((item) {
|
||||||
return DropdownMenuItem<String>(value: item, child: Text(item));
|
// return DropdownMenuItem<String>(value: item, child: Text(item));
|
||||||
}).toList(),
|
// }).toList(),
|
||||||
),
|
// ),
|
||||||
TextField(
|
TextField(
|
||||||
decoration: InputDecoration(labelText: 'Name'),
|
decoration: InputDecoration(labelText: 'Name'),
|
||||||
onChanged: onNameChanged,
|
onChanged: onNameChanged,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user