From 8bad2c49b1404849f5b60aa43ab55ced13416d5c Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Wed, 17 Apr 2019 12:53:19 +0800 Subject: [PATCH] added schedule functionality --- crawlab/routes/base.py | 13 +-- crawlab/routes/schedules.py | 2 + frontend/src/views/schedule/ScheduleList.vue | 88 ++++++++++++++++++-- 3 files changed, 89 insertions(+), 14 deletions(-) diff --git a/crawlab/routes/base.py b/crawlab/routes/base.py index 689b8f6a..8a3d6709 100644 --- a/crawlab/routes/base.py +++ b/crawlab/routes/base.py @@ -38,8 +38,8 @@ class BaseApi(Resource): :param action: :return: """ - import pdb - pdb.set_trace() + # import pdb + # pdb.set_trace() args = self.parser.parse_args() # action by id @@ -85,13 +85,13 @@ class BaseApi(Resource): # TODO: getting status for node - return jsonify({ + return { 'status': 'ok', 'total_count': total_count, 'page_num': page, 'page_size': page_size, - 'items': items - }) + 'items': jsonify(items) + } # get item by id else: @@ -108,6 +108,9 @@ class BaseApi(Resource): if k not in DEFAULT_ARGS: item[k] = args.get(k) item = db_manager.save(col_name=self.col_name, item=item) + + self.after_update(item._id) + return item def update(self, id: str = None) -> (dict, tuple): diff --git a/crawlab/routes/schedules.py b/crawlab/routes/schedules.py index 1eceabde..f966e2cb 100644 --- a/crawlab/routes/schedules.py +++ b/crawlab/routes/schedules.py @@ -13,6 +13,8 @@ class ScheduleApi(BaseApi): col_name = 'schedules' arguments = ( + ('name', str), + ('description', str), ('cron', str), ('spider_id', str) ) diff --git a/frontend/src/views/schedule/ScheduleList.vue b/frontend/src/views/schedule/ScheduleList.vue index b0dbb209..c6359733 100644 --- a/frontend/src/views/schedule/ScheduleList.vue +++ b/frontend/src/views/schedule/ScheduleList.vue @@ -2,7 +2,7 @@
@@ -11,19 +11,34 @@ :inline-message="true" ref="scheduleForm" label-position="right"> - + - + + + + + + + - + {{$t('Cancel')}} - {{$t('Add')}} + {{$t('Submit')}} @@ -55,8 +70,8 @@