diff --git a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql index 32bf5f93..54a6d7bf 100644 --- a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql +++ b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql @@ -31,15 +31,6 @@ fragment fragmentDnsRecords on DnsRecord { } query GetDnsRecords { - services { - allServices { - id - displayName - dnsRecords { - ...fragmentDnsRecords - } - } - } system { domainInfo { domain diff --git a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart index 2b3fd6b2..66bbebac 100644 --- a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart +++ b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart @@ -1869,34 +1869,26 @@ class _CopyWithStubImpl$Query$SystemIsUsingBinds$system$info class Query$GetDnsRecords { Query$GetDnsRecords({ - required this.services, required this.system, this.$__typename = 'Query', }); factory Query$GetDnsRecords.fromJson(Map json) { - final l$services = json['services']; final l$system = json['system']; final l$$__typename = json['__typename']; return Query$GetDnsRecords( - services: Query$GetDnsRecords$services.fromJson( - (l$services as Map)), system: Query$GetDnsRecords$system.fromJson( (l$system as Map)), $__typename: (l$$__typename as String), ); } - final Query$GetDnsRecords$services services; - final Query$GetDnsRecords$system system; final String $__typename; Map toJson() { final _resultData = {}; - final l$services = services; - _resultData['services'] = l$services.toJson(); final l$system = system; _resultData['system'] = l$system.toJson(); final l$$__typename = $__typename; @@ -1906,11 +1898,9 @@ class Query$GetDnsRecords { @override int get hashCode { - final l$services = services; final l$system = system; final l$$__typename = $__typename; return Object.hashAll([ - l$services, l$system, l$$__typename, ]); @@ -1924,11 +1914,6 @@ class Query$GetDnsRecords { if (!(other is Query$GetDnsRecords) || runtimeType != other.runtimeType) { return false; } - final l$services = services; - final lOther$services = other.services; - if (l$services != lOther$services) { - return false; - } final l$system = system; final lOther$system = other.system; if (l$system != lOther$system) { @@ -1961,11 +1946,9 @@ abstract class CopyWith$Query$GetDnsRecords { _CopyWithStubImpl$Query$GetDnsRecords; TRes call({ - Query$GetDnsRecords$services? services, Query$GetDnsRecords$system? system, String? $__typename, }); - CopyWith$Query$GetDnsRecords$services get services; CopyWith$Query$GetDnsRecords$system get system; } @@ -1983,14 +1966,10 @@ class _CopyWithImpl$Query$GetDnsRecords static const _undefined = {}; TRes call({ - Object? services = _undefined, Object? system = _undefined, Object? $__typename = _undefined, }) => _then(Query$GetDnsRecords( - services: services == _undefined || services == null - ? _instance.services - : (services as Query$GetDnsRecords$services), system: system == _undefined || system == null ? _instance.system : (system as Query$GetDnsRecords$system), @@ -1999,12 +1978,6 @@ class _CopyWithImpl$Query$GetDnsRecords : ($__typename as String), )); - CopyWith$Query$GetDnsRecords$services get services { - final local$services = _instance.services; - return CopyWith$Query$GetDnsRecords$services( - local$services, (e) => call(services: e)); - } - CopyWith$Query$GetDnsRecords$system get system { final local$system = _instance.system; return CopyWith$Query$GetDnsRecords$system( @@ -2019,15 +1992,11 @@ class _CopyWithStubImpl$Query$GetDnsRecords TRes _res; call({ - Query$GetDnsRecords$services? services, Query$GetDnsRecords$system? system, String? $__typename, }) => _res; - CopyWith$Query$GetDnsRecords$services get services => - CopyWith$Query$GetDnsRecords$services.stub(_res); - CopyWith$Query$GetDnsRecords$system get system => CopyWith$Query$GetDnsRecords$system.stub(_res); } @@ -2039,69 +2008,6 @@ const documentNodeQueryGetDnsRecords = DocumentNode(definitions: [ variableDefinitions: [], directives: [], selectionSet: SelectionSetNode(selections: [ - FieldNode( - name: NameNode(value: 'services'), - alias: null, - arguments: [], - directives: [], - selectionSet: SelectionSetNode(selections: [ - FieldNode( - name: NameNode(value: 'allServices'), - alias: null, - arguments: [], - directives: [], - selectionSet: SelectionSetNode(selections: [ - FieldNode( - name: NameNode(value: 'id'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - FieldNode( - name: NameNode(value: 'displayName'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - FieldNode( - name: NameNode(value: 'dnsRecords'), - alias: null, - arguments: [], - directives: [], - selectionSet: SelectionSetNode(selections: [ - FragmentSpreadNode( - name: NameNode(value: 'fragmentDnsRecords'), - directives: [], - ), - FieldNode( - name: NameNode(value: '__typename'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - ]), - ), - FieldNode( - name: NameNode(value: '__typename'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - ]), - ), - FieldNode( - name: NameNode(value: '__typename'), - alias: null, - arguments: [], - directives: [], - selectionSet: null, - ), - ]), - ), FieldNode( name: NameNode(value: 'system'), alias: null, @@ -2302,362 +2208,6 @@ extension ClientExtension$Query$GetDnsRecords on graphql.GraphQLClient { } } -class Query$GetDnsRecords$services { - Query$GetDnsRecords$services({ - required this.allServices, - this.$__typename = 'Services', - }); - - factory Query$GetDnsRecords$services.fromJson(Map json) { - final l$allServices = json['allServices']; - final l$$__typename = json['__typename']; - return Query$GetDnsRecords$services( - allServices: (l$allServices as List) - .map((e) => Query$GetDnsRecords$services$allServices.fromJson( - (e as Map))) - .toList(), - $__typename: (l$$__typename as String), - ); - } - - final List allServices; - - final String $__typename; - - Map toJson() { - final _resultData = {}; - final l$allServices = allServices; - _resultData['allServices'] = l$allServices.map((e) => e.toJson()).toList(); - final l$$__typename = $__typename; - _resultData['__typename'] = l$$__typename; - return _resultData; - } - - @override - int get hashCode { - final l$allServices = allServices; - final l$$__typename = $__typename; - return Object.hashAll([ - Object.hashAll(l$allServices.map((v) => v)), - l$$__typename, - ]); - } - - @override - bool operator ==(Object other) { - if (identical(this, other)) { - return true; - } - if (!(other is Query$GetDnsRecords$services) || - runtimeType != other.runtimeType) { - return false; - } - final l$allServices = allServices; - final lOther$allServices = other.allServices; - if (l$allServices.length != lOther$allServices.length) { - return false; - } - for (int i = 0; i < l$allServices.length; i++) { - final l$allServices$entry = l$allServices[i]; - final lOther$allServices$entry = lOther$allServices[i]; - if (l$allServices$entry != lOther$allServices$entry) { - return false; - } - } - final l$$__typename = $__typename; - final lOther$$__typename = other.$__typename; - if (l$$__typename != lOther$$__typename) { - return false; - } - return true; - } -} - -extension UtilityExtension$Query$GetDnsRecords$services - on Query$GetDnsRecords$services { - CopyWith$Query$GetDnsRecords$services - get copyWith => CopyWith$Query$GetDnsRecords$services( - this, - (i) => i, - ); -} - -abstract class CopyWith$Query$GetDnsRecords$services { - factory CopyWith$Query$GetDnsRecords$services( - Query$GetDnsRecords$services instance, - TRes Function(Query$GetDnsRecords$services) then, - ) = _CopyWithImpl$Query$GetDnsRecords$services; - - factory CopyWith$Query$GetDnsRecords$services.stub(TRes res) = - _CopyWithStubImpl$Query$GetDnsRecords$services; - - TRes call({ - List? allServices, - String? $__typename, - }); - TRes allServices( - Iterable Function( - Iterable< - CopyWith$Query$GetDnsRecords$services$allServices< - Query$GetDnsRecords$services$allServices>>) - _fn); -} - -class _CopyWithImpl$Query$GetDnsRecords$services - implements CopyWith$Query$GetDnsRecords$services { - _CopyWithImpl$Query$GetDnsRecords$services( - this._instance, - this._then, - ); - - final Query$GetDnsRecords$services _instance; - - final TRes Function(Query$GetDnsRecords$services) _then; - - static const _undefined = {}; - - TRes call({ - Object? allServices = _undefined, - Object? $__typename = _undefined, - }) => - _then(Query$GetDnsRecords$services( - allServices: allServices == _undefined || allServices == null - ? _instance.allServices - : (allServices as List), - $__typename: $__typename == _undefined || $__typename == null - ? _instance.$__typename - : ($__typename as String), - )); - - TRes allServices( - Iterable Function( - Iterable< - CopyWith$Query$GetDnsRecords$services$allServices< - Query$GetDnsRecords$services$allServices>>) - _fn) => - call( - allServices: _fn(_instance.allServices - .map((e) => CopyWith$Query$GetDnsRecords$services$allServices( - e, - (i) => i, - ))).toList()); -} - -class _CopyWithStubImpl$Query$GetDnsRecords$services - implements CopyWith$Query$GetDnsRecords$services { - _CopyWithStubImpl$Query$GetDnsRecords$services(this._res); - - TRes _res; - - call({ - List? allServices, - String? $__typename, - }) => - _res; - - allServices(_fn) => _res; -} - -class Query$GetDnsRecords$services$allServices { - Query$GetDnsRecords$services$allServices({ - required this.id, - required this.displayName, - this.dnsRecords, - this.$__typename = 'Service', - }); - - factory Query$GetDnsRecords$services$allServices.fromJson( - Map json) { - final l$id = json['id']; - final l$displayName = json['displayName']; - final l$dnsRecords = json['dnsRecords']; - final l$$__typename = json['__typename']; - return Query$GetDnsRecords$services$allServices( - id: (l$id as String), - displayName: (l$displayName as String), - dnsRecords: (l$dnsRecords as List?) - ?.map((e) => - Fragment$fragmentDnsRecords.fromJson((e as Map))) - .toList(), - $__typename: (l$$__typename as String), - ); - } - - final String id; - - final String displayName; - - final List? dnsRecords; - - final String $__typename; - - Map toJson() { - final _resultData = {}; - final l$id = id; - _resultData['id'] = l$id; - final l$displayName = displayName; - _resultData['displayName'] = l$displayName; - final l$dnsRecords = dnsRecords; - _resultData['dnsRecords'] = l$dnsRecords?.map((e) => e.toJson()).toList(); - final l$$__typename = $__typename; - _resultData['__typename'] = l$$__typename; - return _resultData; - } - - @override - int get hashCode { - final l$id = id; - final l$displayName = displayName; - final l$dnsRecords = dnsRecords; - final l$$__typename = $__typename; - return Object.hashAll([ - l$id, - l$displayName, - l$dnsRecords == null ? null : Object.hashAll(l$dnsRecords.map((v) => v)), - l$$__typename, - ]); - } - - @override - bool operator ==(Object other) { - if (identical(this, other)) { - return true; - } - if (!(other is Query$GetDnsRecords$services$allServices) || - runtimeType != other.runtimeType) { - return false; - } - final l$id = id; - final lOther$id = other.id; - if (l$id != lOther$id) { - return false; - } - final l$displayName = displayName; - final lOther$displayName = other.displayName; - if (l$displayName != lOther$displayName) { - return false; - } - final l$dnsRecords = dnsRecords; - final lOther$dnsRecords = other.dnsRecords; - if (l$dnsRecords != null && lOther$dnsRecords != null) { - if (l$dnsRecords.length != lOther$dnsRecords.length) { - return false; - } - for (int i = 0; i < l$dnsRecords.length; i++) { - final l$dnsRecords$entry = l$dnsRecords[i]; - final lOther$dnsRecords$entry = lOther$dnsRecords[i]; - if (l$dnsRecords$entry != lOther$dnsRecords$entry) { - return false; - } - } - } else if (l$dnsRecords != lOther$dnsRecords) { - return false; - } - final l$$__typename = $__typename; - final lOther$$__typename = other.$__typename; - if (l$$__typename != lOther$$__typename) { - return false; - } - return true; - } -} - -extension UtilityExtension$Query$GetDnsRecords$services$allServices - on Query$GetDnsRecords$services$allServices { - CopyWith$Query$GetDnsRecords$services$allServices< - Query$GetDnsRecords$services$allServices> - get copyWith => CopyWith$Query$GetDnsRecords$services$allServices( - this, - (i) => i, - ); -} - -abstract class CopyWith$Query$GetDnsRecords$services$allServices { - factory CopyWith$Query$GetDnsRecords$services$allServices( - Query$GetDnsRecords$services$allServices instance, - TRes Function(Query$GetDnsRecords$services$allServices) then, - ) = _CopyWithImpl$Query$GetDnsRecords$services$allServices; - - factory CopyWith$Query$GetDnsRecords$services$allServices.stub(TRes res) = - _CopyWithStubImpl$Query$GetDnsRecords$services$allServices; - - TRes call({ - String? id, - String? displayName, - List? dnsRecords, - String? $__typename, - }); - TRes dnsRecords( - Iterable? Function( - Iterable< - CopyWith$Fragment$fragmentDnsRecords< - Fragment$fragmentDnsRecords>>?) - _fn); -} - -class _CopyWithImpl$Query$GetDnsRecords$services$allServices - implements CopyWith$Query$GetDnsRecords$services$allServices { - _CopyWithImpl$Query$GetDnsRecords$services$allServices( - this._instance, - this._then, - ); - - final Query$GetDnsRecords$services$allServices _instance; - - final TRes Function(Query$GetDnsRecords$services$allServices) _then; - - static const _undefined = {}; - - TRes call({ - Object? id = _undefined, - Object? displayName = _undefined, - Object? dnsRecords = _undefined, - Object? $__typename = _undefined, - }) => - _then(Query$GetDnsRecords$services$allServices( - id: id == _undefined || id == null ? _instance.id : (id as String), - displayName: displayName == _undefined || displayName == null - ? _instance.displayName - : (displayName as String), - dnsRecords: dnsRecords == _undefined - ? _instance.dnsRecords - : (dnsRecords as List?), - $__typename: $__typename == _undefined || $__typename == null - ? _instance.$__typename - : ($__typename as String), - )); - - TRes dnsRecords( - Iterable? Function( - Iterable< - CopyWith$Fragment$fragmentDnsRecords< - Fragment$fragmentDnsRecords>>?) - _fn) => - call( - dnsRecords: _fn(_instance.dnsRecords - ?.map((e) => CopyWith$Fragment$fragmentDnsRecords( - e, - (i) => i, - )))?.toList()); -} - -class _CopyWithStubImpl$Query$GetDnsRecords$services$allServices - implements CopyWith$Query$GetDnsRecords$services$allServices { - _CopyWithStubImpl$Query$GetDnsRecords$services$allServices(this._res); - - TRes _res; - - call({ - String? id, - String? displayName, - List? dnsRecords, - String? $__typename, - }) => - _res; - - dnsRecords(_fn) => _res; -} - class Query$GetDnsRecords$system { Query$GetDnsRecords$system({ required this.domainInfo, diff --git a/lib/logic/api_maps/graphql_maps/server_api/server_api.dart b/lib/logic/api_maps/graphql_maps/server_api/server_api.dart index 86285001..d59cef10 100644 --- a/lib/logic/api_maps/graphql_maps/server_api/server_api.dart +++ b/lib/logic/api_maps/graphql_maps/server_api/server_api.dart @@ -285,7 +285,7 @@ class ServerApi extends GraphQLApiMap } Future> getDnsRecords() async { - List dnsRecords = []; + List records = []; QueryResult response; try { @@ -294,32 +294,19 @@ class ServerApi extends GraphQLApiMap if (response.hasException) { print(response.exception.toString()); } - final List domainInfoRecords = - response.parsedData!.system.domainInfo.requiredDnsRecords - .map( - ( - final Fragment$fragmentDnsRecords record, - ) => - DnsRecord.fromGraphQL(record), - ) - .toList(); - final List serviceRecords = []; - for (final service in response.parsedData!.services.allServices) { - serviceRecords.addAll( - service.dnsRecords!.map( + records = response.parsedData!.system.domainInfo.requiredDnsRecords + .map( ( final Fragment$fragmentDnsRecords record, ) => DnsRecord.fromGraphQL(record), - ), - ); - } - dnsRecords = [...domainInfoRecords, ...serviceRecords]; + ) + .toList(); } catch (e) { print(e); } - return dnsRecords; + return records; } Future>> getApiTokens() async { diff --git a/lib/logic/cubit/dns_records/dns_records_cubit.dart b/lib/logic/cubit/dns_records/dns_records_cubit.dart index c7b64275..6a476f3e 100644 --- a/lib/logic/cubit/dns_records/dns_records_cubit.dart +++ b/lib/logic/cubit/dns_records/dns_records_cubit.dart @@ -37,7 +37,8 @@ class DnsRecordsCubit emit(const DnsRecordsState()); return; } - final allDnsRecords = await api.getDnsRecords(); + final List allDnsRecords = await api.getDnsRecords(); + allDnsRecords.removeWhere((final record) => record.type == 'AAAA'); final foundRecords = await ProvidersController.currentDnsProvider!.validateDnsRecords( domain!, diff --git a/lib/logic/models/json/dns_providers/cloudflare_dns_adapter.dart b/lib/logic/models/json/dns_providers/cloudflare_dns_adapter.dart index 8132fde2..622e7129 100644 --- a/lib/logic/models/json/dns_providers/cloudflare_dns_adapter.dart +++ b/lib/logic/models/json/dns_providers/cloudflare_dns_adapter.dart @@ -3,15 +3,20 @@ part of 'cloudflare_dns_info.dart'; CloudflareDnsRecord _fromDnsRecord( final DnsRecord dnsRecord, final String rootDomain, -) => - CloudflareDnsRecord( - content: dnsRecord.content, - name: dnsRecord.name, - type: dnsRecord.type, - zoneName: rootDomain, - id: null, - ttl: dnsRecord.ttl, - ); +) { + String name = dnsRecord.name ?? ''; + if (name != rootDomain) { + name = '$name.$rootDomain'; + } + return CloudflareDnsRecord( + content: dnsRecord.content, + name: name, + type: dnsRecord.type, + zoneName: rootDomain, + id: null, + ttl: dnsRecord.ttl, + ); +} DnsRecord _toDnsRecord(final CloudflareDnsRecord cloudflareRecord) => DnsRecord( content: cloudflareRecord.content, diff --git a/lib/logic/providers/dns_providers/cloudflare.dart b/lib/logic/providers/dns_providers/cloudflare.dart index 06691cb0..a3238aed 100644 --- a/lib/logic/providers/dns_providers/cloudflare.dart +++ b/lib/logic/providers/dns_providers/cloudflare.dart @@ -232,8 +232,11 @@ class CloudflareDnsProvider extends DnsProvider { foundRecords.add( DesiredDnsRecord( name: record.name ?? '', + description: record.name?.split('.')[0] ?? '', content: record.content ?? '', isSatisfied: foundContent == content, + type: record.type, + category: DnsRecordsCategory.email, ), ); } else { @@ -246,8 +249,13 @@ class CloudflareDnsProvider extends DnsProvider { foundRecords.add( DesiredDnsRecord( name: record.name ?? '', + description: record.name?.split('.')[0] ?? '', content: record.content ?? '', isSatisfied: foundMatch, + type: record.type, + category: record.type == 'A' + ? DnsRecordsCategory.services + : DnsRecordsCategory.other, ), ); } diff --git a/lib/ui/pages/dns_details/dns_details.dart b/lib/ui/pages/dns_details/dns_details.dart index 98e567a9..9cbe03ab 100644 --- a/lib/ui/pages/dns_details/dns_details.dart +++ b/lib/ui/pages/dns_details/dns_details.dart @@ -151,9 +151,7 @@ class _DnsDetailsPageState extends State { ? neutralColor : errorColor, ), - title: Text( - dnsRecord.description.tr(), - ), + title: Text(dnsRecord.description), subtitle: Text( dnsRecord.displayName ?? dnsRecord.name, ), @@ -196,7 +194,7 @@ class _DnsDetailsPageState extends State { : errorColor, ), title: Text( - dnsRecord.description.tr(), + dnsRecord.description, ), ), ],