diff --git a/frontend/src/__apps/painel/main.js b/frontend/src/__apps/painel/main.js index 9bb9481c6..52784cf25 100644 --- a/frontend/src/__apps/painel/main.js +++ b/frontend/src/__apps/painel/main.js @@ -5,11 +5,17 @@ import Vue from 'vue' import StopWatch from '../../components/StopWatch.vue' import PainelHeader from '../../components/PainelHeader.vue' import PainelParlamentares from '../../components/PainelParlamentares.vue' +import PainelOradores from '../../components/PainelOradores.vue' +import PainelMateria from '../../components/PainelMateria.vue' +import PainelResultado from '../../components/PainelResultado.vue' // register components Vue.component('cronometro', StopWatch) Vue.component('painel-header', PainelHeader) Vue.component('painel-parlamentares', PainelParlamentares) +Vue.component('painel-oradores', PainelOradores) +Vue.component('painel-materia', PainelMateria) +Vue.component('painel-resultado', PainelResultado) new Vue({ el: '#painel', @@ -17,12 +23,16 @@ new Vue({ data() { return { controllerId: null, + // TODO: state here is really needed? state: { sessao_plenaria: '', sessao_plenaria_data: '', sessao_plenaria_hora_inicio: '', votacao: [], - parlamentares: [] + parlamentares: [], + oradores: [], + materia: {}, + resultado: {}, }, ws: null, isOpen: false, @@ -54,21 +64,40 @@ new Vue({ // SETUP STATE console.log(`FROM VUEJS: ${evt.data}`) // DEBUG + // PARLAMENTARES const parlamentaresInstance = this.$refs.parlamentares parlamentaresInstance.parlamentares = msg.parlamentares + // HEADER DO PAINEL //TODO: group in a single SessaoPlenaria object const headerInstance = this.$refs.painelHeader; + // SESSAO_PLENARIA //TODO: setup as child's props? headerInstance.sessao_plenaria = msg.sessao.sessao_plenaria headerInstance.sessao_plenaria_data = msg.sessao.sessao_plenaria_data headerInstance.sessao_plenaria_hora_inicio = msg.sessao.sessao_plenaria_hora_inicio headerInstance.brasao = msg.sessao.brasao - this.state.oradores = msg.oradores - this.state.materia_legislativa_ementa = msg.mensagem_legislativa_ementa - this.state.resultado = msg.votacao + // ORADORES + const oradoresInstance = this.$refs.oradores + oradoresInstance.oradores = msg.oradores + + // MATERIA + const materiaInstance = this.$refs.materia + materiaInstance.materia = msg.materia + + // RESULTADO + const resultadoInstance = this.$refs.resultado + resultadoInstance.resultado = msg.resultado + + if (msg.votos_parlamentares) { // && mostrar voto + parlamentaresInstance.parlamentares.forEach((p)=>{ + if (p.parlamentar_id in msg.votos_parlamentares) { + p.voto = msg.votos_parlamentares[p.parlamentar_id].voto + } + }); + } if (msg.type === 'state') this.state = msg.payload || {} } catch (e) { console.warn('WS parse error:', e) } diff --git a/frontend/src/components/PainelMateria.vue b/frontend/src/components/PainelMateria.vue new file mode 100644 index 000000000..bbe470b9e --- /dev/null +++ b/frontend/src/components/PainelMateria.vue @@ -0,0 +1,35 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/PainelOradores.vue b/frontend/src/components/PainelOradores.vue new file mode 100644 index 000000000..703cfa3eb --- /dev/null +++ b/frontend/src/components/PainelOradores.vue @@ -0,0 +1,31 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/PainelParlamentares.vue b/frontend/src/components/PainelParlamentares.vue index b955eb09f..9981240c5 100644 --- a/frontend/src/components/PainelParlamentares.vue +++ b/frontend/src/components/PainelParlamentares.vue @@ -7,7 +7,7 @@ {{ p.nome_parlamentar }} {{ p.filiacao }} - + {{ p.voto }} diff --git a/frontend/src/components/PainelResultado.vue b/frontend/src/components/PainelResultado.vue new file mode 100644 index 000000000..0323665f5 --- /dev/null +++ b/frontend/src/components/PainelResultado.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/sapl/painel/consumers.py b/sapl/painel/consumers.py index 08bf0aa6e..121247f5b 100644 --- a/sapl/painel/consumers.py +++ b/sapl/painel/consumers.py @@ -27,7 +27,7 @@ def get_dados_painel(pk: int) -> dict: # { 1: { "id": 1, "nome": "fulano", "filiacao": "aquela"}, ...} # [ { "id": 1, "nome": "fulano", "filiacao": "aquela"}, ... ] - + # sessao_plenaria_id/pk = 2546 # Painel presentes = SessaoPresencaView.objects.filter(sessao_plenaria_id=pk, @@ -42,22 +42,26 @@ def get_dados_painel(pk: int) -> dict: ) oradores = [dict(zip(['ordem_pronunciamento', 'nome_parlamentar'], o)) for o in oradores] - votos = SessaoMateriaVotacaoView.objects.get(sessao_plenaria_id=pk, - etapa_sessao='expediente', - materia_id=31919) + votacao = SessaoMateriaVotacaoView.objects.get(sessao_plenaria_id=pk, + etapa_sessao='expediente', + materia_id=31919) + + # TODO: check if votacao has numero_votos! + votacao.numero_votos.update({"num_presentes": len(parlamentares)}) # TODO: recover stopwatch state from DB/Cache stopwatch = { - "type": "stopwatch.state", - "id": "sw:main", - "status": "running", # "running" | "paused" | "stopped" - "started_at_ms": 1699990000123, # epoch ms when (re)started - "elapsed_ms": 5320 + "type": "stopwatch.state", + "id": "sw:main", + "status": "running", # "running" | "paused" | "stopped" + "started_at_ms": 1699990000123, # epoch ms when (re)started + "elapsed_ms": 5320 } dados_sessao = { "type": "data", "sessao": { + "sessao_plenaria_id": sessao.id, "status_painel": sessao.painel_aberto, "brasao": brasao, "mostrar_voto": app_config.mostrar_voto, @@ -71,9 +75,17 @@ def get_dados_painel(pk: int) -> dict: }, "parlamentares": parlamentares, "oradores": oradores, - "votacao": votos.total_votos, # TODO unify into single json - "votos_parlamentar": votos.votos_parlamentares, # TODO: unify into single JSON - "materia_legislativa_ementa": votos.materia.ementa, + "resultado": { + "resultado_votacao": votacao.resultado_votacao, + "resultado": votacao.resultado, + "numero_votos": votacao.numero_votos, + }, + "votos_parlamentares": {p["parlamentar_id"]: p for p in votacao.votos_parlamentares}, + "materia": { + "materia_id": votacao.materia.id, + "texto": str(votacao.materia), + "ementa": votacao.materia.ementa, + }, "stopwatch": stopwatch, # TODO: array of stopwatches } diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 7ebd7bbe8..8f6523cd8 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -658,7 +658,7 @@ def painel_controller_view(request): if command: layer = get_channel_layer() - controller_id = 2393 # TODO: recover from template call + controller_id = 2393 # TODO: sessaoplenaria_id recover from template call group = f"controller_{controller_id}" print(group) diff --git a/sapl/sessao/migrations/0070_views_sessao_plenaria.py b/sapl/sessao/migrations/0070_views_sessao_plenaria.py index 12595f606..eda5cbcb6 100644 --- a/sapl/sessao/migrations/0070_views_sessao_plenaria.py +++ b/sapl/sessao/migrations/0070_views_sessao_plenaria.py @@ -4,7 +4,6 @@ from django.db import migrations class Migration(migrations.Migration): - dependencies = [ ('sessao', '0069_auto_20220919_1705'), ] @@ -153,7 +152,8 @@ class Migration(migrations.Migration): 'expediente' etapa_sessao, em.numero_ordem, em.materia_id, - ml.ementa, + tm.descricao||' nº '||ml.numero||' de '||ml.ano as materia_texto, + ml.ementa materia_ementa, tipo_votacao, CASE tipo_votacao WHEN 1 THEN 'Simbólia' @@ -164,18 +164,20 @@ class Migration(migrations.Migration): END as tipo_votacao_descricao, resultado_votacao, em.resultado, - total_votos, + numero_votos, votos_parlamentares, votacao_aberta FROM sessao_expedientemateria em JOIN materia_materialegislativa ml ON (em.materia_id = ml.id) + JOIN materia_tipomaterialegislativa tm ON (ml.tipo_id = tm.id) LEFT JOIN sessao_registroleitura rl on (rl.expediente_id = em.id) LEFT JOIN LATERAL ( SELECT jsonb_build_object( - 'sim', coalesce(rv.numero_votos_sim, 0), - 'não', coalesce(rv.numero_votos_nao, 0), - 'abstencoes', coalesce(rv.numero_abstencoes, 0) - ) as total_votos, + 'votos_sim', coalesce(rv.numero_votos_sim, 0), + 'votos_nao', coalesce(rv.numero_votos_nao, 0), + 'abstencoes', coalesce(rv.numero_abstencoes, 0), + 'total_votos', coalesce(rv.numero_votos_sim, 0) + coalesce(rv.numero_votos_nao, 0) + coalesce(rv.numero_abstencoes, 0) + ) as numero_votos, trv.nome resultado_votacao FROM sessao_registrovotacao rv JOIN sessao_tiporesultadovotacao trv on (rv.tipo_resultado_votacao_id = trv.id) @@ -204,6 +206,7 @@ class Migration(migrations.Migration): 'ordemdia' etapa_sessao, od.numero_ordem, od.materia_id, + tm.descricao||' nº '||ml.numero||' de '||ml.ano as materia_texto, ml.ementa, tipo_votacao, CASE tipo_votacao @@ -215,18 +218,20 @@ class Migration(migrations.Migration): END as tipo_votacao_descricao, resultado_votacao, od.resultado, - total_votos, + numero_votos, votos_parlamentares, votacao_aberta FROM sessao_ordemdia od JOIN materia_materialegislativa ml ON (od.materia_id = ml.id) + JOIN materia_tipomaterialegislativa tm ON (ml.tipo_id = tm.id) LEFT JOIN sessao_registroleitura rl on (od.id = rl.expediente_id) LEFT JOIN LATERAL ( SELECT jsonb_build_object( - 'sim', coalesce(rv.numero_votos_sim, 0), - 'não', coalesce(rv.numero_votos_nao, 0), - 'abstencoes', coalesce(rv.numero_abstencoes, 0) - ) as total_votos, + 'votos_sim', coalesce(rv.numero_votos_sim, 0), + 'votos_nao', coalesce(rv.numero_votos_nao, 0), + 'abstencoes', coalesce(rv.numero_abstencoes, 0), + 'total_votos', coalesce(rv.numero_votos_sim, 0) + coalesce(rv.numero_votos_nao, 0) + coalesce(rv.numero_abstencoes, 0) + ) as numero_votos, trv.nome resultado_votacao FROM sessao_registrovotacao rv JOIN sessao_tiporesultadovotacao trv on (rv.tipo_resultado_votacao_id = trv.id) @@ -249,7 +254,7 @@ class Migration(migrations.Migration): ) SELECT * FROM votacao_materias - ORDER BY sessao_plenaria_id, etapa_sessao, numero_ordem + ORDER BY sessao_plenaria_id, etapa_sessao, numero_ordem """ ) ] diff --git a/sapl/sessao/models.py b/sapl/sessao/models.py index 6770b573c..3ac1fbeda 100644 --- a/sapl/sessao/models.py +++ b/sapl/sessao/models.py @@ -1117,7 +1117,7 @@ class SessaoMateriaVotacaoView(models.Model): numero_ordem = models.PositiveIntegerField(verbose_name=_('Número de Ordem')) - total_votos = JSONField(null=True, verbose_name=_('Total Votos')) + numero_votos = JSONField(null=True, verbose_name=_('Total Votos')) votos_parlamentares = JSONField(null=True, verbose_name=_('Votos Parlamentares')) diff --git a/sapl/templates/painel/painel_v2.html b/sapl/templates/painel/painel_v2.html index 4583667aa..5f965439b 100644 --- a/sapl/templates/painel/painel_v2.html +++ b/sapl/templates/painel/painel_v2.html @@ -53,27 +53,12 @@
-
-

Oradores

- - - -
- [[ o.ordem_pronunciamento ]]º   [[ o.nome_parlamentar ]]
-
- +

Cronômetros

- -
- Discurso:
Aparte:
Questão de Ordem:
@@ -81,30 +66,9 @@
-
-
-

Resultado

- - -
-
- - -
-
+ -
-

Matéria em Votação

- -
- [[ materia_legislativa_ementa ]] -
- -
+