Browse Source

update sessao 2

master
pedro.luis@sitana.pt 5 years ago
parent
commit
445e8b01e5
5 changed files with 28 additions and 29 deletions
  1. BIN
      dbs/social.mv.db
  2. +3
    -3
      public/scripts/main.js
  3. +1
    -1
      public/scripts/main.js.map
  4. +3
    -4
      server/services/pessoas/get.js
  5. +21
    -21
      ui/src/containers/TabelaPessoas/index.jsx

BIN
dbs/social.mv.db View File


+ 3
- 3
public/scripts/main.js View File

@ -80153,7 +80153,7 @@ var TabelaPessoas = function TabelaPessoas(_ref) {
setCarregando(false); setCarregando(false);
antd_lib_notification__WEBPACK_IMPORTED_MODULE_4___default.a["error"]({ antd_lib_notification__WEBPACK_IMPORTED_MODULE_4___default.a["error"]({
message: 'Tabela de Pessoas', message: 'Tabela de Pessoas',
description: 'Houve uma falha ao carregar a tabela das pessoas..',
description: 'Houve uma falha ao carregar a tabela das pessoas...',
style: { style: {
marginTop: 100 marginTop: 100
} }
@ -80164,7 +80164,7 @@ var TabelaPessoas = function TabelaPessoas(_ref) {
method: "GET", method: "GET",
url: "/services/pessoas", url: "/services/pessoas",
credentials: "include", credentials: "include",
sucess: function sucess(response) {
success: function success(response) {
if (response.json) { if (response.json) {
setTabelaDados(response.json); setTabelaDados(response.json);
setCarregando(false); setCarregando(false);
@ -80173,7 +80173,7 @@ var TabelaPessoas = function TabelaPessoas(_ref) {
} }
}, },
fail: function fail(e) { fail: function fail(e) {
console.log("Erro ao carregar dados");
console.log("Pessoas Fail.", e);
_fail(); _fail();
} }


+ 1
- 1
public/scripts/main.js.map
File diff suppressed because it is too large
View File


+ 3
- 4
server/services/pessoas/get.js View File

@ -1,4 +1,3 @@
const dbPessoas = _db.query(` const dbPessoas = _db.query(`
SELECT SELECT
pessoa.uid, pessoa.uid,
@ -12,7 +11,7 @@ const dbPessoas = _db.query(`
const dados = _val.list() const dados = _val.list()
for(const dbPessoa of dbPessoas) {
for (const dbPessoa of dbPessoas) {
const dbComunidades = _db.query(` const dbComunidades = _db.query(`
SELECT SELECT
comunidade.nome comunidade.nome
@ -21,7 +20,7 @@ for(const dbPessoa of dbPessoas) {
WHERE pessoa_comunidade.pessoa_id = ? WHERE pessoa_comunidade.pessoa_id = ?
`, dbPessoa.getInt("id")) `, dbPessoa.getInt("id"))
const dadosComunidades = _val.list() const dadosComunidades = _val.list()
for(const dbComunidade of dbComunidades) {
for (const dbComunidade of dbComunidades) {
dadosComunidades.add( dadosComunidades.add(
_val.map() _val.map()
.set("nome", dbComunidade.getString("nome")) .set("nome", dbComunidade.getString("nome"))
@ -36,4 +35,4 @@ for(const dbPessoa of dbPessoas) {
) )
} }
_out.json("Pessoas Serviço")
_out.json(dados)

+ 21
- 21
ui/src/containers/TabelaPessoas/index.jsx View File

@ -2,11 +2,11 @@ import React, { useEffect, useState } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import Table from 'antd/lib/table'; import Table from 'antd/lib/table';
import Tag from 'antd/lib/tag'; import Tag from 'antd/lib/tag';
import notification from 'antd/lib/notification'
import notification from 'antd/lib/notification';
const TabelaPessoas = ({ buttonRef, text, click }) => { const TabelaPessoas = ({ buttonRef, text, click }) => {
const [tabelaDados, setTabelaDados ] = useState([]);
const [carregando, setCarregando ] = useState(false);
const [ tabelaDados, setTabelaDados ] = useState([]);
const [ carregando, setCarregando ] = useState(false);
useEffect(() => { useEffect(() => {
setCarregando(true); setCarregando(true);
@ -15,7 +15,7 @@ const TabelaPessoas = ({ buttonRef, text, click }) => {
notification["error"]({ notification["error"]({
message: 'Tabela de Pessoas', message: 'Tabela de Pessoas',
description: description:
'Houve uma falha ao carregar a tabela das pessoas..',
'Houve uma falha ao carregar a tabela das pessoas...',
style: { style: {
marginTop: 100 marginTop: 100
} }
@ -25,51 +25,51 @@ const TabelaPessoas = ({ buttonRef, text, click }) => {
method: "GET", method: "GET",
url: "/services/pessoas", url: "/services/pessoas",
credentials: "include", credentials: "include",
sucess: (response) => {
if(response.json) {
success: (response) => {
if (response.json) {
setTabelaDados(response.json); setTabelaDados(response.json);
setCarregando(false); setCarregando(false);
}
else {
} else {
fail(); fail();
} }
}, },
fail: (e) => { fail: (e) => {
console.log("Erro ao carregar dados");
console.log("Pessoas Fail.", e);
fail(); fail();
} }
})
});
}, []) }, [])
const columns = [ const columns = [
{ {
title: 'Nome', title: 'Nome',
dataIndex:'nome',
key:'nome'
dataIndex: 'nome',
key: 'nome'
}, },
{ {
title: 'Cidade', title: 'Cidade',
dataIndex:'cidade',
key:'cidade'
dataIndex: 'cidade',
key: 'cidade'
}, },
{ {
title: 'Comunidades', title: 'Comunidades',
dataIndex:'comunidades',
key:'comunidades',
dataIndex: 'comunidades',
key: 'comunidades',
render: (comunidades, data) => <> render: (comunidades, data) => <>
{ {
comunidades.map((comunidade) => comunidades.map((comunidade) =>
<Tag key={comunidade.nome}>{comunidade.nome}</Tag>)
<Tag key={comunidade.nome}>{comunidade.nome}</Tag>
)
} }
</> </>
} }
]
];
return (
return (
<div> <div>
<Table columns={columns} dataSource ={tabelaDados} loading ={carregando} />
<Table columns={ columns } dataSource={ tabelaDados } loading={carregando} />
</div> </div>
)
);
}; };
TabelaPessoas.propTypes = { TabelaPessoas.propTypes = {


Loading…
Cancel
Save