Show indexes and Isar id
objectsPerPage changed to 20
some cleanup
MODIFY
packages/isar_inspector/lib/collections.dart
packages/isar_inspector/lib/collections.dart
+import 'dart:math';
+
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:isar_inspector/common.dart';
@@ -122,13 +124,8 @@ class CollectionsList extends ConsumerWidget {
}
String _formatSize(int bytes) {
- if (bytes < 10000) {
- return '${bytes.toStringAsFixed(2)}B';
- } else if (bytes < 1000000) {
- return '${(bytes / 1000).toStringAsFixed(2)}KB';
- } else if (bytes < 1000000000) {
- return '${(bytes / 1000000).toStringAsFixed(2)}MB';
- } else {
- return '${(bytes / 1000000000).toStringAsFixed(2)}GB';
- }
+ if (bytes <= 0) return '0 B';
+ const suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
+ final i = (log(bytes) / log(1000)).floor();
+ return '${(bytes / pow(1000, i)).toStringAsFixed(2)} ${suffixes[i]}';
}

MODIFY
packages/isar_inspector/lib/connected_layout.dart
packages/isar_inspector/lib/connected_layout.dart
@@ -40,9 +40,7 @@ class _ConnectedLayoutState extends ConsumerState<ConnectedLayout> {
children: const [
FilterField(),
SizedBox(height: 25),
- Expanded(
- child: QueryTable(),
- ),
+ Expanded(child: QueryTable()),
],
),
)

MODIFY
packages/isar_inspector/lib/desktop/app.dart
packages/isar_inspector/lib/desktop/app.dart
@@ -28,7 +28,6 @@ class _AppState extends State<App> {
scaffoldBackgroundColor: Colors.transparent,
primaryColor: Colors.blue,
cardColor: const Color(0xff1f2128),
- // Color.fromARGB(255, 40, 41, 46),
dividerColor: const Color.fromARGB(255, 40, 41, 46),
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.all(Colors.blue),

MODIFY
packages/isar_inspector/lib/edit_popup.dart
packages/isar_inspector/lib/edit_popup.dart
@@ -67,7 +67,6 @@ class _EditPopupState extends State<EditPopup> {
Widget build(BuildContext context) {
return SizedBox(
width: widget.type == IsarType.String ? 500 : 300,
- //height: 210,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [

MODIFY
packages/isar_inspector/lib/filter_field.dart
packages/isar_inspector/lib/filter_field.dart
@@ -10,19 +10,11 @@ import 'package:isar_inspector/state/instances_state.dart';
import 'package:isar_inspector/state/isar_connect_state_notifier.dart';
import 'package:isar_inspector/state/query_state.dart';
-class FilterField extends ConsumerStatefulWidget {
+class FilterField extends ConsumerWidget {
const FilterField({super.key});
@override
- ConsumerState<FilterField> createState() => _FilterFieldState();
-}
-
-class _FilterFieldState extends ConsumerState<FilterField> {
- final TextEditingController controller = TextEditingController();
- String? error;
-
- @override
- Widget build(BuildContext context) {
+ Widget build(BuildContext context, WidgetRef ref) {
return Row(
children: [
const SizedBox(width: 20),
@@ -93,10 +85,4 @@ class _FilterFieldState extends ConsumerState<FilterField> {
],
);
}
-
- @override
- void dispose() {
- controller.dispose();
- super.dispose();
- }
}

MODIFY
packages/isar_inspector/lib/query_table.dart
packages/isar_inspector/lib/query_table.dart
@@ -385,17 +385,34 @@ class _TableItemState extends State<TableItem> {
return RichText(
overflow: TextOverflow.ellipsis,
text: TextSpan(
- text: '${widget.data.index ?? widget.data.property.name}: ',
+ text: '',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Colors.white,
),
children: [
+ TextSpan(
+ text: '${widget.data.index ?? widget.data.property.name}',
+ style: TextStyle(
+ decoration: widget.data.property.isIndex
+ ? TextDecoration.underline
+ : null,
+ decorationThickness: 2,
+ decorationColor: Colors.green,
+ decorationStyle: TextDecorationStyle.wavy,
+ ),
+ ),
+ const TextSpan(text: ': '),
TextSpan(
text: value,
style: TextStyle(color: color),
),
+ if (widget.data.property.isId)
+ const TextSpan(
+ text: ' IsarId',
+ style: TextStyle(color: _disableColor),
+ ),
],
),
);

MODIFY
packages/isar_inspector/lib/schema.dart
packages/isar_inspector/lib/schema.dart
@@ -11,16 +11,33 @@ class ICollection {
required this.links,
});
- factory ICollection.fromJson(Map<String, dynamic> json) => ICollection(
+ factory ICollection.fromJson(Map<String, dynamic> json) {
+ final indexes = <String>{};
+ final jsonIndexes = json['indexes'] as List<dynamic>;
+
+ for (var i = 0; i < jsonIndexes.length; i++) {
+ indexes.addAll(
+ //ignore: avoid_dynamic_calls
+ (jsonIndexes[i]['properties'] as List<dynamic>).map(
+ (e) {
+ //ignore: avoid_dynamic_calls
+ return e['name'] as String;
+ },
+ ).toList(),
+ );
+ }
+
+ return ICollection(
name: json['name'] as String,
idName: json['idName'] as String,
properties: (json['properties'] as List<dynamic>)
- .map((e) => IProperty.fromJson(e as Map<String, dynamic>))
+ .map((e) => IProperty.fromJson(e as Map<String, dynamic>, indexes))
.toList(),
links: (json['links'] as List<dynamic>)
.map((e) => ILink.fromJson(e as Map<String, dynamic>))
.toList(),
);
+ }
final String name;
final String idName;
@@ -39,18 +56,23 @@ class IProperty {
const IProperty({
required this.name,
required this.type,
+ this.isIndex = false,
this.isId = false,
});
- factory IProperty.fromJson(Map<String, dynamic> json) => IProperty(
+ factory IProperty.fromJson(Map<String, dynamic> json, Set<String> indexes) {
+ return IProperty(
name: json['name'] as String,
type: IsarType.values.firstWhere((e) => e.name == json['type']),
isId: json['isId'] as bool? ?? false,
+ isIndex: indexes.contains(json['name']),
);
+ }
final String name;
final IsarType type;
final bool isId;
+ final bool isIndex;
}
class ILink {

MODIFY
packages/isar_inspector/lib/state/query_state.dart
packages/isar_inspector/lib/state/query_state.dart
@@ -5,7 +5,7 @@ import 'package:isar_inspector/state/collections_state.dart';
import 'package:isar_inspector/state/instances_state.dart';
import 'package:isar_inspector/state/isar_connect_state_notifier.dart';
-const int objectsPerPage = 50;
+const int objectsPerPage = 20;
class QueryObject {
const QueryObject(this.data);

MODIFY
packages/isar_inspector/lib/web/app.dart
packages/isar_inspector/lib/web/app.dart
@@ -56,7 +56,6 @@ class App extends StatelessWidget {
scaffoldBackgroundColor: Colors.transparent,
primaryColor: Colors.blue,
cardColor: const Color(0xff1f2128),
- // Color.fromARGB(255, 40, 41, 46),
dividerColor: const Color.fromARGB(255, 40, 41, 46),
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.all(Colors.blue),

Show indexes and Isar id

objectsPerPage changed to 20
some cleanup