diff --git a/b0esche_cloud/lib/repositories/mock_auth_repository.dart b/b0esche_cloud/lib/repositories/mock_auth_repository.dart deleted file mode 100644 index 3b8e9c7..0000000 --- a/b0esche_cloud/lib/repositories/mock_auth_repository.dart +++ /dev/null @@ -1,30 +0,0 @@ -import '../models/user.dart'; -import '../repositories/auth_repository.dart'; - -class MockAuthRepository implements AuthRepository { - @override - Future login(String email, String password) async { - await Future.delayed(const Duration(seconds: 1)); - if (email.isNotEmpty && password.isNotEmpty) { - return User( - id: 'mock-user-id', - username: 'mockuser', - email: email, - createdAt: DateTime.now(), - ); - } else { - throw Exception('Invalid credentials'); - } - } - - @override - Future logout() async { - // Mock logout - } - - @override - Future getCurrentUser() async { - // Mock: return null or a user - return null; - } -} diff --git a/b0esche_cloud/lib/repositories/mock_file_repository.dart b/b0esche_cloud/lib/repositories/mock_file_repository.dart deleted file mode 100644 index 89d2559..0000000 --- a/b0esche_cloud/lib/repositories/mock_file_repository.dart +++ /dev/null @@ -1,291 +0,0 @@ -import '../models/file_item.dart'; -import '../models/viewer_session.dart'; -import '../models/editor_session.dart'; -import '../models/annotation.dart'; -import '../models/document_capabilities.dart'; -import '../models/api_error.dart'; -import '../repositories/file_repository.dart'; -import 'package:path/path.dart' as p; -import 'package:uuid/uuid.dart'; - -class MockFileRepository implements FileRepository { - final Map> _orgFiles = {}; - final _uuid = const Uuid(); - - List _getFilesForOrg(String orgId) { - if (!_orgFiles.containsKey(orgId)) { - // Initialize with different files per org - if (orgId == 'org1') { - _orgFiles[orgId] = [ - FileItem( - id: _uuid.v4(), - name: 'Personal Documents', - path: '/Personal Documents', - type: FileType.folder, - lastModified: DateTime.now(), - ), - FileItem( - id: _uuid.v4(), - name: 'Photos', - path: '/Photos', - type: FileType.folder, - lastModified: DateTime.now(), - ), - FileItem( - id: _uuid.v4(), - name: 'resume.pdf', - path: '/resume.pdf', - type: FileType.file, - size: 1024, - lastModified: DateTime.now(), - ), - FileItem( - id: _uuid.v4(), - name: 'notes.txt', - path: '/notes.txt', - type: FileType.file, - size: 256, - lastModified: DateTime.now(), - ), - ]; - } else if (orgId == 'org2') { - _orgFiles[orgId] = [ - FileItem( - id: _uuid.v4(), - name: 'Company Reports', - path: '/Company Reports', - type: FileType.folder, - lastModified: DateTime.now(), - ), - FileItem( - id: _uuid.v4(), - name: 'annual_report.pdf', - path: '/annual_report.pdf', - type: FileType.file, - size: 2048, - lastModified: DateTime.now(), - ), - FileItem( - id: _uuid.v4(), - name: 'presentation.pptx', - path: '/presentation.pptx', - type: FileType.file, - size: 4096, - lastModified: DateTime.now(), - ), - ]; - } else if (orgId == 'org3') { - _orgFiles[orgId] = [ - FileItem( - id: _uuid.v4(), - name: 'Project Code', - path: '/Project Code', - type: FileType.folder, - lastModified: DateTime.now(), - ), - FileItem( - id: _uuid.v4(), - name: 'side_project.dart', - path: '/side_project.dart', - type: FileType.file, - size: 512, - lastModified: DateTime.now(), - ), - ]; - } else { - // Default for new orgs - _orgFiles[orgId] = []; - } - } - return _orgFiles[orgId]!; - } - - @override - Future> getFiles(String orgId, String path) async { - await Future.delayed(const Duration(seconds: 1)); - final files = _getFilesForOrg(orgId); - if (path == '/') { - return files.where((f) => !f.path.substring(1).contains('/')).toList(); - } else { - return files - .where((f) => f.path.startsWith('$path/') && f.path != path) - .toList(); - } - } - - @override - Future getFile(String orgId, String path) async { - final files = _getFilesForOrg(orgId); - final index = files.indexWhere((f) => f.path == path); - return index != -1 ? files[index] : null; - } - - @override - Future requestEditorSession( - String orgId, - String fileId, - ) async { - await Future.delayed(const Duration(seconds: 1)); - // Mock: determine editability - final isEditable = - fileId.endsWith('.docx') || - fileId.endsWith('.xlsx') || - fileId.endsWith('.pptx'); - final editUrl = Uri.parse( - 'https://office.b0esche.cloud/editor/$orgId/$fileId?editable=$isEditable', - ); - final expiresAt = DateTime.now().add(const Duration(minutes: 30)); - return EditorSession( - editUrl: editUrl, - readOnly: !isEditable, - expiresAt: expiresAt, - ); - } - - @override - Future deleteFile(String orgId, String path) async { - final files = _getFilesForOrg(orgId); - files.removeWhere((f) => f.path == path); - } - - @override - Future createFolder( - String orgId, - String parentPath, - String folderName, - ) async { - await Future.delayed(const Duration(seconds: 1)); - final normalizedName = folderName.startsWith('/') - ? folderName.substring(1) - : folderName; - final newPath = parentPath == '/' - ? '/$normalizedName' - : '$parentPath/$normalizedName'; - final files = _getFilesForOrg(orgId); - files.add( - FileItem( - id: _uuid.v4(), - name: normalizedName, - path: newPath, - type: FileType.folder, - lastModified: DateTime.now(), - ), - ); - } - - @override - Future moveFile( - String orgId, - String sourcePath, - String targetPath, - ) async { - await Future.delayed(const Duration(seconds: 1)); - final files = _getFilesForOrg(orgId); - final fileIndex = files.indexWhere((f) => f.path == sourcePath); - if (fileIndex != -1) { - final file = files[fileIndex]; - final newName = file.path.split('/').last; - final newPath = targetPath == '/' ? '/$newName' : '$targetPath/$newName'; - files[fileIndex] = FileItem( - id: file.id, - name: file.name, - path: newPath, - type: file.type, - size: file.size, - lastModified: DateTime.now(), - ); - } - } - - @override - Future renameFile(String orgId, String path, String newName) async { - await Future.delayed(const Duration(seconds: 1)); - final files = _getFilesForOrg(orgId); - final fileIndex = files.indexWhere((f) => f.path == path); - if (fileIndex != -1) { - final file = files[fileIndex]; - final parentPath = p.dirname(path); - final newPath = parentPath == '.' ? '/$newName' : '$parentPath/$newName'; - files[fileIndex] = FileItem( - id: file.id, - name: newName, - path: newPath, - type: file.type, - size: file.size, - lastModified: DateTime.now(), - ); - } - } - - @override - Future> searchFiles(String orgId, String query) async { - await Future.delayed(const Duration(seconds: 1)); - final files = _getFilesForOrg(orgId); - return files - .where((f) => f.name.toLowerCase().contains(query.toLowerCase())) - .toList(); - } - - @override - Future uploadFile(String orgId, FileItem file) async { - await Future.delayed(const Duration(seconds: 1)); - final files = _getFilesForOrg(orgId); - files.add( - FileItem( - id: _uuid.v4(), - name: file.name, - path: file.path, - type: file.type, - size: file.size, - lastModified: file.lastModified, - ), - ); - } - - @override - Future requestViewerSession( - String orgId, - String fileId, - ) async { - await Future.delayed(const Duration(seconds: 1)); - if (fileId.contains('forbidden')) { - throw ApiError( - code: 'permission_denied', - message: 'Access denied', - status: 403, - ); - } - if (fileId.contains('notfound')) { - throw ApiError(code: 'not_found', message: 'File not found', status: 404); - } - // Mock: assume fileId is path, determine if PDF - final isPdf = fileId.endsWith('.pdf'); - final caps = DocumentCapabilities( - canEdit: !isPdf && (fileId.endsWith('.docx') || fileId.endsWith('.xlsx')), - canAnnotate: isPdf, - isPdf: isPdf, - ); - // Mock URL - final viewUrl = Uri.parse( - 'https://office.b0esche.cloud/viewer/$orgId/$fileId', - ); - final token = 'mock-viewer-token'; - final expiresAt = DateTime.now().add(const Duration(minutes: 30)); - return ViewerSession( - viewUrl: viewUrl, - capabilities: caps, - token: token, - expiresAt: expiresAt, - ); - } - - @override - Future saveAnnotations( - String orgId, - String fileId, - List annotations, - ) async { - await Future.delayed(const Duration(seconds: 2)); - // Mock: just delay, assume success - } -}