Reformatting
parent
0879ea8e97
commit
18b737a327
File diff suppressed because it is too large
Load Diff
|
@ -6,28 +6,37 @@ part of 'users.graphql.dart';
|
|||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Fragment$basicMutationReturnFields _$Fragment$basicMutationReturnFieldsFromJson(Map<String, dynamic> json) => Fragment$basicMutationReturnFields(
|
||||
Fragment$basicMutationReturnFields _$Fragment$basicMutationReturnFieldsFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Fragment$basicMutationReturnFields(
|
||||
code: json['code'] as int,
|
||||
message: json['message'] as String,
|
||||
success: json['success'] as bool,
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Fragment$basicMutationReturnFieldsToJson(Fragment$basicMutationReturnFields instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Fragment$basicMutationReturnFieldsToJson(
|
||||
Fragment$basicMutationReturnFields instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Fragment$userFields _$Fragment$userFieldsFromJson(Map<String, dynamic> json) => Fragment$userFields(
|
||||
Fragment$userFields _$Fragment$userFieldsFromJson(Map<String, dynamic> json) =>
|
||||
Fragment$userFields(
|
||||
username: json['username'] as String,
|
||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'], unknownValue: Enum$UserType.$unknown),
|
||||
sshKeys: (json['sshKeys'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
userType: $enumDecode(_$Enum$UserTypeEnumMap, json['userType'],
|
||||
unknownValue: Enum$UserType.$unknown),
|
||||
sshKeys:
|
||||
(json['sshKeys'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Fragment$userFieldsToJson(Fragment$userFields instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Fragment$userFieldsToJson(
|
||||
Fragment$userFields instance) =>
|
||||
<String, dynamic>{
|
||||
'username': instance.username,
|
||||
'userType': _$Enum$UserTypeEnumMap[instance.userType]!,
|
||||
'sshKeys': instance.sshKeys,
|
||||
|
@ -41,83 +50,123 @@ const _$Enum$UserTypeEnumMap = {
|
|||
Enum$UserType.$unknown: r'$unknown',
|
||||
};
|
||||
|
||||
Query$AllUsers _$Query$AllUsersFromJson(Map<String, dynamic> json) => Query$AllUsers(
|
||||
users: Query$AllUsers$users.fromJson(json['users'] as Map<String, dynamic>),
|
||||
Query$AllUsers _$Query$AllUsersFromJson(Map<String, dynamic> json) =>
|
||||
Query$AllUsers(
|
||||
users:
|
||||
Query$AllUsers$users.fromJson(json['users'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Query$AllUsersToJson(Query$AllUsers instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Query$AllUsersToJson(Query$AllUsers instance) =>
|
||||
<String, dynamic>{
|
||||
'users': instance.users.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Query$AllUsers$users _$Query$AllUsers$usersFromJson(Map<String, dynamic> json) => Query$AllUsers$users(
|
||||
allUsers: (json['allUsers'] as List<dynamic>).map((e) => Fragment$userFields.fromJson(e as Map<String, dynamic>)).toList(),
|
||||
rootUser: json['rootUser'] == null ? null : Fragment$userFields.fromJson(json['rootUser'] as Map<String, dynamic>),
|
||||
Query$AllUsers$users _$Query$AllUsers$usersFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Query$AllUsers$users(
|
||||
allUsers: (json['allUsers'] as List<dynamic>)
|
||||
.map((e) => Fragment$userFields.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
rootUser: json['rootUser'] == null
|
||||
? null
|
||||
: Fragment$userFields.fromJson(
|
||||
json['rootUser'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Query$AllUsers$usersToJson(Query$AllUsers$users instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Query$AllUsers$usersToJson(
|
||||
Query$AllUsers$users instance) =>
|
||||
<String, dynamic>{
|
||||
'allUsers': instance.allUsers.map((e) => e.toJson()).toList(),
|
||||
'rootUser': instance.rootUser?.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Variables$Query$GetUser _$Variables$Query$GetUserFromJson(Map<String, dynamic> json) => Variables$Query$GetUser(
|
||||
Variables$Query$GetUser _$Variables$Query$GetUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Query$GetUser(
|
||||
username: json['username'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Variables$Query$GetUserToJson(Variables$Query$GetUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Variables$Query$GetUserToJson(
|
||||
Variables$Query$GetUser instance) =>
|
||||
<String, dynamic>{
|
||||
'username': instance.username,
|
||||
};
|
||||
|
||||
Query$GetUser _$Query$GetUserFromJson(Map<String, dynamic> json) => Query$GetUser(
|
||||
users: Query$GetUser$users.fromJson(json['users'] as Map<String, dynamic>),
|
||||
Query$GetUser _$Query$GetUserFromJson(Map<String, dynamic> json) =>
|
||||
Query$GetUser(
|
||||
users:
|
||||
Query$GetUser$users.fromJson(json['users'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Query$GetUserToJson(Query$GetUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Query$GetUserToJson(Query$GetUser instance) =>
|
||||
<String, dynamic>{
|
||||
'users': instance.users.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Query$GetUser$users _$Query$GetUser$usersFromJson(Map<String, dynamic> json) => Query$GetUser$users(
|
||||
getUser: json['getUser'] == null ? null : Fragment$userFields.fromJson(json['getUser'] as Map<String, dynamic>),
|
||||
Query$GetUser$users _$Query$GetUser$usersFromJson(Map<String, dynamic> json) =>
|
||||
Query$GetUser$users(
|
||||
getUser: json['getUser'] == null
|
||||
? null
|
||||
: Fragment$userFields.fromJson(
|
||||
json['getUser'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Query$GetUser$usersToJson(Query$GetUser$users instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Query$GetUser$usersToJson(
|
||||
Query$GetUser$users instance) =>
|
||||
<String, dynamic>{
|
||||
'getUser': instance.getUser?.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Variables$Mutation$CreateUser _$Variables$Mutation$CreateUserFromJson(Map<String, dynamic> json) => Variables$Mutation$CreateUser(
|
||||
user: Input$UserMutationInput.fromJson(json['user'] as Map<String, dynamic>),
|
||||
Variables$Mutation$CreateUser _$Variables$Mutation$CreateUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Mutation$CreateUser(
|
||||
user: Input$UserMutationInput.fromJson(
|
||||
json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Variables$Mutation$CreateUserToJson(Variables$Mutation$CreateUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Variables$Mutation$CreateUserToJson(
|
||||
Variables$Mutation$CreateUser instance) =>
|
||||
<String, dynamic>{
|
||||
'user': instance.user.toJson(),
|
||||
};
|
||||
|
||||
Mutation$CreateUser _$Mutation$CreateUserFromJson(Map<String, dynamic> json) => Mutation$CreateUser(
|
||||
createUser: Mutation$CreateUser$createUser.fromJson(json['createUser'] as Map<String, dynamic>),
|
||||
Mutation$CreateUser _$Mutation$CreateUserFromJson(Map<String, dynamic> json) =>
|
||||
Mutation$CreateUser(
|
||||
createUser: Mutation$CreateUser$createUser.fromJson(
|
||||
json['createUser'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$CreateUserToJson(Mutation$CreateUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$CreateUserToJson(
|
||||
Mutation$CreateUser instance) =>
|
||||
<String, dynamic>{
|
||||
'createUser': instance.createUser.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Mutation$CreateUser$createUser _$Mutation$CreateUser$createUserFromJson(Map<String, dynamic> json) => Mutation$CreateUser$createUser(
|
||||
Mutation$CreateUser$createUser _$Mutation$CreateUser$createUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Mutation$CreateUser$createUser(
|
||||
code: json['code'] as int,
|
||||
message: json['message'] as String,
|
||||
success: json['success'] as bool,
|
||||
$__typename: json['__typename'] as String,
|
||||
user: json['user'] == null ? null : Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$CreateUser$createUserToJson(Mutation$CreateUser$createUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$CreateUser$createUserToJson(
|
||||
Mutation$CreateUser$createUser instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
|
@ -125,65 +174,92 @@ Map<String, dynamic> _$Mutation$CreateUser$createUserToJson(Mutation$CreateUser$
|
|||
'user': instance.user?.toJson(),
|
||||
};
|
||||
|
||||
Variables$Mutation$DeleteUser _$Variables$Mutation$DeleteUserFromJson(Map<String, dynamic> json) => Variables$Mutation$DeleteUser(
|
||||
Variables$Mutation$DeleteUser _$Variables$Mutation$DeleteUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Mutation$DeleteUser(
|
||||
username: json['username'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Variables$Mutation$DeleteUserToJson(Variables$Mutation$DeleteUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Variables$Mutation$DeleteUserToJson(
|
||||
Variables$Mutation$DeleteUser instance) =>
|
||||
<String, dynamic>{
|
||||
'username': instance.username,
|
||||
};
|
||||
|
||||
Mutation$DeleteUser _$Mutation$DeleteUserFromJson(Map<String, dynamic> json) => Mutation$DeleteUser(
|
||||
deleteUser: Mutation$DeleteUser$deleteUser.fromJson(json['deleteUser'] as Map<String, dynamic>),
|
||||
Mutation$DeleteUser _$Mutation$DeleteUserFromJson(Map<String, dynamic> json) =>
|
||||
Mutation$DeleteUser(
|
||||
deleteUser: Mutation$DeleteUser$deleteUser.fromJson(
|
||||
json['deleteUser'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$DeleteUserToJson(Mutation$DeleteUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$DeleteUserToJson(
|
||||
Mutation$DeleteUser instance) =>
|
||||
<String, dynamic>{
|
||||
'deleteUser': instance.deleteUser.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Mutation$DeleteUser$deleteUser _$Mutation$DeleteUser$deleteUserFromJson(Map<String, dynamic> json) => Mutation$DeleteUser$deleteUser(
|
||||
Mutation$DeleteUser$deleteUser _$Mutation$DeleteUser$deleteUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Mutation$DeleteUser$deleteUser(
|
||||
code: json['code'] as int,
|
||||
message: json['message'] as String,
|
||||
success: json['success'] as bool,
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$DeleteUser$deleteUserToJson(Mutation$DeleteUser$deleteUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$DeleteUser$deleteUserToJson(
|
||||
Mutation$DeleteUser$deleteUser instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Variables$Mutation$UpdateUser _$Variables$Mutation$UpdateUserFromJson(Map<String, dynamic> json) => Variables$Mutation$UpdateUser(
|
||||
user: Input$UserMutationInput.fromJson(json['user'] as Map<String, dynamic>),
|
||||
Variables$Mutation$UpdateUser _$Variables$Mutation$UpdateUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Mutation$UpdateUser(
|
||||
user: Input$UserMutationInput.fromJson(
|
||||
json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Variables$Mutation$UpdateUserToJson(Variables$Mutation$UpdateUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Variables$Mutation$UpdateUserToJson(
|
||||
Variables$Mutation$UpdateUser instance) =>
|
||||
<String, dynamic>{
|
||||
'user': instance.user.toJson(),
|
||||
};
|
||||
|
||||
Mutation$UpdateUser _$Mutation$UpdateUserFromJson(Map<String, dynamic> json) => Mutation$UpdateUser(
|
||||
updateUser: Mutation$UpdateUser$updateUser.fromJson(json['updateUser'] as Map<String, dynamic>),
|
||||
Mutation$UpdateUser _$Mutation$UpdateUserFromJson(Map<String, dynamic> json) =>
|
||||
Mutation$UpdateUser(
|
||||
updateUser: Mutation$UpdateUser$updateUser.fromJson(
|
||||
json['updateUser'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$UpdateUserToJson(Mutation$UpdateUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$UpdateUserToJson(
|
||||
Mutation$UpdateUser instance) =>
|
||||
<String, dynamic>{
|
||||
'updateUser': instance.updateUser.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Mutation$UpdateUser$updateUser _$Mutation$UpdateUser$updateUserFromJson(Map<String, dynamic> json) => Mutation$UpdateUser$updateUser(
|
||||
Mutation$UpdateUser$updateUser _$Mutation$UpdateUser$updateUserFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Mutation$UpdateUser$updateUser(
|
||||
code: json['code'] as int,
|
||||
message: json['message'] as String,
|
||||
success: json['success'] as bool,
|
||||
$__typename: json['__typename'] as String,
|
||||
user: json['user'] == null ? null : Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$UpdateUser$updateUserToJson(Mutation$UpdateUser$updateUser instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$UpdateUser$updateUserToJson(
|
||||
Mutation$UpdateUser$updateUser instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
|
@ -191,33 +267,47 @@ Map<String, dynamic> _$Mutation$UpdateUser$updateUserToJson(Mutation$UpdateUser$
|
|||
'user': instance.user?.toJson(),
|
||||
};
|
||||
|
||||
Variables$Mutation$AddSshKey _$Variables$Mutation$AddSshKeyFromJson(Map<String, dynamic> json) => Variables$Mutation$AddSshKey(
|
||||
sshInput: Input$SshMutationInput.fromJson(json['sshInput'] as Map<String, dynamic>),
|
||||
Variables$Mutation$AddSshKey _$Variables$Mutation$AddSshKeyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Mutation$AddSshKey(
|
||||
sshInput: Input$SshMutationInput.fromJson(
|
||||
json['sshInput'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Variables$Mutation$AddSshKeyToJson(Variables$Mutation$AddSshKey instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Variables$Mutation$AddSshKeyToJson(
|
||||
Variables$Mutation$AddSshKey instance) =>
|
||||
<String, dynamic>{
|
||||
'sshInput': instance.sshInput.toJson(),
|
||||
};
|
||||
|
||||
Mutation$AddSshKey _$Mutation$AddSshKeyFromJson(Map<String, dynamic> json) => Mutation$AddSshKey(
|
||||
addSshKey: Mutation$AddSshKey$addSshKey.fromJson(json['addSshKey'] as Map<String, dynamic>),
|
||||
Mutation$AddSshKey _$Mutation$AddSshKeyFromJson(Map<String, dynamic> json) =>
|
||||
Mutation$AddSshKey(
|
||||
addSshKey: Mutation$AddSshKey$addSshKey.fromJson(
|
||||
json['addSshKey'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$AddSshKeyToJson(Mutation$AddSshKey instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$AddSshKeyToJson(Mutation$AddSshKey instance) =>
|
||||
<String, dynamic>{
|
||||
'addSshKey': instance.addSshKey.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Mutation$AddSshKey$addSshKey _$Mutation$AddSshKey$addSshKeyFromJson(Map<String, dynamic> json) => Mutation$AddSshKey$addSshKey(
|
||||
Mutation$AddSshKey$addSshKey _$Mutation$AddSshKey$addSshKeyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Mutation$AddSshKey$addSshKey(
|
||||
code: json['code'] as int,
|
||||
message: json['message'] as String,
|
||||
success: json['success'] as bool,
|
||||
$__typename: json['__typename'] as String,
|
||||
user: json['user'] == null ? null : Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$AddSshKey$addSshKeyToJson(Mutation$AddSshKey$addSshKey instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$AddSshKey$addSshKeyToJson(
|
||||
Mutation$AddSshKey$addSshKey instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
|
@ -225,33 +315,49 @@ Map<String, dynamic> _$Mutation$AddSshKey$addSshKeyToJson(Mutation$AddSshKey$add
|
|||
'user': instance.user?.toJson(),
|
||||
};
|
||||
|
||||
Variables$Mutation$RemoveSshKey _$Variables$Mutation$RemoveSshKeyFromJson(Map<String, dynamic> json) => Variables$Mutation$RemoveSshKey(
|
||||
sshInput: Input$SshMutationInput.fromJson(json['sshInput'] as Map<String, dynamic>),
|
||||
Variables$Mutation$RemoveSshKey _$Variables$Mutation$RemoveSshKeyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Variables$Mutation$RemoveSshKey(
|
||||
sshInput: Input$SshMutationInput.fromJson(
|
||||
json['sshInput'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Variables$Mutation$RemoveSshKeyToJson(Variables$Mutation$RemoveSshKey instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Variables$Mutation$RemoveSshKeyToJson(
|
||||
Variables$Mutation$RemoveSshKey instance) =>
|
||||
<String, dynamic>{
|
||||
'sshInput': instance.sshInput.toJson(),
|
||||
};
|
||||
|
||||
Mutation$RemoveSshKey _$Mutation$RemoveSshKeyFromJson(Map<String, dynamic> json) => Mutation$RemoveSshKey(
|
||||
removeSshKey: Mutation$RemoveSshKey$removeSshKey.fromJson(json['removeSshKey'] as Map<String, dynamic>),
|
||||
Mutation$RemoveSshKey _$Mutation$RemoveSshKeyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Mutation$RemoveSshKey(
|
||||
removeSshKey: Mutation$RemoveSshKey$removeSshKey.fromJson(
|
||||
json['removeSshKey'] as Map<String, dynamic>),
|
||||
$__typename: json['__typename'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$RemoveSshKeyToJson(Mutation$RemoveSshKey instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$RemoveSshKeyToJson(
|
||||
Mutation$RemoveSshKey instance) =>
|
||||
<String, dynamic>{
|
||||
'removeSshKey': instance.removeSshKey.toJson(),
|
||||
'__typename': instance.$__typename,
|
||||
};
|
||||
|
||||
Mutation$RemoveSshKey$removeSshKey _$Mutation$RemoveSshKey$removeSshKeyFromJson(Map<String, dynamic> json) => Mutation$RemoveSshKey$removeSshKey(
|
||||
Mutation$RemoveSshKey$removeSshKey _$Mutation$RemoveSshKey$removeSshKeyFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
Mutation$RemoveSshKey$removeSshKey(
|
||||
code: json['code'] as int,
|
||||
message: json['message'] as String,
|
||||
success: json['success'] as bool,
|
||||
$__typename: json['__typename'] as String,
|
||||
user: json['user'] == null ? null : Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: Fragment$userFields.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Mutation$RemoveSshKey$removeSshKeyToJson(Mutation$RemoveSshKey$removeSshKey instance) => <String, dynamic>{
|
||||
Map<String, dynamic> _$Mutation$RemoveSshKey$removeSshKeyToJson(
|
||||
Mutation$RemoveSshKey$removeSshKey instance) =>
|
||||
<String, dynamic>{
|
||||
'code': instance.code,
|
||||
'message': instance.message,
|
||||
'success': instance.success,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
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/schema.graphql.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_api.graphql.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_settings.graphql.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/users.graphql.dart';
|
||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||
|
@ -14,11 +14,11 @@ import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
|||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||
import 'package:selfprivacy/logic/models/service.dart';
|
||||
|
||||
part 'volume_api.dart';
|
||||
part 'jobs_api.dart';
|
||||
part 'server_actions_api.dart';
|
||||
part 'services_api.dart';
|
||||
part 'users_api.dart';
|
||||
part 'volume_api.dart';
|
||||
|
||||
class GenericMutationResult {
|
||||
GenericMutationResult({
|
||||
|
@ -42,7 +42,7 @@ class GenericJobMutationReturn extends GenericMutationResult {
|
|||
}
|
||||
|
||||
class ServerApi extends ApiMap
|
||||
with VolumeApi, JobsApi, ServerActionsApi, ServicesApi {
|
||||
with VolumeApi, JobsApi, ServerActionsApi, ServicesApi, UsersApi {
|
||||
ServerApi({
|
||||
this.hasLogger = false,
|
||||
this.isWithToken = true,
|
||||
|
|
|
@ -7,6 +7,7 @@ class UserMutationResult extends GenericMutationResult {
|
|||
final super.message,
|
||||
this.user,
|
||||
});
|
||||
|
||||
final User? user;
|
||||
}
|
||||
|
||||
|
@ -20,13 +21,17 @@ mixin UsersApi on ApiMap {
|
|||
if (response.hasException) {
|
||||
print(response.exception.toString());
|
||||
}
|
||||
users = response.parsedData?.users.allUsers.map<User>((final user) => User.fromGraphQL(user)).toList() ?? [];
|
||||
users = response.parsedData?.users.allUsers
|
||||
.map<User>((final user) => User.fromGraphQL(user))
|
||||
.toList() ??
|
||||
[];
|
||||
final rootUser = response.parsedData?.users.rootUser;
|
||||
if (rootUser != null) {
|
||||
users.add(User.fromGraphQL(rootUser));
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
print("Could not");
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
@ -37,7 +42,8 @@ mixin UsersApi on ApiMap {
|
|||
try {
|
||||
final GraphQLClient client = await getClient();
|
||||
final variables = Variables$Query$GetUser(username: login);
|
||||
response = await client.query$GetUser(Options$Query$GetUser(variables: variables));
|
||||
response = await client
|
||||
.query$GetUser(Options$Query$GetUser(variables: variables));
|
||||
if (response.hasException) {
|
||||
print(response.exception.toString());
|
||||
}
|
||||
|
@ -66,7 +72,9 @@ mixin UsersApi on ApiMap {
|
|||
success: response.parsedData?.createUser.success ?? false,
|
||||
code: response.parsedData?.createUser.code ?? 500,
|
||||
message: response.parsedData?.createUser.message,
|
||||
user: response.parsedData?.createUser.user != null ? User.fromGraphQL(response.parsedData!.createUser.user!) : null,
|
||||
user: response.parsedData?.createUser.user != null
|
||||
? User.fromGraphQL(response.parsedData!.createUser.user!)
|
||||
: null,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
@ -116,7 +124,9 @@ mixin UsersApi on ApiMap {
|
|||
success: response.parsedData?.updateUser.success ?? false,
|
||||
code: response.parsedData?.updateUser.code ?? 500,
|
||||
message: response.parsedData?.updateUser.message,
|
||||
user: response.parsedData?.updateUser.user != null ? User.fromGraphQL(response.parsedData!.updateUser.user!) : null,
|
||||
user: response.parsedData?.updateUser.user != null
|
||||
? User.fromGraphQL(response.parsedData!.updateUser.user!)
|
||||
: null,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
@ -146,7 +156,9 @@ mixin UsersApi on ApiMap {
|
|||
success: response.parsedData?.addSshKey.success ?? false,
|
||||
code: response.parsedData?.addSshKey.code ?? 500,
|
||||
message: response.parsedData?.addSshKey.message,
|
||||
user: response.parsedData?.addSshKey.user != null ? User.fromGraphQL(response.parsedData!.addSshKey.user!) : null,
|
||||
user: response.parsedData?.addSshKey.user != null
|
||||
? User.fromGraphQL(response.parsedData!.addSshKey.user!)
|
||||
: null,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
@ -176,7 +188,9 @@ mixin UsersApi on ApiMap {
|
|||
success: response.parsedData?.removeSshKey.success ?? false,
|
||||
code: response.parsedData?.removeSshKey.code ?? 500,
|
||||
message: response.parsedData?.removeSshKey.message,
|
||||
user: response.parsedData?.removeSshKey.user != null ? User.fromGraphQL(response.parsedData!.removeSshKey.user!) : null,
|
||||
user: response.parsedData?.removeSshKey.user != null
|
||||
? User.fromGraphQL(response.parsedData!.removeSshKey.user!)
|
||||
: null,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
|
|
|
@ -70,7 +70,9 @@ class ServerApi extends ApiMap {
|
|||
baseUrl: 'https://api.$overrideDomain',
|
||||
connectTimeout: 10000,
|
||||
receiveTimeout: 10000,
|
||||
headers: customToken != null ? {'Authorization': 'Bearer $customToken'} : null,
|
||||
headers: customToken != null
|
||||
? {'Authorization': 'Bearer $customToken'}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -141,7 +143,8 @@ class ServerApi extends ApiMap {
|
|||
bool isFoundOnServer = false;
|
||||
int code = 0;
|
||||
|
||||
final bool isUserCreated = (response.statusCode != null) && (response.statusCode == HttpStatus.created);
|
||||
final bool isUserCreated = (response.statusCode != null) &&
|
||||
(response.statusCode == HttpStatus.created);
|
||||
|
||||
if (isUserCreated) {
|
||||
isFoundOnServer = true;
|
||||
|
@ -271,7 +274,9 @@ class ServerApi extends ApiMap {
|
|||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.get('/services/ssh/keys/${user.login}');
|
||||
res = (response.data as List<dynamic>).map((final e) => e as String).toList();
|
||||
res = (response.data as List<dynamic>)
|
||||
.map((final e) => e as String)
|
||||
.toList();
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
return ApiResponse<List<String>>(
|
||||
|
@ -330,7 +335,9 @@ class ServerApi extends ApiMap {
|
|||
return ApiResponse<void>(
|
||||
statusCode: code,
|
||||
data: null,
|
||||
errorMessage: response.data?.containsKey('error') ?? false ? response.data['error'] : null,
|
||||
errorMessage: response.data?.containsKey('error') ?? false
|
||||
? response.data['error']
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -341,7 +348,8 @@ class ServerApi extends ApiMap {
|
|||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.delete('/users/${user.login}');
|
||||
res = response.statusCode == HttpStatus.ok || response.statusCode == HttpStatus.notFound;
|
||||
res = response.statusCode == HttpStatus.ok ||
|
||||
response.statusCode == HttpStatus.notFound;
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
res = false;
|
||||
|
@ -352,7 +360,8 @@ class ServerApi extends ApiMap {
|
|||
}
|
||||
|
||||
@override
|
||||
String get rootAddress => throw UnimplementedError('not used in with implementation');
|
||||
String get rootAddress =>
|
||||
throw UnimplementedError('not used in with implementation');
|
||||
|
||||
Future<bool> apply() async {
|
||||
bool res = false;
|
||||
|
@ -445,7 +454,8 @@ class ServerApi extends ApiMap {
|
|||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.get('/services/restic/backup/list');
|
||||
backups = response.data.map<Backup>((final e) => Backup.fromJson(e)).toList();
|
||||
backups =
|
||||
response.data.map<Backup>((final e) => Backup.fromJson(e)).toList();
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
} catch (e) {
|
||||
|
@ -508,7 +518,9 @@ class ServerApi extends ApiMap {
|
|||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.get('/system/configuration/pull');
|
||||
result = (response.statusCode != null) ? (response.statusCode == HttpStatus.ok) : false;
|
||||
result = (response.statusCode != null)
|
||||
? (response.statusCode == HttpStatus.ok)
|
||||
: false;
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
} finally {
|
||||
|
@ -524,7 +536,9 @@ class ServerApi extends ApiMap {
|
|||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.get('/system/reboot');
|
||||
result = (response.statusCode != null) ? (response.statusCode == HttpStatus.ok) : false;
|
||||
result = (response.statusCode != null)
|
||||
? (response.statusCode == HttpStatus.ok)
|
||||
: false;
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
} finally {
|
||||
|
@ -540,7 +554,9 @@ class ServerApi extends ApiMap {
|
|||
final Dio client = await getClient();
|
||||
try {
|
||||
response = await client.get('/system/configuration/upgrade');
|
||||
result = (response.statusCode != null) ? (response.statusCode == HttpStatus.ok) : false;
|
||||
result = (response.statusCode != null)
|
||||
? (response.statusCode == HttpStatus.ok)
|
||||
: false;
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
} finally {
|
||||
|
@ -589,7 +605,8 @@ class ServerApi extends ApiMap {
|
|||
Future<TimeZoneSettings> getServerTimezone() async {
|
||||
// I am not sure how to initialize TimeZoneSettings with default value...
|
||||
final Dio client = await getClient();
|
||||
final Response response = await client.get('/system/configuration/timezone');
|
||||
final Response response =
|
||||
await client.get('/system/configuration/timezone');
|
||||
close(client);
|
||||
|
||||
return TimeZoneSettings.fromString(response.data);
|
||||
|
@ -616,7 +633,11 @@ class ServerApi extends ApiMap {
|
|||
try {
|
||||
response = await client.get('/services/mailserver/dkim');
|
||||
final Codec<String, String> base64toString = utf8.fuse(base64);
|
||||
dkim = base64toString.decode(response.data).split('(')[1].split(')')[0].replaceAll('"', '');
|
||||
dkim = base64toString
|
||||
.decode(response.data)
|
||||
.split('(')[1]
|
||||
.split(')')[0]
|
||||
.replaceAll('"', '');
|
||||
} on DioError catch (e) {
|
||||
print(e.message);
|
||||
} finally {
|
||||
|
@ -647,7 +668,9 @@ class ServerApi extends ApiMap {
|
|||
|
||||
return ApiResponse(
|
||||
statusCode: code,
|
||||
data: response.data != null ? RecoveryKeyStatus.fromJson(response.data) : null,
|
||||
data: response.data != null
|
||||
? RecoveryKeyStatus.fromJson(response.data)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -817,7 +840,11 @@ class ServerApi extends ApiMap {
|
|||
|
||||
return ApiResponse(
|
||||
statusCode: code,
|
||||
data: (response.data != null) ? response.data.map<ApiToken>((final e) => ApiToken.fromJson(e)).toList() : [],
|
||||
data: (response.data != null)
|
||||
? response.data
|
||||
.map<ApiToken>((final e) => ApiToken.fromJson(e))
|
||||
.toList()
|
||||
: [],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,12 @@ class ServerAuthorizationException implements Exception {
|
|||
class ServerInstallationRepository {
|
||||
Box box = Hive.box(BNames.serverInstallationBox);
|
||||
Box<User> usersBox = Hive.box(BNames.usersBox);
|
||||
ServerProviderApiFactory? serverProviderApiFactory = ApiFactoryCreator.createServerProviderApiFactory(
|
||||
ServerProviderApiFactory? serverProviderApiFactory =
|
||||
ApiFactoryCreator.createServerProviderApiFactory(
|
||||
ServerProvider.hetzner, // TODO: HARDCODE FOR NOW!!!
|
||||
); // TODO: Remove when provider selection is implemented.
|
||||
DnsProviderApiFactory? dnsProviderApiFactory = ApiFactoryCreator.createDnsProviderApiFactory(
|
||||
DnsProviderApiFactory? dnsProviderApiFactory =
|
||||
ApiFactoryCreator.createDnsProviderApiFactory(
|
||||
DnsProvider.cloudflare, // TODO: HARDCODE FOR NOW!!!
|
||||
);
|
||||
|
||||
|
@ -51,11 +53,15 @@ class ServerInstallationRepository {
|
|||
final String? providerApiToken = getIt<ApiConfigModel>().hetznerKey;
|
||||
final String? cloudflareToken = getIt<ApiConfigModel>().cloudFlareKey;
|
||||
final ServerDomain? serverDomain = getIt<ApiConfigModel>().serverDomain;
|
||||
final BackblazeCredential? backblazeCredential = getIt<ApiConfigModel>().backblazeCredential;
|
||||
final ServerHostingDetails? serverDetails = getIt<ApiConfigModel>().serverDetails;
|
||||
final BackblazeCredential? backblazeCredential =
|
||||
getIt<ApiConfigModel>().backblazeCredential;
|
||||
final ServerHostingDetails? serverDetails =
|
||||
getIt<ApiConfigModel>().serverDetails;
|
||||
|
||||
if (serverDetails != null && serverDetails.provider != ServerProvider.unknown) {
|
||||
serverProviderApiFactory = ApiFactoryCreator.createServerProviderApiFactory(
|
||||
if (serverDetails != null &&
|
||||
serverDetails.provider != ServerProvider.unknown) {
|
||||
serverProviderApiFactory =
|
||||
ApiFactoryCreator.createServerProviderApiFactory(
|
||||
serverDetails.provider,
|
||||
);
|
||||
}
|
||||
|
@ -75,12 +81,15 @@ class ServerInstallationRepository {
|
|||
serverDetails: serverDetails!,
|
||||
rootUser: box.get(BNames.rootUser),
|
||||
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
||||
isServerResetedFirstTime: box.get(BNames.isServerResetedFirstTime, defaultValue: false),
|
||||
isServerResetedSecondTime: box.get(BNames.isServerResetedSecondTime, defaultValue: false),
|
||||
isServerResetedFirstTime:
|
||||
box.get(BNames.isServerResetedFirstTime, defaultValue: false),
|
||||
isServerResetedSecondTime:
|
||||
box.get(BNames.isServerResetedSecondTime, defaultValue: false),
|
||||
);
|
||||
}
|
||||
|
||||
if (box.get(BNames.isRecoveringServer, defaultValue: false) && serverDomain != null) {
|
||||
if (box.get(BNames.isRecoveringServer, defaultValue: false) &&
|
||||
serverDomain != null) {
|
||||
return ServerInstallationRecovery(
|
||||
providerApiToken: providerApiToken,
|
||||
cloudFlareKey: cloudflareToken,
|
||||
|
@ -106,8 +115,10 @@ class ServerInstallationRepository {
|
|||
serverDetails: serverDetails,
|
||||
rootUser: box.get(BNames.rootUser),
|
||||
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
||||
isServerResetedFirstTime: box.get(BNames.isServerResetedFirstTime, defaultValue: false),
|
||||
isServerResetedSecondTime: box.get(BNames.isServerResetedSecondTime, defaultValue: false),
|
||||
isServerResetedFirstTime:
|
||||
box.get(BNames.isServerResetedFirstTime, defaultValue: false),
|
||||
isServerResetedSecondTime:
|
||||
box.get(BNames.isServerResetedSecondTime, defaultValue: false),
|
||||
isLoading: box.get(BNames.isLoading, defaultValue: false),
|
||||
dnsMatches: null,
|
||||
);
|
||||
|
@ -171,7 +182,13 @@ class ServerInstallationRepository {
|
|||
final String? ip4,
|
||||
final Map<String, bool> skippedMatches,
|
||||
) async {
|
||||
final List<String> addresses = <String>['$domainName', 'api.$domainName', 'cloud.$domainName', 'meet.$domainName', 'password.$domainName'];
|
||||
final List<String> addresses = <String>[
|
||||
'$domainName',
|
||||
'api.$domainName',
|
||||
'cloud.$domainName',
|
||||
'meet.$domainName',
|
||||
'password.$domainName'
|
||||
];
|
||||
|
||||
final Map<String, bool> matches = <String, bool>{};
|
||||
|
||||
|
@ -187,15 +204,19 @@ class ServerInstallationRepository {
|
|||
);
|
||||
getIt.get<ConsoleModel>().addMessage(
|
||||
Message(
|
||||
text: 'DnsLookup: address: $address, $RRecordType, provider: CLOUDFLARE, ip4: $ip4',
|
||||
text:
|
||||
'DnsLookup: address: $address, $RRecordType, provider: CLOUDFLARE, ip4: $ip4',
|
||||
),
|
||||
);
|
||||
getIt.get<ConsoleModel>().addMessage(
|
||||
Message(
|
||||
text: 'DnsLookup: ${lookupRecordRes == null ? 'empty' : (lookupRecordRes[0].data != ip4 ? 'wrong ip4' : 'right ip4')}',
|
||||
text:
|
||||
'DnsLookup: ${lookupRecordRes == null ? 'empty' : (lookupRecordRes[0].data != ip4 ? 'wrong ip4' : 'right ip4')}',
|
||||
),
|
||||
);
|
||||
if (lookupRecordRes == null || lookupRecordRes.isEmpty || lookupRecordRes[0].data != ip4) {
|
||||
if (lookupRecordRes == null ||
|
||||
lookupRecordRes.isEmpty ||
|
||||
lookupRecordRes[0].data != ip4) {
|
||||
matches[address] = false;
|
||||
} else {
|
||||
matches[address] = true;
|
||||
|
@ -211,7 +232,8 @@ class ServerInstallationRepository {
|
|||
final String cloudFlareKey,
|
||||
final BackblazeCredential backblazeCredential, {
|
||||
required final void Function() onCancel,
|
||||
required final Future<void> Function(ServerHostingDetails serverDetails) onSuccess,
|
||||
required final Future<void> Function(ServerHostingDetails serverDetails)
|
||||
onSuccess,
|
||||
}) async {
|
||||
final ServerProviderApi api = serverProviderApiFactory!.getServerProvider();
|
||||
try {
|
||||
|
@ -315,8 +337,10 @@ class ServerInstallationRepository {
|
|||
final ServerDomain domain, {
|
||||
required final void Function() onCancel,
|
||||
}) async {
|
||||
final DnsProviderApi dnsProviderApi = dnsProviderApiFactory!.getDnsProvider();
|
||||
final ServerProviderApi serverApi = serverProviderApiFactory!.getServerProvider();
|
||||
final DnsProviderApi dnsProviderApi =
|
||||
dnsProviderApiFactory!.getDnsProvider();
|
||||
final ServerProviderApi serverApi =
|
||||
serverProviderApiFactory!.getServerProvider();
|
||||
|
||||
await dnsProviderApi.removeSimilarRecords(
|
||||
ip4: serverDetails.ip4,
|
||||
|
@ -332,7 +356,9 @@ class ServerInstallationRepository {
|
|||
final NavigationService nav = getIt.get<NavigationService>();
|
||||
nav.showPopUpDialog(
|
||||
BrandAlert(
|
||||
title: e.response!.data['errors'][0]['code'] == 1038 ? 'modals.10'.tr() : 'providers.domain.states.error'.tr(),
|
||||
title: e.response!.data['errors'][0]['code'] == 1038
|
||||
? 'modals.10'.tr()
|
||||
: 'providers.domain.states.error'.tr(),
|
||||
contentText: 'modals.6'.tr(),
|
||||
actions: [
|
||||
ActionButton(
|
||||
|
@ -365,7 +391,8 @@ class ServerInstallationRepository {
|
|||
}
|
||||
|
||||
Future<void> createDkimRecord(final ServerDomain cloudFlareDomain) async {
|
||||
final DnsProviderApi dnsProviderApi = dnsProviderApiFactory!.getDnsProvider();
|
||||
final DnsProviderApi dnsProviderApi =
|
||||
dnsProviderApiFactory!.getDnsProvider();
|
||||
final ServerApi api = ServerApi();
|
||||
|
||||
String dkimRecordString = '';
|
||||
|
@ -432,25 +459,31 @@ class ServerInstallationRepository {
|
|||
final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
|
||||
if (kIsWeb) {
|
||||
return deviceInfo.webBrowserInfo.then(
|
||||
(final WebBrowserInfo value) => '${value.browserName} ${value.platform}',
|
||||
(final WebBrowserInfo value) =>
|
||||
'${value.browserName} ${value.platform}',
|
||||
);
|
||||
} else {
|
||||
if (Platform.isAndroid) {
|
||||
return deviceInfo.androidInfo.then(
|
||||
(final AndroidDeviceInfo value) => '${value.model} ${value.version.release}',
|
||||
(final AndroidDeviceInfo value) =>
|
||||
'${value.model} ${value.version.release}',
|
||||
);
|
||||
} else if (Platform.isIOS) {
|
||||
return deviceInfo.iosInfo.then(
|
||||
(final IosDeviceInfo value) => '${value.utsname.machine} ${value.systemName} ${value.systemVersion}',
|
||||
(final IosDeviceInfo value) =>
|
||||
'${value.utsname.machine} ${value.systemName} ${value.systemVersion}',
|
||||
);
|
||||
} else if (Platform.isLinux) {
|
||||
return deviceInfo.linuxInfo.then((final LinuxDeviceInfo value) => value.prettyName);
|
||||
return deviceInfo.linuxInfo
|
||||
.then((final LinuxDeviceInfo value) => value.prettyName);
|
||||
} else if (Platform.isMacOS) {
|
||||
return deviceInfo.macOsInfo.then(
|
||||
(final MacOsDeviceInfo value) => '${value.hostName} ${value.computerName}',
|
||||
(final MacOsDeviceInfo value) =>
|
||||
'${value.hostName} ${value.computerName}',
|
||||
);
|
||||
} else if (Platform.isWindows) {
|
||||
return deviceInfo.windowsInfo.then((final WindowsDeviceInfo value) => value.computerName);
|
||||
return deviceInfo.windowsInfo
|
||||
.then((final WindowsDeviceInfo value) => value.computerName);
|
||||
}
|
||||
}
|
||||
return 'Unidentified';
|
||||
|
@ -542,7 +575,8 @@ class ServerInstallationRepository {
|
|||
);
|
||||
final String serverIp = await getServerIpFromDomain(serverDomain);
|
||||
if (recoveryCapabilities == ServerRecoveryCapabilities.legacy) {
|
||||
final Map<ServiceTypes, bool> apiResponse = await serverApi.servicesPowerCheck();
|
||||
final Map<ServiceTypes, bool> apiResponse =
|
||||
await serverApi.servicesPowerCheck();
|
||||
if (apiResponse.isNotEmpty) {
|
||||
return ServerHostingDetails(
|
||||
apiToken: apiToken,
|
||||
|
@ -565,7 +599,8 @@ class ServerInstallationRepository {
|
|||
);
|
||||
}
|
||||
}
|
||||
final ApiResponse<String> deviceAuthKey = await serverApi.createDeviceToken();
|
||||
final ApiResponse<String> deviceAuthKey =
|
||||
await serverApi.createDeviceToken();
|
||||
final ApiResponse<String> apiResponse = await serverApi.authorizeDevice(
|
||||
DeviceToken(device: await getDeviceName(), token: deviceAuthKey.data),
|
||||
);
|
||||
|
@ -604,7 +639,8 @@ class ServerInstallationRepository {
|
|||
);
|
||||
|
||||
final String? serverApiVersion = await serverApi.getApiVersion();
|
||||
final ApiResponse<List<String>> users = await serverApi.getUsersList(withMainUser: true);
|
||||
final ApiResponse<List<String>> users =
|
||||
await serverApi.getUsersList(withMainUser: true);
|
||||
if (serverApiVersion == null || !users.isSuccess) {
|
||||
return fallbackUser;
|
||||
}
|
||||
|
@ -704,7 +740,8 @@ class ServerInstallationRepository {
|
|||
|
||||
Future<void> deleteServer(final ServerDomain serverDomain) async {
|
||||
final ServerProviderApi api = serverProviderApiFactory!.getServerProvider();
|
||||
final DnsProviderApi dnsProviderApi = dnsProviderApiFactory!.getDnsProvider();
|
||||
final DnsProviderApi dnsProviderApi =
|
||||
dnsProviderApiFactory!.getDnsProvider();
|
||||
|
||||
await api.deleteServer(
|
||||
domainName: serverDomain.domainName,
|
||||
|
|
|
@ -8,14 +8,30 @@ class ServicesState extends ServerInstallationDependendState {
|
|||
const ServicesState.empty() : this(services: const []);
|
||||
|
||||
final List<Service> services;
|
||||
bool get isPasswordManagerEnable => services.firstWhere((final service) => service.id == 'bitwarden', orElse: () => Service.empty).isEnabled;
|
||||
bool get isCloudEnable => services.firstWhere((final service) => service.id == 'nextcloud', orElse: () => Service.empty).isEnabled;
|
||||
bool get isGitEnable => services.firstWhere((final service) => service.id == 'gitea', orElse: () => Service.empty).isEnabled;
|
||||
bool get isSocialNetworkEnable => services.firstWhere((final service) => service.id == 'pleroma', orElse: () => Service.empty).isEnabled;
|
||||
bool get isVpnEnable => services.firstWhere((final service) => service.id == 'ocserv', orElse: () => Service.empty).isEnabled;
|
||||
bool get isPasswordManagerEnable => services
|
||||
.firstWhere((final service) => service.id == 'bitwarden',
|
||||
orElse: () => Service.empty)
|
||||
.isEnabled;
|
||||
bool get isCloudEnable => services
|
||||
.firstWhere((final service) => service.id == 'nextcloud',
|
||||
orElse: () => Service.empty)
|
||||
.isEnabled;
|
||||
bool get isGitEnable => services
|
||||
.firstWhere((final service) => service.id == 'gitea',
|
||||
orElse: () => Service.empty)
|
||||
.isEnabled;
|
||||
bool get isSocialNetworkEnable => services
|
||||
.firstWhere((final service) => service.id == 'pleroma',
|
||||
orElse: () => Service.empty)
|
||||
.isEnabled;
|
||||
bool get isVpnEnable => services
|
||||
.firstWhere((final service) => service.id == 'ocserv',
|
||||
orElse: () => Service.empty)
|
||||
.isEnabled;
|
||||
|
||||
Service? getServiceById(final String id) {
|
||||
final service = services.firstWhere((final service) => service.id == id, orElse: () => Service.empty);
|
||||
final service = services.firstWhere((final service) => service.id == id,
|
||||
orElse: () => Service.empty);
|
||||
if (service.id == 'empty') {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -55,25 +55,30 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
|
|||
box.clear();
|
||||
box.addAll(usersFromServer);
|
||||
} else {
|
||||
getIt<NavigationService>().showSnackBar('users.could_not_fetch_users'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar('users.could_not_fetch_users'.tr());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createUser(final User user) async {
|
||||
// If user exists on server, do nothing
|
||||
if (state.users.any((final User u) => u.login == user.login && u.isFoundOnServer)) {
|
||||
if (state.users
|
||||
.any((final User u) => u.login == user.login && u.isFoundOnServer)) {
|
||||
return;
|
||||
}
|
||||
final String? password = user.password;
|
||||
if (password == null) {
|
||||
getIt<NavigationService>().showSnackBar('users.could_not_create_user'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar('users.could_not_create_user'.tr());
|
||||
return;
|
||||
}
|
||||
// If API returned error, do nothing
|
||||
final UserMutationResult result = await api.createUser(user.login, password);
|
||||
final UserMutationResult result =
|
||||
await api.createUser(user.login, password);
|
||||
final User? createdUser = result.user;
|
||||
if (!result.success || createdUser == null) {
|
||||
getIt<NavigationService>().showSnackBar(result.message ?? 'users.could_not_create_user'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar(result.message ?? 'users.could_not_create_user'.tr());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,7 +92,8 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
|
|||
Future<void> deleteUser(final User user) async {
|
||||
// If user is primary or root, don't delete
|
||||
if (user.type != UserType.normal) {
|
||||
getIt<NavigationService>().showSnackBar('users.could_not_delete_user'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar('users.could_not_delete_user'.tr());
|
||||
return;
|
||||
}
|
||||
final List<User> loadedUsers = List<User>.from(state.users);
|
||||
|
@ -98,23 +104,29 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
|
|||
await box.addAll(loadedUsers);
|
||||
emit(state.copyWith(users: loadedUsers));
|
||||
} else {
|
||||
getIt<NavigationService>().showSnackBar(result.message ?? 'users.could_not_delete_user'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar(result.message ?? 'users.could_not_delete_user'.tr());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> changeUserPassword(final User user, final String newPassword) async {
|
||||
Future<void> changeUserPassword(
|
||||
final User user, final String newPassword) async {
|
||||
if (user.type == UserType.root) {
|
||||
getIt<NavigationService>().showSnackBar('users.could_not_change_password'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar('users.could_not_change_password'.tr());
|
||||
return;
|
||||
}
|
||||
final UserMutationResult result = await api.updateUser(user.login, newPassword);
|
||||
final UserMutationResult result =
|
||||
await api.updateUser(user.login, newPassword);
|
||||
if (!result.success) {
|
||||
getIt<NavigationService>().showSnackBar(result.message ?? 'users.could_not_change_password'.tr());
|
||||
getIt<NavigationService>().showSnackBar(
|
||||
result.message ?? 'users.could_not_change_password'.tr());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addSshKey(final User user, final String publicKey) async {
|
||||
final UserMutationResult result = await api.addSshKey(user.login, publicKey);
|
||||
final UserMutationResult result =
|
||||
await api.addSshKey(user.login, publicKey);
|
||||
if (result.success) {
|
||||
final User updatedUser = result.user!;
|
||||
await box.putAt(box.values.toList().indexOf(user), updatedUser);
|
||||
|
@ -124,12 +136,14 @@ class UsersCubit extends ServerInstallationDependendCubit<UsersState> {
|
|||
),
|
||||
);
|
||||
} else {
|
||||
getIt<NavigationService>().showSnackBar(result.message ?? 'users.could_not_add_ssh_key'.tr());
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar(result.message ?? 'users.could_not_add_ssh_key'.tr());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteSshKey(final User user, final String publicKey) async {
|
||||
final UserMutationResult result = await api.removeSshKey(user.login, publicKey);
|
||||
final UserMutationResult result =
|
||||
await api.removeSshKey(user.login, publicKey);
|
||||
if (result.success) {
|
||||
final User updatedUser = result.user!;
|
||||
await box.putAt(box.values.toList().indexOf(user), updatedUser);
|
||||
|
|
|
@ -5,11 +5,14 @@ class UsersState extends ServerInstallationDependendState {
|
|||
|
||||
final List<User> users;
|
||||
|
||||
User get rootUser => users.firstWhere((final user) => user.type == UserType.root);
|
||||
User get rootUser =>
|
||||
users.firstWhere((final user) => user.type == UserType.root);
|
||||
|
||||
User get primaryUser => users.firstWhere((final user) => user.type == UserType.primary);
|
||||
User get primaryUser =>
|
||||
users.firstWhere((final user) => user.type == UserType.primary);
|
||||
|
||||
List<User> get normalUsers => users.where((final user) => user.type == UserType.normal).toList();
|
||||
List<User> get normalUsers =>
|
||||
users.where((final user) => user.type == UserType.normal).toList();
|
||||
|
||||
@override
|
||||
List<Object> get props => [users];
|
||||
|
@ -21,7 +24,8 @@ class UsersState extends ServerInstallationDependendState {
|
|||
users ?? this.users,
|
||||
);
|
||||
|
||||
bool isLoginRegistered(final String login) => users.any((final User user) => user.login == login);
|
||||
bool isLoginRegistered(final String login) =>
|
||||
users.any((final User user) => user.login == login);
|
||||
|
||||
bool get isEmpty => users.isEmpty;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,8 @@ class User extends Equatable {
|
|||
Color get color => stringToColor(login);
|
||||
|
||||
@override
|
||||
String toString() => '$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note';
|
||||
String toString() =>
|
||||
'$login, ${isFoundOnServer ? 'found' : 'not found'}, ${sshKeys.length} ssh keys, note: $note';
|
||||
}
|
||||
|
||||
@HiveType(typeId: 102)
|
||||
|
|
|
@ -48,7 +48,11 @@ class UserAdapter extends TypeAdapter<User> {
|
|||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is UserAdapter && runtimeType == other.runtimeType && typeId == other.typeId;
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is UserAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class UserTypeAdapter extends TypeAdapter<UserType> {
|
||||
|
@ -88,5 +92,9 @@ class UserTypeAdapter extends TypeAdapter<UserType> {
|
|||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is UserTypeAdapter && runtimeType == other.runtimeType && typeId == other.typeId;
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is UserTypeAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ class _FilledCard extends StatelessWidget {
|
|||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
color: error ? Theme.of(context).colorScheme.errorContainer
|
||||
color: error
|
||||
? Theme.of(context).colorScheme.errorContainer
|
||||
: tertiary
|
||||
? Theme.of(context).colorScheme.tertiaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceVariant,
|
||||
|
|
Loading…
Reference in New Issue