registro de administrador de comunidad

con bug en el envio del correo
This commit is contained in:
Mariela 2022-07-26 16:59:29 -06:00
parent cf0b5c2d27
commit 59d99c1cfb
12 changed files with 1121 additions and 48 deletions

View File

@ -11,13 +11,12 @@ export class AppController {
@Body('last_name') last_name: string,
@Body('email') email: string,
@Body('phone') phone: number,
@Body('password') password: string,
@Body('user_type') user_type: string,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
) {
return this.appService.createAdminSystem(dni, name, last_name, email, phone, password,
user_type, status, date_entry);
return this.appService.createAdminSystem(dni, name, last_name, email, phone,
user_type, status, date_entry);
}
@Post('user/createGuard')
@ -28,13 +27,29 @@ export class AppController {
@Body('last_name') last_name: string,
@Body('email') email: string,
@Body('phone') phone: number,
@Body('password') password: string,
@Body('user_type') user_type: string,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
@Body('community_id') community_id:string
) {
return this.appService.createGuard(dni, name, last_name, email, phone, password,
return this.appService.createGuard(dni, name, last_name, email, phone,
user_type, status, date_entry,community_id);
}
@Post('user/createAdminCommunity')
createAdminCommunity(
//Nombre, Apellidos, Correo electrónico, Cédula, Teléfono, Contraseña
@Body('dni') dni: string,
@Body('name') name: string,
@Body('last_name') last_name: string,
@Body('email') email: string,
@Body('phone') phone: number,
@Body('user_type') user_type: string,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
@Body('community_id') community_id:string
) {
return this.appService.createAdminCommunity(dni, name, last_name, email, phone,
user_type, status, date_entry,community_id);
}
@ -349,4 +364,8 @@ export class AppController {
return this.appService.html(email, name);
}
}

View File

@ -37,11 +37,11 @@ export class AppService {
//POST parameter from API
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number
, password: string, user_type: string, status: string, date_entry: Date) {
, user_type: string, status: string, date_entry: Date) {
const pattern = { cmd: 'createAdminSystem' };
const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
password: password, user_type: user_type, status: status, date_entry: date_entry
password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry
};
return this.clientUserApp
.send<string>(pattern, payload)
@ -51,11 +51,27 @@ export class AppService {
}
createGuard(dni: string, name: string, last_name: string, email: string, phone: number
, password: string, user_type: string, status: string, date_entry: Date, community_id: string) {
, user_type: string, status: string, date_entry: Date, community_id: string) {
const pattern = { cmd: 'createGuard' };
const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
password: password, user_type: user_type, status: status, date_entry: date_entry, community_id
password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry, community_id
};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
createAdminCommunity(dni: string, name: string, last_name: string, email: string, phone: number
, user_type: string, status: string, date_entry: Date, community_id: string) {
const pattern = { cmd: 'createAdminCommunity' };
const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry, community_id
};
return this.clientUserApp
@ -116,7 +132,7 @@ export class AppService {
);
}
deleteAdminSystem(id: string) {
const pattern = { cmd: 'deleteAdminSystem' };
const payload = { id: id };
@ -129,7 +145,7 @@ export class AppService {
inicioSesion(pEmail: string, pPassword: string) {
const pattern = { cmd: 'loginUser' };
const payload = { email: pEmail, password: pPassword};
const payload = { email: pEmail, password: pPassword };
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
@ -153,7 +169,7 @@ export class AppService {
//POST parameter from API
createCommunity(name: string, province: string, canton: string, district: string
, num_houses: number, phone: string, status: string, date_entry: Date, houses: []) {
, num_houses: number, phone: string, status: string, date_entry: Date, houses: []) {
const pattern = { cmd: 'createCommunity' };
const payload = {
name: name, province: province, canton: canton, district: district, num_houses: num_houses,
@ -245,7 +261,7 @@ export class AppService {
, status: string, date_entry: Date) {
const pattern = { cmd: 'createGuest' };
const payload = {
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
status: status, date_entry: date_entry
};
return this.clientGuestApp
@ -276,15 +292,15 @@ export class AppService {
);
}
// ====================== PAYMENTS ===============================
// ====================== PAYMENTS ===============================
//POST parameter from API
createPayment(date_payment: Date, mount: number, description: string, period: string
, status: string, user_id: string, communty_id: string) {
const pattern = { cmd: 'createPayment' };
const payload = {
date_payment: date_payment, mount: mount, description: description,
period: period, status: status, user_id: user_id, communty_id: communty_id
date_payment: date_payment, mount: mount, description: description,
period: period, status: status, user_id: user_id, communty_id: communty_id
};
return this.clientPaymentApp
.send<string>(pattern, payload)
@ -318,12 +334,12 @@ export class AppService {
// ====================== RESERVATIONS ===============================
//POST parameter from API
createReservation(start_time: string, finish_time: string, status: string,
createReservation(start_time: string, finish_time: string, status: string,
date_entry: Date, user_id: string, common_area_id: string) {
const pattern = { cmd: 'createReservation' };
const payload = {
start_time: start_time, finish_time: finish_time, status: status,
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id
start_time: start_time, finish_time: finish_time, status: status,
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id
};
return this.clientReservationApp
.send<string>(pattern, payload)
@ -357,11 +373,11 @@ export class AppService {
// ====================== POSTS ===============================
//POST parameter from API
createPost(post: string, date_entry: Date, user_id: string,
createPost(post: string, date_entry: Date, user_id: string,
community_id: string) {
const pattern = { cmd: 'createPost' };
const payload = {
post: post, date_entry: date_entry, user_id: user_id,
post: post, date_entry: date_entry, user_id: user_id,
community_id: community_id
};
return this.clientPostApp
@ -395,11 +411,11 @@ export class AppService {
// ====================== COMMNENT POSTS ===============================
//Comment parameter from API
createComment(comment: string, date_entry: Date, user_id: string,
createComment(comment: string, date_entry: Date, user_id: string,
post_id: string) {
const pattern = { cmd: 'createComment' };
const payload = {
comment: comment, date_entry: date_entry, user_id: user_id,
comment: comment, date_entry: date_entry, user_id: user_id,
post_id: post_id
};
return this.clientPostApp
@ -433,11 +449,11 @@ export class AppService {
// ====================== REPORTS ===============================
//Report parameter from API
createReport(action: string, description: string, date_entry: Date,
createReport(action: string, description: string, date_entry: Date,
user_id: string) {
const pattern = { cmd: 'createReport' };
const payload = {
action: action, description: description, date_entry: date_entry,
action: action, description: description, date_entry: date_entry,
user_id: user_id
};
return this.clientReportApp
@ -471,7 +487,7 @@ export class AppService {
sendMail(email: string) {
const pattern = { cmd: 'sendMail' };
const payload = { email: email};
const payload = { email: email };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(
@ -481,11 +497,29 @@ export class AppService {
html(email: string, name: string) {
const pattern = { cmd: 'html' };
const payload = { email: email, name: name};
const payload = { email: email, name: name };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
/* Function to generate combination of password */
generatePassword() {
var pass = '';
var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz0123456789@#$';
for (let i = 1; i <= 8; i++) {
var char = Math.floor(Math.random()
* str.length + 1);
pass += str.charAt(char)
}
return pass;
}
}

View File

@ -22,8 +22,8 @@ export class EmailController {
@MessagePattern({ cmd: 'html' })
async postHTMLEmail(@Payload() user: any) {
const url = "http://localhost:3000/";
const image = "images/email.ong";
const url = "http://localhost:3000/";
const image = "images/email.ong";
var response = await this.mailService.sendMail({
to: user["email"],
from: "mbonilla.guti@gmail.com",
@ -36,9 +36,44 @@ export class EmailController {
attachments: [
{
filename: 'email.png',
path: __dirname +'/mails/images/email.png',
path: __dirname + '/mails/images/email.png',
cid: 'logo' //my mistake was putting "cid:logo@cid" here!
}
}
]
});
return response;
}
@MessagePattern({ cmd: 'emailCreateUserAdminCommunity' })
async emailCreateUserAdmin(@Payload() user: any) {
const url = "http://localhost:3000/";
const image = "images/email.png";
const logo = "images/Logo Katoikia.svg";
var response = await this.mailService.sendMail({
to: user["email"],
from: "mbonilla.guti@gmail.com",
subject: 'Usuario registrado',
template: 'emailCreateUserAdmin',
context: {
name: user["name"],
password: user["password"],
date_entry: user["date_entry"],
email: user["email"],
community_name: user['community_name'],
url
},
attachments: [
{
filename: 'email.png',
path: __dirname + '/mails/images/email.png',
cid: 'image_email' //my mistake was putting "cid:logo@cid" here!
},
{
filename: 'Logo Katoikia.svg',
path: __dirname + '/mails/images/Logo Katoikia.svg',
cid: 'logo' //my mistake was putting "cid:logo@cid" here!
}
]
});
return response;

View File

@ -0,0 +1,442 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta charset="utf-8"> <!-- utf-8 works for most cases -->
<meta name="viewport" content="width=device-width"> <!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting"> <!-- Disable auto-scale in iOS 10 Mail entirely -->
<title></title> <!-- The title tag shows in email notifications, like Android 4.4. -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
<!-- CSS Reset : BEGIN -->
<style>
html,
body {
margin: 0 auto !important;
padding: 0 !important;
height: 100% !important;
width: 100% !important;
background: #f1f1f1;
}
/* What it does: Stops email clients resizing small text. */
* {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
/* What it does: Centers email on Android 4.4 */
div[style*="margin: 16px 0"] {
margin: 0 !important;
}
/* What it does: Stops Outlook from adding extra spacing to tables. */
table,
td {
mso-table-lspace: 0pt !important;
mso-table-rspace: 0pt !important;
}
/* What it does: Fixes webkit padding issue. */
table {
border-spacing: 0 !important;
border-collapse: collapse !important;
table-layout: fixed !important;
margin: 0 auto !important;
}
/* What it does: Uses a better rendering method when resizing images in IE. */
img {
-ms-interpolation-mode: bicubic;
}
/* What it does: Prevents Windows 10 Mail from underlining links despite inline CSS. Styles for underlined links should be inline. */
a {
text-decoration: none;
}
/* What it does: A work-around for email clients meddling in triggered links. */
*[x-apple-data-detectors],
/* iOS */
.unstyle-auto-detected-links *,
.aBn {
border-bottom: 0 !important;
cursor: default !important;
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
/* What it does: Prevents Gmail from displaying a download button on large, non-linked images. */
.a6S {
display: none !important;
opacity: 0.01 !important;
}
/* What it does: Prevents Gmail from changing the text color in conversation threads. */
.im {
color: inherit !important;
}
/* If the above doesn't work, add a .g-img class to any image in question. */
img.g-img+div {
display: none !important;
}
/* What it does: Removes right gutter in Gmail iOS app: https://github.com/TedGoas/Cerberus/issues/89 */
/* Create one of these media queries for each additional viewport size you'd like to fix */
/* iPhone 4, 4S, 5, 5S, 5C, and 5SE */
@media only screen and (min-device-width: 320px) and (max-device-width: 374px) {
u~div .email-container {
min-width: 320px !important;
}
}
/* iPhone 6, 6S, 7, 8, and X */
@media only screen and (min-device-width: 375px) and (max-device-width: 413px) {
u~div .email-container {
min-width: 375px !important;
}
}
/* iPhone 6+, 7+, and 8+ */
@media only screen and (min-device-width: 414px) {
u~div .email-container {
min-width: 414px !important;
}
}
</style>
<!-- CSS Reset : END -->
<!-- Progressive Enhancements : BEGIN -->
<style>
.primary {
background: #30e3ca;
}
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, .8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #30e3ca;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, .4);
}
a {
color: #30e3ca;
}
table {}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, .3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, .4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, .8);
}
.heading-section-white h2 {
font-family:
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, .4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
/*FOOTER*/
.footer {
border-top: 1px solid rgba(0, 0, 0, .05);
color: rgba(0, 0, 0, .5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
@media screen and (max-width: 500px) {}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1;">
<center style="width: 100%; background-color: #f1f1f1;">
<div
style="display: none; font-size: 1px;max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden; mso-hide: all; font-family: sans-serif;">
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto;" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em;">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center;">
<h1><a href="#">Katoikia</a></h1>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0;">
<img src="cid:logoLatoikia" alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0;">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h2>Hola, {{ name }}</h2>
<h2>Ha sido registrado como un Administrador General del sitio web Katoikia</h2>
<h3>Fecha de registro {{date_entry}}</h3>
<h3>Estas son sus credenciales:</h3>
<ul>
<li>Correo electronico: {{email}}</li>
<li>Password: {{password}}</li>
</ul>
<h3>Inicie sesión en el sitio web para poder acceder y disfrutar todos sus benefucuin</h3>
<p><a href="{{ url }}" class="btn btn-primary">Iniciar sesión</a></p>
</div>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px;">
<!-- <h3 class="heading">About</h3>
<p>A small river named Duden flows by their place and supplies it with
the necessary regelialia.</p>
-->
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px;">
<!-- <h3 class="heading">Informacion de contacto</h3>
<ul>
<li><span class="text">203 Fake St. Mountain View, San Francisco,
California, USA</span></li>
<li><span class="text">+2 392 3929 210</span></a></li>
</ul>
-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr><!-- end: tr -->
</table>
</div>
</center>
</body>
</html>

View File

@ -0,0 +1,442 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta charset="utf-8"> <!-- utf-8 works for most cases -->
<meta name="viewport" content="width=device-width"> <!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting"> <!-- Disable auto-scale in iOS 10 Mail entirely -->
<title></title> <!-- The title tag shows in email notifications, like Android 4.4. -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
<!-- CSS Reset : BEGIN -->
<style>
html,
body {
margin: 0 auto !important;
padding: 0 !important;
height: 100% !important;
width: 100% !important;
background: #f1f1f1;
}
/* What it does: Stops email clients resizing small text. */
* {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
/* What it does: Centers email on Android 4.4 */
div[style*="margin: 16px 0"] {
margin: 0 !important;
}
/* What it does: Stops Outlook from adding extra spacing to tables. */
table,
td {
mso-table-lspace: 0pt !important;
mso-table-rspace: 0pt !important;
}
/* What it does: Fixes webkit padding issue. */
table {
border-spacing: 0 !important;
border-collapse: collapse !important;
table-layout: fixed !important;
margin: 0 auto !important;
}
/* What it does: Uses a better rendering method when resizing images in IE. */
img {
-ms-interpolation-mode: bicubic;
}
/* What it does: Prevents Windows 10 Mail from underlining links despite inline CSS. Styles for underlined links should be inline. */
a {
text-decoration: none;
}
/* What it does: A work-around for email clients meddling in triggered links. */
*[x-apple-data-detectors],
/* iOS */
.unstyle-auto-detected-links *,
.aBn {
border-bottom: 0 !important;
cursor: default !important;
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
/* What it does: Prevents Gmail from displaying a download button on large, non-linked images. */
.a6S {
display: none !important;
opacity: 0.01 !important;
}
/* What it does: Prevents Gmail from changing the text color in conversation threads. */
.im {
color: inherit !important;
}
/* If the above doesn't work, add a .g-img class to any image in question. */
img.g-img+div {
display: none !important;
}
/* What it does: Removes right gutter in Gmail iOS app: https://github.com/TedGoas/Cerberus/issues/89 */
/* Create one of these media queries for each additional viewport size you'd like to fix */
/* iPhone 4, 4S, 5, 5S, 5C, and 5SE */
@media only screen and (min-device-width: 320px) and (max-device-width: 374px) {
u~div .email-container {
min-width: 320px !important;
}
}
/* iPhone 6, 6S, 7, 8, and X */
@media only screen and (min-device-width: 375px) and (max-device-width: 413px) {
u~div .email-container {
min-width: 375px !important;
}
}
/* iPhone 6+, 7+, and 8+ */
@media only screen and (min-device-width: 414px) {
u~div .email-container {
min-width: 414px !important;
}
}
</style>
<!-- CSS Reset : END -->
<!-- Progressive Enhancements : BEGIN -->
<style>
.primary {
background: #30e3ca;
}
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, .8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #30e3ca;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, .4);
}
a {
color: #30e3ca;
}
table {}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, .3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, .4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, .8);
}
.heading-section-white h2 {
font-family:
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, .4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
/*FOOTER*/
.footer {
border-top: 1px solid rgba(0, 0, 0, .05);
color: rgba(0, 0, 0, .5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
@media screen and (max-width: 500px) {}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1;">
<center style="width: 100%; background-color: #f1f1f1;">
<div
style="display: none; font-size: 1px;max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden; mso-hide: all; font-family: sans-serif;">
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto;" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em;">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center;">
<h1><a href="#">Katoikia</a></h1>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0;">
<img src="cid:logoLatoikia" alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0;">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h2>Hola, {{ name }}</h2>
<h2>Ha sido registrado como un Administrador de la Comunidad `{{community_name}}`</h2>
<h3>Fecha de registro: {{date_entry}}</h3>
<h3>Estas son sus credenciales:</h3>
<ul>
<li>Correo electronico: {{email}}</li>
<li>Password: {{password}}</li>
</ul>
<h3>Inicie sesión en el sitio web para poder acceder y disfrutar todos sus benefucuin</h3>
<p><a href="{{ url }}" class="btn btn-primary">Iniciar sesión</a></p>
</div>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px;">
<!-- <h3 class="heading">About</h3>
<p>A small river named Duden flows by their place and supplies it with
the necessary regelialia.</p>
-->
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px;">
<!-- <h3 class="heading">Informacion de contacto</h3>
<ul>
<li><span class="text">203 Fake St. Mountain View, San Francisco,
California, USA</span></li>
<li><span class="text">+2 392 3929 210</span></a></li>
</ul>
-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr><!-- end: tr -->
</table>
</div>
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -22,6 +22,10 @@ export class UsersController {
return this.userService.create(user);
}
@MessagePattern({ cmd: 'createAdminCommunity' })
createAdminCommunity(@Payload() user: UserDocument) {
return this.userService.createAdminCommunity(user);
}
@MessagePattern({ cmd: 'findAllUsers' })
findAll() {
@ -91,5 +95,7 @@ export class UsersController {
return this.userService.deleteAdminSystem(user["id"]);
}
}

View File

@ -18,6 +18,16 @@ import { ClientsModule, Transport } from "@nestjs/microservices";
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_COMUNIDADES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3002
}
}
]),
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
],
controllers: [UsersController],

View File

@ -4,6 +4,7 @@ import { User, UserDocument } from '../schemas/user.schema';
import { InjectModel } from '@nestjs/mongoose';
import { Md5 } from "md5-typescript";
import { map } from 'rxjs/operators';
import { lastValueFrom } from 'rxjs';
import { RpcException, ClientProxy } from '@nestjs/microservices';
@ -14,6 +15,7 @@ export class UsersService {
constructor(
@InjectModel(User.name) private readonly userModel: Model<UserDocument>,
@Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy,
@Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy,
) { }
private publicKey: string;
@ -23,6 +25,38 @@ export class UsersService {
return this.userModel.create(user);
}
async createAdminCommunity(user: UserDocument) {
let password = user.password;
let passwordEncriptada = Md5.init(user.password);
user.password = passwordEncriptada;
this.userModel.create(user);
let community = await this.findCommunity(user.community_id);
user.community_id = community['name'];
const pattern = { cmd: 'emailCreateUserAdminCommunity' };
const payload = { email: user['email'], password: password, name: user['name'], date_entry: user['date_entry'] };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
async findCommunity(community_id: string) {
const pattern = { cmd: 'findOneCommunity' }
const payload = { _id: community_id }
let callback = await this.clientCommunityApp
.send<string>(pattern, payload)
.pipe(
map((response: string) => ({ response }))
)
const finalValue = await lastValueFrom(callback);
return finalValue['response'];
}
async findAll(): Promise<User[]> {
return this.userModel
.find()
@ -110,7 +144,11 @@ export class UsersService {
}
async deleteAdminSystem(id: string) {
return this.userModel.deleteOne({_id: id}).exec();
return this.userModel.deleteOne({ _id: id }).exec();
}
}

View File

@ -31,6 +31,7 @@ const AdministradoresComunidad = () => {
community_id: '',
community_name: '',
user_type: '2',
date_entry: new Date(),
status: '1'
};
@ -48,8 +49,6 @@ const AdministradoresComunidad = () => {
const dt = useRef(null);
async function listaAdmin() {
let nombres = await fetch('http://localhost:4000/user/findAdminComunidad/', { method: 'GET' })
.then((response) => response.json())
@ -58,14 +57,14 @@ const AdministradoresComunidad = () => {
//item.full_name returns the repositorie name
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
.then((response2) => response2.json())
.then(data => {
console.log(data.message.name);
item.community_name = data.message.name
.then(data => data.message)
.then( data => {
item.community_name = data['name']
return item
})
}));
}).then(data => setListaAdmins(data)
);
})
.then(data => setListaAdmins(data));
}
@ -90,7 +89,7 @@ const AdministradoresComunidad = () => {
const cList = communitiesList.map((item) => ({
label: item.name,
value: item.id,
value: item._id,
}))
@ -153,9 +152,46 @@ const AdministradoresComunidad = () => {
const saveAdminCommunity = () => {
if (adminCommunity.password !== adminCommunity.confirmPassword) {
setSubmitted(true);
} else if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.password && adminCommunity.phone) {
if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.phone) {
let _administrators= [...listaAdmins];
let _adminCommunity = { ...adminCommunity };
_adminCommunity.community_id = communityId;
console.log(_adminCommunity)
console.log(communityId)
fetch('http://localhost:4000/user/createAdminCommunity', {
cache: 'no-cache',
method: 'POST',
body: JSON.stringify(_adminCommunity),
headers: {
'Content-Type': 'application/json'
}
})
.then(
function (response) {
if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status);
else
return response.json();
}
)
.then(() => {
// _adminCommunity.community_id = communitiesList.find(c => c._id === _adminCommunity.community_id).name
_administrators.push(_adminCommunity);
toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Comunidad de vivienda Creada', life: 3000 });
setListaAdmins(_administrators);
setAdminCommunity(emptyAdminCommunity);
})
.catch(
err => console.log('Ocurrió un error con el fetch', err)
);
toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Administrador de Comunidad de vivienda Creada', life: 3000 });
} else {
@ -286,8 +322,9 @@ const AdministradoresComunidad = () => {
}
const handleCommunities = (event) => {
const getCommunity = event.target.value;
setCommunityId(getCommunity);
const getCommunityValue = event.target.value;
setCommunityId(getCommunityValue);
console.log(getCommunityValue)
}
return (
<div className="grid">
@ -397,8 +434,8 @@ const AdministradoresComunidad = () => {
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
<i className="pi pi-home"></i>
</span>
<Dropdown placeholder="--Seleccione la Comunidad a Asignar--" id="administrator" value={communityId} options={cList}
onChange={handleCommunities} required autoFocus className={classNames({ 'p-invalid': submitted && !communityId })}/>
<Dropdown placeholder="--Seleccione la Comunidad a Asignar--" id="administrator" value={communityId} options={cList}
onChange={handleCommunities} required autoFocus className={classNames({ 'p-invalid': submitted && !communityId })} />
</div>
{submitted && !communityId && <small className="p-invalid">Comunidad es requirida.</small>}
</div>

View File

@ -59,6 +59,7 @@ const AdministradoresSistema = () => {
user_type: "1", //1 es admin
status: "1"
};
setSysAdmin(data)
// console.log(data);
fetch('http://localhost:4000/user/createAdminSystem/', {
@ -80,7 +81,7 @@ const AdministradoresSistema = () => {
.then(
function (response) {
let _administrators = [...administrators];
let _admin = { ...response.message };;
let _admin = { ...sysadmin };
_administrators.push(_admin);
setAdministrators(_administrators)
}