feat: implement NPM Proxy Hosts section with reusable entity patterns
Add full Proxy Hosts feature for Control Room: - Data layer: datasource, model with custom JSON converters for NPM API quirks - Domain layer: ProxyHost entity with SSL, caching, websocket support - Presentation: list page, detail/edit page, form widget Add reusable entity page patterns for Control Room sections: - EntityPageScaffold, EntitySection, EntitySettingRow components - EntityForm with create/view/edit mode support - EntityPageModeMixin for consistent mode management - CreateOnlyField for immutable-after-creation fields 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
67d2f777c8
commit
2adb50b352
@@ -0,0 +1,69 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:tatlock_ui/core/api/api_client.dart';
|
||||
import 'package:tatlock_ui/features/control_room/npm/data/models/proxy_host_model.dart';
|
||||
|
||||
part 'proxy_hosts_datasource.g.dart';
|
||||
|
||||
/// Remote data source for NPM proxy host operations via Core API.
|
||||
class ProxyHostsDatasource {
|
||||
ProxyHostsDatasource(this._dio);
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
/// Gets all configured domains from Core API.
|
||||
Future<List<DomainInfoModel>> getDomains() async {
|
||||
final response = await _dio.get<List<dynamic>>(
|
||||
'/infrastructure/domains',
|
||||
);
|
||||
|
||||
return response.data!
|
||||
.map((json) => DomainInfoModel.fromJson(json as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Gets detailed proxy host configuration by ID.
|
||||
Future<ProxyHostModel> getProxyHost(int proxyId) async {
|
||||
final response = await _dio.get<Map<String, dynamic>>(
|
||||
'/infrastructure/proxy/$proxyId',
|
||||
);
|
||||
|
||||
return ProxyHostModel.fromJson(response.data!);
|
||||
}
|
||||
|
||||
/// Creates a new proxy host.
|
||||
Future<void> createProxyHost({
|
||||
required List<String> domainNames,
|
||||
required String forwardScheme,
|
||||
required String forwardHost,
|
||||
required int forwardPort,
|
||||
bool sslEnabled = false,
|
||||
}) async {
|
||||
await _dio.post<void>(
|
||||
'/infrastructure/proxy',
|
||||
data: {
|
||||
'domain_names': domainNames,
|
||||
'forward_scheme': forwardScheme,
|
||||
'forward_host': forwardHost,
|
||||
'forward_port': forwardPort,
|
||||
'ssl_enabled': sslEnabled,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Updates an existing proxy host.
|
||||
Future<void> updateProxyHost(int proxyId, Map<String, dynamic> config) async {
|
||||
await _dio.put<void>(
|
||||
'/infrastructure/proxy/$proxyId',
|
||||
data: config,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides the proxy hosts datasource.
|
||||
@riverpod
|
||||
ProxyHostsDatasource proxyHostsDatasource(Ref ref) {
|
||||
final dio = ref.watch(coreApiClientProvider);
|
||||
return ProxyHostsDatasource(dio);
|
||||
}
|
||||
Reference in New Issue
Block a user