Browse Source

Follow and Unfollow

master
ss.pedroisac 5 years ago
parent
commit
663bf97aad
31 changed files with 961 additions and 558 deletions
  1. +1
    -1
      User/state/57447972.json
  2. +1
    -1
      User/state/global.json
  3. +1
    -3
      config/_development.json
  4. BIN
      dbs/social.mv.db
  5. +599
    -213
      public/scripts/main.js
  6. +1
    -1
      public/scripts/main.js.map
  7. +11
    -0
      server/core/social/userPessoa.js
  8. +42
    -0
      server/services/api/communities/detail.get.js
  9. +1
    -0
      server/services/api/communities/detail.options.js
  10. +1
    -0
      server/services/api/communities/follow.options.js
  11. +11
    -0
      server/services/api/communities/follow.put.js
  12. +32
    -0
      server/services/api/communities/get.js
  13. +9
    -0
      server/services/api/communities/image.get.js
  14. +1
    -0
      server/services/api/communities/options.js
  15. +11
    -0
      server/services/api/communities/unfollow.delete.js
  16. +1
    -0
      server/services/api/communities/unfollow.options.js
  17. +39
    -0
      server/services/api/publications/get.js
  18. +1
    -0
      server/services/api/publications/options.js
  19. +21
    -0
      server/services/api/publications/put.js
  20. +0
    -110
      server/setup/003-pessoa.js
  21. +0
    -161
      server/setup/005-publicao.js
  22. +0
    -51
      server/setup/006-pessoa-comunidade.js
  23. +1
    -1
      server/setup/_schema-form-1-cidade.js
  24. +63
    -3
      server/setup/_schema-form-2-comunidade.js
  25. +5
    -5
      server/setup/_schema-form-3-pessoa.js
  26. +2
    -2
      server/setup/_schema-form-4-pessoa_comunidade.js
  27. +4
    -4
      server/setup/_schema-form-5-publicacao.js
  28. +91
    -0
      website/src/components/Communities/index.js
  29. +0
    -0
      website/src/components/Communities/index.less
  30. +1
    -1
      website/src/index.js
  31. +10
    -1
      website/src/pages/Main/index.js

+ 1
- 1
User/state/57447972.json
File diff suppressed because it is too large
View File


+ 1
- 1
User/state/global.json
File diff suppressed because it is too large
View File


+ 1
- 3
config/_development.json View File

@ -48,9 +48,7 @@
"origins": [
"http://pedro-isac.dev.netuno.org:30730",
"http://localhost:3000",
"http://127.0.0.1:3000",
"https://pedro-cors.herokuapp.com"
"http://127.0.0.1:3000"
]
}
],


BIN
dbs/social.mv.db View File


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


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


+ 11
- 0
server/core/social/userPessoa.js View File

@ -0,0 +1,11 @@
const userPessoa = () => {
const dbPessoa = _db.queryFirst(
`
SELECT *
FROM pessoa
WHERE usuario_id = ?
`, _user.id()
)
return dbPessoa
}

+ 42
- 0
server/services/api/communities/detail.get.js View File

@ -0,0 +1,42 @@
// // _core : social/userPessoa
// const dbComunidade = _db.queryFirst(`
// SELECT
// uid,
// nome,
// descricao,
// imagem,
// (
// SELECT count(id)
// FROM pessoa_comunidade
// WHERE pessoa_id = ?
// AND comunidade_id = comunidade.id
// ) seguindo,
// (
// SELECT count(id)
// FROM pessoa_comunidade
// WHERE comunidade_id = comunidade.id
// ) pessoas,
// (
// SELECT count(id)
// FROM publicacao
// WHERE comunidade_id = comunidade.id
// ) publicacoes
// FROM comunidade
// WHERE active = true
// AND uid = ?::uuid
// ORDER BY nome
// `, userPessoa().getInt("id"), _req.getString("uid"))
// const data = _val.map()
// if (dbComunidade != null) {
// data.set("uid", dbComunidade.getString("uid"))
// .set("name", dbComunidade.getString("nome"))
// .set("description", dbComunidade.getString("descricao"))
// .set("following", dbComunidade.getInt("seguindo") > 0)
// .set("people", dbComunidade.getInt("pessoas"))
// .set("publications", dbComunidade.getInt("publicacoes"))
// }
// _out.json(data)

+ 1
- 0
server/services/api/communities/detail.options.js View File

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

+ 1
- 0
server/services/api/communities/follow.options.js View File

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

+ 11
- 0
server/services/api/communities/follow.put.js View File

@ -0,0 +1,11 @@
// _core : social/userPessoa
const dbComunidade = _db.get('comunidade', _req.getString("uid"))
_db.insert(
"pessoa_comunidade",
_val.map()
.set("pessoa_id", userPessoa().getInt("id"))
.set("comunidade_id", dbComunidade.getInt("id"))
)
_out.json(_val.map().set("result", true))

+ 32
- 0
server/services/api/communities/get.js View File

@ -0,0 +1,32 @@
// _core : social/userPessoa
const dbComunidades = _db.query(`
SELECT
uid,
nome,
descricao,
imagem,
(
SELECT count(id)
FROM pessoa_comunidade
WHERE pessoa_id = ?
AND comunidade_id = comunidade.id
) seguindo
FROM comunidade
WHERE active = true
ORDER BY nome
`, userPessoa().getInt("id"))
const data = _val.list()
for (const dbComunidade of dbComunidades) {
data.add(
_val.map()
.set("uid", dbComunidade.getString("uid"))
.set("name", dbComunidade.getString("nome"))
.set("description", dbComunidade.getString("descricao"))
.set("following", dbComunidade.getInt("seguindo"))
)
}
_out.json(dbComunidades)

+ 9
- 0
server/services/api/communities/image.get.js View File

@ -0,0 +1,9 @@
// const dbComunidade = _db.get('comunidade', _req.getString("uid"))
// _header.contentTypeJPG()
// _header.noCache()
// if (dbComunidade != null && dbComunidade.getString("imagem") != '') {
// const storageImage = _storage.database('comunidade', 'imagem', dbComunidade.getString("imagem"))
// _out.copy(storageImage.inputStream())
// }

+ 1
- 0
server/services/api/communities/options.js View File

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

+ 11
- 0
server/services/api/communities/unfollow.delete.js View File

@ -0,0 +1,11 @@
// _core : social/userPessoa
const dbComunidade = _db.get('comunidade', _req.getString("uid"))
_db.delete(
"pessoa_comunidade",
_val.map()
.set("pessoa_id", userPessoa().getInt("id"))
.set("comunidade_id", dbComunidade.getInt("id"))
)
_out.json(_val.map().set("result", true))

+ 1
- 0
server/services/api/communities/unfollow.options.js View File

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

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

@ -0,0 +1,39 @@
// _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)

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

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

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

@ -0,0 +1,21 @@
// _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))

+ 0
- 110
server/setup/003-pessoa.js View File

@ -1,110 +0,0 @@
// -----------------------------------------------------------
//
// PESSOA
//
// -----------------------------------------------------------
//
// CODE GENERATED AUTOMATICALLY
//
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "60596f2c-a697-4a52-af32-961b9effc1c8")
.set("nome", "Pedro")
.set("sobrenome", "Isac")
.set("email", "ss.pedroisac@gmail.com")
.set("cidade_id", "e2e32bc9-e25e-4073-8b08-357aaa6f11f6")
.set("usuario_id", 0)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
.set("nome", "Jo\u00E3o")
.set("sobrenome", "Silva")
.set("email", "joao.silva@gmail.com")
.set("cidade_id", "10f183aa-d58f-4af8-a996-6aecfd3e31dc")
.set("usuario_id", 0)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "3539cf55-e542-4506-a54b-5389dd0f8b57")
.set("nome", "Marial")
.set("sobrenome", "Joaquina")
.set("email", "maria@gmail.com")
.set("cidade_id", "3fa22855-0443-4944-b53c-371d08938104")
.set("usuario_id", 0)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "46846bef-3614-48fa-b3d3-c4e0f0eb47ce")
.set("nome", "Clara")
.set("sobrenome", "Ara\u00FAjo")
.set("email", "clara@gmail.com")
.set("cidade_id", "10f183aa-d58f-4af8-a996-6aecfd3e31dc")
.set("usuario_id", 0)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "fde1334e-a003-4ae7-8d54-7b0ed5333276")
.set("nome", "Pedro")
.set("sobrenome", "Isac")
.set("email", "isac@gmail.com")
.set("cidade_id", "e2e32bc9-e25e-4073-8b08-357aaa6f11f6")
.set("usuario_id", 4)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "8c35a912-e471-4bb0-a70c-520949d94628")
.set("nome", "Pedro")
.set("sobrenome", "Isac")
.set("email", "grgesac@gmail.com")
.set("cidade_id", "e2e32bc9-e25e-4073-8b08-357aaa6f11f6")
.set("usuario_id", 5)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "07552521-930e-4f21-b00a-f451bf45df45")
.set("nome", "teste")
.set("sobrenome", "teste")
.set("email", "teste@gmail.com")
.set("cidade_id", "e2e32bc9-e25e-4073-8b08-357aaa6f11f6")
.set("usuario_id", 6)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "73526288-e16a-45b2-8565-d9ba7fee2910")
.set("nome", "Pedro")
.set("sobrenome", "Isac")
.set("email", "pedroisac@gmail.com")
.set("cidade_id", "e2e32bc9-e25e-4073-8b08-357aaa6f11f6")
.set("usuario_id", 7)
);
_db.insertIfNotExists(
"pessoa",
_val.init()
.set("uid", "3eaf2dfd-058c-4996-9ddd-797c15c7f028")
.set("nome", "Pedro")
.set("sobrenome", "Isac")
.set("email", "pedro@pedro.com")
.set("cidade_id", "e2e32bc9-e25e-4073-8b08-357aaa6f11f6")
.set("usuario_id", 8)
);

+ 0
- 161
server/setup/005-publicao.js View File

@ -1,161 +0,0 @@
// -----------------------------------------------------------
//
// PUBLICACAO
//
// -----------------------------------------------------------
//
// CODE GENERATED AUTOMATICALLY
//
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "655c1668-3636-49b0-aa4c-9be889e6af3f")
.set("comunidade_id", "3ba722d1-0a5f-47f4-a775-8f8c0a1a0649")
.set("mensagem", "Jogo hoje as 19:00")
.set("momento", _db.timestamp("2021-04-01 05:20:00.0"))
.set("pessoa_id", "60596f2c-a697-4a52-af32-961b9effc1c8")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "a0474547-3a3b-4868-bd1c-bcab73727be3")
.set("comunidade_id", "00b6d9e5-d6ac-40b7-a31b-9f091e0d2647")
.set("mensagem", "Ol\u00E1 pessoal")
.set("momento", _db.timestamp("2021-04-03 19:35:00.0"))
.set("pessoa_id", "3539cf55-e542-4506-a54b-5389dd0f8b57")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "a7e9061c-d4e0-4fe4-b7a6-bd044b2bb233")
.set("comunidade_id", "3ba722d1-0a5f-47f4-a775-8f8c0a1a0649")
.set("mensagem", "wwwdw")
.set("momento", _db.timestamp("2021-04-02 18:00:00.0"))
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "c6633b56-47b7-43e5-b7d4-7d539ac5c9cd")
.set("comunidade_id", "392e4296-5d93-4b50-9fba-84ddbf17b3ee")
.set("mensagem", "dqwdqwxwqxs\nscomcoc")
.set("momento", _db.timestamp("2021-04-03 07:29:00.0"))
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "965739fd-6705-4420-b80d-5b081ad312e3")
.set("comunidade_id", "212db7f3-c03e-4b7c-91eb-507eb66b866a")
.set("mensagem", "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.")
.set("momento", _db.timestamp("2021-04-02 07:32:00.0"))
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "f711a501-a17a-4d97-9765-751a06135895")
.set("comunidade_id", "3ba722d1-0a5f-47f4-a775-8f8c0a1a0649")
.set("mensagem", "widhowid")
.set("momento", _db.timestamp("2021-04-01 18:40:00.0"))
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "6310f87d-daf1-48b3-a20a-7db24e5146e6")
.set("comunidade_id", "212db7f3-c03e-4b7c-91eb-507eb66b866a")
.set("mensagem", "wdbiwbdb")
.set("momento", _db.timestamp("2021-04-02 19:33:00.0"))
.set("pessoa_id", "46846bef-3614-48fa-b3d3-c4e0f0eb47ce")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "fffc2684-3024-4d7f-94c5-10a9760471be")
.set("comunidade_id", "212db7f3-c03e-4b7c-91eb-507eb66b866a")
.set("mensagem", "diwion wnwdn")
.set("momento", _db.timestamp("2021-04-02 18:40:00.0"))
.set("pessoa_id", "3539cf55-e542-4506-a54b-5389dd0f8b57")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "42edf3d1-338c-4f6c-a1d0-a3a0256cf89a")
.set("comunidade_id", "212db7f3-c03e-4b7c-91eb-507eb66b866a")
.set("mensagem", "d3mo3o 3omd3d")
.set("momento", _db.timestamp("2021-04-03 18:35:00.0"))
.set("pessoa_id", "60596f2c-a697-4a52-af32-961b9effc1c8")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "0d2bee19-e6aa-45a8-8802-32daff4a0a57")
.set("comunidade_id", "392e4296-5d93-4b50-9fba-84ddbf17b3ee")
.set("mensagem", "3e3ine")
.set("momento", _db.timestamp("2021-04-03 19:32:00.0"))
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "11e1e1e0-372e-4dc6-b3cf-d23a3f5af815")
.set("comunidade_id", "392e4296-5d93-4b50-9fba-84ddbf17b3ee")
.set("mensagem", "enenfoef")
.set("momento", _db.timestamp("2021-04-03 19:35:00.0"))
.set("pessoa_id", "3539cf55-e542-4506-a54b-5389dd0f8b57")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "082bdd8f-f32f-43c9-b208-a6f33d9b3238")
.set("comunidade_id", "212db7f3-c03e-4b7c-91eb-507eb66b866a")
.set("mensagem", "lmlrmfrf")
.set("momento", _db.timestamp("2021-04-01 19:35:00.0"))
.set("pessoa_id", "3539cf55-e542-4506-a54b-5389dd0f8b57")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "eb3f690d-8033-4118-add7-f14e201eb854")
.set("comunidade_id", "392e4296-5d93-4b50-9fba-84ddbf17b3ee")
.set("mensagem", "33e3")
.set("momento", _db.timestamp("2021-04-01 18:32:00.0"))
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "af28ce16-8021-4cb5-84ec-0d6ed624192a")
.set("comunidade_id", "3ba722d1-0a5f-47f4-a775-8f8c0a1a0649")
.set("mensagem", "3e3e")
.set("momento", _db.timestamp("2021-04-02 20:40:00.0"))
.set("pessoa_id", "46846bef-3614-48fa-b3d3-c4e0f0eb47ce")
);
_db.insertIfNotExists(
"publicacao",
_val.init()
.set("uid", "a88de3fa-b027-4747-8d26-dfab54752fe2")
.set("comunidade_id", "392e4296-5d93-4b50-9fba-84ddbf17b3ee")
.set("mensagem", "3e3e3e")
.set("momento", _db.timestamp("2021-04-14 19:35:00.0"))
.set("pessoa_id", "60596f2c-a697-4a52-af32-961b9effc1c8")
);

+ 0
- 51
server/setup/006-pessoa-comunidade.js View File

@ -1,51 +0,0 @@
// -----------------------------------------------------------
//
// PESSOA_COMUNIDADE
//
// -----------------------------------------------------------
//
// CODE GENERATED AUTOMATICALLY
//
_db.insertIfNotExists(
"pessoa_comunidade",
_val.init()
.set("uid", "cf1c38e9-7b6c-40c0-9772-fb174665ecb7")
.set("comunidade_id", "3ba722d1-0a5f-47f4-a775-8f8c0a1a0649")
.set("pessoa_id", "60596f2c-a697-4a52-af32-961b9effc1c8")
);
_db.insertIfNotExists(
"pessoa_comunidade",
_val.init()
.set("uid", "8090614d-3b46-4943-b73f-c2d2e3419deb")
.set("comunidade_id", "3ba722d1-0a5f-47f4-a775-8f8c0a1a0649")
.set("pessoa_id", "4fd361d2-fcbd-4381-ab4c-7e146db488e6")
);
_db.insertIfNotExists(
"pessoa_comunidade",
_val.init()
.set("uid", "f687e8c9-254e-44e9-9bef-a206e74d92ab")
.set("comunidade_id", "212db7f3-c03e-4b7c-91eb-507eb66b866a")
.set("pessoa_id", "3539cf55-e542-4506-a54b-5389dd0f8b57")
);
_db.insertIfNotExists(
"pessoa_comunidade",
_val.init()
.set("uid", "acae9601-ffb3-4348-ae26-8f83619297e8")
.set("comunidade_id", "00b6d9e5-d6ac-40b7-a31b-9f091e0d2647")
.set("pessoa_id", "46846bef-3614-48fa-b3d3-c4e0f0eb47ce")
);
_db.insertIfNotExists(
"pessoa_comunidade",
_val.init()
.set("uid", "b5282454-62b5-4654-a265-a4e1c5dbb2b5")
.set("comunidade_id", "392e4296-5d93-4b50-9fba-84ddbf17b3ee")
.set("pessoa_id", "46846bef-3614-48fa-b3d3-c4e0f0eb47ce")
);

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

@ -43,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "text")
.set("uid", "1997de37-9878-4056-b479-a992fae81647")
.set("uid", "9ea0ef2e-d84b-4a6e-afad-315a8a0b70ac")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)


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

@ -43,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "select")
.set("uid", "10bd741c-d71e-4e62-be29-f8f5b6edbb00")
.set("uid", "2de0c315-2f45-44ab-b5fe-e526543da475")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -55,6 +55,36 @@ _form.createComponentIfNotExists(
.set("x", 1)
.set("y", 3)
)
_form.createComponentIfNotExists(
"2289a1d1-2223-40ff-9086-be35e13adc27",
_val.init()
.set("colspan", 0)
.set("displayname", "Descricao")
.set("firebase", "")
.set("group_id", 0)
.set("height", 0)
.set("max", 0)
.set("min", 0)
.set("name", "descricao")
.set("notnull", false)
.set("primarykey", false)
.set("properties", "{}")
.set("rowspan", 0)
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "texthtml")
.set("uid", "bf0f13f5-3024-4cf3-b63c-6678d4f29482")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
.set("whenfilter", true)
.set("whennew", true)
.set("whenresult", true)
.set("whenview", true)
.set("width", 0)
.set("x", 1)
.set("y", 4)
)
_form.createComponentIfNotExists(
"2289a1d1-2223-40ff-9086-be35e13adc27",
_val.init()
@ -73,7 +103,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "image")
.set("uid", "ba713534-1bee-49c5-b8dc-9cd11d725008")
.set("uid", "e4e8b238-a641-40ad-a48d-98f6f28cdcac")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -103,7 +133,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "text")
.set("uid", "ac31901c-0e2b-4921-a827-64f7a4935eaa")
.set("uid", "a68a5eac-0243-4e2d-9203-8def75f0cc36")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -115,3 +145,33 @@ _form.createComponentIfNotExists(
.set("x", 1)
.set("y", 1)
)
_form.createComponentIfNotExists(
"2289a1d1-2223-40ff-9086-be35e13adc27",
_val.init()
.set("colspan", 0)
.set("displayname", "Pessoas")
.set("firebase", "")
.set("group_id", 0)
.set("height", 0)
.set("max", 0)
.set("min", 0)
.set("name", "pessoas")
.set("notnull", false)
.set("primarykey", false)
.set("properties", "{\"ITEM_SEPARATOR\":{\"default\":\" # \",\"type\":\"STRING\",\"value\":\" # \"},\"MAX_COLUMN_LENGTH\":{\"default\":\"0\",\"type\":\"INTEGER\",\"value\":\"0\"},\"COLUMN_SEPARATOR\":{\"default\":\" - \",\"type\":\"LINK_SEPARATOR\",\"value\":\" - \"},\"REFERENCE\":{\"default\":\"\",\"type\":\"LINK\",\"value\":\"pessoa_comunidade:comunidade_id\"},\"LINK\":{\"default\":\"\",\"type\":\"LINK\",\"value\":\"pessoa_comunidade:pessoa_id\"},\"SERVICE\":{\"default\":\"com/MultiSelect.netuno\",\"type\":\"STRING\",\"value\":\"com/MultiSelect.netuno\"},\"ONLY_ACTIVES\":{\"default\":\"false\",\"type\":\"BOOLEAN\",\"value\":\"false\"}}")
.set("rowspan", 0)
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "multiselect")
.set("uid", "352d1673-0da1-4d28-813e-f09d719d5ceb")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
.set("whenfilter", true)
.set("whennew", true)
.set("whenresult", true)
.set("whenview", true)
.set("width", 0)
.set("x", 1)
.set("y", 5)
)

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

@ -43,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "select")
.set("uid", "2d5ec985-c445-4e6c-b945-2d3b2b079fd8")
.set("uid", "f1f052ef-2924-4429-8208-f9f2b2a5db8a")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -73,7 +73,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "email")
.set("uid", "e105559a-a073-4bd0-bb8d-c6d51e17c805")
.set("uid", "2f84224f-4a6b-4fe5-9361-8a324f0e7f83")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -103,7 +103,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "text")
.set("uid", "78de815a-23f9-4aea-b4dd-b8e4fba1a489")
.set("uid", "f63614aa-a6cb-4825-bc7d-0d54639f6fc8")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -133,7 +133,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "text")
.set("uid", "472c280d-36a6-4a47-9fd8-31ef5017a7db")
.set("uid", "3afa5745-5bce-427e-a23d-f31c82831e35")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -163,7 +163,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "user")
.set("uid", "41e81857-b314-485b-ab30-22acfd2e3538")
.set("uid", "1e2d8ce6-65af-4e45-b8d3-ec7d620f1336")
.set("user_id", 0)
.set("whenedit", 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("tdwidth", 0)
.set("type", "select")
.set("uid", "d10d4c5f-2d14-49fb-b5e8-8d881e3e64db")
.set("uid", "1c2422c9-a5ef-4c6f-a14e-2eda01059f1b")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -74,7 +74,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "select")
.set("uid", "020eae57-76f4-4731-abbf-9d364d6cce21")
.set("uid", "79609594-f6bf-4f79-ba09-4117f8434dcb")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)


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

@ -43,7 +43,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "select")
.set("uid", "09284f39-e631-43e9-a9f4-33836a57b48e")
.set("uid", "74587f83-98f5-4d70-a56b-08ab3245db9f")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -73,7 +73,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "textarea")
.set("uid", "43668b76-5b8a-444d-b9d0-782186e157ba")
.set("uid", "b1d8ea27-596e-46f5-b9e5-88be74ded899")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -103,7 +103,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "datetime")
.set("uid", "94b1a171-567c-4702-a86a-6585275bca4b")
.set("uid", "2c7759c0-9071-42fd-a028-b4b05f26f346")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)
@ -133,7 +133,7 @@ _form.createComponentIfNotExists(
.set("tdheight", 0)
.set("tdwidth", 0)
.set("type", "select")
.set("uid", "3434ece9-5711-4722-949a-2edd26acb9e5")
.set("uid", "8a12bb87-f0c0-404c-bf3d-bbbbeeaa2992")
.set("user_id", 0)
.set("whenedit", true)
.set("whenexport", true)


+ 91
- 0
website/src/components/Communities/index.js View File

@ -0,0 +1,91 @@
import React, { useEffect, useState } from 'react'
import "./index.less"
import { Table, Tag, Space, notification, Button } from 'antd';
import _service from "@netuno/service-client";
function Communities(){
const [communities, setCommunities] = useState([]);
const [columns, setColumns] = useState([
{
title: 'Comunidade',
dataIndex: 'nome',
},
{
title: 'Seguindo',
dataIndex: 'seguindo',
render: (text, record) => {
return(
<>
{record.seguindo === 0? (
<Button onClick={() => handleFollow(record.uid, record.nome)}>Seguir</Button>
):(
<Button onClick={() => handleUnfollow(record.uid, record.nome)} type="primary">Seguindo</Button>
)}
</>
)
}
},
]);
const handleFollow = (uid, name) => {
_service({
method: 'PUT',
url: "api/communities/follow",
data: {uid: uid},
success: (response) => {
notification.success({
message: `Agora você está seguindo ${name}`
})
},
fail: (e) => {
notification["error"]({
message: `Não foi possível seguir ${name}`,
});
}
});
}
const handleUnfollow = (uid, name) => {
_service({
method: 'DELETE',
url: "api/communities/unfollow",
data: {uid: uid},
success: (response) => {
notification.success({
message: `Você deixou de seguir ${name}`
})
},
fail: (e) => {
notification["error"]({
message: `Não foi possível deixar de seguir ${name}`,
});
console.log(e)
}
});
}
useEffect(() => {
_service({
url:"api/communities/",
method: "GET",
success: (response) => {
setCommunities(response.json);
},
fail: () => {
notification.error({
message: "Erro to load communities"
})
}
})
}, [columns])
return(
<>
<Table columns={columns} dataSource={communities} size="small" />
</>
)
}
export default Communities

+ 0
- 0
website/src/components/Communities/index.less View File


+ 1
- 1
website/src/index.js View File

@ -4,7 +4,7 @@ import App from "./App";
import _service from "@netuno/service-client";
_service.config({
prefix: "http://pedro-isac.dev.netuno.org:30790/services",
prefix: "http://pedro-isac.dev.netuno.org:30790/services/",
});
ReactDOM.render(


+ 10
- 1
website/src/pages/Main/index.js View File

@ -2,13 +2,14 @@ import React, { useState, useEffect } from "react";
import "./index.less";
import { Redirect, Link } from "react-router-dom";
import _auth from "@netuno/auth-client";
import { PageHeader, Dropdown, Menu, notification } from "antd";
import { PageHeader, Dropdown, Menu, notification, Row, Col } from "antd";
import {
DownOutlined,
LogoutOutlined,
SettingOutlined,
} from "@ant-design/icons";
import _service from "@netuno/service-client";
import Communities from '../../components/Communities'
const Main = () => {
const [isLogged, setIsLogged] = useState(false);
@ -54,6 +55,7 @@ const Main = () => {
</Menu>
);
return (
<>
<PageHeader
ghost={false}
title="Social Netuno"
@ -71,6 +73,13 @@ const Main = () => {
</Dropdown>,
]}
/>
<Row>
<Col span={12}>
<Communities />
</Col>
<Col span={12}></Col>
</Row>
</>
);
}
};


Loading…
Cancel
Save