Skip to content

Commit

Permalink
added: success/error step after chatbot is published in cds-modal-act…
Browse files Browse the repository at this point in the history
…ivate-bot component
  • Loading branch information
Gabriele Panico committed Nov 7, 2023
1 parent 7ce0cbe commit 448bf9e
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h5 style="color:#D06079;"> {{'AnErroOccurredWhileActivatingTheBot' | translate

<button *ngIf="DISPLAY_INSTALL_SCRIPT"
class="btn btn-primary cds-blue-button" (click)="DISPLAY_INSTALL_SCRIPT = !DISPLAY_INSTALL_SCRIPT">
<span> {{ "Back" | translate }} </span>
<span> < {{ "Back" | translate }} </span>
</button>
</div> <!-- /.modal-footer -->

Expand All @@ -123,14 +123,49 @@ <h5 style="color:#D06079;"> {{'AnErroOccurredWhileActivatingTheBot' | translate
Publish your flow?
<!-- <h3> {{ 'DoYouWantToActivateTheBotForNewVonversations' | translate: translateparamBotName }} </h3> -->
</div>

<div *ngIf="HAS_COMPLETED_PUBLISH" class="modal-flex">

<span *ngIf="HAS_COMPLETED_PUBLISH_SUCCESS" class="field-box modal-flex">

<svg style="width: 55px;" version="1.1" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 130.2 130.2">
<circle class="path circle" fill="none" stroke="#73AF55" stroke-width="6"
stroke-miterlimit="10" cx="65.1" cy="65.1" r="62.1" />
<polyline class="path check" fill="none" stroke="#73AF55" stroke-width="6"
stroke-linecap="round" stroke-miterlimit="10"
points="100.2,40.2 51.5,88.8 29.8,67.5 " />
</svg>
<h5 style="color:#73AF55;"> {{'BotSuccessfullyActivated' | translate }}</h5>
</span>

<span *ngIf="HAS_COMPLETED_PUBLISH_ERROR" class="field-box modal-flex">

<svg style="width: 55px;" version="1.1" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 130.2 130.2">
<circle class="path circle" fill="none" stroke="#D06079" stroke-width="6"
stroke-miterlimit="10" cx="65.1" cy="65.1" r="62.1" />
<line class="path line" fill="none" stroke="#D06079" stroke-width="6" stroke-linecap="round"
stroke-miterlimit="10" x1="34.4" y1="37.9" x2="95.8" y2="92.3" />
<line class="path line" fill="none" stroke="#D06079" stroke-width="6" stroke-linecap="round"
stroke-miterlimit="10" x1="95.8" y1="38" x2="34.4" y2="92.2" />
</svg>
<h5 style="color:#D06079;"> {{'AnErroOccurredWhileActivatingTheBot' | translate }}</h5>
</span>
</div>
</div> <!-- /.modal-body -->

<div class="cds-modal-footer" id="publishStep">

<button mat-dialog-close
<button *ngIf="!HAS_COMPLETED_PUBLISH"
class="btn btn-primary cds-blue-button">
<span> {{ "Publish" | translate }} </span>
</button>

<button *ngIf="HAS_COMPLETED_PUBLISH_SUCCESS"
class="btn btn-primary cds-blue-button" mat-dialog-close>
<span> {{ "BotsAddEditPage.Continue" | translate }} </span>
</button>

</div> <!-- /.modal-footer -->
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Chatbot } from 'src/app/models/faq_kb-model';
import { Department } from 'src/app/models/department-model';
import { getWidgetWebInstallationScript } from 'src/app/utils/util';
import { AppConfigService } from 'src/app/services/app-config';
import { FaqKbService } from 'src/app/services/faq-kb.service';

@Component({
selector: 'cds-modal-activate-bot',
Expand Down Expand Up @@ -35,6 +36,10 @@ export class CdsModalActivateBotComponent implements OnInit {
HAS_COMPLETED_HOOK_BOOT_TO_DEPT_SUCCESS: boolean = false;
HAS_COMPLETED_HOOK_BOOT_TO_DEPT_ERROR: boolean = false;

HAS_COMPLETED_PUBLISH: boolean = false
HAS_COMPLETED_PUBLISH_SUCCESS: boolean = false
HAS_COMPLETED_PUBLISH_ERROR: boolean = false

translateparamBotName: any
DEPTS_HAS_NOT_A_BOT: boolean = false

Expand All @@ -45,8 +50,8 @@ export class CdsModalActivateBotComponent implements OnInit {

constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
public dialogRef: MatDialogRef<CdsModalActivateBotComponent>,
private departmentService: DepartmentService,
private faqKbService: FaqKbService,
private appConfigService: AppConfigService,
) {
this.logger.log('[ACTIVATE-BOT-MODAL-COMPONENT] data ', data)
Expand All @@ -62,10 +67,6 @@ export class CdsModalActivateBotComponent implements OnInit {
this.webScript = getWidgetWebInstallationScript(this.project_id, config.widgetBaseUrl)
}

onCloseModalAttacchBotToDept() {
this.dialogRef.close()
}


checkDepartmentsForProjectIdHasBot(){
if(this.departments){
Expand Down Expand Up @@ -144,6 +145,21 @@ export class CdsModalActivateBotComponent implements OnInit {
});
}

publish() {
this.faqKbService.publish(this.selectedChatbot).subscribe((data) => {
this.logger.log('[CDS DSBRD] publish - RES ', data)
}, (error) => {
this.HAS_COMPLETED_HOOK_BOOT_TO_DEPT = true
this.HAS_COMPLETED_PUBLISH_ERROR = true
this.logger.error('[CDS DSBRD] publish ERROR ', error);
}, () => {
this.HAS_COMPLETED_HOOK_BOOT_TO_DEPT = true
this.HAS_COMPLETED_PUBLISH_SUCCESS = true

this.logger.log('[CDS DSBRD] publish * COMPLETE *');
});
}


onCopyScript(){
navigator.clipboard.writeText(this.webScript)
Expand Down
4 changes: 3 additions & 1 deletion src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "هل تريد تفعيل bot <span class='bot_name_bold'>{{bot_name}}</span> لإحدى الأقسام التالية؟",
"ActivateBot": "تفعيل البوت",
"BotSuccessfullyActivated": "تم تفعيل البوت بنجاح",
"AnErroOccurredWhileActivatingTheBot": "حدث خطأ أثناء تنشيط الروبوت",
"BotSuccessFullyPublished": "تم نشر البوت بنجاح",
"AnErroOccurredWhileActivatingTheBot": "حدث خطأ أثناء تفعيل البوت",
"AnErroOccurredWhilePublishingTheBot": "حدث خطأ أثناء نشر البوت",
"SelectDepartment": "حدد القسم",
"Ignore": "يتجاهل",
"ActivateFor": "التنشيط لـ",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "Aşağıdakı şöbələrdən biri üçün <span class='bot_name_bold'>{{bot_name}}</span> botunu aktivləşdirmək istəyirsiniz?",
"ActivateBot": "Botu aktivləşdirin",
"BotSuccessfullyActivated": "Bot uğurla aktivləşdirildi",
"BotSuccessFullyPublished": "Bot uğurla yayımlandı",
"AnErroOccurredWhileActivatingTheBot": "Botu aktivləşdirərkən xəta baş verdi",
"AnErroOccurredWhilePublishingTheBot": "Botu dərc edərkən xəta baş verdi",
"SelectDepartment": "Şöbə seçin",
"Ignore": "Məhəl qoyma",
"ActivateFor": "üçün aktivləşdirin",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "Möchten Sie bot <span class='bot_name_bold'>{{bot_name}}</span> für eine der folgenden Abteilungen aktivieren?",
"ActivateBot": "Bot aktivieren",
"BotSuccessfullyActivated": "Bot erfolgreich aktiviert",
"BotSuccessFullyPublished": "Bot erfolgreich veröffentlicht",
"AnErroOccurredWhileActivatingTheBot": "Beim Aktivieren des Bots ist ein Fehler aufgetreten",
"AnErroOccurredWhilePublishingTheBot": "Beim Veröffentlichen des Bots ist ein Fehler aufgetreten",
"SelectDepartment": "Abteilung auswählen",
"Ignore": "Ignorieren",
"ActivateFor": "Aktivieren für",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "Do you want to activate bot <span class='bot_name_bold'>{{bot_name}}</span> for one of the following departments?",
"ActivateBot": "Activate bot",
"BotSuccessfullyActivated": "Bot successfully activated",
"BotSuccessFullyPublished":"Bot successfully published",
"AnErroOccurredWhileActivatingTheBot": "An error occurred while activating the bot",
"AnErroOccurredWhilePublishingTheBot": "An error occurred while publishing the bot",
"SelectDepartment": "Select department",
"Ignore": "Ignore",
"ActivateFor": "Activate for",
Expand Down
6 changes: 4 additions & 2 deletions src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1923,8 +1923,10 @@
"DoYouWantToActivateTheBotForNewConversations": "¿Quieres activar el bot <span class='bot_name_bold'>{{ bot_name }}</span> para nuevas conversaciones?",
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "¿Quieres activar el bot <span class='bot_name_bold'>{{bot_name}}</span> para uno de los siguientes departamentos?",
"ActivateBot": "Activar bot",
"BotSuccessfullyActivated": "Bot activado correctamente",
"AnErroOccurredWhileActivatingTheBot": "Se ha producido un error al activar el bot",
"BotSuccessfullyActivated": "Bot activado con éxito",
"BotSuccessFullyPublished": "Bot publicado con éxito",
"AnErroOccurredWhileActivatingTheBot": "Se produjo un error al activar el bot.",
"AnErroOccurredWhilePublishingTheBot": "Se produjo un error al publicar el bot.",
"SelectDepartment": "Seleccionar departamento",
"Ignore": "Ignorar",
"ActivateFor": "Activar para",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "Voulez-vous activer le bot <span class='bot_name_bold'>{{bot_name}}</span> pour l'un des départements suivants ?",
"ActivateBot": "Activer le bot",
"BotSuccessfullyActivated": "Bot activé avec succès",
"BotSuccessFullyPublished": "Bot publié avec succès",
"AnErroOccurredWhileActivatingTheBot": "Une erreur s'est produite lors de l'activation du bot",
"AnErroOccurredWhilePublishingTheBot": "Une erreur s'est produite lors de la publication du bot",
"SelectDepartment": "Sélectionnez le département",
"Ignore": "Ignorer",
"ActivateFor": "Activer pour",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "Vuoi attivare il bot <span class='bot_name_bold'>{{bot_name}}</span> per uno dei seguenti dipartmenti?",
"ActivateBot": "Attiva il bot",
"BotSuccessfullyActivated": "Bot attivato con successo",
"BotSuccessFullyPublished": "Bot pubblicato con successo",
"AnErroOccurredWhileActivatingTheBot": "Si è verificato un errore durante l'attivazione del bot",
"AnErroOccurredWhilePublishingTheBot": "Si è verificato un errore durante la pubblicazione del bot",
"SelectDepartment": "Seleziona dipartimento",
"Ignore": "Ignora",
"ActivateFor": "Attiva per",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/i18n/kk.json
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,9 @@
"DoYouWantToActivateBotForOneOfTheFollowingDepts": "Төмендегі бөлімдердің біріне арналған <span class='bot_name_bold'>{{bot_name}}</span> ботын іске қосқыңыз келе ме?",
"ActivateBot": "Ботты іске қосыңыз",
"BotSuccessfullyActivated": "Бот сәтті іске қосылды",
"BotSuccessFullyPublished": "Бот сәтті жарияланды",
"AnErroOccurredWhileActivatingTheBot": "Ботты белсендіру кезінде қате орын алды",
"AnErroOccurredWhilePublishingTheBot": "Ботты жариялау кезінде қате орын алды",
"SelectDepartment": "Бөлімді таңдаңыз",
"Ignore": "Елемеу",
"ActivateFor": "үшін белсендіру",
Expand Down

0 comments on commit 448bf9e

Please sign in to comment.