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