mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 15:10:49 +08:00
feat: change single episode monitoring status
This commit is contained in:
5
db/db.go
5
db/db.go
@@ -552,3 +552,8 @@ func (c *Client) GetMovieDummyEpisode(movieId int) (*ent.Episode, error) {
|
||||
func (c *Client) GetDownloadClient(id int) (*ent.DownloadClients, error) {
|
||||
return c.ent.DownloadClients.Query().Where(downloadclients.ID(id)).First(context.Background())
|
||||
}
|
||||
|
||||
|
||||
func (c *Client) SetEpisodeMonitoring(id int, b bool) error {
|
||||
return c.ent.Episode.Update().Where(episode.ID(id)).SetMonitored(b).Exec(context.Background())
|
||||
}
|
||||
@@ -67,6 +67,7 @@ func (s *Server) Serve() error {
|
||||
setting.GET("/about", HttpHandler(s.About))
|
||||
setting.POST("/parse/tv", HttpHandler(s.ParseTv))
|
||||
setting.POST("/parse/movie", HttpHandler(s.ParseMovie))
|
||||
setting.POST("/monitoring", HttpHandler(s.ChangeEpisodeMonitoring))
|
||||
}
|
||||
activity := api.Group("/activity")
|
||||
{
|
||||
|
||||
@@ -193,3 +193,17 @@ func (s *Server) DeleteDownloadCLient(c *gin.Context) (interface{}, error) {
|
||||
s.db.DeleteDownloadCLient(id)
|
||||
return "success", nil
|
||||
}
|
||||
|
||||
type episodeMonitoringIn struct {
|
||||
EpisodeID int `json:"episode_id"`
|
||||
Monitor bool `json:"monitor"`
|
||||
}
|
||||
|
||||
func (s *Server) ChangeEpisodeMonitoring(c *gin.Context) (interface{}, error) {
|
||||
var in episodeMonitoringIn
|
||||
if err := c.ShouldBindJSON(&in); err != nil {
|
||||
return nil, errors.Wrap(err, "bind")
|
||||
}
|
||||
s.db.SetEpisodeMonitoring(in.EpisodeID, in.Monitor)
|
||||
return "success", nil
|
||||
}
|
||||
@@ -35,7 +35,8 @@ CustomTransitionPage buildPageWithDefaultTransition<T>({
|
||||
reverseTransitionDuration: Duration.zero,
|
||||
key: state.pageKey,
|
||||
child: child,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) => child,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
||||
child,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -123,14 +124,22 @@ class _MyAppState extends ConsumerState<MyApp> {
|
||||
child: MaterialApp.router(
|
||||
title: 'Polaris 影视追踪下载',
|
||||
theme: ThemeData(
|
||||
fontFamily: "NotoSansSC",
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.blueAccent,
|
||||
brightness: Brightness.dark,
|
||||
surface: Colors.black54),
|
||||
useMaterial3: true,
|
||||
//scaffoldBackgroundColor: Color.fromARGB(255, 26, 24, 24)
|
||||
),
|
||||
fontFamily: "NotoSansSC",
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.blueAccent,
|
||||
brightness: Brightness.dark,
|
||||
surface: Colors.black54),
|
||||
useMaterial3: true,
|
||||
//scaffoldBackgroundColor: Color.fromARGB(255, 26, 24, 24)
|
||||
tooltipTheme: TooltipThemeData(
|
||||
textStyle: const TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black54,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
)),
|
||||
routerConfig: router,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -33,6 +33,7 @@ class APIs {
|
||||
static final logsBaseUrl = "$_baseUrl/api/v1/logs/";
|
||||
static final logFilesUrl = "$_baseUrl/api/v1/setting/logfiles";
|
||||
static final aboutUrl = "$_baseUrl/api/v1/setting/about";
|
||||
static final changeMonitoringUrl = "$_baseUrl/api/v1/setting/monitoring";
|
||||
|
||||
static final notifierAllUrl = "$_baseUrl/api/v1/notifier/all";
|
||||
static final notifierDeleteUrl = "$_baseUrl/api/v1/notifier/id/";
|
||||
|
||||
@@ -48,6 +48,19 @@ class SeriesDetailData
|
||||
var name = (sp.data as Map<String, dynamic>)["name"];
|
||||
return name;
|
||||
}
|
||||
|
||||
Future<void> changeMonitoringStatus(int episodeId, bool b) async {
|
||||
final dio = APIs.getDio();
|
||||
var resp = await dio.post(APIs.changeMonitoringUrl, data: {
|
||||
"episode_id": episodeId,
|
||||
"monitor": b,
|
||||
});
|
||||
var sp = ServerResponse.fromJson(resp.data);
|
||||
if (sp.code != 0) {
|
||||
throw sp.message;
|
||||
}
|
||||
ref.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
class SeriesDetails {
|
||||
|
||||
@@ -57,15 +57,33 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
|
||||
child: Icon(Icons.download_done),
|
||||
)
|
||||
: (ep.monitored == true
|
||||
? const Tooltip(
|
||||
? Tooltip(
|
||||
message: "监控中",
|
||||
child: Icon(Icons.alarm),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(mediaDetailsProvider(
|
||||
widget.seriesId)
|
||||
.notifier)
|
||||
.changeMonitoringStatus(
|
||||
ep.id!, false);
|
||||
},
|
||||
icon: const Icon(Icons.alarm)),
|
||||
)
|
||||
: const Opacity(
|
||||
: Opacity(
|
||||
opacity: 0.7,
|
||||
child: Tooltip(
|
||||
message: "未监控",
|
||||
child: Icon(Icons.alarm_off),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(mediaDetailsProvider(
|
||||
widget.seriesId)
|
||||
.notifier)
|
||||
.changeMonitoringStatus(
|
||||
ep.id!, true);
|
||||
},
|
||||
icon: const Icon(Icons.alarm_off)),
|
||||
),
|
||||
)))),
|
||||
),
|
||||
@@ -88,10 +106,10 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
IconButton(
|
||||
Tooltip(message: "查看可用资源",child: IconButton(
|
||||
onPressed: () => showAvailableTorrents(widget.seriesId,
|
||||
ep.seasonNumber ?? 0, ep.episodeNumber ?? 0),
|
||||
icon: const Icon(Icons.manage_search))
|
||||
icon: const Icon(Icons.manage_search)),)
|
||||
],
|
||||
))
|
||||
]);
|
||||
@@ -136,10 +154,10 @@ class _TvDetailsPageState extends ConsumerState<TvDetailsPage> {
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
IconButton(
|
||||
Tooltip(message: "查看可用资源",child: IconButton(
|
||||
onPressed: () =>
|
||||
showAvailableTorrents(widget.seriesId, k, 0),
|
||||
icon: const Icon(Icons.manage_search))
|
||||
icon: const Icon(Icons.manage_search)),)
|
||||
],
|
||||
))
|
||||
], rows: m[k]!),
|
||||
|
||||
@@ -68,13 +68,10 @@ class _DetailCardState extends ConsumerState<DetailCard> {
|
||||
const SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
Text(
|
||||
Expanded(child: Text(
|
||||
"${widget.details.mediaType == "tv" ? widget.details.storage!.tvPath : widget.details.storage!.moviePath}"
|
||||
"${widget.details.targetDir}"),
|
||||
const SizedBox(
|
||||
width: 30,
|
||||
),
|
||||
],
|
||||
"${widget.details.targetDir}"),)
|
||||
],
|
||||
),
|
||||
const Divider(thickness: 1, height: 1),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user