2022-06-11 23:12:06 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-06-25 20:46:51 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-10-22 22:15:34 +02:00
|
|
|
import 'package:immich_mobile/shared/models/server_info/server_config.model.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/server_info/server_disk_info.model.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/server_info/server_features.model.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/server_info/server_version.model.dart';
|
2022-08-03 07:04:34 +02:00
|
|
|
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
2022-07-13 14:23:48 +02:00
|
|
|
import 'package:immich_mobile/shared/services/api.service.dart';
|
2022-02-03 18:06:44 +02:00
|
|
|
|
2022-07-13 14:23:48 +02:00
|
|
|
final serverInfoServiceProvider = Provider(
|
|
|
|
(ref) => ServerInfoService(
|
|
|
|
ref.watch(apiServiceProvider),
|
|
|
|
),
|
|
|
|
);
|
2022-06-25 20:46:51 +02:00
|
|
|
|
2022-02-03 18:06:44 +02:00
|
|
|
class ServerInfoService {
|
2022-07-13 14:23:48 +02:00
|
|
|
final ApiService _apiService;
|
2022-08-03 07:04:34 +02:00
|
|
|
|
2022-07-13 14:23:48 +02:00
|
|
|
ServerInfoService(this._apiService);
|
2022-02-03 18:06:44 +02:00
|
|
|
|
2023-10-22 22:15:34 +02:00
|
|
|
Future<ServerDiskInfo?> getServerInfo() async {
|
2022-07-13 14:23:48 +02:00
|
|
|
try {
|
2023-10-22 22:15:34 +02:00
|
|
|
final dto = await _apiService.serverInfoApi.getServerInfo();
|
|
|
|
if (dto != null) {
|
|
|
|
return ServerDiskInfo.fromDto(dto);
|
|
|
|
}
|
2022-07-13 14:23:48 +02:00
|
|
|
} catch (e) {
|
|
|
|
debugPrint("Error [getServerInfo] ${e.toString()}");
|
|
|
|
}
|
2023-10-22 22:15:34 +02:00
|
|
|
return null;
|
2022-02-03 18:06:44 +02:00
|
|
|
}
|
2022-03-11 00:09:03 +02:00
|
|
|
|
2023-10-22 22:15:34 +02:00
|
|
|
Future<ServerVersion?> getServerVersion() async {
|
2022-06-11 23:12:06 +02:00
|
|
|
try {
|
2023-10-22 22:15:34 +02:00
|
|
|
final dto = await _apiService.serverInfoApi.getServerVersion();
|
|
|
|
if (dto != null) {
|
|
|
|
return ServerVersion.fromDto(dto);
|
|
|
|
}
|
2022-06-11 23:12:06 +02:00
|
|
|
} catch (e) {
|
2023-09-28 05:26:48 +02:00
|
|
|
debugPrint("Error [getServerVersion] ${e.toString()}");
|
|
|
|
}
|
2023-10-22 22:15:34 +02:00
|
|
|
return null;
|
2023-09-28 05:26:48 +02:00
|
|
|
}
|
|
|
|
|
2023-10-22 22:15:34 +02:00
|
|
|
Future<ServerFeatures?> getServerFeatures() async {
|
2023-09-28 05:26:48 +02:00
|
|
|
try {
|
2023-10-22 22:15:34 +02:00
|
|
|
final dto = await _apiService.serverInfoApi.getServerFeatures();
|
|
|
|
if (dto != null) {
|
|
|
|
return ServerFeatures.fromDto(dto);
|
|
|
|
}
|
2023-09-28 05:26:48 +02:00
|
|
|
} catch (e) {
|
|
|
|
debugPrint("Error [getServerFeatures] ${e.toString()}");
|
|
|
|
}
|
2023-10-22 22:15:34 +02:00
|
|
|
return null;
|
2023-09-28 05:26:48 +02:00
|
|
|
}
|
|
|
|
|
2023-10-22 22:15:34 +02:00
|
|
|
Future<ServerConfig?> getServerConfig() async {
|
2023-09-28 05:26:48 +02:00
|
|
|
try {
|
2023-10-22 22:15:34 +02:00
|
|
|
final dto = await _apiService.serverInfoApi.getServerConfig();
|
|
|
|
if (dto != null) {
|
|
|
|
return ServerConfig.fromDto(dto);
|
|
|
|
}
|
2023-09-28 05:26:48 +02:00
|
|
|
} catch (e) {
|
|
|
|
debugPrint("Error [getServerConfig] ${e.toString()}");
|
2022-06-11 23:12:06 +02:00
|
|
|
}
|
2023-10-22 22:15:34 +02:00
|
|
|
return null;
|
2022-03-22 08:22:04 +02:00
|
|
|
}
|
2022-02-03 18:06:44 +02:00
|
|
|
}
|