Skip to content

Commit

Permalink
Improved Files-View.
Browse files Browse the repository at this point in the history
Added Config Tab with editor for configs.
  • Loading branch information
Clon1998 committed Apr 28, 2022
1 parent 63fa426 commit 5086cbc
Show file tree
Hide file tree
Showing 29 changed files with 635 additions and 198 deletions.
6 changes: 4 additions & 2 deletions lib/app/app_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import 'package:mobileraker/ui/views/console/console_viewmodel.dart';
import 'package:mobileraker/ui/views/dashboard/dashboard_view.dart';
import 'package:mobileraker/ui/views/dashboard/tabs/control_tab_viewmodel.dart';
import 'package:mobileraker/ui/views/dashboard/tabs/general_tab_viewmodel.dart';
import 'package:mobileraker/ui/views/files/details/file_details_view.dart';
import 'package:mobileraker/ui/views/files/details/config_file_details_view.dart';
import 'package:mobileraker/ui/views/files/details/gcode_file_details_view.dart';
import 'package:mobileraker/ui/views/files/files_view.dart';
import 'package:mobileraker/ui/views/fullcam/full_cam_view.dart';
import 'package:mobileraker/ui/views/overview/overview_view.dart';
Expand All @@ -42,7 +43,8 @@ import 'package:stacked_services/stacked_services.dart';
MaterialRoute(page: PrinterAdd),
MaterialRoute(page: PrinterEdit),
MaterialRoute(page: FilesView),
MaterialRoute(page: FileDetailView),
MaterialRoute(page: GCodeFileDetailView),
MaterialRoute(page: ConfigFileDetailView),
MaterialRoute(page: SettingView),
MaterialRoute(page: ImprintView),
MaterialRoute(page: QrScannerView),
Expand Down
3 changes: 0 additions & 3 deletions lib/domain/hive/webcam_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ class WebcamSetting {
WebcamSetting(this.name, this.url);

double get yTransformation {
var vertical = flipVertical;

if (flipVertical)
return pi;
else
return 0;
}

double get xTransformation {

if (flipHorizontal)
return pi;
else
Expand Down
4 changes: 2 additions & 2 deletions lib/dto/files/gcode_file.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:mobileraker/dto/files/file.dart';
import 'package:mobileraker/dto/files/remote_file.dart';
import 'package:mobileraker/dto/files/gcode_thumbnail.dart';

class GCodeFile extends File {
class GCodeFile extends RemoteFile {
double? printStartTime;

String? jobID;
Expand Down
36 changes: 36 additions & 0 deletions lib/dto/files/moonraker/file_api_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:enum_to_string/enum_to_string.dart';
import 'package:mobileraker/dto/files/moonraker/file_notification_item.dart';
import 'package:mobileraker/dto/files/moonraker/file_notification_source_item.dart';
import 'package:mobileraker/service/moonraker/file_service.dart';

class FileApiResponse {
final FileAction fileAction;
final FileNotificationItem item;
final FileNotificationSourceItem? sourceItem;

FileApiResponse.fromJson(Map<String, dynamic> json)
: this.fileAction =
EnumToString.fromString(FileAction.values, json['action'])!,
this.item = FileNotificationItem.fromJson(json['item']),
this.sourceItem = (json.containsKey('source_item'))
? FileNotificationSourceItem.fromJson(json['source_item'])
: null;


@override
bool operator ==(Object other) =>
identical(this, other) ||
other is FileApiResponse &&
runtimeType == other.runtimeType &&
fileAction == other.fileAction &&
item == other.item &&
sourceItem == other.sourceItem;

@override
int get hashCode => fileAction.hashCode ^ item.hashCode ^ sourceItem.hashCode;

@override
String toString() {
return 'FileListChangedNotification{fileAction: $fileAction, item: $item, sourceItem: $sourceItem}';
}
}
30 changes: 30 additions & 0 deletions lib/dto/files/moonraker/file_notification_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class FileNotificationItem {
final String path;
final String root;
final int? size;
final double? modified;

String get fullPath => '$root/$path';

FileNotificationItem.fromJson(Map<String, dynamic> json)
: this.path = json['path'],
this.root = json['root'],
this.size = json['size'],
this.modified = double.tryParse(json['modified'].toString());

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is FileNotificationItem &&
runtimeType == other.runtimeType &&
path == other.path &&
root == other.root;

@override
int get hashCode => path.hashCode ^ root.hashCode;

@override
String toString() {
return 'FileNotificationItem{path: $path, root: $root, size: $size, modified: $modified}';
}
}
26 changes: 26 additions & 0 deletions lib/dto/files/moonraker/file_notification_source_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class FileNotificationSourceItem {
final String path;
final String root;

FileNotificationSourceItem.fromJson(Map<String, dynamic> json)
: this.path = json['path'],
this.root = json['root'];

String get fullPath => '$root/$path';

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is FileNotificationSourceItem &&
runtimeType == other.runtimeType &&
path == other.path &&
root == other.root;

@override
int get hashCode => path.hashCode ^ root.hashCode;

@override
String toString() {
return 'FileListChangedSourceItem{path: $path, root: $root}';
}
}
22 changes: 0 additions & 22 deletions lib/dto/files/notification/file_list_changed_item.dart

This file was deleted.

16 changes: 0 additions & 16 deletions lib/dto/files/notification/file_list_changed_notification.dart

This file was deleted.

18 changes: 0 additions & 18 deletions lib/dto/files/notification/file_list_changed_source_item.dart

This file was deleted.

10 changes: 6 additions & 4 deletions lib/dto/files/file.dart → lib/dto/files/remote_file.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class File {
File(this.name, this.modified, this.size, this.parentPath);
class RemoteFile {
RemoteFile(this.name, this.modified, this.size, this.parentPath);

File.fromJson(Map<String, dynamic> json, this.parentPath)
RemoteFile.fromJson(Map<String, dynamic> json, this.parentPath)
: name = json['filename'],
size = json['size'],
modified = json['modified'];
Expand All @@ -16,14 +16,16 @@ class File {
/// Path to the location/directory where the file is located
String parentPath;

String get absolutPath => '$parentPath/$name';

DateTime? get modifiedDate {
return DateTime.fromMillisecondsSinceEpoch(modified.toInt() * 1000);
}

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is File &&
other is RemoteFile &&
runtimeType == other.runtimeType &&
name == other.name &&
modified == other.modified &&
Expand Down
15 changes: 7 additions & 8 deletions lib/repository/machine_settings_moonraker_repository.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:developer';

import 'package:mobileraker/app/app_setup.locator.dart';
import 'package:mobileraker/app/app_setup.logger.dart';
import 'package:mobileraker/datasource/json_rpc_client.dart';
Expand All @@ -12,20 +10,21 @@ class MachineSettingsMoonrakerRepository implements MachineSettingsRepository {
final _logger = getLogger('MachineSettingsMoonrakerRepository');
final _databaseService = locator<MoonrakerDatabaseClient>();


@override
Future<void> update(MachineSettings machineSettings,[JsonRpcClient? jsonRpcClient]) async {
Future<void> update(MachineSettings machineSettings,
[JsonRpcClient? jsonRpcClient]) async {
machineSettings.lastModified = DateTime.now();

await _databaseService.addDatabaseItem('mobileraker', 'settings', machineSettings, jsonRpcClient);
await _databaseService.addDatabaseItem(
'mobileraker', 'settings', machineSettings, jsonRpcClient);
}

@override
Future<MachineSettings?> get([JsonRpcClient? jsonRpcClient]) async {
var json = await _databaseService.getDatabaseItem('mobileraker', key:'settings', client: jsonRpcClient);
var json = await _databaseService.getDatabaseItem('mobileraker',
key: 'settings', client: jsonRpcClient);

if (json == null)
return null;
if (json == null) return null;

return MachineSettings.fromJson(json);
}
Expand Down
Loading

0 comments on commit 5086cbc

Please sign in to comment.