mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
依赖管理支持批量添加
This commit is contained in:
@@ -89,24 +89,21 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> startTasks(
|
static Future<HttpResponse<NullResponse>> startTasks(List<String> crons) async {
|
||||||
List<String> crons) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.runTasks,
|
Url.runTasks,
|
||||||
crons,
|
crons,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> stopTasks(
|
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
||||||
List<String> crons) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.stopTasks,
|
Url.stopTasks,
|
||||||
crons,
|
crons,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> updatePassword(
|
static Future<HttpResponse<NullResponse>> updatePassword(String name, String password) async {
|
||||||
String name, String password) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.updatePassword,
|
Url.updatePassword,
|
||||||
{
|
{
|
||||||
@@ -130,11 +127,7 @@ class Api {
|
|||||||
int? id,
|
int? id,
|
||||||
String? nId,
|
String? nId,
|
||||||
}) async {
|
}) async {
|
||||||
var data = <String, dynamic>{
|
var data = <String, dynamic>{"name": name, "command": command, "schedule": cron};
|
||||||
"name": name,
|
|
||||||
"command": command,
|
|
||||||
"schedule": cron
|
|
||||||
};
|
|
||||||
|
|
||||||
if (id != null || nId != null) {
|
if (id != null || nId != null) {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@@ -202,8 +195,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> saveFile(
|
static Future<HttpResponse<NullResponse>> saveFile(String name, String content) async {
|
||||||
String name, String content) async {
|
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.saveFile,
|
Url.saveFile,
|
||||||
{"content": content, "name": name},
|
{"content": content, "name": name},
|
||||||
@@ -268,8 +260,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> moveEnv(
|
static Future<HttpResponse<NullResponse>> moveEnv(String id, int fromIndex, int toIndex) async {
|
||||||
String id, int fromIndex, int toIndex) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.envMove(id),
|
Url.envMove(id),
|
||||||
{"fromIndex": fromIndex, "toIndex": toIndex},
|
{"fromIndex": fromIndex, "toIndex": toIndex},
|
||||||
@@ -284,12 +275,10 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
||||||
return await Http.get<List<TaskLogBean>>(Url.taskLog, null,
|
return await Http.get<List<TaskLogBean>>(Url.taskLog, null, serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs");
|
||||||
serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> taskLogDetail(
|
static Future<HttpResponse<String>> taskLogDetail(String name, String path) async {
|
||||||
String name, String path) async {
|
|
||||||
if (Utils.isUpperVersion2_13_0()) {
|
if (Utils.isUpperVersion2_13_0()) {
|
||||||
return await Http.get<String>(
|
return await Http.get<String>(
|
||||||
Url.taskLogDetail + name + "?path=" + path,
|
Url.taskLogDetail + name + "?path=" + path,
|
||||||
@@ -311,8 +300,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> updateScript(
|
static Future<HttpResponse<NullResponse>> updateScript(String name, String path, String content) async {
|
||||||
String name, String path, String content) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.scriptDetail,
|
Url.scriptDetail,
|
||||||
{
|
{
|
||||||
@@ -323,8 +311,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> delScript(
|
static Future<HttpResponse<NullResponse>> delScript(String name, String path) async {
|
||||||
String name, String path) async {
|
|
||||||
return await Http.delete<NullResponse>(
|
return await Http.delete<NullResponse>(
|
||||||
Url.scriptDetail,
|
Url.scriptDetail,
|
||||||
{
|
{
|
||||||
@@ -334,8 +321,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> scriptDetail(
|
static Future<HttpResponse<String>> scriptDetail(String name, String? path) async {
|
||||||
String name, String? path) async {
|
|
||||||
return await Http.get<String>(
|
return await Http.get<String>(
|
||||||
Url.scriptDetail + name,
|
Url.scriptDetail + name,
|
||||||
{
|
{
|
||||||
@@ -344,8 +330,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<DependencyBean>>> dependencies(
|
static Future<HttpResponse<List<DependencyBean>>> dependencies(String type) async {
|
||||||
String type) async {
|
|
||||||
return await Http.get<List<DependencyBean>>(
|
return await Http.get<List<DependencyBean>>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
{
|
{
|
||||||
@@ -354,8 +339,7 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> dependencyReinstall(
|
static Future<HttpResponse<NullResponse>> dependencyReinstall(String id) async {
|
||||||
String id) async {
|
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
[id],
|
[id],
|
||||||
@@ -369,21 +353,14 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addDependency(
|
static Future<HttpResponse<NullResponse>> addDependency(List<Map<String, dynamic>> list) async {
|
||||||
String name, int type) async {
|
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
[
|
list,
|
||||||
{
|
|
||||||
"name": name,
|
|
||||||
"type": type,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addScript(
|
static Future<HttpResponse<NullResponse>> addScript(String name, String path, String content) async {
|
||||||
String name, String path, String content) async {
|
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.addScript,
|
Url.addScript,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ class _AddDependencyPageState extends ConsumerState<AddDependencyPage> {
|
|||||||
),
|
),
|
||||||
TextField(
|
TextField(
|
||||||
controller: _nameController,
|
controller: _nameController,
|
||||||
|
maxLines: 10,
|
||||||
|
minLines: 1,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||||
hintText: "请输入名称",
|
hintText: "请输入名称",
|
||||||
@@ -149,10 +151,18 @@ class _AddDependencyPageState extends ConsumerState<AddDependencyPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpResponse<NullResponse> response = await Api.addDependency(
|
List<Map<String, dynamic>> list = [];
|
||||||
_nameController.text,
|
|
||||||
depedencyType.index,
|
List<String> names = _nameController.text.split("\n");
|
||||||
);
|
list.addAll(names
|
||||||
|
.map(
|
||||||
|
(e) => {
|
||||||
|
"name": e,
|
||||||
|
"type": depedencyType.index,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.toList());
|
||||||
|
HttpResponse<NullResponse> response = await Api.addDependency(list);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
"新增成功".toast();
|
"新增成功".toast();
|
||||||
|
|||||||
Reference in New Issue
Block a user