WebUI 增加筛选

This commit is contained in:
Cp0204 2024-04-02 02:20:26 +08:00
parent 8c3603bcad
commit cacba43d65
2 changed files with 105 additions and 70 deletions

View File

@ -25,7 +25,7 @@ script_path = os.environ.get("SCRIPT_PATH", "./quark_auto_save.py")
config_path = os.environ.get("CONFIG_PATH", "./config/quark_config.json")
app = Flask(__name__)
app.config["APP_VERSION"] = "0.2.5.1"
app.config["APP_VERSION"] = "0.2.6"
app.secret_key = "ca943f6db6dd34823d36ab08d8d6f65d"
app.json.ensure_ascii = False
app.json.sort_keys = False

View File

@ -103,7 +103,22 @@
<h2>任务列表</h2>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">任务分类</label>
<div class="col-sm-10">
<select class="form-control" v-model="taskDirSelected">
<option v-for="(dir, index) in taskDirs" :value="dir" v-html="dir"></option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">名称筛选</label>
<div class="col-sm-10">
<input type="text" class="form-control mb-2" v-model="taskNameFilter">
</div>
</div>
<div v-for="(task, index) in formData.tasklist" :key="index" class="task mb-3">
<template v-if="(taskDirSelected == '' || getParentDirectory(task.savepath) == taskDirSelected) && task.taskname.includes(taskNameFilter)">
<hr>
<div class="form-group row">
<div class="col">
@ -165,6 +180,7 @@
<input type="number" name="emby_id[]" class="form-control mb-2" v-model="task.emby_id" placeholder="可选">
</div>
</div>
</template>
</div>
<div class="row">
<div class="col-sm-12 text-center">
@ -228,7 +244,20 @@
},
tasklist: []
},
run_log: ""
newTask: {
taskname: "",
shareurl: "",
savepath: "",
pattern: "",
replace: "",
enddate: "",
emby_id: "",
runweek: [1, 2, 3, 4, 5, 6, 7]
},
run_log: "",
taskDirs: [""],
taskDirSelected: "",
taskNameFilter: ""
},
watch: {
'formData.push_config': {
@ -263,6 +292,12 @@
}
return task;
});
// 存所有任务父目录
response.data.tasklist.forEach(item => {
parentDir = this.getParentDirectory(item.savepath)
if (!this.taskDirs.includes(parentDir))
this.taskDirs.push(parentDir);
});
this.formData = response.data;
})
.catch(error => {
@ -296,16 +331,10 @@
this.$delete(this.formData.push_config, key);
},
addTask() {
this.formData.tasklist.push({
taskname: "",
shareurl: "",
savepath: "",
pattern: "",
replace: "",
enddate: "",
emby_id: "",
runweek: [1, 2, 3, 4, 5, 6, 7]
});
newTask = { ...this.newTask }
newTask.taskname = this.taskNameFilter
newTask.savepath = this.taskDirSelected + "/" + newTask.taskname
this.formData.tasklist.push(newTask);
},
removeTask(index) {
if (confirm("确认删除吗?"))
@ -325,6 +354,12 @@
this.run_log = "错误:\n" + error
console.error('Error:', error);
});
},
getParentDirectory(path) {
parentDir = path.substring(0, path.lastIndexOf('/'))
if (parentDir == "")
parentDir = "/"
return parentDir;
}
}
});