Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
10 kB
1
Indexable
Never
import dash
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_table as dt
from dash_table.Format import Format, Group, Scheme, Symbol
import datetime
from datetime import timedelta
#import connect
import plotly.graph_objects as go
import pandas as pd
import math
import re
import numpy as np
from flask import send_file
import io
import flask 
import os
import sys
from waitress import serve
import json
#import kaleido
import plotly
import base64
from app import app
import utils
import mysql_queries
import mssql_queries
import mssql_conn
import constants

#to su sve libraries

#evo dole ludila

# controls = dbc.FormGroup(
#     [
    #     dbc.Row([
    #         dbc.Col(
    #         html.Div(["Start Time: ", constants.start_date_picker],
    #                 ),
    #             ),
    #         dbc.Col(
    #             html.Div([constants.start_time_picker])
    #         )
    #     ],style={"marginBottom":"0.5em"}),
    #             dbc.Row([
    #         dbc.Col(
    #         html.Div(["End Time: ", constants.end_date_picker]),
    #             ),
    #         dbc.Col(
    #                 constants.end_time_picker
    #             ),
    #     ]),
    # html.Hr(),
    # dbc.Row([
    #     dbc.Col([
    #                 html.Div(["Theoretical Cycle Time (in s):"]),
    #         ]),
    #     dbc.Col([
    #                dcc.Input(id="taktzeit", type="text", persistence=True, required=True),
    #         ])
    # ],style={"marginBottom":"0.5em"}
    # ),
    # dbc.Row([
    #     dbc.Col([
    #                 html.Div(["Theoretical Efficiency (in %)"])
    #         ]),
    #     dbc.Col([
    #                dcc.Input(id="effizienz", type="text", persistence=True, required=True)
    #         ])
    # ],style={"marginBottom":"0.5em"}),
    # html.Hr(),
    # dbc.Row([
    #     dbc.Col([
    #                 html.Div(["Database"])
    #         ]),
    #     dbc.Col([
    #                 constants.database
    #         ])
    # ],style={"marginBottom":"1em"}),
    # dbc.Row([
    #     dbc.Col([
    #                 html.Div(["Type"])
    #         ]),
    #     dbc.Col([
    #                 constants.part_type_selection
    #         ])
    # ],style={"marginBottom":"1em"}),
    # dbc.Row([
    #     dbc.Col([
    #                 html.Div(["Worker Name"])
    #         ]),
    #     dbc.Col([
    #                 constants.worker_selection
    #         ])
    # ],style={"marginBottom":"1em"}),
    # dbc.Row([
    #     dbc.Col([
    #                 html.Div(["Language"])
    #         ]),
    #     dbc.Col([ constants.language])
    # ],style={"marginBottom":"0.5em"}),
    # html.Hr(),
    
#komentar dino je lijep
    dbc.Row([
         html.H2('Parameters', style={"marginLeft":"1.5em"}), # stavio marginu
        html.Hr(),
                dbc.Col(
            html.Div(["Start Time:", constants.start_date_picker],
                    ),
                ),
            dbc.Col(
                html.Div([ constants.start_time_picker ])
            )
        ],style={"marginBottom":"0.5em"}),
                dbc.Row([
            dbc.Col(
            html.Div(["End Time:", constants.end_date_picker]),
                ),
            dbc.Col( constants.end_time_picker ),
             dbc.Col(
            html.Div(["Start Time:", constants.start_date_picker],
                    ),
                ),
            dbc.Col(
                html.Div([ constants.start_time_picker ])
            )
        ],style={"marginBottom":"0.5em"}),
                dbc.Row([
            dbc.Col(
            html.Div(["End Time: ", constants.end_date_picker]),
                ),
            dbc.Col( constants.end_time_picker ),
    
    
    ],style={"marginBottom":"0.5em"}),


    html.Hr(),
    

    dbc.Button(
        id='submit_button',
        n_clicks=0,
        children='Submit',
        color='secondary',
        block=True
        ),
        
    html.Hr(),
    html.Div(id="alert11"),
    html.Div(id="alert12"),
    html.Div(id="alert13"),
    html.Div(id="link1"),
    html.Div(id="link12")
    ]
) 


controls = dbc.FormGroup(
    [
        dbc.Row([
            dbc.Col(
            html.Div(["Start Time: ", constants.start_date_picker],
                    ),
                ),
            dbc.Col(
                html.Div([constants.start_time_picker])
            )
        ],style={"marginBottom":"0.5em"}),
                dbc.Row([
            dbc.Col(
            html.Div(["End Time: ", constants.end_date_picker]),
                ),
            dbc.Col(
                    constants.end_time_picker
                ),
        ]),
    html.Hr(),
    dbc.Row([
        dbc.Col([
                    html.Div(["Theoretical Cycle Time (in s):"]),
            ]),
        dbc.Col([
                   dcc.Input(id="taktzeit", type="text", persistence=True, required=True),
            ])
    ],style={"marginBottom":"0.5em"}
    ),
    dbc.Row([
        dbc.Col([
                    html.Div(["Theoretical Efficiency (in %)"])
            ]),
        dbc.Col([
                   dcc.Input(id="effizienz", type="text", persistence=True, required=True)
            ])
    ],style={"marginBottom":"0.5em"}),
    html.Hr(),
    dbc.Row([
        dbc.Col([
                    html.Div(["Database"])
            ]),
        dbc.Col([
                    constants.database
            ])
    ],style={"marginBottom":"1em"}),
    dbc.Row([
        dbc.Col([
                    html.Div(["Type"])
            ]),
        dbc.Col([
                    constants.part_type_selection
            ])
    ],style={"marginBottom":"1em"}),
    dbc.Row([
        dbc.Col([
                    html.Div(["Worker Name"])
            ]),
        dbc.Col([
                    constants.worker_selection
            ])
    ],style={"marginBottom":"1em"}),
    dbc.Row([
        dbc.Col([
                    html.Div(["Language"])
            ]),
        dbc.Col([ constants.language])
    ],style={"marginBottom":"0.5em"}),
    html.Hr(),
    
#komentar dino je lijep
    dbc.Row([
         html.H2('Parameters', style={"marginLeft":"1.5em"}), # stavio marginu
        html.Hr(),
                dbc.Col(
            html.Div(["Start Time:", constants.start_date_picker],
                    ),
                ),
            dbc.Col(
                html.Div([ constants.start_time_picker ])
            )
        ],style={"marginBottom":"0.5em"}),
                dbc.Row([
            dbc.Col(
            html.Div(["End Time:", constants.end_date_picker]),
                ),
            dbc.Col( constants.end_time_picker ),
             dbc.Col(
            html.Div(["Start Time:", constants.start_date_picker],
                    ),
                ),
            dbc.Col(
                html.Div([ constants.start_time_picker ])
            )
        ],style={"marginBottom":"1em"}),
                dbc.Row([
            dbc.Col(
            html.Div(["End Time:", constants.end_date_picker]),
                ),
            dbc.Col( constants.end_time_picker ),
    
    
    ],style={"marginBottom":"2em"}),#pokazuje szbmit ispod parameters
    dbc.Button(
        id='submit_button2',#pokazuje szbmit ispod parameters
        n_clicks=0,
        children='Submit',
        color='primary',
        block=True
        ),
        


    html.Hr(),
    

    dbc.Button(
        id='submit_button2',
        n_clicks=0,
        children='Submit',
        color='primary',
        block=True
        ),
        
    html.Hr(),
    html.Div(id="alert11"),
    html.Div(id="alert12"),
    html.Div(id="alert13"),
    html.Div(id="link1"),
    html.Div(id="link12")
    ]
)

sidebar = html.Div(
    [
        html.H2('Parameters', style=constants.TEXT_STYLE),
        html.Hr(),
        controls
    ],
    style=constants.SIDEBAR_STYLE,
)

sidebar = html.Div(
    [
        html.H2('Downtime and Reasons', style=constants.TEXT_STYLE),
        html.H3('Parameters', style=constants.TEXT_STYLE),
        html.Hr(),
        controls
    ],
    style=constants.SIDEBAR_STYLE,
)
sidebar = html.Div(
    [
        html.H2('Downtime and Reasons', style=constants.TEXT_STYLE),
        html.H3('Parameters', style=constants.TEXT_STYLE),
        html.Hr(),
        controls
    ],
    style=constants.SIDEBAR_STYLE,
)

content = html.Div(
    [
        dcc.Tabs([
            dcc.Tab(label='Report', children=[
                dcc.Store(id="filtered_query_output"),
                html.Div(id="production_numbers", style={"display" : "none"}),
                dcc.Store(id="total_number_of_parts"),
                dcc.Store(id="new_intermediate_values"),
                html.Div(id='produktionsdaten', style={'display': 'none'}),
                html.Div(id='file_dates', style={'display': 'none'}),
                dcc.Store(id="pareto_graph"),
                dcc.Store(id="production_graph"),
                html.Div(id="table1"),
                dcc.Store(id="excel_data11"),
                dcc.Store(id="excel_data12"),
                dcc.Store(id="excel_data13"),
                dcc.Store(id="excel_data_error_log"),
                html.Hr(),
                dbc.Row([
                    dbc.Col([
                        html.Div(children=html.Strong(id='fehler_zahl'))
                    ]),
                    dbc.Col([
                        html.Div(children=html.Strong(id='fehler_dauer'))
                    ]),
                    dbc.Col([
                        html.Div(children=html.Strong(id='verlust_menge'))
                    ])
                ],style={"marginBottom":"0.5em"}),
                dbc.Row([
                    dbc.Col([
                        html.Div(children=html.Strong(id='ok_parts'))
                    ]),
                    dbc.Col([
                        html.Div(children=html.Strong(id='faulty_parts'))
                    ]),
                    dbc.Col([
                        html.Div(children=html.Strong(id='mean_cycle_time'))
                    ])
                ])
            ]),
            dcc.Tab(label='Pareto Diagram', children=[
                dcc.Graph(id="pareto_diagram", style={"height":800}),
            ]),
            dcc.Tab(label='By Station', children=[
                dcc.Graph(id="by_station"),
            ]),
        ]),
    ],
    style=constants.CONTENT_STYLE,
    id="content"
)

layout = html.Div([sidebar, content])