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 75d36d0a..5f175e8a 100644 --- a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql +++ b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql @@ -21,6 +21,14 @@ query SystemSettings { } } +query SystemIsUsingBinds { + system { + info { + usingBinds + } + } +} + query DomainInfo { system { domainInfo { 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 4a920a4d..924f5d00 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 @@ -939,6 +939,416 @@ class _CopyWithStubImpl$Query$SystemSettings$system$settings$ssh _res; } +@JsonSerializable(explicitToJson: true) +class Query$SystemIsUsingBinds { + Query$SystemIsUsingBinds({required this.system, required this.$__typename}); + + @override + factory Query$SystemIsUsingBinds.fromJson(Map json) => + _$Query$SystemIsUsingBindsFromJson(json); + + final Query$SystemIsUsingBinds$system system; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => _$Query$SystemIsUsingBindsToJson(this); + int get hashCode { + final l$system = system; + final l$$__typename = $__typename; + return Object.hashAll([l$system, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$SystemIsUsingBinds) || + runtimeType != other.runtimeType) return false; + final l$system = system; + final lOther$system = other.system; + if (l$system != lOther$system) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$SystemIsUsingBinds + on Query$SystemIsUsingBinds { + CopyWith$Query$SystemIsUsingBinds get copyWith => + CopyWith$Query$SystemIsUsingBinds(this, (i) => i); +} + +abstract class CopyWith$Query$SystemIsUsingBinds { + factory CopyWith$Query$SystemIsUsingBinds(Query$SystemIsUsingBinds instance, + TRes Function(Query$SystemIsUsingBinds) then) = + _CopyWithImpl$Query$SystemIsUsingBinds; + + factory CopyWith$Query$SystemIsUsingBinds.stub(TRes res) = + _CopyWithStubImpl$Query$SystemIsUsingBinds; + + TRes call({Query$SystemIsUsingBinds$system? system, String? $__typename}); + CopyWith$Query$SystemIsUsingBinds$system get system; +} + +class _CopyWithImpl$Query$SystemIsUsingBinds + implements CopyWith$Query$SystemIsUsingBinds { + _CopyWithImpl$Query$SystemIsUsingBinds(this._instance, this._then); + + final Query$SystemIsUsingBinds _instance; + + final TRes Function(Query$SystemIsUsingBinds) _then; + + static const _undefined = {}; + + TRes call({Object? system = _undefined, Object? $__typename = _undefined}) => + _then(Query$SystemIsUsingBinds( + system: system == _undefined || system == null + ? _instance.system + : (system as Query$SystemIsUsingBinds$system), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); + CopyWith$Query$SystemIsUsingBinds$system get system { + final local$system = _instance.system; + return CopyWith$Query$SystemIsUsingBinds$system( + local$system, (e) => call(system: e)); + } +} + +class _CopyWithStubImpl$Query$SystemIsUsingBinds + implements CopyWith$Query$SystemIsUsingBinds { + _CopyWithStubImpl$Query$SystemIsUsingBinds(this._res); + + TRes _res; + + call({Query$SystemIsUsingBinds$system? system, String? $__typename}) => _res; + CopyWith$Query$SystemIsUsingBinds$system get system => + CopyWith$Query$SystemIsUsingBinds$system.stub(_res); +} + +const documentNodeQuerySystemIsUsingBinds = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'SystemIsUsingBinds'), + variableDefinitions: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'system'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'info'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'usingBinds'), + 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: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), +]); +Query$SystemIsUsingBinds _parserFn$Query$SystemIsUsingBinds( + Map data) => + Query$SystemIsUsingBinds.fromJson(data); + +class Options$Query$SystemIsUsingBinds + extends graphql.QueryOptions { + Options$Query$SystemIsUsingBinds( + {String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Duration? pollInterval, + graphql.Context? context}) + : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult, + pollInterval: pollInterval, + context: context, + document: documentNodeQuerySystemIsUsingBinds, + parserFn: _parserFn$Query$SystemIsUsingBinds); +} + +class WatchOptions$Query$SystemIsUsingBinds + extends graphql.WatchQueryOptions { + WatchOptions$Query$SystemIsUsingBinds( + {String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false}) + : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult, + context: context, + document: documentNodeQuerySystemIsUsingBinds, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Query$SystemIsUsingBinds); +} + +class FetchMoreOptions$Query$SystemIsUsingBinds + extends graphql.FetchMoreOptions { + FetchMoreOptions$Query$SystemIsUsingBinds( + {required graphql.UpdateQuery updateQuery}) + : super( + updateQuery: updateQuery, + document: documentNodeQuerySystemIsUsingBinds); +} + +extension ClientExtension$Query$SystemIsUsingBinds on graphql.GraphQLClient { + Future> + query$SystemIsUsingBinds( + [Options$Query$SystemIsUsingBinds? options]) async => + await this.query(options ?? Options$Query$SystemIsUsingBinds()); + graphql.ObservableQuery + watchQuery$SystemIsUsingBinds( + [WatchOptions$Query$SystemIsUsingBinds? options]) => + this.watchQuery(options ?? WatchOptions$Query$SystemIsUsingBinds()); + void writeQuery$SystemIsUsingBinds( + {required Query$SystemIsUsingBinds data, bool broadcast = true}) => + this.writeQuery( + graphql.Request( + operation: graphql.Operation( + document: documentNodeQuerySystemIsUsingBinds)), + data: data.toJson(), + broadcast: broadcast); + Query$SystemIsUsingBinds? readQuery$SystemIsUsingBinds( + {bool optimistic = true}) { + final result = this.readQuery( + graphql.Request( + operation: graphql.Operation( + document: documentNodeQuerySystemIsUsingBinds)), + optimistic: optimistic); + return result == null ? null : Query$SystemIsUsingBinds.fromJson(result); + } +} + +@JsonSerializable(explicitToJson: true) +class Query$SystemIsUsingBinds$system { + Query$SystemIsUsingBinds$system( + {required this.info, required this.$__typename}); + + @override + factory Query$SystemIsUsingBinds$system.fromJson(Map json) => + _$Query$SystemIsUsingBinds$systemFromJson(json); + + final Query$SystemIsUsingBinds$system$info info; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => + _$Query$SystemIsUsingBinds$systemToJson(this); + int get hashCode { + final l$info = info; + final l$$__typename = $__typename; + return Object.hashAll([l$info, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$SystemIsUsingBinds$system) || + runtimeType != other.runtimeType) return false; + final l$info = info; + final lOther$info = other.info; + if (l$info != lOther$info) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$SystemIsUsingBinds$system + on Query$SystemIsUsingBinds$system { + CopyWith$Query$SystemIsUsingBinds$system + get copyWith => CopyWith$Query$SystemIsUsingBinds$system(this, (i) => i); +} + +abstract class CopyWith$Query$SystemIsUsingBinds$system { + factory CopyWith$Query$SystemIsUsingBinds$system( + Query$SystemIsUsingBinds$system instance, + TRes Function(Query$SystemIsUsingBinds$system) then) = + _CopyWithImpl$Query$SystemIsUsingBinds$system; + + factory CopyWith$Query$SystemIsUsingBinds$system.stub(TRes res) = + _CopyWithStubImpl$Query$SystemIsUsingBinds$system; + + TRes call({Query$SystemIsUsingBinds$system$info? info, String? $__typename}); + CopyWith$Query$SystemIsUsingBinds$system$info get info; +} + +class _CopyWithImpl$Query$SystemIsUsingBinds$system + implements CopyWith$Query$SystemIsUsingBinds$system { + _CopyWithImpl$Query$SystemIsUsingBinds$system(this._instance, this._then); + + final Query$SystemIsUsingBinds$system _instance; + + final TRes Function(Query$SystemIsUsingBinds$system) _then; + + static const _undefined = {}; + + TRes call({Object? info = _undefined, Object? $__typename = _undefined}) => + _then(Query$SystemIsUsingBinds$system( + info: info == _undefined || info == null + ? _instance.info + : (info as Query$SystemIsUsingBinds$system$info), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); + CopyWith$Query$SystemIsUsingBinds$system$info get info { + final local$info = _instance.info; + return CopyWith$Query$SystemIsUsingBinds$system$info( + local$info, (e) => call(info: e)); + } +} + +class _CopyWithStubImpl$Query$SystemIsUsingBinds$system + implements CopyWith$Query$SystemIsUsingBinds$system { + _CopyWithStubImpl$Query$SystemIsUsingBinds$system(this._res); + + TRes _res; + + call({Query$SystemIsUsingBinds$system$info? info, String? $__typename}) => + _res; + CopyWith$Query$SystemIsUsingBinds$system$info get info => + CopyWith$Query$SystemIsUsingBinds$system$info.stub(_res); +} + +@JsonSerializable(explicitToJson: true) +class Query$SystemIsUsingBinds$system$info { + Query$SystemIsUsingBinds$system$info( + {required this.usingBinds, required this.$__typename}); + + @override + factory Query$SystemIsUsingBinds$system$info.fromJson( + Map json) => + _$Query$SystemIsUsingBinds$system$infoFromJson(json); + + final bool usingBinds; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => + _$Query$SystemIsUsingBinds$system$infoToJson(this); + int get hashCode { + final l$usingBinds = usingBinds; + final l$$__typename = $__typename; + return Object.hashAll([l$usingBinds, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$SystemIsUsingBinds$system$info) || + runtimeType != other.runtimeType) return false; + final l$usingBinds = usingBinds; + final lOther$usingBinds = other.usingBinds; + if (l$usingBinds != lOther$usingBinds) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$SystemIsUsingBinds$system$info + on Query$SystemIsUsingBinds$system$info { + CopyWith$Query$SystemIsUsingBinds$system$info< + Query$SystemIsUsingBinds$system$info> + get copyWith => + CopyWith$Query$SystemIsUsingBinds$system$info(this, (i) => i); +} + +abstract class CopyWith$Query$SystemIsUsingBinds$system$info { + factory CopyWith$Query$SystemIsUsingBinds$system$info( + Query$SystemIsUsingBinds$system$info instance, + TRes Function(Query$SystemIsUsingBinds$system$info) then) = + _CopyWithImpl$Query$SystemIsUsingBinds$system$info; + + factory CopyWith$Query$SystemIsUsingBinds$system$info.stub(TRes res) = + _CopyWithStubImpl$Query$SystemIsUsingBinds$system$info; + + TRes call({bool? usingBinds, String? $__typename}); +} + +class _CopyWithImpl$Query$SystemIsUsingBinds$system$info + implements CopyWith$Query$SystemIsUsingBinds$system$info { + _CopyWithImpl$Query$SystemIsUsingBinds$system$info( + this._instance, this._then); + + final Query$SystemIsUsingBinds$system$info _instance; + + final TRes Function(Query$SystemIsUsingBinds$system$info) _then; + + static const _undefined = {}; + + TRes call( + {Object? usingBinds = _undefined, + Object? $__typename = _undefined}) => + _then(Query$SystemIsUsingBinds$system$info( + usingBinds: usingBinds == _undefined || usingBinds == null + ? _instance.usingBinds + : (usingBinds as bool), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); +} + +class _CopyWithStubImpl$Query$SystemIsUsingBinds$system$info + implements CopyWith$Query$SystemIsUsingBinds$system$info { + _CopyWithStubImpl$Query$SystemIsUsingBinds$system$info(this._res); + + TRes _res; + + call({bool? usingBinds, String? $__typename}) => _res; +} + @JsonSerializable(explicitToJson: true) class Query$DomainInfo { Query$DomainInfo({required this.system, required this.$__typename}); diff --git a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.g.dart b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.g.dart index d3e51515..d60ae006 100644 --- a/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.g.dart +++ b/lib/logic/api_maps/graphql_maps/schema/server_settings.graphql.g.dart @@ -113,6 +113,50 @@ Map _$Query$SystemSettings$system$settings$sshToJson( '__typename': instance.$__typename, }; +Query$SystemIsUsingBinds _$Query$SystemIsUsingBindsFromJson( + Map json) => + Query$SystemIsUsingBinds( + system: Query$SystemIsUsingBinds$system.fromJson( + json['system'] as Map), + $__typename: json['__typename'] as String, + ); + +Map _$Query$SystemIsUsingBindsToJson( + Query$SystemIsUsingBinds instance) => + { + 'system': instance.system.toJson(), + '__typename': instance.$__typename, + }; + +Query$SystemIsUsingBinds$system _$Query$SystemIsUsingBinds$systemFromJson( + Map json) => + Query$SystemIsUsingBinds$system( + info: Query$SystemIsUsingBinds$system$info.fromJson( + json['info'] as Map), + $__typename: json['__typename'] as String, + ); + +Map _$Query$SystemIsUsingBinds$systemToJson( + Query$SystemIsUsingBinds$system instance) => + { + 'info': instance.info.toJson(), + '__typename': instance.$__typename, + }; + +Query$SystemIsUsingBinds$system$info + _$Query$SystemIsUsingBinds$system$infoFromJson(Map json) => + Query$SystemIsUsingBinds$system$info( + usingBinds: json['usingBinds'] as bool, + $__typename: json['__typename'] as String, + ); + +Map _$Query$SystemIsUsingBinds$system$infoToJson( + Query$SystemIsUsingBinds$system$info instance) => + { + 'usingBinds': instance.usingBinds, + '__typename': instance.$__typename, + }; + Query$DomainInfo _$Query$DomainInfoFromJson(Map json) => Query$DomainInfo( system: Query$DomainInfo$system.fromJson( diff --git a/lib/logic/api_maps/graphql_maps/server_api/server.dart b/lib/logic/api_maps/graphql_maps/server_api/server.dart index 13ea67a7..4fb757e2 100644 --- a/lib/logic/api_maps/graphql_maps/server_api/server.dart +++ b/lib/logic/api_maps/graphql_maps/server_api/server.dart @@ -2,6 +2,7 @@ import 'package:graphql/client.dart'; import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/api_map.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/schema.graphql.dart'; +import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_api.graphql.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/disk_volumes.graphql.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart'; @@ -73,6 +74,23 @@ class ServerApi extends ApiMap return apiVersion; } + Future isUsingBinds() async { + QueryResult response; + bool usesBinds = false; + + try { + final GraphQLClient client = await getClient(); + response = await client.query$SystemIsUsingBinds(); + if (response.hasException) { + print(response.exception.toString()); + } + usesBinds = response.data!['system']['info']['usingBinds']; + } catch (e) { + print(e); + } + return usesBinds; + } + Future> getApiTokens() async { QueryResult response; List tokens = []; @@ -89,7 +107,6 @@ class ServerApi extends ApiMap } catch (e) { print(e); } - return tokens; } diff --git a/lib/logic/cubit/server_volumes/server_volume_cubit.dart b/lib/logic/cubit/server_volumes/server_volume_cubit.dart index 13015d0b..53b185c7 100644 --- a/lib/logic/cubit/server_volumes/server_volume_cubit.dart +++ b/lib/logic/cubit/server_volumes/server_volume_cubit.dart @@ -20,13 +20,15 @@ class ApiServerVolumeCubit } Future _refetch() async { - final List volumes = - await serverApi.getServerDiskVolumes(); + final volumes = await serverApi.getServerDiskVolumes(); + final usesBinds = await serverApi.isUsingBinds(); + var status = LoadingStatus.error; + if (volumes.isNotEmpty) { - emit(ApiServerVolumeState(volumes, LoadingStatus.success)); - } else { - emit(const ApiServerVolumeState([], LoadingStatus.error)); + status = LoadingStatus.success; } + + emit(ApiServerVolumeState(volumes, status, usesBinds)); } @override diff --git a/lib/logic/cubit/server_volumes/server_volume_state.dart b/lib/logic/cubit/server_volumes/server_volume_state.dart index 3c267710..12b0b9be 100644 --- a/lib/logic/cubit/server_volumes/server_volume_state.dart +++ b/lib/logic/cubit/server_volumes/server_volume_state.dart @@ -1,11 +1,21 @@ part of 'server_volume_cubit.dart'; class ApiServerVolumeState extends ServerInstallationDependendState { - const ApiServerVolumeState(this._volumes, this.status); + const ApiServerVolumeState( + this._volumes, + this.status, + this.usesBinds, + ); const ApiServerVolumeState.initial() - : this(const [], LoadingStatus.uninitialized); + : this( + const [], + LoadingStatus.uninitialized, + null, + ); + final List _volumes; + final bool? usesBinds; final LoadingStatus status; List get volumes => _volumes; @@ -13,12 +23,14 @@ class ApiServerVolumeState extends ServerInstallationDependendState { ApiServerVolumeState copyWith({ final List? volumes, final LoadingStatus? status, + final bool? usesBinds, }) => ApiServerVolumeState( volumes ?? _volumes, status ?? this.status, + usesBinds ?? this.usesBinds, ); @override - List get props => [_volumes]; + List get props => [_volumes, status, usesBinds]; }