From 6c577e494c631bc54c2b81cf3f70f0e7d746b7f8 Mon Sep 17 00:00:00 2001 From: Edward Oliveira Date: Mon, 17 Nov 2025 10:35:01 -0300 Subject: [PATCH] WIP --- docker/docker-compose.yaml | 12 +- frontend/src/__apps/painel/main.js | 58 +++++- sapl/templates/painel/painel_v2.html | 301 ++++----------------------- 3 files changed, 102 insertions(+), 269 deletions(-) diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 95f81876f..13f673b8d 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -1,6 +1,6 @@ services: sapldb: - image: postgres:10.5-alpine + image: postgres:16-bookworm restart: always container_name: postgres labels: @@ -36,11 +36,11 @@ services: image: redis:7-alpine command: ["redis-server", "--save", "", "--appendonly", "no"] sapl: - image: interlegis/sapl:3.1.164-RC5 -# build: -# context: ../ -# dockerfile: ./docker/Dockerfile -# container_name: sapl +# image: interlegis/sapl:3.1.164-RC5 + build: + context: ../ + dockerfile: ./docker/Dockerfile + container_name: sapl labels: NAME: "sapl" restart: always diff --git a/frontend/src/__apps/painel/main.js b/frontend/src/__apps/painel/main.js index 48ef1ffee..5e86aff6e 100644 --- a/frontend/src/__apps/painel/main.js +++ b/frontend/src/__apps/painel/main.js @@ -1,5 +1,6 @@ import './scss/painel.scss' +// main.js (Vue 2) import Vue from 'vue' new Vue({ @@ -7,8 +8,61 @@ new Vue({ delimiters: ['[[', ']]'], data() { return { - parlamentares: [{ nome: 'zé' }, { nome: 'maria' }, { nome: 'antonio' }] + controllerId: null, + state: { + sessao_plenaria: '', + sessao_plenaria_data: '', + sessao_plenaria_hora_inicio: '', + votacao: [], + parlamentares: [] + }, + ws: null, + isOpen: false, + error: null, } }, - mounted() { console.log('Vue mounted'); } + mounted() { + // $el is guaranteed here + const el = this.$el + // prefer data-attr; fallback to global if you set it + this.controllerId = el.dataset.controllerId || window.controllerId + console.log(`ControllerId: ${this.controllerId}`) + this.connectWS() + }, + beforeDestroy() { this.closeWS() }, + methods: { + wsUrl() { + const proto = location.protocol === 'https:' ? 'wss' : 'ws' + return `${proto}://${location.host}/ws/painel/${this.controllerId}/` + }, + connectWS() { + const url = this.wsUrl() + this.ws = new WebSocket(url) + + this.ws.addEventListener('open', () => { this.isOpen = true; this.error = null }) + this.ws.addEventListener('message', (evt) => { + try { + const msg = JSON.parse(evt.data) + // SETUP STATE + console.log(`FROM VUEJS: ${evt.data}`) // DEBUG + this.state.parlamentares = msg.presentes + //TODO: group in a single sessao object + this.state.sessao_plenaria = msg.sessao.sessao_plenaria + this.state.sessao_plenaria_data = msg.sessao.sessao_plenaria_data + this.state.sessao_plenaria_hora_inicio = msg.sessao.sessao_plenaria_hora_inicio + this.state.brasao = msg.sessao.brasao + + this.state.oradores = msg.oradores + this.state.materia_legislativa_ementa = msg.mensagem_legislativa_ementa + this.state.resultado = msg.votacao + + if (msg.type === 'state') this.state = msg.payload || {} + } catch (e) { console.warn('WS parse error:', e) } + }) + this.ws.addEventListener('close', () => { this.isOpen = false; setTimeout(() => this.connectWS(), 800) }) + this.ws.addEventListener('error', (e) => { this.error = e }) + }, + closeWS() { try { this.ws && this.ws.close() } catch (_) {} }, + startStopwatch() { if (this.isOpen) this.ws.send(JSON.stringify({ type:'notify', stopwatch:'start' })) }, + } }) diff --git a/sapl/templates/painel/painel_v2.html b/sapl/templates/painel/painel_v2.html index 5bd8fae6c..a13dd8f32 100644 --- a/sapl/templates/painel/painel_v2.html +++ b/sapl/templates/painel/painel_v2.html @@ -39,63 +39,64 @@ - - - - - +{% block vue_content %} - + +
-
-

-
+ -
-
- +
+

[[ state.sessao_plenaria ]]

-
- -
-
-{% block vue_content %} -
-
- [[ parlamentar.nome ]] +
+
+ [[ state.sessao_plenaria_data ]] +
+
+ [[ state.sessao_plenaria_data ]] +
-
-{% endblock %} -
-
- +
+
+ +
-
-
-

-
- -
-
-
-
+
+
+

+
+
+
+
+
-

Parlamentares

+ + + + + + +
[[ p.nome_parlamentar ]] [[ p.filiacao ]]

Oradores

- + + + +
+ [[ o.ordem_pronunciamento ]]º   [[ o.nome_parlamentar ]]
@@ -136,7 +137,7 @@

Matéria em Votação


- + [[ materia_legislativa_ementa ]]
@@ -148,7 +149,8 @@
-
+ +{% endblock %} {% block webpack_loader_js %} {% render_chunk_vendors 'js' %} @@ -158,227 +160,4 @@ {% block webpack_loader_chunks_js %} {% endblock webpack_loader_chunks_js %} - \ No newline at end of file