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);
antd_lib_notification__WEBPACK_IMPORTED_MODULE_4___default.a["error"]({
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: {
marginTop: 100
}
@ -80164,7 +80164,7 @@ var TabelaPessoas = function TabelaPessoas(_ref) {
method: "GET",
url: "/services/pessoas",
credentials: "include",
sucess: function sucess(response) {
success: function success(response) {
if (response.json) {
setTabelaDados(response.json);
setCarregando(false);
@ -80173,7 +80173,7 @@ var TabelaPessoas = function TabelaPessoas(_ref) {
}
},
fail: function fail(e) {
console.log("Erro ao carregar dados");
console.log("Pessoas Fail.", e);
_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(`
SELECT
pessoa.uid,
@ -12,7 +11,7 @@ const dbPessoas = _db.query(`
const dados = _val.list()
for(const dbPessoa of dbPessoas) {
for (const dbPessoa of dbPessoas) {
const dbComunidades = _db.query(`
SELECT
comunidade.nome
@ -21,7 +20,7 @@ for(const dbPessoa of dbPessoas) {
WHERE pessoa_comunidade.pessoa_id = ?
`, dbPessoa.getInt("id"))
const dadosComunidades = _val.list()
for(const dbComunidade of dbComunidades) {
for (const dbComunidade of dbComunidades) {
dadosComunidades.add(
_val.map()
.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 Table from 'antd/lib/table';
import Tag from 'antd/lib/tag';
import notification from 'antd/lib/notification'
import notification from 'antd/lib/notification';
const TabelaPessoas = ({ buttonRef, text, click }) => {
const [tabelaDados, setTabelaDados ] = useState([]);
const [carregando, setCarregando ] = useState(false);
const [ tabelaDados, setTabelaDados ] = useState([]);
const [ carregando, setCarregando ] = useState(false);
useEffect(() => {
setCarregando(true);
@ -15,7 +15,7 @@ const TabelaPessoas = ({ buttonRef, text, click }) => {
notification["error"]({
message: 'Tabela de Pessoas',
description:
'Houve uma falha ao carregar a tabela das pessoas..',
'Houve uma falha ao carregar a tabela das pessoas...',
style: {
marginTop: 100
}
@ -25,51 +25,51 @@ const TabelaPessoas = ({ buttonRef, text, click }) => {
method: "GET",
url: "/services/pessoas",
credentials: "include",
sucess: (response) => {
if(response.json) {
success: (response) => {
if (response.json) {
setTabelaDados(response.json);
setCarregando(false);
}
else {
} else {
fail();
}
},
fail: (e) => {
console.log("Erro ao carregar dados");
console.log("Pessoas Fail.", e);
fail();
}
})
});
}, [])
const columns = [
{
title: 'Nome',
dataIndex:'nome',
key:'nome'
dataIndex: 'nome',
key: 'nome'
},
{
title: 'Cidade',
dataIndex:'cidade',
key:'cidade'
dataIndex: 'cidade',
key: 'cidade'
},
{
title: 'Comunidades',
dataIndex:'comunidades',
key:'comunidades',
dataIndex: 'comunidades',
key: 'comunidades',
render: (comunidades, data) => <>
{
comunidades.map((comunidade) =>
<Tag key={comunidade.nome}>{comunidade.nome}</Tag>)
<Tag key={comunidade.nome}>{comunidade.nome}</Tag>
)
}
</>
}
]
];
return (
return (
<div>
<Table columns={columns} dataSource ={tabelaDados} loading ={carregando} />
<Table columns={ columns } dataSource={ tabelaDados } loading={carregando} />
</div>
)
);
};
TabelaPessoas.propTypes = {


Loading…
Cancel
Save