def calendar(): scheduling_form = SchedulingForm(request.form) scheduling_form.job.choices = Job.choices() tasks = {} for task in Task.query.all(): # javascript dates range from 0 to 11, we must account for that by # substracting 1 to the month for the date to be properly displayed in # the calendar if not task.start_date: continue python_month = search( r'.*-(\d{2})-.*', task.aps_date('start_date') ).group(1) month = '{:02}'.format((int(python_month) - 1) % 12) js_date = [int(i) for i in sub( r"(\d+)-(\d+)-(\d+) (\d+):(\d+).*", r"\1," + month + r",\3,\4,\5", task.aps_date('start_date') ).split(',')] tasks[task.name] = { 'date': js_date, } return render_template( 'calendar.html', tasks=tasks, scheduling_form=scheduling_form )
def workflows(): scheduling_form = SchedulingForm(request.form) return render_template('workflow_management.html', names=pretty_names, scheduling_form=scheduling_form, fields=('name', 'description', 'type'), workflows=Workflow.serialize(), form=WorkflowCreationForm(request.form))
def task_management(): scheduling_form = SchedulingForm(request.form) scheduling_form.scripts.choices = Script.choices() return render_template('task_management.html', fields=task_public_properties, tasks=ScheduledTask.serialize(), compare_form=CompareForm(request.form), scheduling_form=scheduling_form)
def task_management(): scheduling_form = SchedulingForm(request.form) scheduling_form.nodes.choices = Node.choices() scheduling_form.pools.choices = Pool.choices() scheduling_form.job.choices = Job.choices() return render_template('task_management.html', fields=task_public_properties, tasks=Task.serialize(), compare_form=CompareForm(request.form), scheduling_form=scheduling_form)
def task_management(task_type): scheduling_form = SchedulingForm(request.form) scheduling_form.devices.choices = Device.choices() scheduling_form.pools.choices = Pool.choices() scheduling_form.job.choices = Job.choices() task_class = ScriptTask if task_type == 'script' else WorkflowTask return render_template(f'{task_type}_tasks.html', fields=task_public_properties, tasks=task_class.serialize(), compare_form=CompareForm(request.form), scheduling_form=scheduling_form)
def scripts(): scheduling_form = SchedulingForm(request.form) scheduling_form.nodes.choices = Node.choices() scheduling_form.pools.choices = Pool.choices() scheduling_form.job.choices = Job.choices() return render_template( 'script_management.html', fields=script_public_properties, type_to_form={t: s(request.form) for t, s in type_to_form.items()}, names=pretty_names, scheduling_form=scheduling_form, scripts=Script.serialize())
def view(view_type): add_device_form = AddDevice(request.form) add_link_form = AddLink(request.form) all_devices = Device.choices() add_link_form.source.choices = all_devices add_link_form.destination.choices = all_devices view_options_form = ViewOptionsForm(request.form) google_earth_form = GoogleEarthForm(request.form) scheduling_form = SchedulingForm(request.form) scheduling_form.job.choices = Job.choices() scheduling_form.devices.choices = all_devices scheduling_form.pools.choices = Pool.choices() labels = {'device': 'name', 'link': 'name'} if 'view_options' in request.form: # update labels labels = { 'device': request.form['device_label'], 'link': request.form['link_label'] } # for the sake of better performances, the view defaults to markercluster # if there are more than 2000 devices view = 'leaflet' if len(Device.query.all()) < 2000 else 'markercluster' if 'view' in request.form: view = request.form['view'] # name to id name_to_id = { device.name: id for id, device in enumerate(Device.query.all()) } return render_template( f'{view_type}_view.html', pools=Pool.query.all(), parameters=Parameters.query.one().serialized, view=view, scheduling_form=scheduling_form, view_options_form=view_options_form, google_earth_form=google_earth_form, add_device_form=add_device_form, add_link_form=add_link_form, device_fields=device_public_properties, link_fields=link_public_properties, labels=labels, names=pretty_names, device_subtypes=device_subtypes, link_colors=link_subtype_to_color, name_to_id=name_to_id, devices=Device.serialize(), links=Link.serialize() )
def workflow_editor(workflow_id=None): workflow_editor_form = WorkflowEditorForm(request.form) workflow_editor_form.workflow.choices = Workflow.choices() workflow = get_obj(Workflow, id=workflow_id).serialized if workflow_id else None scheduling_form = SchedulingForm(request.form) scheduling_form.scripts.choices = Script.choices() scheduling_form.nodes.choices = Node.choices() scheduling_form.pools.choices = Pool.choices() print(workflow) return render_template('workflow_editor.html', workflow_editor_form=workflow_editor_form, scheduling_form=scheduling_form, compare_form=CompareForm(request.form), names=pretty_names, workflow=workflow)
def workflow_editor(workflow_id=None): add_existing_task_form = AddExistingTaskForm(request.form) workflow_editor_form = WorkflowEditorForm(request.form) workflow_editor_form.workflow.choices = Workflow.choices() workflow = get_obj(Workflow, id=workflow_id) scheduling_form = SchedulingForm(request.form) scheduling_form.job.choices = Job.choices() scheduling_form.nodes.choices = Node.choices() scheduling_form.pools.choices = Pool.choices() add_existing_task_form.task.choices = Task.choices() return render_template( 'workflow_editor.html', add_existing_task_form=add_existing_task_form, workflow_editor_form=workflow_editor_form, scheduling_form=scheduling_form, compare_form=CompareForm(request.form), names=pretty_names, workflow=workflow.serialized if workflow_id else None)
def view(view_type): add_node_form = AddNode(request.form) add_link_form = AddLink(request.form) all_nodes = Node.choices() add_link_form.source.choices = add_link_form.destination.choices = all_nodes view_options_form = ViewOptionsForm(request.form) google_earth_form = GoogleEarthForm(request.form) scheduling_form = SchedulingForm(request.form) scheduling_form.scripts.choices = Script.choices() scheduling_form.nodes.choices = all_nodes scheduling_form.pools.choices = Pool.choices() labels = {'node': 'name', 'link': 'name'} if 'view_options' in request.form: # update labels labels = { 'node': request.form['node_label'], 'link': request.form['link_label'] } # for the sake of better performances, the view defaults to markercluster # if there are more than 2000 nodes view = 'leaflet' if len(Node.query.all()) < 2000 else 'markercluster' if 'view' in request.form: view = request.form['view'] # name to id name_to_id = {node.name: id for id, node in enumerate(Node.query.all())} return render_template('{}_view.html'.format(view_type), pools=Pool.query.all(), parameters=Parameters.query.one().serialized, view=view, scheduling_form=scheduling_form, view_options_form=view_options_form, google_earth_form=google_earth_form, add_node_form=add_node_form, add_link_form=add_link_form, node_fields=node_public_properties, link_fields=link_public_properties, labels=labels, names=pretty_names, subtypes=list(node_class), name_to_id=name_to_id, nodes=Node.serialize(), links=Link.serialize())