mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 15:10:49 +08:00
feat: add size to activity
This commit is contained in:
2
db/db.go
2
db/db.go
@@ -474,7 +474,7 @@ func (c *Client) SetDefaultStorageByName(name string) error {
|
||||
func (c *Client) SaveHistoryRecord(h ent.History) (*ent.History, error) {
|
||||
return c.ent.History.Create().SetMediaID(h.MediaID).SetEpisodeID(h.EpisodeID).SetDate(time.Now()).
|
||||
SetStatus(h.Status).SetTargetDir(h.TargetDir).SetSourceTitle(h.SourceTitle).SetIndexerID(h.IndexerID).
|
||||
SetDownloadClientID(h.DownloadClientID).SetSaved(h.Saved).Save(context.TODO())
|
||||
SetDownloadClientID(h.DownloadClientID).SetSize(h.Size).SetSaved(h.Saved).Save(context.TODO())
|
||||
}
|
||||
|
||||
func (c *Client) SetHistoryStatus(id int, status history.Status) error {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:percent_indicator/circular_percent_indicator.dart';
|
||||
import 'package:ui/providers/activity.dart';
|
||||
import 'package:ui/widgets/progress_indicator.dart';
|
||||
import 'package:ui/widgets/utils.dart';
|
||||
import 'package:ui/widgets/widgets.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
@@ -99,13 +99,26 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
||||
double p = ac.progress == null
|
||||
? 0
|
||||
: ac.progress!.toDouble() / 100;
|
||||
return Tooltip(message: "${ac.progress}%",child: CircularProgressIndicator(
|
||||
return Tooltip(
|
||||
message: "${ac.progress}%",
|
||||
child: CircularProgressIndicator(
|
||||
backgroundColor: Colors.black26,
|
||||
value: p,
|
||||
),);
|
||||
),
|
||||
);
|
||||
}(),
|
||||
title: Text("$index " + (ac.sourceTitle ?? "")),
|
||||
subtitle: Text("开始时间:${timeago.format(ac.date!)}"),
|
||||
title:
|
||||
Text( (ac.sourceTitle ?? "")),
|
||||
subtitle: Opacity(
|
||||
opacity: 0.7,
|
||||
child: Wrap(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text("开始时间:${timeago.format(ac.date!)}"),
|
||||
Text("大小:${(ac.size ?? 0).readableFileSize()}")
|
||||
],
|
||||
),
|
||||
),
|
||||
trailing: selectedTab == 0
|
||||
? IconButton(
|
||||
tooltip: "删除任务",
|
||||
@@ -135,71 +148,3 @@ class _ActivityPageState extends ConsumerState<ActivityPage>
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityDataSource extends DataTableSource {
|
||||
List<Activity> activities;
|
||||
Function(int)? onDelete;
|
||||
ActivityDataSource({required this.activities, this.onDelete});
|
||||
|
||||
@override
|
||||
int get rowCount => activities.length;
|
||||
|
||||
@override
|
||||
DataRow? getRow(int index) {
|
||||
final activity = activities[index];
|
||||
return DataRow(cells: [
|
||||
DataCell(Text("${activity.id}")),
|
||||
DataCell(Text("${activity.sourceTitle}")),
|
||||
DataCell(Text("${activity.date!.toLocal()}")),
|
||||
DataCell(() {
|
||||
if (activity.status == "uploading") {
|
||||
return const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: Tooltip(
|
||||
message: "正在上传到指定存储",
|
||||
child: CircularProgressIndicator(),
|
||||
));
|
||||
} else if (activity.status == "fail") {
|
||||
return const Tooltip(
|
||||
message: "下载失败",
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
color: Colors.red,
|
||||
));
|
||||
} else if (activity.status == "success") {
|
||||
return const Tooltip(
|
||||
message: "下载成功",
|
||||
child: Icon(
|
||||
Icons.check,
|
||||
color: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double p =
|
||||
activity.progress == null ? 0 : activity.progress!.toDouble() / 100;
|
||||
return CircularPercentIndicator(
|
||||
radius: 15.0,
|
||||
lineWidth: 5.0,
|
||||
percent: p,
|
||||
center: Text("${p * 100}"),
|
||||
progressColor: Colors.green,
|
||||
);
|
||||
}()),
|
||||
onDelete != null
|
||||
? DataCell(Tooltip(
|
||||
message: "删除任务",
|
||||
child: IconButton(
|
||||
onPressed: () => onDelete!(activity.id!),
|
||||
icon: const Icon(Icons.delete))))
|
||||
: const DataCell(Text("-"))
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isRowCountApproximate => false;
|
||||
|
||||
@override
|
||||
int get selectedRowCount => 0;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ class Activity {
|
||||
required this.targetDir,
|
||||
required this.status,
|
||||
required this.saved,
|
||||
required this.progress});
|
||||
required this.progress,
|
||||
required this.size});
|
||||
|
||||
final int? id;
|
||||
final int? mediaId;
|
||||
@@ -79,6 +80,7 @@ class Activity {
|
||||
final String? status;
|
||||
final String? saved;
|
||||
final int? progress;
|
||||
final int? size;
|
||||
|
||||
factory Activity.fromJson(Map<String, dynamic> json) {
|
||||
return Activity(
|
||||
@@ -90,6 +92,7 @@ class Activity {
|
||||
targetDir: json["target_dir"],
|
||||
status: json["status"],
|
||||
saved: json["saved"],
|
||||
progress: json["progress"]);
|
||||
progress: json["progress"],
|
||||
size: json["size"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,14 +317,6 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
percent_indicator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: percent_indicator
|
||||
sha256: c37099ad833a883c9d71782321cb65c3a848c21b6939b6185f0ff6640d05814c
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.2.3"
|
||||
phone_numbers_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -40,7 +40,6 @@ dependencies:
|
||||
flutter_riverpod: ^2.5.1
|
||||
quiver: ^3.2.1
|
||||
flutter_login: ^5.0.0
|
||||
percent_indicator: ^4.2.3
|
||||
intl: ^0.19.0
|
||||
flutter_adaptive_scaffold: ^0.1.11+1
|
||||
flutter_form_builder: ^9.3.0
|
||||
|
||||
Reference in New Issue
Block a user