Skip to content

Commit

Permalink
Merge pull request #8 from leonidus96/master
Browse files Browse the repository at this point in the history
Seconda versione services plugin
  • Loading branch information
ddetommaso authored Mar 4, 2024
2 parents 0d5cce8 + 985318e commit 4926a2c
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 1,062 deletions.
7 changes: 6 additions & 1 deletion src/app/application-page/application-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class ApplicationPageComponent implements OnInit{
dialogRef.afterClosed().subscribe(args => {
this.appState.configureApplication(this.application,args).subscribe(() => {
this.application.isConfigured = true;
this.sessionStorage.saveIsApplicationConfigured(this.application.robotName,this.application.name,true)
this.canShowApplication = true;
})
})
Expand All @@ -62,13 +63,16 @@ export class ApplicationPageComponent implements OnInit{
//ed esistono argomenti da selezionare, mostro il popup degli argomenti
if(argsTemplateExists){
this.application.args = {};
this.application.isConfigured = false;
this.sessionStorage.saveApplicationArgs(this.application.robotName,this.application.name,{})
this.sessionStorage.saveIsApplicationConfigured(this.application.robotName,this.application.name,false)
this.openArgsDialog()

//e non esistono argomenti da selezionare, invio la configure vuota
} else {
this.appState.configureApplication(this.application,{}).subscribe(() => {
this.application.isConfigured = true;
this.sessionStorage.saveIsApplicationConfigured(this.application.robotName,this.application.name,true)
this.canShowApplication = true;
})
}
Expand Down Expand Up @@ -136,15 +140,16 @@ export class ApplicationPageComponent implements OnInit{
const argsTemplateExists = Object.keys(this.application.argsTemplate).length !== 0
const areArgsSet = this.application.args && Object.keys(this.application.args).length !== 0
const isApplicationConfigured = this.application.isConfigured;

//se l'applicazione è gia stata configurata mostro il dialog per scegliere se ripristinare la sessione
if(isApplicationConfigured){

this.openRestoreSessionDialog()

//se l'applicazione non è gia stata configurata e non ci sono argomenti da configurare, invio la configure senza parametri
} else if(!argsTemplateExists){
this.appState.configureApplication(this.application, {}).subscribe(() => {
this.application.isConfigured = true;
this.sessionStorage.saveIsApplicationConfigured(this.application.robotName,this.application.name,true)
this.canShowApplication = true;
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<ng-template #emptyActionsBlock>
<div style="display:flex;height:100%;width:100%;align-items: center;justify-content: center;">
Non ci sono action associate a questa applicazione.
There are no action for this application.
</div>
</ng-template>

Expand Down
56 changes: 32 additions & 24 deletions src/app/plugins/robot-speech/robot-speech.component.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {ChangeDetectorRef, Component, ElementRef, ViewChild} from '@angular/core';
import { WidgetBaseComponent } from '../../widget-base/widget-base.component';
import {WidgetBaseComponent} from '../../widget-base/widget-base.component';
import {MatInput} from "@angular/material/input";

@Component({
selector: 'app-robot-speech',
templateUrl: './robot-speech.component.html',
styleUrl: './robot-speech.component.css'
})
export class RobotSpeechComponent extends WidgetBaseComponent{
export class RobotSpeechComponent extends WidgetBaseComponent {

@ViewChild('scrollContainer') private myScrollContainer: ElementRef;
@ViewChild('messageInput',{read:MatInput}) messageInput: MatInput;
@ViewChild('messageInput', {read: MatInput}) messageInput: MatInput;

readonly messageColors = {
"CREATED":'lightgray',
"SENDING":'#FFF778FF',
"SENT":'lightgreen',
"FAILED":'indianred'
"CREATED": 'lightgray',
"SENDING": '#FFF778FF',
"SENT": 'lightgreen',
"FAILED": 'indianred'
}
messages:{text:string,status:string}[] = [];
messages: { text: string, status: string }[] = [];
newMessage = ""
inputDisabled = false;

Expand All @@ -30,38 +30,46 @@ export class RobotSpeechComponent extends WidgetBaseComponent{
this.sendMessage()
}

sendMessage(){
sendMessage() {
if (this.newMessage.trim()) {
this.inputDisabled = true;
let messageObject = {
text:this.newMessage,
status:"CREATED"
text: this.newMessage,
status: "CREATED"
};
this.newMessage = "";
this.messages.push(messageObject);
this.cdr.detectChanges()
this.scrollToBottom()
this.speechSayAsync(messageObject.text).subscribe(requestID => {
const onRunningCallback = () => {
messageObject.status = "SENDING";
}
const onDoneCallback = () => {
messageObject.status = "SENT";
this.inputDisabled = false;
}
this.speechSayAsync(messageObject.text).subscribe({
next: requestID => {
const onRunningCallback = () => {
messageObject.status = "SENDING";
}
const onDoneCallback = () => {
messageObject.status = "SENT";
this.inputDisabled = false;
}

const onFailedCallback = () => {
messageObject.status = "FAILED";
this.inputDisabled = false;
}

const onFailedCallback = () => {
this.checkAsyncRequestStatus(requestID, () => {
}, onRunningCallback, onDoneCallback, onFailedCallback)

},
error: err => {
messageObject.status = "FAILED";
this.inputDisabled = false;
}

this.checkAsyncRequestStatus(requestID,() =>{},onRunningCallback,onDoneCallback,onFailedCallback)

})
}
}

scrollToBottom(){

scrollToBottom() {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ng-container *ngIf="!isLoading;else elseBlock">
<div style="width:100%;height:100%;display:flex;flex-direction: column">
<mat-form-field subscriptSizing="dynamic" appearance="outline" style="width:100%;background-color: white">
<input matInput [(ngModel)]="search" placeholder="Search action..." >
<input matInput [(ngModel)]="search" placeholder="Search service..." >
<span matSuffix><mat-icon style="margin-right:10px">search</mat-icon></span>
</mat-form-field>
<div class="widget-container">
Expand Down Expand Up @@ -81,7 +81,7 @@

<ng-template #emptyActionsBlock>
<div style="display:flex;height:100%;width:100%;align-items: center;justify-content: center;">
Non ci sono action associate a questa applicazione.
There are no services for this application.
</div>
</ng-template>

Expand Down
14 changes: 8 additions & 6 deletions src/app/plugins/services-manager/services-manager.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ServicesManagerComponent extends WidgetBaseComponent implements OnI
}
})

this.runServiceAsync(selectedService.name,selectedService.args).subscribe(reqID => {
this.runServiceAsync(`${this.application.name}.${selectedService.name}`,selectedService.args).subscribe(reqID => {

//console.log("RISPOSTA PLAYACTION: ",reqID)

Expand Down Expand Up @@ -125,11 +125,13 @@ export class ServicesManagerComponent extends WidgetBaseComponent implements OnI
ngOnInit() {
this.getApplicationServices().subscribe({
next: services => {
//const filteredActions = actions.filter(action => action.startsWith(this.application.name + ".")).map(action => action.substring(this.application.name.length + 1))
//const newActions: Action[] = filteredActions.map(action => {
//return {actionID: action, actionState: ActionState.ACTIVE}
//})
this.services = services;
const filteredServices = services.filter(service => service.name.startsWith(this.application.name + ".")).map(service => {
return {
...service,
name:service.name.substring(this.application.name.length + 1)
}
})
this.services = filteredServices;
this.isLoading = false;
//console.log(this.actions)
},
Expand Down
Loading

0 comments on commit 4926a2c

Please sign in to comment.