Browse Source

Sessnao 17

master
eduveks 5 years ago
parent
commit
5efd3472b0
13 changed files with 217 additions and 20 deletions
  1. +40
    -0
      server/services/api/publications/get.js
  2. +2
    -0
      server/services/api/publications/options.js
  3. +22
    -0
      server/services/api/publications/put.js
  4. +1
    -1
      server/setup/_schema-form-1-cidade.js
  5. +5
    -5
      server/setup/_schema-form-2-comunidade.js
  6. +5
    -7
      server/setup/_schema-form-3-pessoa.js
  7. +2
    -2
      server/setup/_schema-form-4-pessoa_comunidade.js
  8. +5
    -5
      server/setup/_schema-form-5-publicacao.js
  9. +65
    -0
      website/src/containers/PublicationForm/index.js
  10. +8
    -0
      website/src/containers/PublicationForm/index.less
  11. +49
    -0
      website/src/containers/PublicationsList/index.js
  12. +8
    -0
      website/src/containers/PublicationsList/index.less
  13. +5
    -0
      website/src/pages/Community/index.js

+ 40
- 0
server/services/api/publications/get.js View File

@ -0,0 +1,40 @@
// _core : social/userPessoa
const dbPublicacoes = _db.query(`
SELECT
publicacao.uid,
pessoa.nome,
pessoa.sobrenome,
publicacao.momento,
comunidade.nome AS "comunidade",
cidade.nome AS "cidade",
publicacao.mensagem
FROM publicacao
INNER JOIN pessoa ON publicacao.pessoa_id = pessoa.id
INNER JOIN comunidade ON publicacao.comunidade_id = comunidade.id
INNER JOIN cidade ON pessoa.cidade_id = cidade.id
WHERE publicacao.active = true
AND comunidade.id IN (
SELECT
comunidade.id
FROM pessoa_comunidade
WHERE pessoa_id = ?
)
ORDER BY momento desc, cidade.nome, comunidade.nome
`, userPessoa().getInt("id"))
const data = _val.list()
for (const dbPublicacao of dbPublicacoes) {
data.add(
_val.map()
.set("uid", dbPublicacao.getString("uid"))
.set("name", dbPublicacao.getString("nome") +' '+ dbPublicacao.getString("sobrenome"))
.set("moment", dbPublicacao.getSQLTimestamp("momento"))
.set("community", dbPublicacao.getString("comunidade"))
.set("city", dbPublicacao.getString("cidade"))
.set("message", dbPublicacao.getString("mensagem"))
)
}
_out.json(data)

+ 2
- 0
server/services/api/publications/options.js View File

@ -0,0 +1,2 @@
_out.json(_val.map().set("result", true))

+ 22
- 0
server/services/api/publications/put.js View File

@ -0,0 +1,22 @@
// _core : social/userPessoa
const message = _req.getString("message")
const communityUid = _req.getString("community_uid")
const dbComunidade = _db.get('comunidade', communityUid)
const data = _val.map()
.set("pessoa_id", userPessoa().getInt("id"))
.set("mensagem", message)
.set("momento", _db.timestamp())
if (dbComunidade) {
data.set("comunidade_id", dbComunidade.getInt("id"))
}
_db.insert(
"publicacao",
data
)
_out.json(_val.map().set("result", true))

+ 1
- 1
server/setup/_schema-form-1-cidade.js View File

@ -43,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "text") .set("type", "text")
.set("uid", "1e96ea9a-2ab8-4017-8940-be887a218d40")
.set("uid", "5baa007f-b257-4348-b5f9-e3b3b0acab20")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)


+ 5
- 5
server/setup/_schema-form-2-comunidade.js View File

@ -43,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "select") .set("type", "select")
.set("uid", "bae32a17-9f46-4d6b-9eaf-446ad0433b2b")
.set("uid", "f486c105-92b6-4bbc-bc23-68991dedbe6a")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -73,7 +73,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "texthtml") .set("type", "texthtml")
.set("uid", "4206cc5b-69ef-4cb7-a6a3-8a2f013be6bb")
.set("uid", "1b7c6e1d-5ed6-4c96-923c-ebeb3d2e4129")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -103,7 +103,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "image") .set("type", "image")
.set("uid", "2ee59c1a-0a2e-44cc-b7a2-9e004a03e21c")
.set("uid", "14f076e8-cf51-4789-94e8-d2984cf443b2")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -133,7 +133,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "text") .set("type", "text")
.set("uid", "cfc6a437-eb64-4b03-9662-af4bba066023")
.set("uid", "2bbd4246-d0e5-4003-996f-e5fd878d1433")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -163,7 +163,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "multiselect") .set("type", "multiselect")
.set("uid", "5ac88174-db49-4200-a192-9964e8cd1951")
.set("uid", "6ad8354b-ce2a-4f19-8471-08310180795d")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)


+ 5
- 7
server/setup/_schema-form-3-pessoa.js View File

@ -20,12 +20,10 @@ _form.createIfNotExists(
.set("export_xls", true) .set("export_xls", true)
.set("export_xml", true) .set("export_xml", true)
.set("firebase", "") .set("firebase", "")
.set("group_uid", "4cb2df92-ddae-4426-b054-50b53b5eec6f")
.set("name", "pessoa") .set("name", "pessoa")
.set("report", false) .set("report", false)
.set("show_id", true) .set("show_id", true)
.set("uid", "262e9f17-3d70-4067-b28d-bafc98f56d80") .set("uid", "262e9f17-3d70-4067-b28d-bafc98f56d80")
.set("user_uid", "658660bc-efe4-4236-8114-31cd19fc3c80")
) )
_form.createComponentIfNotExists( _form.createComponentIfNotExists(
"262e9f17-3d70-4067-b28d-bafc98f56d80", "262e9f17-3d70-4067-b28d-bafc98f56d80",
@ -45,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "select") .set("type", "select")
.set("uid", "970e6464-a8ff-4271-b918-5be62a1a17b1")
.set("uid", "4509d89f-2680-42e1-862c-10c1e250c275")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -75,7 +73,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "email") .set("type", "email")
.set("uid", "3fdac963-bd9e-4942-9716-afe27ffec01e")
.set("uid", "857f954e-3a1e-47d2-84a4-1eeb5356f5cb")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -105,7 +103,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "text") .set("type", "text")
.set("uid", "389329ea-84ad-4b77-8673-06bc0e2e7d66")
.set("uid", "2ec76837-7104-476f-9a7d-9367883b9b89")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -135,7 +133,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "text") .set("type", "text")
.set("uid", "79615e56-bfa4-49f3-853f-2a6d8328d88e")
.set("uid", "2ab8c260-6cce-4746-b05a-3912965615e8")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -165,7 +163,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "user") .set("type", "user")
.set("uid", "13867837-920d-44b8-8511-9b9123720bea")
.set("uid", "3e00412b-e688-40fe-8200-2dceafa42da7")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)


+ 2
- 2
server/setup/_schema-form-4-pessoa_comunidade.js View File

@ -44,7 +44,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "select") .set("type", "select")
.set("uid", "fd7d1365-2272-41a7-b8f5-2fb5bd17a0b2")
.set("uid", "59dba70e-898f-4fb1-b6d7-af3ba4446385")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -74,7 +74,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "select") .set("type", "select")
.set("uid", "77cd4d81-0e70-4ddb-a6a9-8c09cc599c73")
.set("uid", "5d80ca44-c83a-45d4-a537-d5a184731064")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)


+ 5
- 5
server/setup/_schema-form-5-publicacao.js View File

@ -36,14 +36,14 @@ _form.createComponentIfNotExists(
.set("max", 0) .set("max", 0)
.set("min", 0) .set("min", 0)
.set("name", "comunidade_id") .set("name", "comunidade_id")
.set("notnull", true)
.set("notnull", false)
.set("primarykey", false) .set("primarykey", false)
.set("properties", "{\"MAX_COLUMN_LENGTH\":{\"default\":\"0\",\"type\":\"INTEGER\",\"value\":\"0\"},\"COLUMN_SEPARATOR\":{\"default\":\" - \",\"type\":\"LINK_SEPARATOR\",\"value\":\" - \"},\"LINK\":{\"default\":\"\",\"type\":\"LINK\",\"value\":\"comunidade:nome\"},\"SERVICE\":{\"default\":\"com/Select.netuno\",\"type\":\"STRING\",\"value\":\"com/Select.netuno\"},\"ONLY_ACTIVES\":{\"default\":\"false\",\"type\":\"BOOLEAN\",\"value\":\"false\"}}") .set("properties", "{\"MAX_COLUMN_LENGTH\":{\"default\":\"0\",\"type\":\"INTEGER\",\"value\":\"0\"},\"COLUMN_SEPARATOR\":{\"default\":\" - \",\"type\":\"LINK_SEPARATOR\",\"value\":\" - \"},\"LINK\":{\"default\":\"\",\"type\":\"LINK\",\"value\":\"comunidade:nome\"},\"SERVICE\":{\"default\":\"com/Select.netuno\",\"type\":\"STRING\",\"value\":\"com/Select.netuno\"},\"ONLY_ACTIVES\":{\"default\":\"false\",\"type\":\"BOOLEAN\",\"value\":\"false\"}}")
.set("rowspan", 0) .set("rowspan", 0)
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "select") .set("type", "select")
.set("uid", "d0321e7d-0543-40d9-8cbc-0b3d4169b3be")
.set("uid", "d241be61-1b79-49db-8b42-8a5632550811")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -73,7 +73,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "textarea") .set("type", "textarea")
.set("uid", "7486f7ea-e143-4004-929c-02e98fc22958")
.set("uid", "89a4f632-fed7-4f8a-bbf1-97c1eab9ac04")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -103,7 +103,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "datetime") .set("type", "datetime")
.set("uid", "5528afca-3a7f-46f7-b2d8-f5b4d319a51e")
.set("uid", "a0d20c4a-0bc7-4ccb-94d5-cee332bfca9b")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)
@ -133,7 +133,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0) .set("tdheight", 0)
.set("tdwidth", 0) .set("tdwidth", 0)
.set("type", "select") .set("type", "select")
.set("uid", "73b72808-57c6-41ba-a072-ea198d364ea9")
.set("uid", "ad40ef86-8aa7-46ad-b966-9a4872a4b447")
.set("user_id", 0) .set("user_id", 0)
.set("whenedit", true) .set("whenedit", true)
.set("whenexport", true) .set("whenexport", true)


+ 65
- 0
website/src/containers/PublicationForm/index.js View File

@ -0,0 +1,65 @@
import React, { useEffect, useRef, useState} from 'react';
import _service from '@netuno/service-client';
import { Form, Input, Button, Upload, notification } from 'antd';
import "./index.less";
const { TextArea } = Input;
export default ({ communityUid, onPublish })=> {
const form = useRef(null);
const onFinish = (values)=> {
_service({
method: 'PUT',
url: "api/publications",
data: {
community_uid: communityUid,
message: values.message
},
success: (response) => {
if (onPublish) {
onPublish();
}
form.current.resetFields();
notification["error"]({
message: 'Publicação',
description: 'A publicação foi guardada com sucesso.',
});
},
fail: (e) => {
console.log("Service Error", e);
notification["error"]({
message: 'Publicação',
description: 'Não foi possível guardar a publicação.',
});
}
});
};
return (
<Form
ref={ form }
name="basic"
layout="vertical"
onFinish={ onFinish }
>
<Form.Item
label="Mensagem"
name="message"
rules={
[{
required: true,
message: "Por favor preencha a mensagem."
}]
}>
<TextArea rows={4} />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
Publicar
</Button>
</Form.Item>
</Form>
);
};

+ 8
- 0
website/src/containers/PublicationForm/index.less View File

@ -0,0 +1,8 @@
.communities {
&__list {
list-style: none;
padding: 0;
margin: 0;
}
}

+ 49
- 0
website/src/containers/PublicationsList/index.js View File

@ -0,0 +1,49 @@
import React, { useEffect, useState} from 'react';
import { Link } from "react-router-dom";
import _service from '@netuno/service-client';
import { Button, notification } from 'antd';
import { CheckCircleOutlined } from '@ant-design/icons';
import "./index.less";
export default ({ communityUid })=> {
const [publications, setPublications] = useState(null);
useEffect(() => {
_service({
url: "api/publications",
data: { communityUid },
success: (response) => {
setPublications(response.json);
},
fail: (e) => {
console.log("Service Error", e);
notification["error"]({
message: 'Publicações',
description: 'Não foi possível carregar as publicações.',
});
}
});
}, []);
return (
<div>
<h1>Publicações</h1>
{
publications && publications.map(
({ name, message, moment, city, community }) => {
return (
<div>
<b>{name}</b>
<div>{message}</div>
{city}: <i>{moment}</i> em <i>{community}</i>
</div>
);
}
)
}
</div>
);
};

+ 8
- 0
website/src/containers/PublicationsList/index.less View File

@ -0,0 +1,8 @@
.communities {
&__list {
list-style: none;
padding: 0;
margin: 0;
}
}

+ 5
- 0
website/src/pages/Community/index.js View File

@ -8,6 +8,9 @@ import { Button, Spin, Row, Col, notification } from 'antd';
import { CheckCircleOutlined } from '@ant-design/icons'; import { CheckCircleOutlined } from '@ant-design/icons';
import PublicationForm from '../../containers/PublicationForm';
import PublicationsList from '../../containers/PublicationsList';
import "./index.less"; import "./index.less";
export default ()=> { export default ()=> {
@ -66,6 +69,8 @@ export default ()=> {
<Col span={8}>Publicações: {data.publications}</Col> <Col span={8}>Publicações: {data.publications}</Col>
<Col span={8}>{ following ? <><CheckCircleOutlined /> Seguindo</> : <Button type="link" onClick={onFollow}>Seguir</Button> }</Col> <Col span={8}>{ following ? <><CheckCircleOutlined /> Seguindo</> : <Button type="link" onClick={onFollow}>Seguir</Button> }</Col>
</Row> </Row>
<PublicationForm communityUid={uid} />
<PublicationsList communityUid={uid} />
</div> </div>
); );
}; };

Loading…
Cancel
Save