continue management portal

This commit is contained in:
2025-03-01 07:13:08 -06:00
parent 52f0d755ba
commit d54ba8203a
6 changed files with 155 additions and 2 deletions

View File

@ -1,10 +1,34 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:repertory/types/mount_config.dart';
class Mount with ChangeNotifier {
final MountConfig mountConfig;
Mount(this.mountConfig);
Mount(this.mountConfig) {
_fetch();
}
String get name => mountConfig.name;
String get type => mountConfig.type;
Future<void> _fetch() async {
final response = await http.get(
Uri.parse(
Uri.encodeFull('${Uri.base.origin}/api/v1/mount?name=$name&type=$type'),
),
);
if (response.statusCode == 200) {
mountConfig.updateSettings(jsonDecode(response.body));
notifyListeners();
return;
}
}
void refresh() {
_fetch();
}
}

View File

@ -1,12 +1,20 @@
import 'package:collection/collection.dart';
class MountConfig {
final String _name;
final String _type;
Map<String, dynamic> _settings = {};
MountConfig({required name, required type}) : _name = name, _type = type;
UnmodifiableMapView get items => UnmodifiableMapView(_settings);
String get name => _name;
String get type => _type;
factory MountConfig.fromJson(String type, String name) {
return MountConfig(name: name, type: type);
}
void updateSettings(Map<String, dynamic> settings) {
_settings = settings;
}
}