Prepare webdavApi.dart implementation
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
// import 'package:json_annotation/json_annotation.dart';
|
||||
// import 'package:webdav_client/webdav_client.dart';
|
||||
//
|
||||
// part 'cacheableFile.g.dart';
|
||||
//
|
||||
// @JsonSerializable(explicitToJson: true)
|
||||
// class CacheableFile {
|
||||
// String? path;
|
||||
// bool? isDir;
|
||||
// String? name;
|
||||
// String? mimeType;
|
||||
// int? size;
|
||||
// String? eTag;
|
||||
// DateTime? cTime;
|
||||
// DateTime? mTime;
|
||||
//
|
||||
// CacheableFile(this.path, this.isDir, this.name, this.mimeType, this.size,
|
||||
// this.eTag, this.cTime, this.mTime);
|
||||
//
|
||||
// CacheableFile.fromDavFile(File file) {
|
||||
// path = file.path;
|
||||
// isDir = file.isDir;
|
||||
// name = file.name;
|
||||
// mimeType = file.mimeType;
|
||||
// size = file.size;
|
||||
// eTag = file.eTag;
|
||||
// cTime = file.cTime;
|
||||
// mTime = file.mTime;
|
||||
// }
|
||||
//
|
||||
// File toDavFile() {
|
||||
// return File(
|
||||
// path: path,
|
||||
// isDir: isDir,
|
||||
// name: name,
|
||||
// mimeType: mimeType,
|
||||
// size: size,
|
||||
// eTag: eTag,
|
||||
// cTime: cTime,
|
||||
// mTime: mTime
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// factory CacheableFile.fromJson(Map<String, dynamic> json) => _$CacheableFileFromJson(json);
|
||||
// Map<String, dynamic> toJson() => _$CacheableFileToJson(this);
|
||||
// }
|
@ -0,0 +1,31 @@
|
||||
// // GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
//
|
||||
// part of 'cacheableFile.dart';
|
||||
//
|
||||
// // **************************************************************************
|
||||
// // JsonSerializableGenerator
|
||||
// // **************************************************************************
|
||||
//
|
||||
// CacheableFile _$CacheableFileFromJson(Map<String, dynamic> json) =>
|
||||
// CacheableFile(
|
||||
// json['path'] as String?,
|
||||
// json['isDir'] as bool?,
|
||||
// json['name'] as String?,
|
||||
// json['mimeType'] as String?,
|
||||
// json['size'] as int?,
|
||||
// json['eTag'] as String?,
|
||||
// json['cTime'] == null ? null : DateTime.parse(json['cTime'] as String),
|
||||
// json['mTime'] == null ? null : DateTime.parse(json['mTime'] as String),
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> _$CacheableFileToJson(CacheableFile instance) =>
|
||||
// <String, dynamic>{
|
||||
// 'path': instance.path,
|
||||
// 'isDir': instance.isDir,
|
||||
// 'name': instance.name,
|
||||
// 'mimeType': instance.mimeType,
|
||||
// 'size': instance.size,
|
||||
// 'eTag': instance.eTag,
|
||||
// 'cTime': instance.cTime?.toIso8601String(),
|
||||
// 'mTime': instance.mTime?.toIso8601String(),
|
||||
// };
|
@ -0,0 +1,21 @@
|
||||
//
|
||||
// import 'package:marianum_mobile/api/apiParams.dart';
|
||||
// import 'package:marianum_mobile/api/apiResponse.dart';
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/cacheableFile.dart';
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart';
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart';
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/webdavApi.dart';
|
||||
// import 'package:webdav_client/webdav_client.dart';
|
||||
//
|
||||
// class ListFiles extends WebdavApi<ListFilesParams> {
|
||||
// ListFilesParams params;
|
||||
//
|
||||
// ListFiles(this.params) : super(params);
|
||||
//
|
||||
// @override
|
||||
// Future<ListFilesResponse> run() async {
|
||||
// Set<CacheableFile> files = (await (await WebdavApi.webdav).readDir(params.path)).map((e) => CacheableFile.fromDavFile(e)).toSet();
|
||||
//
|
||||
// return ListFilesResponse(files);
|
||||
// }
|
||||
// }
|
@ -0,0 +1,33 @@
|
||||
// import 'dart:convert';
|
||||
// import 'dart:developer';
|
||||
//
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFiles.dart';
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesParams.dart';
|
||||
// import 'package:marianum_mobile/api/marianumcloud/webdav/queries/listFiles/listFilesResponse.dart';
|
||||
// import 'package:marianum_mobile/api/requestCache.dart';
|
||||
// import 'package:webdav_client/webdav_client.dart';
|
||||
//
|
||||
// class ListFilesCache extends RequestCache<ListFilesResponse> {
|
||||
// String path;
|
||||
//
|
||||
// ListFilesCache({required onUpdate, required this.path}) : super(RequestCache.cacheNothing, onUpdate) {
|
||||
// String cacheName = path.replaceAll(RegExp("[^A-Za-z0-9]"), "_"); //TODO this is very evil, "/ü/" > "___" also "/ä/" > "___"
|
||||
// log(cacheName);
|
||||
//
|
||||
// start("MarianumMobile", "wd-folder-$cacheName");
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Future<ListFilesResponse> onLoad() async {
|
||||
// log("Loading remote data");
|
||||
// ListFilesResponse data = await ListFiles(ListFilesParams(path)).run();
|
||||
// return data;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// ListFilesResponse onLocalData(String json) {
|
||||
// log("Loading local data");
|
||||
// return ListFilesResponse.fromJson(jsonDecode(json));
|
||||
// }
|
||||
//
|
||||
// }
|
@ -0,0 +1,15 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../../../../apiParams.dart';
|
||||
|
||||
part 'listFilesParams.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class ListFilesParams extends ApiParams {
|
||||
String path;
|
||||
|
||||
ListFilesParams(this.path);
|
||||
|
||||
factory ListFilesParams.fromJson(Map<String, dynamic> json) => _$ListFilesParamsFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ListFilesParamsToJson(this);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'listFilesParams.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ListFilesParams _$ListFilesParamsFromJson(Map<String, dynamic> json) =>
|
||||
ListFilesParams(
|
||||
json['path'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ListFilesParamsToJson(ListFilesParams instance) =>
|
||||
<String, dynamic>{
|
||||
'path': instance.path,
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
// import 'package:json_annotation/json_annotation.dart';
|
||||
// import 'package:marianum_mobile/api/apiResponse.dart';
|
||||
//
|
||||
// import 'cacheableFile.dart';
|
||||
//
|
||||
// part 'listFilesResponse.g.dart';
|
||||
//
|
||||
// @JsonSerializable(explicitToJson: true)
|
||||
// class ListFilesResponse extends ApiResponse {
|
||||
// Set<CacheableFile> files;
|
||||
//
|
||||
// ListFilesResponse(this.files);
|
||||
//
|
||||
// factory ListFilesResponse.fromJson(Map<String, dynamic> json) => _$ListFilesResponseFromJson(json);
|
||||
// Map<String, dynamic> toJson() => _$ListFilesResponseToJson(this);
|
||||
// }
|
@ -0,0 +1,19 @@
|
||||
// // GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
//
|
||||
// part of 'listFilesResponse.dart';
|
||||
//
|
||||
// // **************************************************************************
|
||||
// // JsonSerializableGenerator
|
||||
// // **************************************************************************
|
||||
//
|
||||
// ListFilesResponse _$ListFilesResponseFromJson(Map<String, dynamic> json) =>
|
||||
// ListFilesResponse(
|
||||
// (json['files'] as List<dynamic>)
|
||||
// .map((e) => CacheableFile.fromJson(e as Map<String, dynamic>))
|
||||
// .toSet(),
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> _$ListFilesResponseToJson(ListFilesResponse instance) =>
|
||||
// <String, dynamic>{
|
||||
// 'files': instance.files.map((e) => e.toJson()).toList(),
|
||||
// };
|
Reference in New Issue
Block a user