mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
新增任务详情页
This commit is contained in:
@@ -8,7 +8,6 @@ import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
|||||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
|
||||||
|
|
||||||
import 'url.dart';
|
import 'url.dart';
|
||||||
|
|
||||||
@@ -58,24 +57,17 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<TaskDetailBean>> taskDetail(String cron) async {
|
static Future<HttpResponse<NullResponse>> addTask(String name, String command, String cron, {String? id}) async {
|
||||||
return await Http.get<TaskDetailBean>(
|
|
||||||
Url.taskDetail + cron,
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<HttpResponse<TaskDetailBean>> addTask(String name, String command, String cron, {String? id}) async {
|
|
||||||
var data = {"name": name, "command": command, "schedule": cron};
|
var data = {"name": name, "command": command, "schedule": cron};
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
data["_id"] = id;
|
data["_id"] = id;
|
||||||
return await Http.put<TaskDetailBean>(
|
return await Http.put<NullResponse>(
|
||||||
Url.addTask,
|
Url.addTask,
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return await Http.post<TaskDetailBean>(
|
return await Http.post<NullResponse>(
|
||||||
Url.addTask,
|
Url.addTask,
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ import 'package:qinglong_app/module/others/task_log/task_log_detail_page.dart';
|
|||||||
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
|
||||||
import 'package:qinglong_app/module/task/add_task_page.dart';
|
import 'package:qinglong_app/module/task/add_task_page.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
|
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
|
||||||
|
|
||||||
class Routes {
|
class Routes {
|
||||||
static const String routeHomePage = "/home/homepage";
|
static const String routeHomePage = "/home/homepage";
|
||||||
static const String routeLogin = "/login";
|
static const String routeLogin = "/login";
|
||||||
static const String routeAddTask = "/task/add";
|
static const String routeAddTask = "/task/add";
|
||||||
|
static const String routeTaskDetail = "/task/detail";
|
||||||
static const String routeAddDependency = "/task/dependency";
|
static const String routeAddDependency = "/task/dependency";
|
||||||
static const String routeAddEnv = "/env/add";
|
static const String routeAddEnv = "/env/add";
|
||||||
static const String routeConfigEdit = "/config/edit";
|
static const String routeConfigEdit = "/config/edit";
|
||||||
@@ -45,7 +47,7 @@ class Routes {
|
|||||||
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
||||||
}
|
}
|
||||||
case routeAddDependency:
|
case routeAddDependency:
|
||||||
return CupertinoPageRoute(builder: (context) => const AddDependenyPage());
|
return CupertinoPageRoute(builder: (context) => const AddDependenyPage());
|
||||||
case routeAddEnv:
|
case routeAddEnv:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
@@ -91,6 +93,12 @@ class Routes {
|
|||||||
path: (settings.arguments as Map)["path"],
|
path: (settings.arguments as Map)["path"],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
case routeTaskDetail:
|
||||||
|
return CupertinoPageRoute(
|
||||||
|
builder: (context) => TaskDetailPage(
|
||||||
|
settings.arguments as TaskBean,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
1216
lib/base/ui/ql_context_menu.dart
Normal file
1216
lib/base/ui/ql_context_menu.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,6 @@ import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
|
|||||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class JsonConversion$Json {
|
class JsonConversion$Json {
|
||||||
@@ -61,11 +60,7 @@ class JsonConversion$Json {
|
|||||||
if(type == (TaskBean).toString()){
|
if(type == (TaskBean).toString()){
|
||||||
return TaskBean.jsonConversion(json) as M;
|
return TaskBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (TaskDetailBean).toString()){
|
|
||||||
return TaskDetailBean.jsonConversion(json) as M;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw Exception("not found");
|
throw Exception("not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,11 +100,7 @@ class JsonConversion$Json {
|
|||||||
if(<TaskBean>[] is M){
|
if(<TaskBean>[] is M){
|
||||||
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList() as M;
|
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<TaskDetailBean>[] is M){
|
|
||||||
return data.map<TaskDetailBean>((e) => TaskDetailBean.jsonConversion(e)).toList() as M;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw Exception("not found");
|
throw Exception("not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import 'package:qinglong_app/base/http/api.dart';
|
|||||||
import 'package:qinglong_app/base/http/http.dart';
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
import 'package:qinglong_app/module/others/dependencies/dependency_viewmodel.dart';
|
import 'package:qinglong_app/module/others/dependencies/dependency_viewmodel.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
|
||||||
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
|
||||||
import 'package:qinglong_app/utils/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
class AddDependenyPage extends ConsumerStatefulWidget {
|
class AddDependenyPage extends ConsumerStatefulWidget {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:qinglong_app/base/http/api.dart';
|
|||||||
import 'package:qinglong_app/base/http/http.dart';
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
|
||||||
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
||||||
import 'package:qinglong_app/utils/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
@@ -202,7 +201,7 @@ class _AddTaskPageState extends ConsumerState<AddTaskPage> {
|
|||||||
taskBean.name = _nameController.text;
|
taskBean.name = _nameController.text;
|
||||||
taskBean.command = _commandController.text;
|
taskBean.command = _commandController.text;
|
||||||
taskBean.schedule = _cronController.text;
|
taskBean.schedule = _cronController.text;
|
||||||
HttpResponse<TaskDetailBean> response = await Api.addTask(
|
HttpResponse<NullResponse> response = await Api.addTask(
|
||||||
_nameController.text, _commandController.text, _cronController.text,
|
_nameController.text, _commandController.text, _cronController.text,
|
||||||
id: taskBean.sId);
|
id: taskBean.sId);
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
|
|
||||||
|
|
||||||
@JsonConversion()
|
|
||||||
class TaskDetailBean {
|
|
||||||
String? name;
|
|
||||||
String? command;
|
|
||||||
String? schedule;
|
|
||||||
bool? saved;
|
|
||||||
String? sId;
|
|
||||||
int? created;
|
|
||||||
int? status;
|
|
||||||
String? timestamp;
|
|
||||||
int? isSystem;
|
|
||||||
int? isDisabled;
|
|
||||||
String? logPath;
|
|
||||||
int? isPinned;
|
|
||||||
|
|
||||||
TaskDetailBean(
|
|
||||||
{this.name,
|
|
||||||
this.command,
|
|
||||||
this.schedule,
|
|
||||||
this.saved,
|
|
||||||
this.sId,
|
|
||||||
this.created,
|
|
||||||
this.status,
|
|
||||||
this.timestamp,
|
|
||||||
this.isSystem,
|
|
||||||
this.isDisabled,
|
|
||||||
this.logPath,
|
|
||||||
this.isPinned});
|
|
||||||
|
|
||||||
TaskDetailBean.fromJson(Map<String, dynamic> json) {
|
|
||||||
name = json['name'];
|
|
||||||
command = json['command'];
|
|
||||||
schedule = json['schedule'];
|
|
||||||
saved = json['saved'];
|
|
||||||
sId = json['_id'];
|
|
||||||
created = json['created'];
|
|
||||||
status = json['status'];
|
|
||||||
timestamp = json['timestamp'];
|
|
||||||
isSystem = json['isSystem'];
|
|
||||||
isDisabled = json['isDisabled'];
|
|
||||||
logPath = json['log_path'];
|
|
||||||
isPinned = json['isPinned'];
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
||||||
data['name'] = this.name;
|
|
||||||
data['command'] = this.command;
|
|
||||||
data['schedule'] = this.schedule;
|
|
||||||
data['saved'] = this.saved;
|
|
||||||
data['_id'] = this.sId;
|
|
||||||
data['created'] = this.created;
|
|
||||||
data['status'] = this.status;
|
|
||||||
data['timestamp'] = this.timestamp;
|
|
||||||
data['isSystem'] = this.isSystem;
|
|
||||||
data['isDisabled'] = this.isDisabled;
|
|
||||||
data['log_path'] = this.logPath;
|
|
||||||
data['isPinned'] = this.isPinned;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TaskDetailBean jsonConversion(Map<String, dynamic> json) {
|
|
||||||
return TaskDetailBean.fromJson(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:qinglong_app/base/base_state_widget.dart';
|
|
||||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/module/task/intime_log/intime_log_page.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_viewmodel.dart';
|
import 'package:qinglong_app/utils/utils.dart';
|
||||||
|
|
||||||
class TaskDetailPage extends ConsumerStatefulWidget {
|
class TaskDetailPage extends ConsumerStatefulWidget {
|
||||||
final TaskBean taskBean;
|
final TaskBean taskBean;
|
||||||
@@ -20,17 +22,181 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: QlAppBar(
|
appBar: QlAppBar(
|
||||||
canBack: true,
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
title: widget.taskBean.name ?? "",
|
title: widget.taskBean.name ?? "",
|
||||||
),
|
),
|
||||||
body: BaseStateWidget<TaskDetailViewModel>(
|
body: SingleChildScrollView(
|
||||||
model: taskDetailProvider,
|
child: Container(
|
||||||
builder: (WidgetRef context, TaskDetailViewModel value, Widget? child) {
|
margin: const EdgeInsets.symmetric(
|
||||||
return Container();
|
horizontal: 15,
|
||||||
},
|
vertical: 10,
|
||||||
onReady: (model) {
|
),
|
||||||
model.loadDetail(widget.taskBean.sId!);
|
padding: const EdgeInsets.only(
|
||||||
},
|
top: 10,
|
||||||
|
bottom: 10,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "ID",
|
||||||
|
desc: widget.taskBean.sId ?? "",
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "任务",
|
||||||
|
desc: widget.taskBean.command ?? "",
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "创建时间",
|
||||||
|
desc: Utils.formatMessageTime(widget.taskBean.created ?? 0),
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "任务定时",
|
||||||
|
desc: widget.taskBean.schedule ?? "",
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "最后运行时间",
|
||||||
|
desc: Utils.formatMessageTime(widget.taskBean.lastExecutionTime ?? 0),
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "最后运行时长",
|
||||||
|
desc: widget.taskBean.lastRunningTime == null ? "-" : "${widget.taskBean.lastRunningTime ?? "-"}秒",
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () {
|
||||||
|
showLog();
|
||||||
|
},
|
||||||
|
child: TaskDetailCell(
|
||||||
|
title: "日志路径",
|
||||||
|
desc: widget.taskBean.logPath ?? "-",
|
||||||
|
taped: () {
|
||||||
|
showLog();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "运行状态",
|
||||||
|
desc: widget.taskBean.status == 0 ? "正在运行" : "空闲",
|
||||||
|
),
|
||||||
|
TaskDetailCell(
|
||||||
|
title: "脚本状态",
|
||||||
|
desc: widget.taskBean.isDisabled == 1 ? "已禁用" : "正常",
|
||||||
|
hideDivide: true,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showLog() {
|
||||||
|
showCupertinoDialog(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return CupertinoAlertDialog(
|
||||||
|
title: Text(
|
||||||
|
"${widget.taskBean.name}运行日志",
|
||||||
|
maxLines: 1,
|
||||||
|
style: const TextStyle(overflow: TextOverflow.ellipsis),
|
||||||
|
),
|
||||||
|
content: InTimeLogPage(widget.taskBean.sId!, widget.taskBean.status == 0),
|
||||||
|
actions: [
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text(
|
||||||
|
"知道了",
|
||||||
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
context: context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TaskDetailCell extends ConsumerWidget {
|
||||||
|
final String title;
|
||||||
|
final String? desc;
|
||||||
|
final Widget? icon;
|
||||||
|
final bool hideDivide;
|
||||||
|
final Function? taped;
|
||||||
|
|
||||||
|
const TaskDetailCell({
|
||||||
|
Key? key,
|
||||||
|
required this.title,
|
||||||
|
this.desc,
|
||||||
|
this.icon,
|
||||||
|
this.hideDivide = false,
|
||||||
|
this.taped,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 10,
|
||||||
|
left: 15,
|
||||||
|
right: 10,
|
||||||
|
bottom: 10,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 30,
|
||||||
|
),
|
||||||
|
desc != null
|
||||||
|
? Expanded(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: SelectableText(
|
||||||
|
desc!,
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
onTap: () {
|
||||||
|
if (taped != null) {
|
||||||
|
taped!();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Expanded(
|
||||||
|
child: Align(alignment: Alignment.centerRight, child: icon!),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
hideDivide
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: const Divider(
|
||||||
|
indent: 15,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:qinglong_app/base/base_viewmodel.dart';
|
|
||||||
import 'package:qinglong_app/base/http/api.dart';
|
|
||||||
import 'package:qinglong_app/base/http/http.dart';
|
|
||||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
|
||||||
|
|
||||||
var taskDetailProvider =
|
|
||||||
AutoDisposeChangeNotifierProvider<TaskDetailViewModel>((ref) {
|
|
||||||
return TaskDetailViewModel();
|
|
||||||
});
|
|
||||||
|
|
||||||
class TaskDetailViewModel extends BaseViewModel {
|
|
||||||
TaskDetailBean? bean;
|
|
||||||
|
|
||||||
TaskDetailViewModel();
|
|
||||||
|
|
||||||
Future<void> loadDetail(String id) async {
|
|
||||||
loading(notify: true);
|
|
||||||
|
|
||||||
HttpResponse<TaskDetailBean> response = await Api.taskDetail(id);
|
|
||||||
|
|
||||||
if (response.success) {
|
|
||||||
bean = response.bean;
|
|
||||||
success();
|
|
||||||
} else {
|
|
||||||
failed(response.message, notify: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,7 @@ import 'package:qinglong_app/base/theme.dart';
|
|||||||
import 'package:qinglong_app/base/ui/abs_underline_tabindicator.dart';
|
import 'package:qinglong_app/base/ui/abs_underline_tabindicator.dart';
|
||||||
import 'package:qinglong_app/base/ui/empty_widget.dart';
|
import 'package:qinglong_app/base/ui/empty_widget.dart';
|
||||||
import 'package:qinglong_app/base/ui/menu.dart';
|
import 'package:qinglong_app/base/ui/menu.dart';
|
||||||
|
import 'package:qinglong_app/base/ui/ql_context_menu.dart';
|
||||||
import 'package:qinglong_app/module/task/intime_log/intime_log_page.dart';
|
import 'package:qinglong_app/module/task/intime_log/intime_log_page.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
||||||
@@ -103,8 +104,7 @@ class _TaskPageState extends State<TaskPage> {
|
|||||||
if (_searchController.text.isEmpty ||
|
if (_searchController.text.isEmpty ||
|
||||||
(item.name?.contains(_searchController.text) ?? false) ||
|
(item.name?.contains(_searchController.text) ?? false) ||
|
||||||
(item.command?.contains(_searchController.text) ?? false) ||
|
(item.command?.contains(_searchController.text) ?? false) ||
|
||||||
(item.schedule?.contains(_searchController.text) ??
|
(item.schedule?.contains(_searchController.text) ?? false)) {
|
||||||
false)) {
|
|
||||||
return TaskItemCell(item, ref);
|
return TaskItemCell(item, ref);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@@ -162,21 +162,20 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
final TaskBean bean;
|
final TaskBean bean;
|
||||||
final WidgetRef ref;
|
final WidgetRef ref;
|
||||||
|
|
||||||
const TaskItemCell(this.bean, this.ref, {Key? key}) : super(key: key);
|
TaskItemCell(this.bean, this.ref, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: CupertinoContextMenu(
|
child: QlCupertinoContextMenu(
|
||||||
|
bean: bean,
|
||||||
actions: [
|
actions: [
|
||||||
QLCupertinoContextMenuAction(
|
QLCupertinoContextMenuAction(
|
||||||
child: Text(
|
child: Text(
|
||||||
bean.status! == 1 ? "运行" : "停止运行",
|
bean.status! == 1 ? "运行" : "停止运行",
|
||||||
),
|
),
|
||||||
trailingIcon: bean.status! == 1
|
trailingIcon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
||||||
? CupertinoIcons.memories
|
|
||||||
: CupertinoIcons.stop_circle,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
startCron(context, ref);
|
startCron(context, ref);
|
||||||
@@ -194,8 +193,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
child: const Text("编辑"),
|
child: const Text("编辑"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context)
|
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean);
|
||||||
.pushNamed(Routes.routeAddTask, arguments: bean);
|
|
||||||
},
|
},
|
||||||
trailingIcon: CupertinoIcons.pencil_outline,
|
trailingIcon: CupertinoIcons.pencil_outline,
|
||||||
),
|
),
|
||||||
@@ -205,9 +203,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
pinTask();
|
pinTask();
|
||||||
},
|
},
|
||||||
trailingIcon: bean.isPinned! == 0
|
trailingIcon: bean.isPinned! == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
||||||
? CupertinoIcons.pin
|
|
||||||
: CupertinoIcons.pin_slash,
|
|
||||||
),
|
),
|
||||||
QLCupertinoContextMenuAction(
|
QLCupertinoContextMenuAction(
|
||||||
child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"),
|
child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"),
|
||||||
@@ -216,9 +212,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
enableTask();
|
enableTask();
|
||||||
},
|
},
|
||||||
isDestructiveAction: true,
|
isDestructiveAction: true,
|
||||||
trailingIcon: bean.isDisabled! == 0
|
trailingIcon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
? Icons.dnd_forwardslash
|
|
||||||
: Icons.check_circle_outline_sharp,
|
|
||||||
),
|
),
|
||||||
QLCupertinoContextMenuAction(
|
QLCupertinoContextMenuAction(
|
||||||
child: const Text("删除"),
|
child: const Text("删除"),
|
||||||
@@ -242,8 +236,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color:
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
ref.watch(themeProvider).themeColor.titleColor(),
|
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -267,9 +260,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
color: bean.isPinned == 1
|
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
|
||||||
? ref.watch(themeProvider).themeColor.pinColor()
|
|
||||||
: Colors.transparent,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
vertical: 8,
|
vertical: 8,
|
||||||
@@ -289,10 +280,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: ref
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
.watch(themeProvider)
|
|
||||||
.themeColor
|
|
||||||
.titleColor(),
|
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -313,16 +301,11 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
Material(
|
Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
(bean.lastExecutionTime == null ||
|
(bean.lastExecutionTime == null || bean.lastExecutionTime == 0) ? "-" : Utils.formatMessageTime(bean.lastExecutionTime!),
|
||||||
bean.lastExecutionTime == 0)
|
|
||||||
? "-"
|
|
||||||
: Utils.formatMessageTime(
|
|
||||||
bean.lastExecutionTime!),
|
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color:
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -341,8 +324,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color:
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -373,53 +355,11 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startCron(BuildContext context, WidgetRef ref) {
|
startCron(BuildContext context, WidgetRef ref) {
|
||||||
showCupertinoDialog(
|
ref.read(taskProvider).runCrons(bean.sId!);
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoAlertDialog(
|
|
||||||
title: const Text("确认运行"),
|
|
||||||
content: Text("确认运行定时任务 ${bean.name ?? ""} 吗"),
|
|
||||||
actions: [
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: const Text("取消"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: const Text("确定"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ref.read(taskProvider).runCrons(bean.sId!);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopCron(BuildContext context, WidgetRef ref) {
|
stopCron(BuildContext context, WidgetRef ref) {
|
||||||
showCupertinoDialog(
|
ref.read(taskProvider).stopCrons(bean.sId!);
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoAlertDialog(
|
|
||||||
title: const Text("确认停止"),
|
|
||||||
content: Text("确认停止定时任务 ${bean.name ?? ""} 吗"),
|
|
||||||
actions: [
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: const Text("取消"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: const Text("确定"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ref.read(taskProvider).stopCrons(bean.sId!);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logCron(BuildContext context, WidgetRef ref) {
|
logCron(BuildContext context, WidgetRef ref) {
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String formatMessageTime(int time) {
|
static String formatMessageTime(int time) {
|
||||||
|
if(time == 0){
|
||||||
|
return "-";
|
||||||
|
}
|
||||||
DateTime current = DateTime.now();
|
DateTime current = DateTime.now();
|
||||||
DateTime chatTime;
|
DateTime chatTime;
|
||||||
if (time.toString().length == 10) {
|
if (time.toString().length == 10) {
|
||||||
|
|||||||
Reference in New Issue
Block a user