示例#1
0
def _source(integration_name, name, job_number=None):

    # Get source
    source = (database['session'].query(Source).filter(
        Source.integration_name == integration_name).filter(
            Source.name == name).first())
    if not source:
        abort(404)

    # Check access
    if not _check_source_access(source):
        abort(401, 'You are not authorized to access this source')

    # Get selected job
    if job_number:
        job = (database['session'].query(Job).filter(
            Job.source == source).filter(Job.number == job_number).first())
        if not job:
            abort(404)

    # Get default job
    else:
        job = source.last_job

    return render_component('Source',
                            props={
                                'source': source.to_api(with_job_history=True),
                                'job': job.to_api() if job else None,
                            })
示例#2
0
def job(job_id):
    job = models.job.get(job_id)
    if not job:
        abort(404)
    return render_component('Job', props={
        'job': job,
    })
示例#3
0
def try_goodtables():
    return render_component('DemoForm',
                            props={
                                'apiUrl': settings.DEMO_API_URL,
                                'apiToken': settings.DEMO_API_TOKEN,
                                'apiSourceId': settings.DEMO_API_SOURCE_ID,
                            })
示例#4
0
def home():
    return render_component('User',
                            props={
                                'userName':
                                getattr(current_user, 'display_name', None),
                                'userEmail':
                                getattr(current_user, 'email', None),
                            })
示例#5
0
def dashboard():
    user_id = session.get('user_id')
    if not user_id:
        return redirect(url_for('site.home'))
    # TODO: Get most recent job per source
    github_jobs = models.job.get_by_integration('github', limit=5)
    s3_jobs = models.job.get_by_integration('s3', limit=5)
    return render_component('Dashboard',
                            props={
                                'githubJobs': github_jobs,
                                's3Jobs': s3_jobs,
                            })
示例#6
0
def dashboard():
    if not current_user.is_authenticated:
        return redirect(url_for('site.home'))

    # Get user sources
    sources = (database['session'].query(Source).join(
        Job, isouter=True).filter(Source.users.any(id=current_user.id)).filter(
            Source.active == true()).order_by(Job.created.desc().nullslast(),
                                              Source.name).all())

    if sources:
        sources = [source.to_api(with_last_job=True) for source in sources]

    return render_component('Dashboard', props={
        'sources': sources,
    })
示例#7
0
def jobs():
    jobs = models.job.find()
    return render_component('Jobs', props={
        'jobs': jobs,
    })
示例#8
0
def home():
    if session.get('user_id'):
        return redirect(url_for('site.dashboard'))
    return render_component('Home')
示例#9
0
def s3_settings():
    return render_component('S3Settings')
示例#10
0
def index():
    jobs = models.job.get_by_integration('s3')
    return render_component('S3Home', props={
        'jobs': jobs,
    })
示例#11
0
def _error_response(code, err):
    if request.path.startswith('/api/'):
        return jsonify({'status': code, 'message': err.description}), code
    else:
        return (render_component('Error{}'.format(code),
                                 props={'message': err.description}), code)
示例#12
0
def settings_page():
    if not current_user.is_authenticated:
        return redirect(url_for('site.home'))
    return render_component('Settings')
示例#13
0
def about():
    return render_component('About')
示例#14
0
def home():
    if current_user.is_authenticated:
        return redirect(url_for('site.dashboard'))
    return render_component('Landing')
示例#15
0
def server_error(err):
    return (render_component('Error500'), 500)
示例#16
0
def not_found_error(err):
    return (render_component('Error404'), 404)