Commit Β·
4e775fd
1
Parent(s): 35ba74e
feat: Add PMJA Receiving Dashboard page for data visualization and session management.
Browse files- pages/rec.py +80 -4
pages/rec.py
CHANGED
|
@@ -7,7 +7,7 @@ import streamlit.components.v1 as components
|
|
| 7 |
from gs_client import read_ws
|
| 8 |
|
| 9 |
st.set_page_config(layout="wide", initial_sidebar_state="collapsed", page_title="PMJA - Dashboard Recebimento")
|
| 10 |
-
|
| 11 |
# ββ SESSION βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
_cc = CookieController()
|
| 13 |
COOKIE_NAME = "pmja_session"
|
|
@@ -166,9 +166,85 @@ def build_frames(df_plot, df_rec, sistemas, cores_sistemas, anos_unicos,
|
|
| 166 |
return frames, meses_pt
|
| 167 |
|
| 168 |
# ββ LOAD DATA βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
|
| 174 |
if df_recebimento is not None and not df_recebimento.empty:
|
|
|
|
| 7 |
from gs_client import read_ws
|
| 8 |
|
| 9 |
st.set_page_config(layout="wide", initial_sidebar_state="collapsed", page_title="PMJA - Dashboard Recebimento")
|
| 10 |
+
#carregando
|
| 11 |
# ββ SESSION βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
_cc = CookieController()
|
| 13 |
COOKIE_NAME = "pmja_session"
|
|
|
|
| 166 |
return frames, meses_pt
|
| 167 |
|
| 168 |
# ββ LOAD DATA βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 169 |
+
# ββ LOADING SCREEN βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 170 |
+
loading_html = """
|
| 171 |
+
<style>
|
| 172 |
+
*{margin:0;padding:0;box-sizing:border-box}
|
| 173 |
+
.overlay{
|
| 174 |
+
position:fixed;inset:0;
|
| 175 |
+
background:linear-gradient(135deg,#003a70 0%,#0056A3 100%);
|
| 176 |
+
display:flex;flex-direction:column;align-items:center;justify-content:center;
|
| 177 |
+
z-index:99999;font-family:'DM Sans',sans-serif;
|
| 178 |
+
transition:opacity .5s;
|
| 179 |
+
}
|
| 180 |
+
.logos{display:flex;align-items:center;gap:32px;margin-bottom:48px}
|
| 181 |
+
.logo-img{height:40px;filter:brightness(0) invert(1);opacity:.9}
|
| 182 |
+
.divider{width:1px;height:40px;background:rgba(255,255,255,.25)}
|
| 183 |
+
.title{font-size:22px;color:#fff;font-weight:800;letter-spacing:-.5px;
|
| 184 |
+
margin-bottom:4px;text-align:center;font-family:'Sora',sans-serif}
|
| 185 |
+
.subtitle{font-size:13px;color:rgba(255,255,255,.7);font-weight:600;
|
| 186 |
+
margin-bottom:52px;text-align:center}
|
| 187 |
+
.bar-wrap{width:280px;height:4px;background:rgba(255,255,255,.15);
|
| 188 |
+
border-radius:99px;overflow:hidden;margin-bottom:20px}
|
| 189 |
+
.bar-fill{height:100%;width:0%;background:#fff;border-radius:99px;transition:width .4s ease}
|
| 190 |
+
.status{font-size:12px;color:rgba(255,255,255,.65);font-weight:600;
|
| 191 |
+
letter-spacing:.3px;min-height:18px;text-align:center}
|
| 192 |
+
.dots span{animation:blink 1.2s infinite;opacity:0}
|
| 193 |
+
.dots span:nth-child(2){animation-delay:.2s}
|
| 194 |
+
.dots span:nth-child(3){animation-delay:.4s}
|
| 195 |
+
@keyframes blink{0%,100%{opacity:0}50%{opacity:1}}
|
| 196 |
+
.spinner{width:36px;height:36px;border:3px solid rgba(255,255,255,.2);
|
| 197 |
+
border-top-color:#fff;border-radius:50%;animation:spin .8s linear infinite;
|
| 198 |
+
margin-bottom:32px}
|
| 199 |
+
@keyframes spin{to{transform:rotate(360deg)}}
|
| 200 |
+
</style>
|
| 201 |
+
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600;700;800&family=Sora:wght@700;800&display=swap" rel="stylesheet">
|
| 202 |
+
|
| 203 |
+
<div class="overlay" id="overlay">
|
| 204 |
+
<div class="logos">
|
| 205 |
+
<img class="logo-img" src="https://companieslogo.com/img/orig/AZ2.F-d26946db.png?t=1720244490" alt="AZ">
|
| 206 |
+
<div class="divider"></div>
|
| 207 |
+
<img class="logo-img" src="https://upload.wikimedia.org/wikipedia/commons/8/8f/Logo-engie.svg" alt="Engie">
|
| 208 |
+
</div>
|
| 209 |
+
<div class="spinner"></div>
|
| 210 |
+
<div class="title">PMJA β Dashboard Recebimento</div>
|
| 211 |
+
<div class="subtitle">GestΓ£o de Materiais</div>
|
| 212 |
+
<div class="bar-wrap"><div class="bar-fill" id="bar"></div></div>
|
| 213 |
+
<div class="status" id="status">
|
| 214 |
+
Conectando ao Google Sheets
|
| 215 |
+
<span class="dots"><span>.</span><span>.</span><span>.</span></span>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
|
| 219 |
+
<script>
|
| 220 |
+
var steps=[
|
| 221 |
+
{p:18, msg:'Conectando ao Google Sheets'},
|
| 222 |
+
{p:40, msg:'Carregando dados de recebimento'},
|
| 223 |
+
{p:62, msg:'Processando mΓ©tricas'},
|
| 224 |
+
{p:80, msg:'Montando grΓ‘ficos'},
|
| 225 |
+
{p:95, msg:'Quase pronto'}
|
| 226 |
+
];
|
| 227 |
+
var i=0;
|
| 228 |
+
function next(){
|
| 229 |
+
if(i>=steps.length) return;
|
| 230 |
+
var s=steps[i++];
|
| 231 |
+
document.getElementById('bar').style.width=s.p+'%';
|
| 232 |
+
document.getElementById('status').innerHTML=
|
| 233 |
+
s.msg+'<span class="dots"><span>.</span><span>.</span><span>.</span></span>';
|
| 234 |
+
setTimeout(next, 950+Math.random()*550);
|
| 235 |
+
}
|
| 236 |
+
setTimeout(next, 300);
|
| 237 |
+
</script>
|
| 238 |
+
"""
|
| 239 |
+
|
| 240 |
+
loading_placeholder = st.empty()
|
| 241 |
+
loading_placeholder.components.v1.html(loading_html, height=0)
|
| 242 |
+
|
| 243 |
+
df_recebimento = read_ws("recebimento")
|
| 244 |
+
df_rec_dados = read_ws("rec_dados")
|
| 245 |
+
|
| 246 |
+
# Fecha o loading ao terminar
|
| 247 |
+
loading_placeholder.empty()
|
| 248 |
|
| 249 |
|
| 250 |
if df_recebimento is not None and not df_recebimento.empty:
|