Exemple #1
0
def name_trails(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the transformed segments file
    transformed_segments_path = '{0}/opentrails/segments.geojson.zip'.format(
        dataset.id)
    transformed_segments_zip = datastore.read(transformed_segments_path)

    # Unzip it
    segments_path = unzip(transformed_segments_zip, '.geojson', [])
    transformed_segments = json.load(open(segments_path))

    # Generate a list of (name, ids) tuples
    named_trails = make_named_trails(transformed_segments['features'])

    file = StringIO()
    cols = 'id', 'name', 'segment_ids', 'description', 'part_of'
    writer = csv.writer(file)
    writer.writerow(cols)
    for row in named_trails:
        writer.writerow([(row[c] or '').encode('utf8') for c in cols])

    named_trails_path = '{0}/opentrails/named_trails.csv'.format(dataset.id)
    datastore.write(named_trails_path, file)

    return redirect('/datasets/' + dataset.id + '/named-trails', code=303)
Exemple #2
0
def named_trails(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    return render_template('dataset-04-named-trails.html', dataset=dataset)
Exemple #3
0
def view_stewards(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    return render_template('dataset-05-stewards.html', dataset=dataset)
Exemple #4
0
def view_stewards(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    return render_template('dataset-05-stewards.html', dataset=dataset)
Exemple #5
0
def update_output(cl, filename, contents, year):
    if cl == 0:
        return html.P('')
    if filename is None:
        return html.P('Загрузите файл')
    try:
        ras = filename.split('.')[-1]
        if ras != 'xlsx':
            return html.P('Неправильный формат, нужен xlsx')
        content_type, content_string = contents.split(",")
        decoded = base64.b64decode(content_string)
        df = pd.ExcelFile(io.BytesIO(decoded))
        df = functions.prepare_form(df, year)
        var = df[df['№'].notnull()]
        nan = sum(var.iloc[:, 1:].isnull().sum().values)
        df_old = functions.get_dataset()
        a = len(set(df_old.columns))
        b = len(set(df.columns))
        if a - b == 0:
            df = pd.concat([df_old, df])
            df = df.drop_duplicates()
            df.to_csv('dataset/result_df.csv', index=False)
            if nan > 0:
                return html.P(
                    'Файл {} принят, но в файле есть пропуски'.format(
                        filename))
            else:
                return html.P('Файл {} принят'.format(filename))
        else:
            raise Exception
    except:
        return html.P('Неправильная форма')
Exemple #6
0
def buttom(cl, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13):
    if cl == 0:
        return html.P('', style={'color': 'red'})
    else:
        if all([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13]):
            try:
                f4, f5, f6, f7, f8, f9, f10, f11 = float(f4), float(f5), float(
                    f6), float(f7), float(f8), float(f9), float(f10), float(
                        f11)
                df = pd.DataFrame([[
                    999, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13
                ]],
                                  columns=functions.online_columns)
                df['Отношение периодов, %'] = (
                    df['Отчетный период текущего года (В натуральном выражении)']
                    /
                    df['Отчетный период прошлого года (В натуральном выражении)']
                ) * 100
                df['Отношение месяцев, %'] = (
                    df['Отчетный месяц текущего года (В натуральном выражении)']
                    /
                    df['Отчетный месяц прошлого года (В натуральном выражении)']
                ) * 100
                df_old = functions.get_dataset()
                df = pd.concat([df_old, df])
                df = df.drop_duplicates()
                df.to_csv('dataset/result_df.csv', index=False)
                return html.P('Анкета загружена')
            except:
                return html.P(
                    'Проверьте правильность заполнения. Используйте точку для разделения дробной части'
                )
        else:
            return html.P('Заполните все поля')
Exemple #7
0
def name_trails(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the transformed segments file
    transformed_segments_path = '{0}/opentrails/segments.geojson.zip'.format(dataset.id)
    transformed_segments_zip = datastore.read(transformed_segments_path)

    # Unzip it
    segments_path = unzip(transformed_segments_zip, '.geojson', [])
    transformed_segments = json.load(open(segments_path))

    # Generate a list of (name, ids) tuples
    named_trails = make_named_trails(transformed_segments['features'])
    
    file = StringIO()
    cols = 'id', 'name', 'segment_ids', 'description', 'part_of'
    writer = csv.writer(file)
    writer.writerow(cols)
    for row in named_trails:
        writer.writerow([(row[c] or '').encode('utf8') for c in cols])

    named_trails_path = '{0}/opentrails/named_trails.csv'.format(dataset.id)
    datastore.write(named_trails_path, file)

    return redirect('/datasets/' + dataset.id + '/named-trails', code=303)
Exemple #8
0
def transform_trailheads(dataset_id):
    '''
    Grab a zip file off of datastore
    Unzip it
    Transform into opentrails
    Upload
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the original trailheads file
    up_trailheads_name = '{0}/uploads/trail-trailheads.geojson.zip'.format(dataset.id)
    up_trailheads_zip = datastore.read(up_trailheads_name)

    # Unzip it
    up_trailheads_path = unzip(up_trailheads_zip, '.geojson', [])
    up_trailheads = json.load(open(up_trailheads_path))
    messages, ot_trailheads = trailheads_transform(up_trailheads, dataset)

    # Save messages for output
    transform_messages_path = dataset.id + "/opentrails/trailheads-messages.json"
    datastore.write(transform_messages_path, StringIO(json.dumps(messages)))

    # Make a zip from transformed trailheads
    ot_trailheads_zip = StringIO()
    ot_trailheads_raw = json.dumps(ot_trailheads, sort_keys=True)
    zip_file(ot_trailheads_zip, ot_trailheads_raw, 'trailheads.geojson')

    # Upload transformed trailheads and messages
    zip_path = '{0}/opentrails/trailheads.geojson.zip'.format(dataset.id)
    datastore.write(zip_path, ot_trailheads_zip)

    return redirect('/datasets/' + dataset.id + '/transformed-trailheads', code=303)
Exemple #9
0
def named_trails(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    return render_template('dataset-04-named-trails.html', dataset=dataset)
Exemple #10
0
def existing_validation(id):
    '''
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, id)
    if not dataset:
        return make_response("No dataset Found", 404)

    return render_template('check-01-upload-opentrails.html', dataset=dataset)
Exemple #11
0
def download_opentrails_data(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    buffer = package_opentrails_archive(dataset)

    return send_file(buffer, 'application/zip')
Exemple #12
0
def existing_validation(id):
    '''
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, id)
    if not dataset:
        return make_response("No dataset Found", 404)

    return render_template('check-01-upload-opentrails.html', dataset=dataset)
Exemple #13
0
def download_opentrails_data(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    buffer = package_opentrails_archive(dataset)

    return send_file(buffer, 'application/zip')
Exemple #14
0
def get_json_dataset(request):
    if request.method == 'POST':
        queryset = request.POST
        table = request.POST['table']
        dimensions = queryset.getlist('dimensions[]')
        filters = json.loads(request.POST.get('filters'))
        package = 'Sales'
        dataset = f.get_dataset(table, dimensions, filters)
        #print(dataset)
        return HttpResponse(dataset)
Exemple #15
0
def validated_results(dataset_id):
    ''' 
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No dataset Found", 404)

    path = '{0}/opentrails/validate-messages.json'.format(dataset.id)
    messages = map(tuple, json.load(datastore.read(path)))
    
    return render_template('check-02-validated-opentrails.html', messages=messages)
Exemple #16
0
def validated_results(dataset_id):
    ''' 
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No dataset Found", 404)

    path = '{0}/opentrails/validate-messages.json'.format(dataset.id)
    messages = map(tuple, json.load(datastore.read(path)))

    return render_template('check-02-validated-opentrails.html',
                           messages=messages)
Exemple #17
0
def opex_dashboard_v2(request):
    """Renders the opex dashboard."""
    assert isinstance(request, HttpRequest)
    dataset = f.get_dataset("transactions",
                            ['package', 'sub_package', 'vendor', 'gl'])
    return render(
        request, 'v2/opex_dashboard.html', {
            'data2': dataset,
            'title': 'Home Page',
            'year': datetime.now().year,
            'page': 'opex_dashboard_v2',
            'session': f.get_session_info(request)
        })
Exemple #18
0
def opex_dashboard(request):
    """Renders the opex dashboard."""
    assert isinstance(request, HttpRequest)
    dataset = f.get_dataset("transactions",
                            ['package', 'sub_package', 'vendor'])
    return render(request,
                  'app/OPEX/dashboard.html',
                  context_instance=RequestContext(
                      request, {
                          'data2': dataset,
                          'title': 'Home Page',
                          'year': datetime.now().year,
                      }))
Exemple #19
0
def show_sample_segment(dataset_id):
    '''
    Show an example row of data
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No dataset Found", 404)

    features = get_sample_segment_features(dataset)

    keys = list(sorted(features[0]['properties'].keys()))
    args = dict(dataset=dataset, uploaded_features=features, uploaded_keys=keys)
    return render_template("dataset-02-show-sample-segment.html", **args)
Exemple #20
0
def opex_visi_dashboard(request):
    """Renders the opex dashboard."""
    assert isinstance(request, HttpRequest)
    dataset = f.get_dataset("transactions",
                            ['package', 'sub_package', 'vendor', 'country'])
    return render(
        request, 'v2/visibility_dashboard2.html', {
            'data2': dataset,
            'title': 'Home Page',
            'year': datetime.now().year,
            'user': request.user,
            'page': 'opex_visi_dashboard',
            'session': f.get_session_info(request)
        })
Exemple #21
0
def existing_dataset(id):
    '''
    Reads available files on S3 to figure out how far a dataset has gotten in the process
    '''

    # Init some variable
    # sample_segment, opentrails_sample_segment = False, False

    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, id)
    if not dataset:
        return make_response("No dataset Found", 404)

    # return render_template('index.html', steward = steward, sample_segment = sample_segment, opentrails_sample_segment = opentrails_sample_segment)
    return render_template('dataset-01-upload-segments.html', dataset=dataset)
Exemple #22
0
def existing_dataset(id):
    '''
    Reads available files on S3 to figure out how far a dataset has gotten in the process
    '''

    # Init some variable
    # sample_segment, opentrails_sample_segment = False, False

    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, id)
    if not dataset:
        return make_response("No dataset Found", 404)

    # return render_template('index.html', steward = steward, sample_segment = sample_segment, opentrails_sample_segment = opentrails_sample_segment)
    return render_template('dataset-01-upload-segments.html', dataset=dataset)
Exemple #23
0
def show_sample_trailhead(dataset_id):
    '''
    Show an example row of data
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No dataset Found", 404)

    features = get_sample_trailhead_features(dataset)

    keys = list(sorted(features[0]['properties'].keys()))
    args = dict(dataset=dataset,
                uploaded_features=features,
                uploaded_keys=keys)
    return render_template("dataset-07-show-sample-trailhead.html", **args)
Exemple #24
0
def create_steward(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    steward_fields = 'name', 'id', 'url', 'phone', 'address', 'publisher', 'license'
    steward_values = [request.form.get(f, None) for f in steward_fields]

    steward_values[steward_fields.index('id')] = '0' # This is assigned in segments_transform()
    steward_values[steward_fields.index('publisher')] = 'no' # Better safe than sorry
    
    file = StringIO()
    cols = 'id', 'name', 'segment_ids', 'description', 'part_of'
    writer = csv.writer(file)
    writer.writerow(steward_fields)
    writer.writerow([(v or '').encode('utf8') for v in steward_values])
    
    stewards_path = '{0}/opentrails/stewards.csv'.format(dataset.id)
    datastore.write(stewards_path, file)

    return redirect('/datasets/' + dataset.id + '/stewards', code=303)
Exemple #25
0
def transformed_trailheads(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the original trailheads file
    uploaded_features = get_sample_trailhead_features(dataset)
    uploaded_keys = list(sorted(uploaded_features[0]['properties'].keys()))

    # Download the transformed trailheads file
    transformed_features = get_sample_transformed_trailhead_features(dataset)
    transformed_keys = list(
        sorted(transformed_features[0]['properties'].keys()))

    # Download the transformed trailheads messages file
    messages_path = '{0}/opentrails/trailheads-messages.json'.format(
        dataset.id)
    data = json.load(datastore.read(messages_path))

    try:
        messages = [(type, id, words) for (type, id, words) in data]
    except ValueError:
        # Old stored format.
        messages = [(type, None, words) for (type, words) in data]

    message_types = [message[0] for message in messages]

    vars = dict(dataset=dataset,
                messages=messages,
                uploaded_keys=uploaded_keys,
                uploaded_features=uploaded_features,
                transformed_features=transformed_features,
                transformed_keys=transformed_keys,
                transform_succeeded=bool('error' not in message_types))

    return render_template('dataset-08-transformed-trailheads.html', **vars)
Exemple #26
0
def transform_trailheads(dataset_id):
    '''
    Grab a zip file off of datastore
    Unzip it
    Transform into opentrails
    Upload
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the original trailheads file
    up_trailheads_name = '{0}/uploads/trail-trailheads.geojson.zip'.format(
        dataset.id)
    up_trailheads_zip = datastore.read(up_trailheads_name)

    # Unzip it
    up_trailheads_path = unzip(up_trailheads_zip, '.geojson', [])
    up_trailheads = json.load(open(up_trailheads_path))
    messages, ot_trailheads = trailheads_transform(up_trailheads, dataset)

    # Save messages for output
    transform_messages_path = dataset.id + "/opentrails/trailheads-messages.json"
    datastore.write(transform_messages_path, StringIO(json.dumps(messages)))

    # Make a zip from transformed trailheads
    ot_trailheads_zip = StringIO()
    ot_trailheads_raw = json.dumps(ot_trailheads, sort_keys=True)
    zip_file(ot_trailheads_zip, ot_trailheads_raw, 'trailheads.geojson')

    # Upload transformed trailheads and messages
    zip_path = '{0}/opentrails/trailheads.geojson.zip'.format(dataset.id)
    datastore.write(zip_path, ot_trailheads_zip)

    return redirect('/datasets/' + dataset.id + '/transformed-trailheads',
                    code=303)
Exemple #27
0
def transformed_trailheads(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the original trailheads file
    uploaded_features = get_sample_trailhead_features(dataset)
    uploaded_keys = list(sorted(uploaded_features[0]['properties'].keys()))

    # Download the transformed trailheads file
    transformed_features = get_sample_transformed_trailhead_features(dataset)
    transformed_keys = list(sorted(transformed_features[0]['properties'].keys()))

    # Download the transformed trailheads messages file
    messages_path = '{0}/opentrails/trailheads-messages.json'.format(dataset.id)
    data = json.load(datastore.read(messages_path))

    try:
        messages = [(type, id, words) for (type, id, words) in data]
    except ValueError:
        # Old stored format.
        messages = [(type, None, words) for (type, words) in data]

    message_types = [message[0] for message in messages]

    vars = dict(
        dataset = dataset,
        messages = messages,
        uploaded_keys = uploaded_keys,
        uploaded_features = uploaded_features,
        transformed_features = transformed_features,
        transformed_keys = transformed_keys,
        transform_succeeded = bool('error' not in message_types)
        )

    return render_template('dataset-08-transformed-trailheads.html', **vars)
Exemple #28
0
def create_steward(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    steward_fields = 'name', 'id', 'url', 'phone', 'address', 'publisher', 'license'
    steward_values = [request.form.get(f, None) for f in steward_fields]

    steward_values[steward_fields.index(
        'id')] = '0'  # This is assigned in segments_transform()
    steward_values[steward_fields.index(
        'publisher')] = 'no'  # Better safe than sorry

    file = StringIO()
    cols = 'id', 'name', 'segment_ids', 'description', 'part_of'
    writer = csv.writer(file)
    writer.writerow(steward_fields)
    writer.writerow([(v or '').encode('utf8') for v in steward_values])

    stewards_path = '{0}/opentrails/stewards.csv'.format(dataset.id)
    datastore.write(stewards_path, file)

    return redirect('/datasets/' + dataset.id + '/stewards', code=303)
Exemple #29
0
def render_content(tab):
    if tab == 'tab-1':
        return html.Div([
            html.H3(const.about_us,
                    style={
                        'width': '45%',
                        'padding': '0 0 0 20px',
                        'display': 'inline-block',
                        'vertical-align': 'top',
                        'font-size': '20px',
                        'color': 'white'
                    }),
            html.Div(html.Img(src=app.get_asset_url('scale_1200.webp'),
                              style={'width': '95%'}),
                     style={
                         'width': '45%',
                         'height': '40px',
                         'display': 'inline-block',
                         'vertical-align': 'top',
                         'padding': '20px'
                     })
        ])

    elif tab == 'tab-2':
        return html.Div(
            [
                #1 pic
                html.Div([
                    html.Div([
                        html.
                        H3('Объемы производства предприятий РБ в натуральном выражении',
                           style=const.tab2_h),
                        html.Label('Выберите месяц (один и более)',
                                   style=const.tab2_label),
                        html.Div(dcc.Checklist(
                            id='pic1-month',
                            options=const.tab2_months,
                            value=['январь'],
                            labelStyle=const.tab2_checklist,
                        ),
                                 style=const.tab2_div_check),
                        html.Label('Тип отчетного периода',
                                   style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id='pic1-period',
                            options=const.tab2_periods,
                            value=
                            'Отчетный период прошлого года (В натуральном выражении)',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop),
                        html.Label('Год', style=const.tab2_label),
                        html.Div(dcc.Dropdown(id="pic1-year",
                                              options=const.tab2_years,
                                              value=2020,
                                              style=const.tab2_drop),
                                 style=const.tab2_div_drop)
                    ],
                             style=const.tab2_left),
                    html.Div(dcc.Graph(
                        id='pic1',
                        figure=functions.pic1([
                            'январь'
                        ], functions.get_dataset(
                        ), 'Отчетный месяц прошлого года (В натуральном выражении)',
                                              2020),
                        style=const.tab2_graph),
                             style=const.tab2_right)
                ],
                         style=const.tab2_each_block),
                #2 pic
                html.Div([
                    html.Div([
                        html.H3('Индекс промышленного производства',
                                style=const.tab2_h),
                        html.Label('Отношение', style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id="pic2-relat",
                            options=[{
                                'label': 'Отношение периодов, %',
                                'value': 'Отношение периодов, %'
                            }, {
                                'label': 'Отношение месяцев, %',
                                'value': 'Отношение месяцев, %'
                            }],
                            value='Отношение периодов, %',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop),
                        html.Label('Выберите года', style=const.tab2_label),
                        html.Div(dcc.Checklist(
                            id='pic2-years',
                            options=const.tab2_years,
                            value=[2020],
                            labelStyle=const.tab2_checklist,
                        ),
                                 style=const.tab2_div_check),
                        html.Label('Выберите предприятие',
                                   style=const.tab2_label),
                        html.Div(dcc.Dropdown(id="pic2-slider",
                                              options=functions.get_man(
                                                  functions.get_dataset()),
                                              value=functions.man_value(),
                                              style=const.tab2_drop),
                                 style=const.tab2_div_drop)
                    ],
                             style=const.tab2_left),
                    html.Div(
                        dcc.Graph(id='pic2',
                                  figure=functions.pic2(
                                      functions.get_dataset(), 'Предприятие 1',
                                      'Отношение периодов, %', [2020]),
                                  style=const.tab2_graph),
                        style=const.tab2_right)
                ],
                         style=const.tab2_each_block),
                #3 pic
                html.Div([
                    html.Div([
                        html.H3('Индекс промышленного производства',
                                style=const.tab2_h),
                        html.Label('Тип отчетного периода',
                                   style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id='pic3-period',
                            options=const.tab2_periods,
                            value=
                            'Отчетный период прошлого года (В натуральном выражении)',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop),
                        html.Label('Выберите года', style=const.tab2_label),
                        html.Div(dcc.Checklist(
                            id='pic3-years',
                            options=const.tab2_years,
                            value=[2020],
                            labelStyle=const.tab2_checklist,
                        ),
                                 style=const.tab2_div_check),
                        html.Label('Вид деятельности/ОКВЭД',
                                   style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id="pic3-stat",
                            options=[{
                                'label': 'Вид деятельности',
                                'value': 'Вид деятельности'
                            }, {
                                'label': 'ОКВЭД',
                                'value': 'ОКВЭД'
                            }],
                            value='Вид деятельности',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop),
                    ],
                             style=const.tab2_left),
                    html.Div(dcc.Graph(
                        id='pic3',
                        figure=functions.pic3(
                            functions.get_dataset(), [2020],
                            'Отчетный период прошлого года (В натуральном выражении)',
                            'Вид деятельности'),
                        style=const.tab2_graph),
                             style=const.tab2_right)
                ],
                         style=const.tab2_each_block),
                #4 pic
                html.Div([
                    html.Div([
                        html.H3('Индекс промышленного производства',
                                style=const.tab2_h),
                        html.Label('Тип отчетного периода',
                                   style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id='pic4-period',
                            options=const.tab2_periods,
                            value=
                            'Отчетный период прошлого года (В натуральном выражении)',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop),
                        html.Label('Месяца (один и более)',
                                   style=const.tab2_label),
                        html.Div(dcc.Checklist(
                            id='pic4-month',
                            options=const.tab2_months,
                            value=['январь'],
                            labelStyle=const.tab2_checklist,
                        ),
                                 style=const.tab2_div_check),
                        html.Label('Вид деятельности/ОКВЭД',
                                   style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id="pic4-stat",
                            options=[{
                                'label': 'Вид деятельности',
                                'value': 'Вид деятельности'
                            }, {
                                'label': 'ОКВЭД',
                                'value': 'ОКВЭД'
                            }],
                            value='Вид деятельности',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop),
                    ],
                             style=const.tab2_left),
                    html.Div(dcc.Graph(
                        id='pic4',
                        figure=functions.pic3(
                            functions.get_dataset(), [2020],
                            'Отчетный период прошлого года (В натуральном выражении)',
                            'Вид деятельности'),
                        style=const.tab2_graph),
                             style=const.tab2_right)
                ],
                         style=const.tab2_each_block),
                # 5 pic
                html.Div([
                    html.Div([
                        html.H3(
                            'Индекс промышленного производства по регионам',
                            style=const.tab2_h),
                        html.Label('Выберите регион (один и более)',
                                   style=const.tab2_label),
                        html.Div(dcc.Checklist(
                            id='rosstat-reg',
                            options=const.tab2_rosstat_reg,
                            value=[
                                'Республика Башкортостан',
                                'Республика Татарстан'
                            ],
                            labelStyle=const.tab2_checklist,
                        ),
                                 style=const.tab2_div_check),
                        html.Label('Выберите ОКВЭД', style=const.tab2_label),
                        html.Div(dcc.Dropdown(
                            id="rosstat-man-type",
                            options=const.tab2_rosstat_man,
                            value='Обрабатывающие производства',
                            style=const.tab2_drop),
                                 style=const.tab2_div_drop)
                    ],
                             style=const.tab2_left),
                    html.Div(dcc.Graph(
                        id='pic5',
                        figure=functions.pic5(df_rosstat, [
                            'Республика Башкортостан', 'Республика Татарстан'
                        ], 'Обрабатывающие производства'),
                        style=const.tab2_graph),
                             style=const.tab2_right)
                ],
                         style=const.tab2_each_block),
                # 7 pic
                html.Div([
                    html.Div([html.H3('Тепловая карта', style=const.tab2_h)],
                             style=const.tab2_left),
                    html.Div(dcc.Graph(
                        id='pic7', figure=fig7, style=const.tab2_graph),
                             style=const.tab2_each_block)
                ],
                         style=const.tab2_each_block)
            ],
            style=const.tab2_each_block)
    elif tab == 'tab-3':
        return html.Div(
            [
                html.Div([
                    html.H3('Онлайн форма', style=const.tab3_h),
                    html.
                    H3('На этой странице, каждое предприятие может подать отчет онлайн, заполнив форму',
                       style=const.tab3_label)
                ],
                         style=const.tab3_each_block),
                # 1 half
                html.Div([
                    html.Label('Наименование предприятия',
                               style=const.tab3_label_form),
                    html.Div(dcc.Input(id="f1",
                                       placeholder="Наименование предприятия",
                                       style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label('Выберите ОКВЭД', style=const.tab3_label_form),
                    html.Div(dcc.Dropdown(id="f2",
                                          options=const.tab2_rosstat_man,
                                          value='Обрабатывающие производства',
                                          style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label('Выберите вид деятельности',
                               style=const.tab3_label_form),
                    html.Div(dcc.Dropdown(
                        id="f3",
                        options=functions.get_label_activity(),
                        value=functions.get_label_activity()[0]['value'],
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный период прошлого года (В натуральном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f4",
                        placeholder=
                        "Отчетный период прошлого года (В натуральном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный период прошлого года (В стоимостном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f5",
                        placeholder=
                        "Отчетный период прошлого года (В стоимостном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный период текущего года (В натуральном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f6",
                        placeholder=
                        "Отчетный период текущего года (В натуральном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный период текущего года (В стоимостном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f7",
                        placeholder=
                        "Отчетный период текущего года (В стоимостном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                ],
                         style=const.tab3_half),
                # 2 half
                html.Div([
                    html.Label(
                        'Отчетный месяц прошлого года (В натуральном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f8",
                        placeholder=
                        "Отчетный месяц прошлого года (В натуральном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный месяц прошлого года (В стоимостном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f9",
                        placeholder=
                        "Отчетный месяц прошлого года (В стоимостном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный месяц текущего года (В натуральном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f10",
                        placeholder=
                        "Отчетный месяц текущего года (В натуральном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label(
                        'Отчетный месяц текущего года (В стоимостном выражении)',
                        style=const.tab3_label_form),
                    html.Div(dcc.Input(
                        id="f11",
                        placeholder=
                        "Отчетный месяц текущего года (В стоимостном выражении)",
                        style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label('Месяц', style=const.tab3_label_form),
                    html.Div(dcc.Dropdown(id="f12",
                                          options=const.tab2_months,
                                          value='январь',
                                          style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Label('Год', style=const.tab3_label_form),
                    html.Div(dcc.Dropdown(id="f13",
                                          options=const.tab2_years,
                                          value=2020,
                                          style=const.tab3_drop),
                             style=const.tab3_div_drop),
                    html.Div(html.Button('Подать форму',
                                         id='fsubmit',
                                         n_clicks=0,
                                         style=const.button),
                             style=const.tab3_button),
                    html.Div(id='f14', style=const.alert)
                ],
                         style=const.tab3_half)
            ],
            style=const.tab3_each_block)
    elif tab == 'tab-4':
        return html.Div([
            html.Div([
                html.H3('Форма загрузки файла', style=const.tab4_h),
                html.H3(
                    'Страница для загрузки данных по форме 36 в формате xlsx',
                    style=const.tab4_label),
                html.Label('Выберите год', style=const.tab4_label_form),
                html.Div(dcc.Dropdown(id="tab4-f0",
                                      options=const.tab2_years,
                                      value=2020,
                                      style=const.tab4_drop),
                         style=const.tab4_div_drop),
                dcc.Upload(id='upload-data',
                           children=html.Div(
                               ['Перетащите или ',
                                html.A('выберите файл')],
                               style=const.tab4_drop),
                           style=const.tab4_div_drop,
                           multiple=False),
                html.Div(id='tab4-output1', style=const.alert),
                html.Div(html.Button('Отправить файл',
                                     id='tab4-fsubmit',
                                     n_clicks=0,
                                     style=const.button),
                         style=const.tab4_button),
                html.Div(id='tab4-output2', style=const.alert),
            ],
                     style=const.tab4_half_l),
            html.Div([
                html.Div([
                    html.H3('Анализ предприятий с пустыми значениями в отчете',
                            style=const.tab4_h),
                    html.Div(html.Label('Выберите месяц (один и более)',
                                        style=const.tab4_label),
                             style={
                                 'width': '35%',
                                 'display': 'inline-block',
                                 'textAlign': 'center',
                                 'vertical-align': 'top'
                             }),
                    html.Div(html.Label('Выберите года',
                                        style=const.tab4_label),
                             style={
                                 'width': '33%',
                                 'display': 'inline-block',
                                 'textAlign': 'center',
                                 'vertical-align': 'top'
                             }),
                    html.Div(html.Label('Количество', style=const.tab4_label),
                             style={
                                 'width': '31%',
                                 'display': 'inline-block',
                                 'textAlign': 'center',
                                 'vertical-align': 'top'
                             }),
                    html.Div(html.Div(dcc.Checklist(
                        id='tab4-f1',
                        options=const.tab2_months,
                        value=['январь'],
                        labelStyle=const.tab4_checklist,
                    ),
                                      style=const.tab4_div_check),
                             style={
                                 'width': '35%',
                                 'display': 'inline-block',
                                 'textAlign': 'center',
                                 'vertical-align': 'top'
                             }),
                    html.Div(html.Div(dcc.Checklist(
                        id='tab4-f2',
                        options=const.tab2_years,
                        value=[2020],
                        labelStyle=const.tab4_checklist,
                    ),
                                      style=const.tab4_div_check),
                             style={
                                 'width': '33%',
                                 'display': 'inline-block',
                                 'textAlign': 'center',
                                 'vertical-align': 'top'
                             }),
                    html.Div(html.Div(dcc.RadioItems(
                        id='tab4-f3',
                        options=[
                            {
                                'label': 'Количество nan',
                                'value': True
                            },
                            {
                                'label': 'Отчеты с nan',
                                'value': False
                            },
                        ],
                        value=True,
                        labelStyle={
                            'width': '100%',
                            'textAlign': 'left',
                            'display': 'inline-block',
                            'color': 'white',
                            'font-size': '18px',
                            'vertical-align': 'top'
                        },
                    ),
                                      style=const.tab4_div_check),
                             style={
                                 'width': '31%',
                                 'display': 'inline-block',
                                 'textAlign': 'center',
                                 'vertical-align': 'top'
                             }),
                ],
                         style=const.tab4_each_block),
                html.Div(
                    dcc.Graph(
                        id='pic6',
                        figure=functions.pic6(functions.get_dataset(),
                                              ['январь', 'февраль'], [2020],
                                              each=True),
                        style=const.tab2_graph))
            ],
                     style=const.tab4_half_r),
        ],
                        style=const.tab4_each_block)
Exemple #30
0
def update_charts2(man, relat, years):
    return functions.pic2(functions.get_dataset(), man, relat, years)
Exemple #31
0
def update_charts3(years, period, stat):
    return functions.pic3(functions.get_dataset(), years, period, stat)
Exemple #32
0
def update_charts4(months, period, stat):
    return functions.pic4(functions.get_dataset(), months, period, stat)
Exemple #33
0
def update_charts6(months, years, each):
    return functions.pic6(functions.get_dataset(), months, years, each=each)
Exemple #34
0
def update_charts1(months, period, year):
    return functions.pic1(months, functions.get_dataset(), period, year)