|
|
@@ -31,6 +31,12 @@
|
|
|
.ID {
|
|
|
width: 10%;
|
|
|
}
|
|
|
+ .excel th,.excel td{
|
|
|
+ text-align: center;
|
|
|
+ font-size: 13px;
|
|
|
+ padding: 10px;
|
|
|
+ max-width: 200px!important;
|
|
|
+ }
|
|
|
</style>
|
|
|
</head>
|
|
|
|
|
|
@@ -43,7 +49,7 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="row" style="margin-top: 40px;">
|
|
|
-
|
|
|
+
|
|
|
<div class="col-md-7" id="taskInfo" style="margin:0 auto" v-if="show">
|
|
|
|
|
|
|
|
|
@@ -70,7 +76,80 @@
|
|
|
<!-- /.modal-content -->
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
+ <div class="modal fade" id="excelModal" tabindex="-1" role="dialog" aria-labelledby="excelModalLabel" aria-hidden="true">
|
|
|
+ <div class="modal-dialog modal-lg">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h4 class="modal-title" id="excelModalLabel">{{"Read from Excel~从Excel文件读取输入参数" | lang}}</h4>
|
|
|
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body">
|
|
|
+<!-- <form action="/upload" method="post" enctype="multipart/form-data">-->
|
|
|
+ <div>
|
|
|
+ <div class="form-group" style="margin-bottom: 10px">
|
|
|
+ <label>{{"Please select an Excel file (.xlsx)~请选择一个Excel文件(.xlsx)" | lang}}</label>
|
|
|
+ <input type="file" class="form-control-file" id="excelFile" name="file">
|
|
|
+ <label style="display: block; margin-top:10px;margin-bottom: 0">{{fileUploadStatus | lang}}</label>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <button @click="submitFile" class="btn btn-primary" style="min-width: 100px;margin-bottom:10px">{{"Upload~上传" | lang}}</button>
|
|
|
+
|
|
|
+<!-- </form>-->
|
|
|
+ </div>
|
|
|
+ <label style="margin:10px 0">{{"Please design an Excel file (.xlsx) according to the following format and upload it above.~请按照以下格式设计一个Excel文件(.xlsx),并在上方上传:" | lang}}</label>
|
|
|
+ <table class="table table-bordered excel" style="text-align: center; font-size: 13px">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th scope="col">{{"Invoke Name 1~调用名称1" | lang}}</th>
|
|
|
+ <th scope="col">{{"Invoke Name 2~调用名称2" | lang}}</th>
|
|
|
+ <th scope="col">...</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr>
|
|
|
+ <td>{{"Argument Value 1_1~参数值1_1" | lang}}</td>
|
|
|
+ <td>{{"Argument Value 2_1~参数值2_1" | lang}}</td>
|
|
|
+ <td>...</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td>{{"Argument Value 1_1~参数值1_2" | lang}}</td>
|
|
|
+ <td>{{"Argument Value 2_1~参数值2_2" | lang}}</td>
|
|
|
+ <td>...</td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ <label>{{"The 'Invoke Name' is shown at the main table of this page, such as 'urlList_0' is the invoke name of the open page operation.~“调用名称”在本页面的主表格中显示,例如“urlList_0”是“打开网页“操作的调用名称。" | lang}}</label>
|
|
|
+ <label>{{"You can just put part of the arguments in the Excel file, and the values of the rest of the arguments will be set to default. Example table for this task is:~您可以只在Excel文件中放入部分参数,其余参数值将被设置为默认值。一个针对此任务的表格示例为:" | lang}}</label>
|
|
|
+ <table class="table table-bordered excel">
|
|
|
+ <tbody>
|
|
|
+ <tr>
|
|
|
+ <td v-for="i in Math.min(3, task.inputParameters.length)" v-if="task.inputParameters.length>0">
|
|
|
+ {{task.inputParameters[i-1]["name"]}}
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <td v-for="i in Math.min(3, task.inputParameters.length)" v-if="task.inputParameters.length>0">
|
|
|
+ {{task.inputParameters[i-1]['value']}}
|
|
|
+ </td>
|
|
|
+ <tr>
|
|
|
+ <tr>
|
|
|
+ <td v-for="i in Math.min(3, task.inputParameters.length)">
|
|
|
+ <div v-if="task.inputParameters[i-1]['name'].indexOf('url') >=0">
|
|
|
+ {{task.inputParameters[i-1]['value']}}
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- /.modal-content -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
<nav aria-label="breadcrumb">
|
|
|
<ol class="breadcrumb" style="padding-left:0;background-color: white">
|
|
|
<li @click="gotoHome" class="breadcrumb-item"><a href="#">{{"Home~首页" | lang}}</a></li>
|
|
|
@@ -86,7 +165,10 @@
|
|
|
<p style="word-wrap: break-word;word-break: break-all;overflow: hidden;max-height: 100px;">{{"API URL (POST):~API 调用网址(POST):" |
|
|
|
lang}} {{backEndAddressServiceWrapper}}/invokeTask?id={{task["id"]}}</p>
|
|
|
<p style="word-wrap: break-word;word-break: break-all;overflow: hidden;max-height: 100px;">{{"Click here to see how to invoke task by API via POST request: ~点此查看通过POST方式进行API调用的示例代码:" | lang}}<a target="_blank" href="https://github.com/NaiboWang/EasySpider/wiki/API-Invoke-Example">https://github.com/NaiboWang/EasySpider/wiki/API-Invoke-Example</a></p>
|
|
|
- <p>{{"Please Input Parameters:~请输入参数值:" | lang}} </p>
|
|
|
+ <p><button class="btn btn-primary" @click="readFromExcel">{{"Read parameters from Excel file~从Excel文件读取输入参数"
|
|
|
+ | lang}}
|
|
|
+ </button></p>
|
|
|
+ <p>{{"Please Input Parameters:~请输入参数值:" | lang}}</p>
|
|
|
<form id="form">
|
|
|
<table class="table table-bordered">
|
|
|
<tbody>
|
|
|
@@ -161,7 +243,9 @@
|
|
|
task: {},
|
|
|
show: false, //是否渲染
|
|
|
ID: "",
|
|
|
+ file:null,
|
|
|
user_data_folder:"",
|
|
|
+ fileUploadStatus: "Status: Waiting for upload~状态:等待上传",
|
|
|
with_user_data: true,
|
|
|
backEndAddressServiceWrapper: getUrlParam("backEndAddressServiceWrapper"),
|
|
|
command: "./easyspider_executestage ",
|
|
|
@@ -190,7 +274,46 @@
|
|
|
url = "taskInfo.html?id="+getUrlParam("id")+"&lang=en&type="+getUrlParam("type")+"&wsport="+getUrlParam("wsport")+"&backEndAddressServiceWrapper=" + app.$data.backEndAddressServiceWrapper
|
|
|
}
|
|
|
window.location.href = url;
|
|
|
- }, invokeTask: function () {
|
|
|
+ }, readFromExcel: function(){
|
|
|
+ $('#excelModal').modal('show');
|
|
|
+ }, submitFile: function() {
|
|
|
+ let form_data = new FormData();
|
|
|
+ this.file = $('#excelFile').prop('files')[0];
|
|
|
+ if(this.file == null || $('#excelFile').val() == ""){
|
|
|
+ this.fileUploadStatus = "Status: Please select a file~状态:请选择文件";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.file.name.split('.').pop() !== 'xlsx' ) {
|
|
|
+ this.fileUploadStatus = "Status: Only xlsx files are allowed!~状态:只允许上传xlsx文件!";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // form_data.append('file', this.file);
|
|
|
+ form_data.append('file', $('#excelFile').prop('files')[0]);
|
|
|
+ // console.log(app.$data.backEndAddressServiceWrapper + "/excelUpload",)
|
|
|
+ $.ajax({
|
|
|
+ url: app.$data.backEndAddressServiceWrapper.replace("8074","8075") + "/excelUpload",
|
|
|
+ type: 'POST',
|
|
|
+ data: form_data,
|
|
|
+ processData: false,
|
|
|
+ contentType: false,
|
|
|
+ success: function(response) {
|
|
|
+ response = JSON.parse(response);
|
|
|
+ $('#excelModal').modal('hide');
|
|
|
+ app.$data.fileUploadStatus = "Status: Upload successfully~状态:上传成功";
|
|
|
+ $('#excelFile').val("");
|
|
|
+ let inputParameters = app.$data.task.inputParameters;
|
|
|
+ inputParameters.forEach(function (item, index) {
|
|
|
+ if(Object.keys(response).includes(item.name)){
|
|
|
+ item.value = "\r\n".join(response[item.name]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ error: function(err) {
|
|
|
+ app.$data.fileUploadStatus = "Status: Upload failed~状态:上传失败";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ invokeTask: function () {
|
|
|
let text = "";
|
|
|
// if (getUrlParam("lang") == "en" || getUrlParam("lang") == "") {
|
|
|
// text = "Are you sure to get the Execution ID (EID) of current running task?";
|
|
|
@@ -257,7 +380,7 @@
|
|
|
// } else {
|
|
|
// text = "确定要立即在本地运行此任务吗?";
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
this.with_user_data = with_user_data;
|
|
|
// if (confirm(text)) {
|
|
|
let para = {};
|
|
|
@@ -292,7 +415,7 @@
|
|
|
},
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
function changeCommand() {
|
|
|
$.get(app.$data.backEndAddressServiceWrapper + "/queryOSVersion", function (OSInfo) {
|
|
|
if(OSInfo.version == 'win32' && OSInfo.bit == 'x64'){
|
|
|
@@ -316,7 +439,7 @@
|
|
|
app.$data.task = result;
|
|
|
app.$data.show = true;
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
ws = new WebSocket("ws://localhost:"+getUrlParam("wsport"));
|
|
|
ws.onopen = function () {
|
|
|
// Web Socket 已连接上,使用 send() 方法发送数据
|
|
|
@@ -338,4 +461,4 @@
|
|
|
// 关闭 websocket
|
|
|
console.log("连接已关闭...");
|
|
|
};
|
|
|
-</script>
|
|
|
+</script>
|