mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-08 04:30:46 -06:00
[client] update offtheline, use single action queue
This commit is contained in:
@@ -25,7 +25,7 @@ void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
PhylumDirectories.instance.initialize();
|
||||
logger = Logger(level: Level.info, printer: PrettyPrinter(methodCount: 0, noBoxingByDefault: true));
|
||||
logger = Logger(level: Level.debug, printer: PrettyPrinter(methodCount: 0, noBoxingByDefault: true));
|
||||
OTL.logger = logger;
|
||||
GoRouter.optionURLReflectsImperativeAPIs = true;
|
||||
// We use multiple distinct databases for different accounts, so this is expected behavior
|
||||
|
||||
@@ -151,8 +151,8 @@ class SyncButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final qState = context.select<PhylumActionQueueState, _SyncState>((state) {
|
||||
if (state.error > 0) return _SyncState.error;
|
||||
if (state.submitting > 0) return _SyncState.syncing;
|
||||
if (state.error) return _SyncState.error;
|
||||
if (state.paused) return _SyncState.paused;
|
||||
return _SyncState.done;
|
||||
});
|
||||
|
||||
@@ -9,26 +9,44 @@ class ActionQueueList extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final queue = context.select<PhylumActionQueueState, Iterable<PhylumAction>>((state) => state.actions.keys).toList(growable: false);
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: queue.length,
|
||||
itemBuilder: (context, i) {
|
||||
return ActionView(action: queue[i]);
|
||||
},
|
||||
final actions = context.select<PhylumActionQueueState, List<QueuedAction<PhylumAccount>>>((state) => state.actions);
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, i) {
|
||||
if (i == 0) {
|
||||
return const ListTile(
|
||||
dense: true,
|
||||
title: Text('Actions'),
|
||||
);
|
||||
}
|
||||
return ActionView(action: actions[i - 1]);
|
||||
},
|
||||
childCount: actions.length + 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ActionView extends StatelessWidget {
|
||||
final PhylumAction action;
|
||||
ActionView({required this.action}) : super(key: ValueKey(action.key));
|
||||
final QueuedAction<PhylumAccount> action;
|
||||
ActionView({required this.action}) : super(key: ValueKey(action.id));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = context.select<PhylumActionQueueState, ActionStatus>((state) => state.actions[action]!);
|
||||
return switch (state) {
|
||||
ActionStatusWaiting() || ActionStatusReady() || ActionStatusSubmitting() || ActionStatusDone() => buildSimpleInfoTile(context, state),
|
||||
return StreamBuilder(
|
||||
stream: action.statusNotifier.stream,
|
||||
initialData: action.status,
|
||||
builder: (context, snapshot) => buildTile(context, snapshot.data!),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTile(BuildContext context, ActionStatus status) {
|
||||
return switch (status) {
|
||||
ActionStatusWaiting() || ActionStatusReady() || ActionStatusSubmitting() || ActionStatusDone() => buildSimpleInfoTile(context, status),
|
||||
ActionStatusError(error: final error) => buildErrorInfoTile(context, error),
|
||||
};
|
||||
}
|
||||
@@ -36,11 +54,11 @@ class ActionView extends StatelessWidget {
|
||||
Widget buildSimpleInfoTile(BuildContext context, ActionStatus status) {
|
||||
final account = context.read<PhylumAccount>();
|
||||
return ListTile(
|
||||
title: Text(action.generateDescription(account)),
|
||||
title: Text(action.action.generateDescription(account)),
|
||||
subtitle: Text(status.toString()),
|
||||
trailing: status is ActionStatusSubmitting
|
||||
? null
|
||||
: IconButton(onPressed: () => context.read<ApiActionQueue>().deleteAction(action), icon: const Icon(Icons.delete)),
|
||||
: IconButton(onPressed: () => context.read<PhylumActionQueue>().deleteAction(action.id), icon: const Icon(Icons.delete)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,13 +71,13 @@ class ActionView extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
return ListTile(
|
||||
title: Text(action.generateDescription(account), overflow: TextOverflow.fade),
|
||||
title: Text(action.action.generateDescription(account), overflow: TextOverflow.fade),
|
||||
subtitle: Text(description),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(icon: const Icon(Icons.refresh), onPressed: () => context.read<PhylumActionQueue>().retryAction(action)),
|
||||
IconButton(icon: const Icon(Icons.delete), onPressed: () => context.read<PhylumActionQueue>().deleteAction(action)),
|
||||
IconButton(icon: const Icon(Icons.refresh), onPressed: () => context.read<PhylumActionQueue>().retryAction(action.id)),
|
||||
IconButton(icon: const Icon(Icons.delete), onPressed: () => context.read<PhylumActionQueue>().deleteAction(action.id)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -576,11 +576,9 @@ packages:
|
||||
offtheline:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: eb424e19dc4e23169e70a857c8d8011f4be528ff
|
||||
resolved-ref: eb424e19dc4e23169e70a857c8d8011f4be528ff
|
||||
url: "https://codeberg.org/shroff/offtheline.git"
|
||||
source: git
|
||||
path: "../../offtheline"
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.15.0"
|
||||
open_file:
|
||||
dependency: "direct main"
|
||||
|
||||
@@ -21,7 +21,7 @@ dependencies:
|
||||
offtheline:
|
||||
git:
|
||||
url: https://codeberg.org/shroff/offtheline.git
|
||||
ref: eb424e19dc4e23169e70a857c8d8011f4be528ff
|
||||
ref: 1636cedb55d1dc4c30985d7cc2b2084cea7810ef
|
||||
open_file:
|
||||
path:
|
||||
path_provider:
|
||||
@@ -41,5 +41,9 @@ dev_dependencies:
|
||||
drift_dev: ^2.19.1
|
||||
build_runner: ^2.4.12
|
||||
|
||||
dependency_overrides:
|
||||
offtheline:
|
||||
path: ../../offtheline
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
@@ -6,6 +6,6 @@ podman run -d \
|
||||
-e POSTGRES_USER=phylum \
|
||||
-e POSTGRES_PASSWORD=phylum \
|
||||
-e POSTGRES_DB=phylum \
|
||||
-p 5432:5432
|
||||
postgres:latest
|
||||
```
|
||||
-p 5432:5432 \
|
||||
docker.io/postgres:latest
|
||||
```
|
||||
|
||||
@@ -67,8 +67,9 @@ func createEngine(logBody bool, corsEnabled bool, corsOrigins []string) *gin.Eng
|
||||
engine := gin.New()
|
||||
engine.Use(gin.Logger(), gin.CustomRecovery(func(c *gin.Context, err any) {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
|
||||
"code": "internal_server_error",
|
||||
"msg": "Internal Server Error",
|
||||
"status": 500,
|
||||
"code": "internal_server_error",
|
||||
"msg": "Internal Server Error",
|
||||
})
|
||||
}))
|
||||
if core.Default.Debug && logBody {
|
||||
|
||||
@@ -267,7 +267,7 @@ func (f filesystem) DeleteRecursive(r Resource, hardDelete bool) (uuid.UUIDs, er
|
||||
|
||||
func (f filesystem) UpdateName(r Resource, name string) (Resource, error) {
|
||||
if r.Name() == name {
|
||||
return nil, nil
|
||||
return r, nil
|
||||
}
|
||||
if r.ParentID() == nil {
|
||||
return nil, ErrInsufficientPermissions
|
||||
|
||||
Reference in New Issue
Block a user