Skip to content

Commit

Permalink
Merge branch 'funcionalidadURL'
Browse files Browse the repository at this point in the history
# Conflicts:
#	eda/eda_api/lib/router.ts
#	eda/eda_app/src/app/module/pages/dashboard/dashboard.component.ts
#	eda/eda_app/src/app/module/pages/pages.module.ts
  • Loading branch information
jortilles committed Oct 25, 2024
2 parents 30eff70 + f7579c5 commit bf13b13
Show file tree
Hide file tree
Showing 14 changed files with 662 additions and 3 deletions.
1 change: 1 addition & 0 deletions eda/eda_api/lib/module/dashboard/model/dashboard.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface IDashboardConfig {
styles:any;
tag: any;
external?: any;
urls:any;
}

const DashboardSchema = new mongoose.Schema({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { NextFunction, Request, Response } from 'express';
import { HttpException } from '../global/model/index';


export class FuncionalidadUrlController {


static async checkUrl(req: Request, res: Response, next: NextFunction) {

try {
const response = await req.body
const {url} = response;

// Hacemos un fetch a la url solicitada por el frontend
fetch(url)
.then( r => {
res.status(200).json({
ok: true,
msg: 'Respuesta correcta',
});
})
.catch(error => {
console.error('Error fetching data', error);
res.status(500).json({
ok: false,
msg: 'Error en la petición o en la URL',
});
});

} catch (err) {
return next(new HttpException(501, 'Error in SMPT configuration file'));
}

}

}
10 changes: 10 additions & 0 deletions eda/eda_api/lib/module/funcionalidadUrl/funcionalidadUrl.router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as express from 'express';
import { authGuard } from '../../guards/auth-guard';
import { roleGuard } from '../../guards/role-guard';
import { FuncionalidadUrlController } from './funcionalidadUrl.controller';

const router = express.Router();

router.post('/check', authGuard, roleGuard, FuncionalidadUrlController.checkUrl);

export default router;
4 changes: 4 additions & 0 deletions eda/eda_api/lib/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import AddTableRouter from './module/addtabletomodel/addtable.router';
import DataSourceRouter from './module/datasource/datasource.router';
import UploadsRouter from './module/uploads/uploads.router';
import MailRouter from './module/mail/mail.router';
import FuncionalidadUrl from './module/funcionalidadUrl/funcionalidadUrl.router';
import DocuRouter from './routes/api/api-docs'
import DocuRouter from './routes/api/api-docs';
import ExcelRouter from './module/excel/excel-sheet.router';
import ThirdPartyRouter from './module/thirdParty/thirdParty.router';
Expand All @@ -24,6 +26,8 @@ router.use('/addTable', AddTableRouter );

router.use('/mail', MailRouter);

router.use('/funcionalidadUrl', FuncionalidadUrl);

router.use('/excel-sheets',ExcelRouter);

router.use('/tp', ThirdPartyRouter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ <h3 *ngIf="!titleClick" class="eda-title"> {{title}} </h3>
<!-- ============================================================== -->
<save-as-dialog *ngIf="saveasController" [controller]="saveasController"></save-as-dialog>

<!-- ============================================================== -->
<!-- URLS ACTION -->
<!-- ============================================================== -->

<urls-action *ngIf="urlsController" [controller]="urlsController"></urls-action>


<!-- ============================================================== -->
<!-- EDIT STYLES -->
Expand Down Expand Up @@ -232,6 +238,13 @@ <h3 *ngIf="!titleClick" class="eda-title"> {{title}} </h3>
</div>
</div>

<div class="right-sidebar-blocks-options block-options-bg pointer mt-1" (click)="openUrlsConfig();">
<div>
<i class="fa fa-link"></i>
<span i18n="@@opcionUrls" class="ml-2">ACCIÓN PERSONALIZADA</span>
</div>
</div>



</p-sidebar>
Expand Down
32 changes: 30 additions & 2 deletions eda/eda_app/src/app/module/pages/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
public emailController: EdaDialogController;
public saveasController: EdaDialogController;
public editStylesController: EdaDialogController;
public urlsController: EdaDialogController;
public applyToAllfilter: { present: boolean, refferenceTable: string, id: string };
public grups: IGroup[] = [];
public toLitle: boolean = false;
Expand Down Expand Up @@ -83,6 +84,8 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
public addTag: boolean = false;
public sendViaMailConfig: any = { enabled: false };

public urls: any[] = [];


// Display Variables
public display_v = {
Expand Down Expand Up @@ -378,7 +381,6 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {

private initializeDashboard(): void {
const me = this;

me.route.paramMap.subscribe(
params => me.id = params.get('id'),
err => me.alertService.addError(err)
Expand Down Expand Up @@ -406,6 +408,10 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
me.selectedTags = me.selectedTagsForDashboard(me.tags, config.tag)
me.refreshTime = config.refreshTime;
me.onlyIcanEdit = config.onlyIcanEdit;
me.urls = config['urls'];
if(me.urls===undefined) {
me.urls=[];
}
if (me.refreshTime) {
this.stopRefresh = false;
this.startCountdown(me.refreshTime);
Expand Down Expand Up @@ -926,6 +932,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
public editStyles() {
this.display_v.rightSidebar = false;
const params = this.styles;

this.editStylesController = new EdaDialogController({
params,
close: (event, response) => {
Expand Down Expand Up @@ -1090,7 +1097,8 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
mailingAlertsEnabled: this.getMailingAlertsEnabled(),
sendViaMailConfig: this.sendViaMailConfig,
onlyIcanEdit: this.onlyIcanEdit,
styles : this.styles
styles : this.styles,
urls: this.urls

},
group: this.form.value.group ? _.map(this.form.value.group, '_id') : undefined
Expand Down Expand Up @@ -1199,6 +1207,26 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {

}

// Funcion que agregar urls para acción personalizada
public openUrlsConfig() {
const urls = this.urls;
const params = {urls: urls};

this.display_v.rightSidebar = false;
this.urlsController = new EdaDialogController({
params,
close: (event, response) => {
if(!_.isEqual(event, EdaDialogCloseEvent.NONE)){
this.urls = response.urls;
this.dashboardService._notSaved.next(true);
}
this.urlsController = undefined;
}
})
}



// Others
public handleSelectedBtn(event): void {
const groupControl = this.form.get('group');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.description{
margin-top: 30px;
font-size: small;
padding: 1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<eda-dialog [inject]="dialog">

<div body>
<div class="card" *ngIf="urls?.length > 0">
<p-scrollPanel [style]="{width: '100%', height: '100%'}">
<p-table [value]="urls" dataKey="id" editMode="row">
<ng-template pTemplate="header">
<tr>
<th i18n="@@actionUrl" style="width:40%">Acción</th>
<th i18n="@@descriptionUrl" style="width:40%">Descripción</th>
<th i18n="@@editionUrl" style="width:20%">Edición</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-action let-editing="editing" let-ri="rowIndex">
<tr [pEditableRow]="action">
<td style="max-width: 300px;">
<p-cellEditor>
<ng-template pTemplate="input">
<input pInputText type="text" [(ngModel)]="action.name" required>
<p class="d-inline ml-1 mr-1">URL: </p>
<input pInputText type="text" [(ngModel)]="action.url" required>
</ng-template>
<ng-template pTemplate="output">
<button pButton type="button" [label]="action.name"
class="p-button-outlined w-100" (click)="customAction(action)"></button>
</ng-template>
</p-cellEditor>
</td>
<td>
<p-cellEditor>
<ng-template pTemplate="input">
<input pInputText type="text" [(ngModel)]="action.description" required>
</ng-template>
<ng-template pTemplate="output">
<div>{{action.description}}</div>
</ng-template>
</p-cellEditor>
</td>
<td>
<div class="flex align-items-center justify-content-center gap-2">
<button *ngIf="!editing" pButton pRipple type="button" pInitEditableRow
icon="pi pi-pencil" (click)="onRowEditInit(action)"
class="p-button-rounded p-button-text"></button>
<button *ngIf="editing" pButton pRipple type="button" pSaveEditableRow
icon="pi pi-check" (click)="onRowEditSave(action)"
class="p-button-rounded p-button-text p-button-success mr-2"></button>
<button *ngIf="editing" pButton pRipple type="button" pCancelEditableRow
icon="pi pi-refresh" (click)="onRowEditCancel(action, ri)"
class="p-button-rounded p-button-text p-button-warning"></button>
<button *ngIf="editing" pButton pRipple type="button" pCancelEditableRow
icon="pi pi-trash" (click)="onRowEditDelete(ri)"
class="p-button-rounded p-button-text p-button-danger"></button>
</div>
</td>
</tr>
</ng-template>
</p-table>
</p-scrollPanel>
</div>

<div class="card mt-15 pb-3">


<div class="container">


<div class="row">
<div class="col-sm-7">

<div class="row">
<div class="col-sm-12">
<h5 i18n="@@urlTextConfiguration" style="padding: 12px;">Configuración de url y nombre de acción personalizada: </h5>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<label i18n="@@urlString" for="URL">URL: </label>
</div>
<div class="col-sm-9">
<input class="col-sm-12" pInputText id="url" type="text" [(ngModel)]="urlAdd" />
</div>
</div>
<div class="row">
<div class="col-sm-3">
<label i18n="@@urlName" for="Nombre">Nombre: </label>
</div>
<div class="col-sm-9">
<input class="col-sm-12" pInputText id="nombre" type="text" [(ngModel)]="nameAdd" />
</div>
</div>
<div class="row">
<div class="col-sm-3">
<label i18n="@@urlDescription" for="Nombre">Descripción: </label>
</div>
<div class="col-sm-9">
<input class="col-sm-12" pInputText id="description" type="text" [(ngModel)]="descriptionAdd" />
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p-button i18n-label="@@textLabelUrl" label="Agregar url" styleClass="p-button-success"
(click)="addUrlDashboard(urlAdd, nameAdd, descriptionAdd)"></p-button>
</div>
</div>




</div>
<div i18n="@@resumeTextConfiguration" class="col-sm-5 description ">

Puedes configurar una acción personalizada que quieras ejecutar.
Te permite llamar a una URL que haga una acción que quieras invocar.
Puede ser una llamada a una api, a un endpoint de una app
o incluso invocar procesos de carga desde una llamada http.
Una vez configurado podrás invocarlo siempre que que quieras desde el botón.

</div>
</div>





</div>
</div>
</div>


<div footer>
<div class="ui-dialog-buttonpanel ui-widget-content ui-helper-clearfix text-right">
<button [disabled]="(clonedUrls | json)!==({}|json)" type="submit" pButton icon="fa fa-save"
i18n-label="@@guardarBtn" label="Confirmar" icon="fa fa-check" id="eda_add_dashboard_confirmar"
(click)="urlsConfirmed()"></button>
<button type="button" pButton icon="fa fa-times" (click)="closeDialog()"
class="p-button-raised p-button-danger" i18n-label="@@cerrarBtn" label="Cancelar"></button>
</div>
</div>

</eda-dialog>
Loading

0 comments on commit bf13b13

Please sign in to comment.