fixed long collection name overlap
added download query json
MODIFY
packages/isar/lib/src/isar_connect.dart
packages/isar/lib/src/isar_connect.dart
@@ -163,9 +163,8 @@ abstract class _IsarConnect {
}
static Future<List<dynamic>> _exportJson(Map<String, dynamic> params) async {
- final collection = Isar.getInstance(params['instance'] as String)!
- .getCollectionByNameInternal(params['collection'] as String)!;
- return collection.where().exportJson();
+ final query = _getQuery(params);
+ return query.exportJson();
}
static Query<dynamic> _getQuery(Map<String, dynamic> params) {

MODIFY
packages/isar_inspector/lib/collections.dart
packages/isar_inspector/lib/collections.dart
@@ -36,14 +36,19 @@ class CollectionsList extends ConsumerWidget {
padding: const EdgeInsets.only(left: 25, right: 10),
child: Row(
children: [
- Text(
+ Expanded(
+ child: Tooltip(
+ message: collection.name,
+ child: Text(
collection.name,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
),
),
- const Spacer(),
if (info != null) ...[
Column(
crossAxisAlignment: CrossAxisAlignment.end,
@@ -68,11 +73,15 @@ class CollectionsList extends ConsumerWidget {
],
GestureDetector(
onTap: () async {
+ final query = ConnectQuery(
+ instance: selectedInstance,
+ collection: collection.name,
+ );
+
+ final data = await isarConnect.exportJson(query);
+
await download(
- await isarConnect.exportJson(
- selectedInstance,
- collection.name,
- ),
+ data,
'${selectedInstance}_${collection.name}.json',
);
},

MODIFY
packages/isar_inspector/lib/filter_field.dart
packages/isar_inspector/lib/filter_field.dart
@@ -3,6 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:isar/isar.dart';
+import 'package:isar_inspector/desktop/download.dart'
+ if (dart.library.html) 'package:isar_inspector/web/download.dart';
import 'package:isar_inspector/query_parser.dart';
import 'package:isar_inspector/schema.dart';
import 'package:isar_inspector/state/collections_state.dart';
@@ -59,6 +61,22 @@ class _FilterFieldState extends ConsumerState<FilterField> {
child: const Text('Query'),
),
const SizedBox(width: 20),
+ ElevatedButton(
+ onPressed: () async {
+ final selectedCollection = ref.read(selectedCollectionPod).value!;
+ final filter = _parseFilter(selectedCollection);
+ final q = ConnectQuery(
+ instance: ref.read(selectedInstancePod).value!,
+ collection: selectedCollection.name,
+ filter: filter,
+ );
+
+ final data = await ref.read(isarConnectPod.notifier).exportJson(q);
+ await download(data, '${q.instance}_${q.collection}_query.json');
+ },
+ child: const Text('Download'),
+ ),
+ const SizedBox(width: 20),
ElevatedButton(
onPressed: () {
final selectedCollection = ref.read(selectedCollectionPod).value!;
@@ -71,7 +89,7 @@ class _FilterFieldState extends ConsumerState<FilterField> {
ref.read(isarConnectPod.notifier).removeQuery(query);
},
child: const Text('Remove'),
- )
+ ),
],
);
}

MODIFY
packages/isar_inspector/lib/state/isar_connect_state_notifier.dart
packages/isar_inspector/lib/state/isar_connect_state_notifier.dart
@@ -164,10 +164,10 @@ class IsarConnectStateNotifier
);
}
- Future<List<dynamic>> exportJson(String instance, String collection) async {
+ Future<List<dynamic>> exportJson(ConnectQuery query) async {
final data = await _call<List<dynamic>>(
ConnectAction.exportJson,
- args: {'instance': instance, 'collection': collection},
+ args: query.toJson(),
timeout: kLongTimeout,
);

fixed long collection name overlap

added download query json