File size: 2,117 Bytes
0f0ef8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import streamlit as st
import streamlit.components.v1 as components
from banco import SessionLocal
from models import LogAcesso
from datetime import datetime


# =====================================================
# AUDITORIA
# =====================================================
def registrar_auditoria(acao):
    db = SessionLocal()
    try:
        db.add(LogAcesso(
            usuario=st.session_state.get("usuario", "desconhecido"),
            acao=acao,
            tabela="bi",
            data_hora=datetime.now()
        ))
        db.commit()
    finally:
        db.close()


# =====================================================
# APP PRINCIPAL
# =====================================================
def main():
    st.title("๐Ÿ“Š Business Intelligence")

    st.caption("Indicadores e dashboards oficiais")

    # ๐Ÿ” Auditoria de acesso
    registrar_auditoria("ACESSO_BI")

    # =====================================================
    # SELEร‡รƒO DE DASHBOARD
    # =====================================================
    dashboards = {
        "๐Ÿ“ˆ Performance Operacional": {
            "url": "https://app.powerbi.com/view?r=SEU_LINK_AQUI",
            "height": 800
        },
        "๐Ÿ“Š Qualidade e Erros": {
            "url": "https://app.powerbi.com/view?r=SEU_LINK_AQUI",
            "height": 800
        },
        "๐Ÿ“ฆ Produtividade FPSO": {
            "url": "https://app.powerbi.com/view?r=SEU_LINK_AQUI",
            "height": 900
        }
    }

    opcao = st.selectbox("Selecione o Dashboard", dashboards.keys())

    dash = dashboards[opcao]

    st.divider()

    # =====================================================
    # EMBED DO POWER BI
    # =====================================================
    components.html(
        f"""

        <iframe

            width="100%"

            height="{dash['height']}"

            src="{dash['url']}"

            frameborder="0"

            allowfullscreen="true">

        </iframe>

        """,
        height=dash["height"] + 20
    )