Commit ecfc6a97 authored by Sebastian Chicoma's avatar Sebastian Chicoma

Merge branch 'developer' of http://git.tbs.com:8888/ByteBot/web/bytebot-workspace into developer

parents b7b26102 4ad8580a
...@@ -126,7 +126,6 @@ export function createTranslateLoader(http: HttpClient) { ...@@ -126,7 +126,6 @@ export function createTranslateLoader(http: HttpClient) {
// { provide: HTTP_INTERCEPTORS, useClass: AgentFakeBackendInterceptor, multi: true }, // { provide: HTTP_INTERCEPTORS, useClass: AgentFakeBackendInterceptor, multi: true },
{ provide: APP_INITIALIZER, useFactory: init_app, deps: [InitCommonsService, TranslateService], multi: true } { provide: APP_INITIALIZER, useFactory: init_app, deps: [InitCommonsService, TranslateService], multi: true }
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
...@@ -217,14 +217,12 @@ const channels = [ ...@@ -217,14 +217,12 @@ const channels = [
const fileOK = { const fileOK = {
"uuid": "6850b631-5cb1-4614-8f0e-e43441d7bd35", "uuid": "6850b631-5cb1-4614-8f0e-e43441d7bd35",
"data": {
"id": 100, "id": 100,
"name": "vacaciones-preguntas.xls", "fileName": "vacaciones-preguntas.xls",
"description": "Preguntas Vacaciones", "description": "Preguntas Vacaciones",
"status": "PS", "status": "PS",
"user": "", "user": "",
"uploadDate": "" "uploadDate": ""
}
}; };
@Injectable() @Injectable()
......
...@@ -5,9 +5,12 @@ import { of } from 'rxjs'; ...@@ -5,9 +5,12 @@ import { of } from 'rxjs';
import { map, catchError } from 'rxjs/operators'; import { map, catchError } from 'rxjs/operators';
import { AgentService } from '../../../service/agent.service'; import { AgentService } from '../../../service/agent.service';
import { MatDialogRef } from '@angular/material'; import { MatDialogRef } from '@angular/material';
import { NotificationService, NotificationType } from '@xdf/commons';
import { TranslateService } from '@ngx-translate/core';
export class FileUploadModel { export class FileUploadModel {
id: number; id: number;
uuid: string;
filename: string; filename: string;
status: string; status: string;
user: string; user: string;
...@@ -31,6 +34,8 @@ export class CaFileUploadModalComponent implements OnInit { ...@@ -31,6 +34,8 @@ export class CaFileUploadModalComponent implements OnInit {
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private agentService: AgentService, private agentService: AgentService,
private _notificationService: NotificationService,
private _translateService: TranslateService,
public dialogRef: MatDialogRef<CaFileUploadModalComponent> public dialogRef: MatDialogRef<CaFileUploadModalComponent>
) { ) {
this.formGroup = this.formBuilder.group({ this.formGroup = this.formBuilder.group({
...@@ -86,20 +91,34 @@ export class CaFileUploadModalComponent implements OnInit { ...@@ -86,20 +91,34 @@ export class CaFileUploadModalComponent implements OnInit {
}) })
).subscribe((event: any) => { ).subscribe((event: any) => {
if (typeof (event) === 'object') { if (typeof (event) === 'object') {
let info = event.body.data; let info = event.body;
this.fileInfo = new FileUploadModel();
if (info) { if (info) {
let status = info.fileValidationResult.status;
if ("OK" === status) {
this.fileInfo.id = info.id; this.fileInfo.id = info.id;
this.fileInfo.filename = info.name; this.fileInfo.uuid = info.uuid;
this.fileInfo.filename = info.fileName;
this.fileInfo.status = info.status; this.fileInfo.status = info.status;
this.fileInfo.user = info.user; this.fileInfo.user = info.user;
this.fileInfo.uploadDate = info.uploadDate; this.fileInfo.uploadDate = info.uploadDate;
} else {
this.fileInfo.id = null;
this.fileInfo.filename = null;
this.fileInfo.status = null;
this.fileInfo.user = null;
this.fileInfo.uploadDate = null;
} else if ("INCOMPATIBLE_EXTENSION" === status) {
this.formGroup.controls.file.setValue(null);
let message = "label.file.incompatible.extension";
this._notificationService.showMessage(this._translateService.instant(message) + "[" + this.accept + "]", null, NotificationType.error);
} else if ("CONTENT_ERROR" === status) {
this.formGroup.controls.file.setValue(null);
console.log(info.fileValidationResult);
} else if ("HEADER_ERROR" === status) {
this.formGroup.controls.file.setValue(null);
console.log(info.fileValidationResult);
}
} else {
this.formGroup.controls.file.setValue(null); this.formGroup.controls.file.setValue(null);
} }
} }
......
<div class="panel-viewer-wrapper"> <div class="panel-viewer-wrapper">
<div class="panel-viewer-title"> <div class="panel-viewer-title">
<i class="fa fa-info-circle"></i> <mat-icon>dns</mat-icon>
{{'label.frequent-questions.title' | translate}} {{'label.questions.title' | translate}}
</div> </div>
<div class="panel-viewer-body"> <div class="panel-viewer-body">
...@@ -10,57 +10,60 @@ ...@@ -10,57 +10,60 @@
<div class="col-10"> <div class="col-10">
<div class="row pt-2" *ngIf="!viewMode"> <div class="row pt-2" *ngIf="!viewMode">
<div class="col-12 no-padding"> <div class="col-12 no-padding">
<button mat-mini-fab color="primary" (click)="addFile()" class="pull-right"> <button type="button" class="btn btn-outline-primary btn-sm pull-right" (click)="addFile()">
<mat-icon>file_upload</mat-icon> <i class="fa fa-file-excel-o"></i>
<span class="visible-md-inline visible-lg-inline visible-xl-inline">
{{'btn.new.file' | translate}}
</span>
</button> </button>
</div> </div>
</div> </div>
<div class="row pt-2"> <div class="row pt-2">
<div class="col-12 table-container mat-elevation-z8" style="padding-bottom:15px;"> <div class="col-12 table-container mat-elevation-z8 p-b-15">
<table mat-table [dataSource]="dataSource" matSort> <table mat-table [dataSource]="dataSource" matSort>
<!-- Load ID --> <!-- Load ID -->
<ng-container matColumnDef="id"> <ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header style="width: 10%;"> ID de carga </th> <th mat-header-cell *matHeaderCellDef mat-sort-header class="w-id">{{'label.file.id' | translate}}</th>
<td mat-cell *matCellDef="let element" style="width: 10%;"> {{element.id}} </td> <td mat-cell *matCellDef="let element" class="w-id"> {{element.id}} </td>
</ng-container> </ng-container>
<!-- Filename --> <!-- Filename -->
<ng-container matColumnDef="filename"> <ng-container matColumnDef="filename">
<th mat-header-cell *matHeaderCellDef mat-sort-header style="width: 15%;"> Nombre del archivo </th> <th mat-header-cell *matHeaderCellDef mat-sort-header class="w-filename">{{'label.file.name' | translate}}</th>
<td mat-cell *matCellDef="let element" style="width: 15%;"> {{element.filename}} </td> <td mat-cell *matCellDef="let element" class="w-filename"> {{element.filename}} </td>
</ng-container> </ng-container>
<!-- Description --> <!-- Description -->
<ng-container matColumnDef="description"> <ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef mat-sort-header style="width: 18%;"> Descripción </th> <th mat-header-cell *matHeaderCellDef mat-sort-header class="w-description">{{'label.file.description' | translate}}</th>
<td mat-cell *matCellDef="let element" style="width: 18%;"> {{element.description}} </td> <td mat-cell *matCellDef="let element" class="w-description"> {{element.description}} </td>
</ng-container> </ng-container>
<!-- Status --> <!-- Status -->
<ng-container matColumnDef="status"> <ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef mat-sort-header style="width: 12%;"> Estado </th> <th mat-header-cell *matHeaderCellDef mat-sort-header class="w-status">{{'label.file.status' | translate}}</th>
<td mat-cell *matCellDef="let element" style="width: 12%;"> <td mat-cell *matCellDef="let element" class="w-status">
<span [ngClass]="getClassStatus(element.status)">{{ getTextStatus(element.status) }}</span> <span [ngClass]="getClassStatus(element.status)">{{ getTextStatus(element.status) }}</span>
</td> </td>
</ng-container> </ng-container>
<!-- User --> <!-- User -->
<ng-container matColumnDef="user"> <ng-container matColumnDef="user">
<th mat-header-cell *matHeaderCellDef mat-sort-header style="width: 15%;"> Usuario </th> <th mat-header-cell *matHeaderCellDef mat-sort-header class="w-user">{{'label.file.user' | translate}}</th>
<td mat-cell *matCellDef="let element" style="width: 15%;"> {{element.user}} </td> <td mat-cell *matCellDef="let element" class="w-user"> {{element.user}} </td>
</ng-container> </ng-container>
<!-- Fecha de carga --> <!-- Fecha de carga -->
<ng-container matColumnDef="uploadDate"> <ng-container matColumnDef="uploadDate">
<th mat-header-cell *matHeaderCellDef style="width: 10%;"> Fecha de carga </th> <th mat-header-cell *matHeaderCellDef class="w-uploadDate">{{'label.file.upload.date' | translate}}</th>
<td mat-cell *matCellDef="let element" style="width: 10%;"> {{element.uploadDate}} </td> <td mat-cell *matCellDef="let element" class="w-uploadDate"> {{element.uploadDate}} </td>
</ng-container> </ng-container>
<!-- Actions --> <!-- Actions -->
<ng-container matColumnDef="actions"> <ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef style="width: 20%;"></th> <th mat-header-cell *matHeaderCellDef class="w-actions"></th>
<td mat-cell *matCellDef="let element; let $index = index" style="width: 20%;" class="text-center"> <td mat-cell *matCellDef="let element; let $index = index" class="w-actions text-center">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-default btn-sm" (click)="onDeleteRecord(element, $index)" <button type="button" class="btn btn-default btn-sm" (click)="onDeleteRecord(element, $index)"
[disabled]="!resourceAuth['delete'] || viewMode"> [disabled]="!resourceAuth['delete'] || viewMode">
......
...@@ -219,3 +219,35 @@ tr.inner-element-row-expanded td { ...@@ -219,3 +219,35 @@ tr.inner-element-row-expanded td {
display: table-cell !important; display: table-cell !important;
} }
} }
.p-b-15 {
padding-bottom: 15px;
}
.w-id {
width: 10%;
}
.w-filename {
width: 15%;
}
.w-description {
width: 18%;
}
.w-status {
width: 12%;
}
.w-user {
width: 15%;
}
.w-uploadDate {
width: 10%;
}
.w-actions {
width: 20%;
}
import { Component, OnInit, Input, ViewContainerRef, ElementRef, ViewChild, ChangeDetectorRef } from '@angular/core'; import { Component, OnInit, Input, ViewContainerRef, ViewChild } from '@angular/core';
import { MatStepper, MatDialog, MatTableDataSource, MatSort } from '@angular/material'; import { MatStepper, MatDialog, MatTableDataSource, MatSort } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { animate, trigger, state, transition, style } from '@angular/animations'; import { animate, trigger, state, transition, style } from '@angular/animations';
import { AuthorizationService } from '@xdf/security'; import { AuthorizationService } from '@xdf/security';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { UploadService } from '../upload.service';
import { CaFileUploadModalComponent, FileUploadModel } from '../ca-file-upload-modal/ca-file-upload-modal.component'; import { CaFileUploadModalComponent, FileUploadModel } from '../ca-file-upload-modal/ca-file-upload-modal.component';
@Component({ @Component({
...@@ -37,12 +36,12 @@ export class CaFrequentQuestionsComponent implements OnInit { ...@@ -37,12 +36,12 @@ export class CaFrequentQuestionsComponent implements OnInit {
mapStatus = { mapStatus = {
"LO": { "LO": {
"text": "label.status.loaded", "class": "label label-primary",
"class": "label label-primary" "text": "label.status.loaded"
}, },
"PS": { "PS": {
"text": "label.status.pending", "class": "label label-warning",
"class": "label label-warning" "text": "label.status.pending"
} }
}; };
...@@ -54,10 +53,8 @@ export class CaFrequentQuestionsComponent implements OnInit { ...@@ -54,10 +53,8 @@ export class CaFrequentQuestionsComponent implements OnInit {
protected vcRef: ViewContainerRef, protected vcRef: ViewContainerRef,
protected authorizationService: AuthorizationService, protected authorizationService: AuthorizationService,
private translate: TranslateService, private translate: TranslateService,
private uploadService: UploadService,
private _activatedRoute: ActivatedRoute, private _activatedRoute: ActivatedRoute,
private matDialog: MatDialog, private matDialog: MatDialog
private changeDetectorRefs: ChangeDetectorRef
) { ) {
this.viewMode = this._activatedRoute.snapshot.data.mode === 'view'; this.viewMode = this._activatedRoute.snapshot.data.mode === 'view';
......
...@@ -4,6 +4,8 @@ import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms' ...@@ -4,6 +4,8 @@ import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms'
import { MatStepper } from '@angular/material'; import { MatStepper } from '@angular/material';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { animate, trigger, state, transition, style } from '@angular/animations'; import { animate, trigger, state, transition, style } from '@angular/animations';
import { NotificationService, NotificationType } from '@xdf/commons';
import { TranslateService } from '@ngx-translate/core';
export const FILE_TYPE = { export const FILE_TYPE = {
image: /image.*/, image: /image.*/,
...@@ -51,9 +53,14 @@ export class CaGeneralInformationComponent implements OnInit { ...@@ -51,9 +53,14 @@ export class CaGeneralInformationComponent implements OnInit {
} }
]; ];
acceptedImageTypes = ['image/png', 'image/jpeg', 'image/gif'];
acceptedTypes = "PNG, JPEG, GIF";
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private _activatedRoute: ActivatedRoute private _activatedRoute: ActivatedRoute,
private _notificationService: NotificationService,
private _translateService: TranslateService
) { ) {
this.viewMode = this._activatedRoute.snapshot.data.mode === 'view'; this.viewMode = this._activatedRoute.snapshot.data.mode === 'view';
...@@ -118,11 +125,19 @@ export class CaGeneralInformationComponent implements OnInit { ...@@ -118,11 +125,19 @@ export class CaGeneralInformationComponent implements OnInit {
uploadFiles(event) { uploadFiles(event) {
for (const i in event) { for (const i in event) {
if (event[i] instanceof File) { if (event[i] instanceof File) {
let eventTemp = event[i];
if (this.acceptedImageTypes.includes(eventTemp.type)) {
const reader = new FileReader(); const reader = new FileReader();
reader.onload = () => { reader.onload = () => {
this.formGroup.controls['imageAvatar'].setValue(reader.result as string); this.formGroup.controls['imageAvatar'].setValue(reader.result as string);
}; };
reader.readAsDataURL(event[i]); reader.readAsDataURL(event[i]);
} else {
let message = "label.imageAvatar.incompatible.extension";
this._notificationService.showMessage(this._translateService.instant(message) + "[" + this.acceptedTypes + "]", null, NotificationType.error);
}
} }
} }
} }
......
{ {
"home.subtitle": "Welcome to XDF Project", "home.subtitle": "Welcome to XDF Project",
"home.comments": "It is an application skeleton for a typical web app. You can use it to quickly bootstrap your webapp projects and dev environment." "home.comments": "It is an application skeleton for a typical web app. You can use it to quickly bootstrap your webapp projects and dev environment.",
"btn.previous": "Back",
"label.agent": "Agents",
"agent_avatar": "Avatar",
"agent_code": "ID",
"agent_name": "Name",
"agent_version": "Version",
"agent_status": "Status",
"agent_country": "Country",
"agent_timezone": "Timezone",
"btn.file.upload" : "Upload",
"btn.accept": "Accept",
"label.deployment-channels.title": "Deployment channels",
"label.deployment-channels.description": "Configure the messaging channels that will be used by the agent",
"label.channels": "Configured channels",
"label.active": "Active",
"label.inactive": "Inactive",
"label.name": "Name",
"label.deployment-channels.configuration": "Deployment channels",
"label.deployment-channels.configuration.description": "Select a deployment channel",
"label.status.pending" : "Pending",
"label.status.loaded" : "Loaded",
"label.status.off" : "Disabled",
"label.created": "Created",
"label.deployed": "Deployed",
"label.general-information.title" : "General information",
"label.general-information.description" : "Register the basic information for the agent",
"label.avatar" : "Avatar",
"label.description" : "Description",
"label.version" : "Version",
"label.country" : "Country",
"label.timezone" : "Timezone",
"label.language" : "Language",
"label.type" : "Agent type",
"label.questions.title" : "Frequent questions",
"label.questions.description" : "Upload files whose content will be used as training for the agent",
"btn.new.file" : "New file",
"label.file.id" : "ID",
"label.file.name" : "Name",
"label.file.description" : "Description",
"label.file.status" : "Status",
"label.file.user" : "User",
"label.file.upload.date" : "Loaded date",
"label.file-upload.title" : "Questions file",
"label.file-upload.description" : "The question file will be used as material training",
"label.file" : "File",
"label.file.incompatible.extension" : "Invalid file. Just accept the following file extensions ",
"label.imageAvatar.incompatible.extension" : "Invalid file. Just accept the followeing image types "
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"btn.file.upload" : "Cargar", "btn.file.upload" : "Cargar",
"btn.accept": "Aceptar", "btn.accept": "Aceptar",
"label.deployment-channels.title": "Canales de despliegue", "label.deployment-channels.title": "Canales de despliegue",
"label.deployment-channels.description": "Configure los canales de mensajería por los cuáles interactuará el agente", "label.deployment-channels.description": "Configure los canales de mensajería por los cuales interactuará el agente",
"label.channels": "Canales configurados", "label.channels": "Canales configurados",
"label.active": "Activo", "label.active": "Activo",
"label.inactive": "Inactivo", "label.inactive": "Inactivo",
...@@ -27,15 +27,27 @@ ...@@ -27,15 +27,27 @@
"label.created": "Creado", "label.created": "Creado",
"label.deployed": "Desplegado", "label.deployed": "Desplegado",
"breadcrumb.agent": "Agentes", "breadcrumb.agent": "Agentes",
"label.general-information.title": "Información general", "label.general-information.title" : "Información general",
"label.general-information.description": "Ingrese los datos principales para la identificación del agente", "label.general-information.description" : "Registre la información correspondiente al agente",
"label.questions.title": "Preguntas frecuentes", "label.avatar" : "Avatar",
"label.questions.description": "Realice la carga de información para el uso de las preguntas frecuentes que utilizará el agente", "label.description" : "Descripción",
"label.avatar": "Avatar", "label.version" : "Versión",
"label.description": "Descripción", "label.country" : "País",
"label.version": "Versión", "label.timezone" : "Zona horaria",
"label.country": "País", "label.language" : "Idioma",
"label.timezone": "Zona horaria", "label.type" : "Tipo de agente",
"label.language": "Idioma", "label.questions.title" : "Preguntas frecuentes",
"label.type": "Tipo" "label.questions.description" : "Cargue los archivos con las preguntas frecuentes de entrenamiento",
"btn.new.file" : "Nuevo archivo",
"label.file.id" : "ID",
"label.file.name" : "Nombre",
"label.file.description" : "Descripción",
"label.file.status" : "Estado",
"label.file.user" : "Usuario",
"label.file.upload.date" : "Fecha de carga",
"label.file-upload.title" : "Archivo de preguntas",
"label.file-upload.description" : "El archivo de preguntas se utilizará para el entrenamiento del bot",
"label.file" : "Archivo",
"label.file.incompatible.extension" : "Archivo no válido. Sólo se aceptan archivos con extensión ",
"label.imageAvatar.incompatible.extension" : "Archivo no válido. Sólo se aceptan imágenes y con formato "
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment