repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
design-studio
github_2023
Tiledesk
typescript
CdsActionReplySettingsComponent.ngOnDestroy
ngOnDestroy() { if (this.subscriptionChangedConnector) { this.subscriptionChangedConnector.unsubscribe(); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-settings/cds-action-reply-settings.component.ts#L73-L77
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplySettingsComponent.initializeConnector
initializeConnector() { this.idIntentSelected = this.idAction.split('/')[0]; this.idConnectorNoInput = this.idAction + '/noInput'; this.idConnectorNoMatch = this.idAction + '/noMatch'; this.listOfIntents = this.intentService.getListOfIntents(); this.checkConnectionStatus(); this.checkButtonsInCommands(); }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-settings/cds-action-reply-settings.component.ts#L83-L90
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplySettingsComponent.checkButtonsInCommands
private checkButtonsInCommands(){ let commands = this.action.attributes.commands if(commands && commands.length > 0){ let messages = commands.filter(command => command.type === TYPE_COMMAND.MESSAGE) messages.forEach(el => { if(!el || !el.message || !el.message.attributes){ this.isConnectorInputDisabled = true; this.isConnectorMatchDisabled = true; return; } if(el.message.attributes.attachment && el.message.attributes.attachment.buttons && el.message.attributes.attachment.buttons.length > 0){ this.isConnectorInputDisabled = false; this.isConnectorMatchDisabled = false; return; }else{ //CASE: no buttons in message element this.isConnectorInputDisabled = true; this.isConnectorMatchDisabled = true; return; } }) } }
// PRIVATE FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-settings/cds-action-reply-settings.component.ts#L182-L205
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplySettingsComponent.onClickDelayTime
onClickDelayTime(opened: boolean){ // this.canShowFilter = !opened; }
/** onClickDelayTime */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-settings/cds-action-reply-settings.component.ts#L210-L212
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplySettingsComponent.onChangeDelayTime
onChangeDelayTime(value:number){ this.action.noInputTimeout = value*1000; // this.canShowFilter = true; this.changeActionReply.emit(); }
/** onChangeDelayTime */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-settings/cds-action-reply-settings.component.ts#L215-L219
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplySettingsComponent.onChangeTextarea
onChangeTextarea(text:string, key: string) { if(!this.previewMode){ this.action[key] = text; // this.changeActionReply.emit(); } }
/** onChangeTextarea */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-settings/cds-action-reply-settings.component.ts#L222-L227
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.ngOnInit
ngOnInit(): void { this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { this.connector = connector; this.updateConnector(); }); this.initialize(); }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L61-L67
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.ngOnDestroy
ngOnDestroy() { if (this.subscriptionChangedConnector) { this.subscriptionChangedConnector.unsubscribe(); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L70-L74
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.initialize
private initialize(){ this.delayTime = (this.wait && this.wait.time || this.wait.time === 0)? (this.wait.time/1000) : 500/1000; this.checkButtons(); this.buttons = this.intentService.patchButtons(this.buttons, this.idAction); this.idIntent = this.idAction.split('/')[0]; if(this.response && this.response._tdJSONCondition && this.response._tdJSONCondition.conditions.length > 0){ this.filterConditionExist = true } }
// PRIVATE FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L82-L90
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.updateConnector
private updateConnector(){ try { const array = this.connector.fromId.split("/"); const idButton = array[array.length - 1]; const idConnector = this.idAction+'/'+idButton; const buttonChanged = this.buttons.find(obj => obj.uid === idButton); if(idConnector === this.connector.fromId && buttonChanged){ this.logger.log('updateConnector [CdsActionReplyTextComponent]:: buttonChanged: ', this.connector, buttonChanged, this.buttons, idButton); if(this.connector.deleted){ // DELETE // this.logger.log('[CdsActionReplyTextComponent] deleteConnector :: ', this.connector); buttonChanged.__isConnected = false; buttonChanged.__idConnector = this.connector.fromId; buttonChanged.__idConnection = null; buttonChanged.action = ''; buttonChanged.type = TYPE_BUTTON.TEXT; if(this.connector.save)this.updateAndSaveAction.emit(this.connector); } else { // ADD / EDIT buttonChanged.__idConnector = this.connector.fromId; buttonChanged.action = buttonChanged.action? buttonChanged.action : '#' + this.connector.toId; buttonChanged.type = TYPE_BUTTON.ACTION; // this.logger.log('[CdsActionReplyTextComponent] updateConnector :: ', buttonChanged); if(!buttonChanged.__isConnected){ buttonChanged.__isConnected = true; buttonChanged.__idConnection = this.connector.fromId+"/"+this.connector.toId; // if(this.connector.notify) // this.updateAndSaveAction.emit(); if(this.connector.save)this.updateAndSaveAction.emit(this.connector); // this.changeActionReply.emit(); } } // this.changeActionReply.emit(); } } catch (error) { this.logger.error('error: ', error); } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L124-L162
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onClickDelayTime
onClickDelayTime(opened: boolean){ this.canShowFilter = !opened; }
/** onClickDelayTime */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L169-L171
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onChangeDelayTime
onChangeDelayTime(value:number){ this.delayTime = value; this.wait.time = value*1000; this.canShowFilter = true; this.changeActionReply.emit(); }
/** onChangeDelayTime */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L174-L179
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onChangeExpression
onChangeExpression(expression: Expression){ this.response._tdJSONCondition = expression; this.filterConditionExist = expression && expression.conditions.length > 0? true : false; this.changeActionReply.emit(); }
/** onChangeExpression */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L182-L186
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onDeleteActionReply
onDeleteActionReply(){ this.deleteActionReply.emit(this.index); }
/** onDeleteActionReply */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L189-L191
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onMoveUpResponse
onMoveUpResponse(){ this.moveUpResponse.emit(this.index); }
/** onMoveUpResponse */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L194-L196
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onMoveDownResponse
onMoveDownResponse(){ this.moveDownResponse.emit(this.index); }
/** onMoveDownResponse */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L199-L201
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onChangeTextarea
onChangeTextarea(text:string) { if(!this.previewMode){ this.response.text = text; // this.changeActionReply.emit(); } }
/** onChangeTextarea */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L204-L209
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onOpenButtonPanel
onOpenButtonPanel(button){ this.logger.log('[ACTION REPLY TEXT] onOpenButtonPanel ', button, this.response.attributes.attachment.buttons); this.openButtonPanel.emit(button); }
/** onOpenButtonPanel */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L222-L225
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.onButtonControl
onButtonControl(action: string, index: number ){ switch(action){ case 'delete': /** onDeleteButton */ this.deleteButton.emit({index: index, buttons: this.buttons}); break; case 'moveLeft': break; case 'moveRight': break; case 'new': /** onCreateNewButton */ this.createNewButton.emit(this.index); break; } }
/** onButtonControl */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L228-L241
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionReplyTextComponent.dropButtons
dropButtons(event: CdkDragDrop<string[]>) { moveItemInArray(this.buttons, event.previousIndex, event.currentIndex); this.connectorService.updateConnector(this.idIntent); this.changeActionReply.emit(); }
/** dropButtons */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-reply/elements/cds-action-reply-text/cds-action-reply-text.component.ts#L244-L248
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionSendWhatsappComponent.ngOnDestroy
ngOnDestroy() { if (this.subscriptionChangedConnector) { this.subscriptionChangedConnector.unsubscribe(); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-send-whatsapp/cds-action-send-whatsapp.component.ts#L71-L75
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsWhatsappReceiverComponent.checkParameters
checkParameters() { // let text_header_result = this.header_params.find(p => !p.text || p.text == ''); let media_header_result = this.header_params.find(p => (p.text == '') || (p.image && (!p.image.link || p.image.link == '')) || (p.document && (!p.document.link || p.document.link == '')) || (p.location && (!p.location.name || !p.location.address || !p.location.latitude || !p.location.longitude))); let body_result = this.body_params.find(p => !p.text || p.text == ''); let url_buttton_result = this.buttons_params.find(p => !p.text || p.text == ''); this.logger.log('[WHATSAPP RECEIVER] checkParameters media',media_header_result) this.logger.log('[WHATSAPP RECEIVER] checkParameters body',body_result) this.logger.log('[WHATSAPP RECEIVER] checkParameters url',url_buttton_result) if (( !media_header_result) && !body_result && !url_buttton_result) { this.logger.log(" ** PARAMETRI COMPLETI **") this.emitParams(); let preview_container = this.elementRef.nativeElement.querySelector('#parameters-container'); preview_container.classList.remove('highlighted'); } else { let preview_container = this.elementRef.nativeElement.querySelector('#parameters-container'); preview_container.classList.add('highlighted'); } }
// evaluate saving partial objects
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-send-whatsapp/whatsapp-receiver/whatsapp-receiver.component.ts#L282-L301
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestV2Component.ngOnInit
ngOnInit(): void { this.logger.debug("[ACTION-WEB-REQUEST-v2] action detail: ", this.action); this.subscriptionChangedConnector = this.intentService.isChangedConnector$.subscribe((connector: any) => { this.logger.debug('[ACTION-WEB-REQUEST-v2] isChangedConnector -->', connector); let connectorId = this.idIntentSelected+"/"+this.action._tdActionId; if(connector.fromId.startsWith(connectorId)){ this.connector = connector; this.updateConnector(); } }); this.initialize(); }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request-v2/cds-action-web-request-v2.component.ts#L76-L87
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestV2Component.ngOnDestroy
ngOnDestroy() { if (this.subscriptionChangedConnector) { this.subscriptionChangedConnector.unsubscribe(); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request-v2/cds-action-web-request-v2.component.ts#L90-L94
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestV2Component.checkConnectionStatus
private checkConnectionStatus(){ if(this.action.trueIntent){ this.isConnectedTrue = true; const posId = this.action.trueIntent.indexOf("#"); if (posId !== -1) { const toId = this.action.trueIntent.slice(posId+1); this.idConnectionTrue = this.idConnectorTrue+"/"+toId; } } else { this.isConnectedTrue = false; this.idConnectionTrue = null; } if(this.action.falseIntent){ this.isConnectedFalse = true; const posId = this.action.falseIntent.indexOf("#"); if (posId !== -1) { const toId = this.action.falseIntent.slice(posId+1); this.idConnectionFalse = this.idConnectorFalse+"/"+toId; } } else { this.isConnectedFalse = false; this.idConnectionFalse = null; } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request-v2/cds-action-web-request-v2.component.ts#L121-L144
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestV2Component.initialize
private initialize(){ this.initializeAttributes(); this.methods = Object.keys(TYPE_METHOD_REQUEST).map((key, index) => { return { label: key, value: key } }) this.jsonHeader = this.action.headersString this.bodyOptions.forEach(el => { el.value ===this.action.bodyType? el.checked= true: el.checked = false }) // this.jsonIsValid = this.isValidJson(this.action.jsonBody); if(this.action.jsonBody){ this.body = this.action.jsonBody; this.body = this.formatJSON(this.body, "\t"); } this.jsonSettings = { timeout: 20000} if(this.action.settings){ this.jsonSettings = this.action.settings } if(!this.action.formData){ this.action.formData = [] } this.assignments = this.action.assignments if(this.intentSelected){ this.initializeConnector(); } this.autocompleteHeaderOptions = []; HEADER_TYPE.forEach(el => this.autocompleteHeaderOptions.push({label: el.label, value: el.value})) }
// CUSTOM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request-v2/cds-action-web-request-v2.component.ts#L194-L220
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestV2Component.onChangeMethodButton
onChangeMethodButton(e: {label: string, value: string}){ this.action.method = e.value; this.updateAndSaveAction.emit({type: TYPE_UPDATE_ACTION.ACTION, element: this.action}); }
// EVENT FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request-v2/cds-action-web-request-v2.component.ts#L265-L268
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestComponent.ngOnInit
ngOnInit(): void { // on init }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request/cds-action-web-request.component.ts#L39-L41
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestComponent.initialize
private initialize(){ this.methods = Object.keys(TYPE_METHOD_REQUEST).map((key, index) => { return { label: key, value: key } }) this.jsonHeader = this.action.headersString; this.jsonIsValid = this.isValidJson(this.action.jsonBody); if(this.jsonIsValid){ this.jsonBody = this.action.jsonBody; this.jsonBody = this.formatJSON(this.jsonBody, "\t"); } this.assignments = this.action.assignments }
// CUSTOM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request/cds-action-web-request.component.ts#L53-L64
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionWebRequestComponent.onChangeMethodButton
onChangeMethodButton(e: {label: string, value: string}){ this.action.method = e.value; this.updateAndSaveAction.emit() }
// EVENT FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/cds-action-web-request/cds-action-web-request.component.ts#L98-L101
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.generateJsonIntentForm
generateJsonIntentForm() { this.logger.log('[FORM-COMP] generateJsonIntentForm') if (this.selectedFormId && !this.selectedForm) { this.getFieldFromId(this.selectedFormId); } this.logger.log('[FORM-COMP] selectedForm ', this.selectedForm) if (this.selectedForm) { this.selectedForm.to_JSON(); this.intentForm = this.selectedForm; this.intentForm.cancelCommands = this.cancelCommands; this.intentForm.cancelReply = this.cancelReply; this.intentForm.to_JSON(); // this.fields = JSON.parse(JSON.stringify(this.selectedForm.fields)); this.fields = this.selectedForm.fields; this.intentFormSize = Object.keys(this.intentForm).length; this.logger.log('[FORM-COMP] generateJsonIntentForm ', this.intentForm) } this.displayCancelButton = false; this.displaySettingsButton = true; this.logger.log('[FORM-COMP] generateJsonIntentForm displaySettingsButton:', this.displaySettingsButton, ' displayCancelButton', this.displayCancelButton) // se sto creando un form custom che non ha campi if (this.fields.length === 0) { this.displayEditForm = false; this.displayAddForm = true; this.openAddEditForm(); } this.jsonGenerator(); }
/** CREATE NEW FORM */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L165-L192
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.confirmDeleteModal
confirmDeleteModal(index: string) { this.logger.log('[FORM-COMP] confirmDeleteModal index ', index) this.logger.log('[FORM-COMP] confirmDeleteModal this.idForm ', this.idForm) if (index === this.idForm) { // if (index === this.selectedFormId) { this.deleteForm(); } else { this.displayAddForm = false; this.displayEditForm = false; let i: number = +index; this.fields.splice(i, 1); if (this.fields.length === 0) { this.deleteForm(); } this.intentForm.fields = this.fields; this.logger.log('confirmDeleteModal::: ', this.intentForm, this.fields); } this.jsonGenerator(); this.displayMODAL = false; }
/** Event modal confirm delete field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L326-L346
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.closeDeleteModal
closeDeleteModal(i: number) { this.displayMODAL = false; }
/** Event modal close delete field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L396-L398
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.eventAddField
eventAddField() { this.displayEditForm = false; this.selectedField = null; this.displayAddForm = true; this.openAddEditForm(); this.logger.log('[FORM-COMP] eventAddField displayEditForm ', this.displayEditForm) this.logger.log('[FORM-COMP] eventAddField selectedField ', this.selectedField) this.logger.log('[FORM-COMP] eventAddField displayAddForm ', this.displayAddForm) }
/** Event add field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L401-L409
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.eventEditField
eventEditField(i: number) { this.closeAddEditForm(); setTimeout(() => { this.selectedField = this.fields[i]; this.displayAddForm = false; this.displayEditForm = true; this.openAddEditForm(); }, 300); this.logger.log('[FORM-COMP] eventEditField selectedField ', this.selectedField) this.logger.log('[FORM-COMP] eventEditField displayAddForm ', this.displayAddForm) this.logger.log('[FORM-COMP] eventEditField displayEditForm ', this.displayEditForm) }
/** Event edit field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L412-L423
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.closeAddEditForm
closeAddEditForm() { this.displayAddForm = false; this.displayEditForm = false; this.displayTilebotAddEditForm = true; this.scrollToTop(); this.logger.log('[FORM-COMP] closeAddEditForm displayAddForm ', this.displayAddForm) this.logger.log('[FORM-COMP] closeAddEditForm displayEditForm ', this.displayEditForm) this.logger.log('[FORM-COMP] closeAddEditForm displayEditForm ', this.displayTilebotAddEditForm) }
/** Event close add/edit form accordion */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L436-L444
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.saveAddEditForm
saveAddEditForm(event: any) { const objIndex = this.fields.findIndex(obj => obj.name === event.name); if (objIndex === -1) { this.fields.push(event); } else { this.fields.splice(objIndex, 1, event); } if (this.intentForm) { this.intentForm.fields = this.fields; this.logger.log('[FORM-COMP] saveAddEditForm intentForm ', this.intentForm) } this.displayAddForm = false; this.displayEditForm = false; this.displayTilebotAddEditForm = true; this.jsonGenerator(); }
/** Event SAVE field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L447-L462
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsFormComponent.onChangedFormFields
onChangedFormFields(event:any){ try { const objIndex = this.fields.findIndex(obj => obj.name === event.name); if (objIndex === -1) { this.fields.push(event); } else { this.fields.splice(objIndex, 1, event); } if (this.intentForm) { this.intentForm.fields = this.fields; } // this.intentSelected.form = this.intentForm; // this.updateIntentForm.emit(this.intentForm); this.logger.log('[FORM-COMP] saveAddEditForm intentForm ', this.intentForm); this.jsonGenerator(); } catch (error) { this.logger.log('[FORM-COMP] error ', error); } }
/** Events of FORM EDIT ADD */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form.component.ts#L491-L509
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FormEditAddComponent.onChangeParameterName
onChangeParameterName(parameterName) { parameterName.toString(); this.fieldName = parameterName.replace(/[^A-Z0-9_]+/ig, ""); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form-edit-add/form-edit-add.component.ts#L198-L201
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FormEditAddComponent.save
save() { // this.logger.log('[TILEBOT-EDIT-ADD] save ') if (this.checkFields()) { // this.displayInfoMessage = false; this.showForm = false; this.field.name = this.fieldName ? this.fieldName : ''; this.field.type = this.fieldType ? this.fieldType.toUpperCase() : null; this.field.regex = this.fieldRegex ? this.fieldRegex : TYPE_REGEX.customRGEX; if(!this.fieldLabel || this.fieldLabel.trim().length === 0){ delete this.field.label } else { this.field.label = this.fieldLabel.trim(); } if(!this.fieldErrorLabel || this.fieldErrorLabel.trim().length === 0){ delete this.field.errorLabel; } else { this.field.errorLabel = this.fieldErrorLabel.trim(); } // this.fieldRegex = this.field.regex.toString(); this.logger.log('[TILEBOT-EDIT-ADD] checkFields field ', this.field); this.saveAddEditForm.emit(this.field); } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form-edit-add/form-edit-add.component.ts#L214-L236
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FormEditAddComponent.onSelectedAttributeParam
onSelectedAttributeParam(variableSelected: {name: string, value: string}){ this.hasSelectedVariable = true; this.fieldName = variableSelected.value; this.field.name = variableSelected.value; if(this.displayAddForm === false){ this.changedFormFields.emit(this.field); this.logger.log('onSelectedAttributeParam:: ', this.field); } }
/** START EVENTS */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form-edit-add/form-edit-add.component.ts#L260-L268
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FormEditAddComponent.onChangeValidationType
onChangeValidationType(event: {label: string, value: string}) { this.field.type = event.value; this.setRegex(); if(this.displayAddForm === false){ this.changedFormFields.emit(this.field); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form-edit-add/form-edit-add.component.ts#L301-L307
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FormFieldComponent.deleteFieldModal
deleteFieldModal(index:number) { this.openDeleteFieldModal.emit(index); }
/** Event modal open delete field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form-field/form-field.component.ts#L44-L46
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
FormFieldComponent.editField
editField(index:number){ this.selectedObjectId = index; this.eventEditField.emit(index); }
/** Event edit field */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/form/form-field/form-field.component.ts#L49-L52
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsQuestionComponent.trackByIndex
trackByIndex(index: number, obj: any): any { return index; }
// serve per mantenere il focus nel campo input mentre si edita un valore
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list/question/question.component.ts#L80-L82
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsAddActionMenuComponent.constructor
constructor(public translate: TranslateService) { }
// @Output() clickedOutOfAddActionMenu= new EventEmitter();
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/shared/cds-add-action-menu/cds-add-action-menu.component.ts#L26-L26
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsAddActionMenuComponent.onSearchAction
onSearchAction(searchText) { searchText = searchText.toLocaleLowerCase() if (!searchText) { this.filterMenuItemsList = this.menuItemsList } this.filterMenuItemsList = this._filter(searchText, this.menuItemsList) }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/shared/cds-add-action-menu/cds-add-action-menu.component.ts#L94-L101
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsAddActionMenuComponent.onAddActionFromActionMenu
onAddActionFromActionMenu(item){ let event = { 'type': item.value.type } this.actionToSearch = undefined; this.filterMenuItemsList = this.menuItemsList; this.addActionFromActionMenu.emit(event); }
// return it.toLocaleLowerCase().includes(searchText);
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/shared/cds-add-action-menu/cds-add-action-menu.component.ts#L110-L117
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.ngOnInit
ngOnInit(): void { this.initializeApp(); this.user = this.tiledeskAuthService.getCurrentUser(); }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L49-L52
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.detectFiles
detectFiles(event: any){ this.logger.debug('[IMAGE-UPLOAD] detectFiles: ', event); if (event) { this.selectedFiles = event.target.files; this.logger.debug('[IMAGE-UPLOAD] AppComponent:detectFiles::selectedFiles', this.selectedFiles); // this.onAttachmentButtonClicked.emit(this.selectedFiles) if (this.selectedFiles == null) { this.isFilePendingToUpload = false; } else { this.isFilePendingToUpload = true; } this.logger.debug('[IMAGE-UPLOAD] AppComponent:detectFiles::selectedFiles::isFilePendingToUpload', this.isFilePendingToUpload); this.logger.debug('[IMAGE-UPLOAD] fileChange: ', event.target.files); if (event.target.files.length <= 0) { this.isFilePendingToUpload = false; } else { this.isFilePendingToUpload = true; } const that = this; if (event.target.files && event.target.files[0]) { const canUploadFile = checkAcceptedFile(event.target.files[0].type, '.wav') if(!canUploadFile){ this.logger.error('[IMAGE-UPLOAD] detectFiles: can not upload current file type--> NOT ALLOWED', '.wav', event.target.files[0].type) this.isFilePendingToUpload = false; return; } const nameFile = event.target.files[0].name; const typeFile = event.target.files[0].type; const size = event.target.files[0].size const reader = new FileReader(); that.logger.debug('[AUDIO-UPLOAD] OK preload: ', nameFile, typeFile, reader); reader.addEventListener('load', function () { that.logger.debug('[AUDIO-UPLOAD] addEventListener load', reader.result); // that.isFileSelected = true; // se inizia con image if (typeFile.startsWith('image') && !typeFile.includes('svg')) { const imageXLoad = new Image; that.logger.debug('[AUDIO-UPLOAD] onload ', imageXLoad); imageXLoad.src = reader.result.toString(); imageXLoad.title = nameFile; imageXLoad.onload = function () { that.logger.debug('[AUDIO-UPLOAD] onload image'); // that.arrayFilesLoad.push(imageXLoad); const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16); that.arrayFilesLoad[0] = { uid: uid, file: imageXLoad, type: typeFile, size: size }; that.logger.debug('[AUDIO-UPLOAD] OK: ', that.arrayFilesLoad[0]); // SEND MESSAGE that.loadFile(); }; } else { that.logger.debug('[AUDIO-UPLOAD] onload file'); const fileXLoad = { src: reader.result.toString(), title: nameFile }; // that.arrayFilesLoad.push(imageXLoad); const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16); that.arrayFilesLoad[0] = { uid: uid, file: fileXLoad, type: typeFile, size: size }; that.logger.debug('[AUDIO-UPLOAD] OK: ', that.arrayFilesLoad[0]); // SEND MESSAGE that.loadFile(); } }, false); if (event.target.files[0]) { reader.readAsDataURL(event.target.files[0]); that.logger.debug('[AUDIO-UPLOAD] reader-result: ', event.target.files[0]); } } } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L132-L206
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.setImageSize
private setImageSize(uploadedFiles){ let fileReader = new FileReader(); fileReader.readAsDataURL(uploadedFiles) fileReader.onload = () => { // when file has loaded var img = new Image(); img.src = fileReader.result.toString() img.onload = () => { this.logger.log('imageeee', img.width, img.height) this.metadata.width = img.width; this.metadata.height = img.height; this.metadata.name = uploadedFiles.name this.metadata.type = uploadedFiles.type this.onChangeMetadata.emit(this.metadata) }; }; // setTimeout(() => { // try { // var width = this.myIdentifier.nativeElement.offsetWidth; // var height = this.myIdentifier.nativeElement.offsetHeight; // this.myIdentifier.nativeElement.setAttribute("width", width); // this.myIdentifier.nativeElement.setAttribute("height", height); // // this.metadata.width = width; // // this.metadata.height = height; // } catch (error) { // this.logger.log('myIdentifier:' + error); // } // }, 0); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L301-L328
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.readAsDataURL
readAsDataURL(e: any) { this.logger.log('eventtt', e) let dataFiles = " " if (e.type === 'change') { dataFiles = e.target.files; } else if (e.type === 'drop') { dataFiles = e.dataTransfer.files } else { dataFiles = e.files } // const attributes = { files: dataFiles, enableBackdropDismiss: false }; // --------------------------------------------------------------------- // USE CASE IMAGE // --------------------------------------------------------------------- let event:any = { target: { files: dataFiles} } try { if (event) { this.detectFiles(event); } } catch (error) { this.logger.log("error: ", error); } // if (file.type.startsWith('image') && !file.type.includes('svg')) { // const reader = new FileReader(); // let that = this; // reader.onload = (e: any) => { // this.logger.log("CARICATA IMMAGINE::: ", e.target); // // this.metadata.src = e.target.result; // var img = new Image(); // img.src = this.metadata.src; // img.onload = function() { // that.setImageSize(); // }; // img.onerror = function(e) { // this.logger.log("ERROR ::: ", e); // }; // } // reader.readAsDataURL(file); // // --------------------------------------------------------------------- // // USE CASE SVG // // --------------------------------------------------------------------- // } else if (file.type.startsWith('image') && file.type.includes('svg')) { // const preview = document.querySelector('#img-preview') as HTMLImageElement // const reader = new FileReader(); // const that = this; // reader.addEventListener('load',function () { // const img = reader.result.toString(); // this.logger.log('FIREBASE-UPLOAD USE CASE SVG LoaderPreviewPage readAsDataURL img ',img) // // that.arrayFiles.push(that.sanitizer.bypassSecurityTrustResourceUrl(img)) // // if (!that.fileSelected) { // // that.fileSelected = that.sanitizer.bypassSecurityTrustResourceUrl(img) // // } // },false); // if (file) { // reader.readAsDataURL(file); // } // // --------------------------------------------------------------------- // // USE CASE FILE // // --------------------------------------------------------------------- // } else { // this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE ',file) // this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE TYPE',file.type) // let file_extension = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length) || file.name // this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE EXTENSION', file_extension) // let file_name = file.name // this.logger.log( '[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE NAME', file_name) // // this.createFile() // } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L332-L401
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.drop
drop(ev: any) { ev.preventDefault(); ev.stopPropagation(); const fileList = ev.dataTransfer.files this.isHovering = false if (fileList.length > 0) { const file: File = fileList[0]; var mimeType = fileList[0].type; const canUploadFile = checkAcceptedFile(mimeType, '.wav') if(!canUploadFile){ this.presentToastOnlyImageFilesAreAllowedToDrag() this.logger.error('[IMAGE-UPLOAD] detectFiles: can not upload current file type--> NOT ALLOWED', '.wav', mimeType) return; } this.handleDropEvent(ev); } }
// DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L422-L438
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.allowDrop
allowDrop(ev: any) { ev.preventDefault() ev.stopPropagation() this.isHovering = true }
// DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L446-L450
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSAudioUploadComponent.drag
drag(ev: any) { ev.preventDefault(); ev.stopPropagation() this.isHovering = false }
// DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/audio-upload/audio-upload.component.ts#L453-L457
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSDelaySliderComponent.formatLabel
formatLabel(value: number): string { this.delayTime = value; return `${value}`+ 's'; }
// EVENTS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/delay-slider/delay-slider.component.ts#L30-L33
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSDelayTextComponent.formatLabel
formatLabel(value: number): string { this.delayTime = value; const d = secondsToDhms(this.delayTime).getDays(); const h = secondsToDhms(this.delayTime).getHours(); const m = secondsToDhms(this.delayTime).getMinutes(); let number = this.delayTime let unit = 's' if(d > 0){ number = d; unit = 'd' } else if(h > 0){ number = h; unit = 'h' }else if( m> 0){ number = m; unit = 'm' } return number + unit // return `${value}`+ 's'; }
// EVENTS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/delay-text/delay-text.component.ts#L40-L61
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSElementFromUrlComponent.onCloseImagePanel
onCloseImagePanel(){ // this.showAddImage = false; }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/element-from-url/element-from-url.component.ts#L53-L55
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSElementFromUrlComponent.onChangeTextArea
onChangeTextArea(text:string) { this.pathElement = text; }
/** onChangeTextarea */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/element-from-url/element-from-url.component.ts#L67-L69
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
HeightSliderComponent.formatLabel
formatLabel(value: number): string { this.heightIframe = value; return `${value}`+ 'px'; }
// EVENTS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/height-slider/height-slider.component.ts#L30-L33
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.ngOnInit
ngOnInit(): void { this.initializeApp(); this.user = this.tiledeskAuthService.getCurrentUser(); this.fileUploadAccept = filterImageMimeTypesAndExtensions(this.appConfigService.getConfig().fileUploadAccept).join(','); }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L52-L56
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.detectFiles
detectFiles(event: any){ this.logger.debug('[IMAGE-UPLOAD] detectFiles: ', event); if (event) { this.selectedFiles = event.target.files; this.logger.debug('[IMAGE-UPLOAD] AppComponent:detectFiles::selectedFiles', this.selectedFiles); // this.onAttachmentButtonClicked.emit(this.selectedFiles) if (this.selectedFiles == null) { this.isFilePendingToUpload = false; } else { this.isFilePendingToUpload = true; } this.logger.debug('[IMAGE-UPLOAD] AppComponent:detectFiles::selectedFiles::isFilePendingToUpload', this.isFilePendingToUpload); this.logger.debug('[IMAGE-UPLOAD] fileChange: ', event.target.files); if (event.target.files.length <= 0) { this.isFilePendingToUpload = false; } else { this.isFilePendingToUpload = true; } const that = this; if (event.target.files && event.target.files[0]) { const canUploadFile = checkAcceptedFile(event.target.files[0].type, this.fileUploadAccept) if(!canUploadFile){ this.presentToastOnlyImageFilesAreAllowedToDrag() this.logger.error('[IMAGE-UPLOAD] detectFiles: can not upload current file type--> NOT ALLOWED', this.fileUploadAccept) this.isFilePendingToUpload = false; return; } const nameFile = event.target.files[0].name; const typeFile = event.target.files[0].type; const size = event.target.files[0].size const reader = new FileReader(); that.logger.debug('[IMAGE-UPLOAD] OK preload: ', nameFile, typeFile, reader); reader.addEventListener('load', function () { that.logger.debug('[IMAGE-UPLOAD] addEventListener load', reader.result); // that.isFileSelected = true; // se inizia con image if (typeFile.startsWith('image') && !typeFile.includes('svg')) { const imageXLoad = new Image; that.logger.debug('[IMAGE-UPLOAD] onload ', imageXLoad); imageXLoad.src = reader.result.toString(); imageXLoad.title = nameFile; imageXLoad.onload = function () { that.logger.debug('[IMAGE-UPLOAD] onload image'); // that.arrayFilesLoad.push(imageXLoad); const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16); that.arrayFilesLoad[0] = { uid: uid, file: imageXLoad, type: typeFile, size: size }; that.logger.debug('[IMAGE-UPLOAD] OK: ', that.arrayFilesLoad[0]); // SEND MESSAGE that.loadFile(); }; } else { that.logger.debug('[[IMAGE-UPLOAD] onload file'); const fileXLoad = { src: reader.result.toString(), title: nameFile }; // that.arrayFilesLoad.push(imageXLoad); const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16); that.arrayFilesLoad[0] = { uid: uid, file: fileXLoad, type: typeFile, size: size }; that.logger.debug('[IMAGE-UPLOAD] OK: ', that.arrayFilesLoad[0]); // SEND MESSAGE that.loadFile(); } }, false); if (event.target.files[0]) { reader.readAsDataURL(event.target.files[0]); that.logger.debug('[IMAGE-UPLOAD] reader-result: ', event.target.files[0]); } } } }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L136-L211
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.setImageSize
private setImageSize(uploadedFiles){ let fileReader = new FileReader(); fileReader.readAsDataURL(uploadedFiles) fileReader.onload = () => { // when file has loaded var img = new Image(); img.src = fileReader.result.toString() img.onload = () => { this.logger.log('imageeee', img.width, img.height) this.metadata.width = img.width; this.metadata.height = img.height; this.metadata.name = uploadedFiles.name this.metadata.type = uploadedFiles.type this.onChangeMetadata.emit(this.metadata) }; }; // setTimeout(() => { // try { // var width = this.myIdentifier.nativeElement.offsetWidth; // var height = this.myIdentifier.nativeElement.offsetHeight; // this.myIdentifier.nativeElement.setAttribute("width", width); // this.myIdentifier.nativeElement.setAttribute("height", height); // // this.metadata.width = width; // // this.metadata.height = height; // } catch (error) { // this.logger.log('myIdentifier:' + error); // } // }, 0); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L306-L333
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.readAsDataURL
readAsDataURL(e: any) { this.logger.log('eventtt', e) let dataFiles = " " if (e.type === 'change') { dataFiles = e.target.files; } else if (e.type === 'drop') { dataFiles = e.dataTransfer.files } else { dataFiles = e.files } // const attributes = { files: dataFiles, enableBackdropDismiss: false }; // --------------------------------------------------------------------- // USE CASE IMAGE // --------------------------------------------------------------------- let event:any = { target: { files: dataFiles} } try { if (event) { this.detectFiles(event); } } catch (error) { this.logger.log("error: ", error); } // if (file.type.startsWith('image') && !file.type.includes('svg')) { // const reader = new FileReader(); // let that = this; // reader.onload = (e: any) => { // this.logger.log("CARICATA IMMAGINE::: ", e.target); // // this.metadata.src = e.target.result; // var img = new Image(); // img.src = this.metadata.src; // img.onload = function() { // that.setImageSize(); // }; // img.onerror = function(e) { // this.logger.log("ERROR ::: ", e); // }; // } // reader.readAsDataURL(file); // // --------------------------------------------------------------------- // // USE CASE SVG // // --------------------------------------------------------------------- // } else if (file.type.startsWith('image') && file.type.includes('svg')) { // const preview = document.querySelector('#img-preview') as HTMLImageElement // const reader = new FileReader(); // const that = this; // reader.addEventListener('load',function () { // const img = reader.result.toString(); // this.logger.log('FIREBASE-UPLOAD USE CASE SVG LoaderPreviewPage readAsDataURL img ',img) // // that.arrayFiles.push(that.sanitizer.bypassSecurityTrustResourceUrl(img)) // // if (!that.fileSelected) { // // that.fileSelected = that.sanitizer.bypassSecurityTrustResourceUrl(img) // // } // },false); // if (file) { // reader.readAsDataURL(file); // } // // --------------------------------------------------------------------- // // USE CASE FILE // // --------------------------------------------------------------------- // } else { // this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE ',file) // this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE TYPE',file.type) // let file_extension = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length) || file.name // this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE EXTENSION', file_extension) // let file_name = file.name // this.logger.log( '[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE FILE - FILE NAME', file_name) // // this.createFile() // } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L337-L406
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.drop
drop(ev: any) { ev.preventDefault(); ev.stopPropagation(); const fileList = ev.dataTransfer.files this.isHovering = false if (fileList.length > 0) { const file: File = fileList[0]; var mimeType = fileList[0].type; // const isAccepted = this.checkAcceptedFile(mimeType); const canUploadFile = checkAcceptedFile(mimeType, this.fileUploadAccept) if(!canUploadFile){ this.presentToastOnlyImageFilesAreAllowedToDrag() this.logger.error('[IMAGE-UPLOAD] dropEvent: can not upload current file type--> NOT ALLOWED', this.fileUploadAccept) return; } this.handleDropEvent(ev); } }
// DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L427-L444
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.allowDrop
allowDrop(ev: any) { ev.preventDefault() ev.stopPropagation() this.isHovering = true }
// DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L452-L456
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSImageUploadComponent.drag
drag(ev: any) { ev.preventDefault() ev.stopPropagation() this.isHovering = false }
// DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/image-upload/image-upload.component.ts#L459-L463
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CDSTextareaComponent.onClickTextareaOpenSetAttributePopover
onClickTextareaOpenSetAttributePopover(){ this.logger.log('onClickTextareaOpenSetAttributePopover', this.readonly, this.setAttributeBtn); if(this.readonly === true && this.setAttributeBtn == true){ this.addVariable.toggle(); this.openSetAttributePopover(); } }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/base-elements/textarea/textarea.component.ts#L118-L124
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.addEventListener
addEventListener() { let that = this; document.addEventListener( "connector-release-on-intent", (e: CustomEvent) => { // this.logger.log('[CDS-INTENT] connector-release-on-intent e ', e) // this.logger.log('[CDS-INTENT] Connector released on intent - id intent', e.detail.toId) // this.logger.log('[CDS-INTENT] Connector released on intent - this.intent.intent_id', this.intent.intent_id) // movingBorder // flashBorder if (e.detail.toId === this.intent.intent_id) { const intentContentEl = <HTMLElement>document.querySelector(`#intent-content-${e.detail.toId}`); const blockHeaderEl = <HTMLElement>document.querySelector(`#block-header-${e.detail.toId}`); // this.logger.log('[CDS-INTENT] Connector released on intent - intentContentEl', intentContentEl) // this.logger.log('[CDS-INTENT] Connector released on intent - blockHeaderEl', blockHeaderEl) intentContentEl.classList.remove("outline-border") intentContentEl.classList.add("ripple-effect") // , "rippleEffect" setTimeout(() => { intentContentEl.classList.remove("ripple-effect") }, 2000); } }, true ); document.addEventListener( "connector-moved-over-intent", (e: CustomEvent) => { this.logger.log('[CDS-INTENT] Connector Moved over intent e ', e); // movingBorder // flashBorder if (e.detail.toId === this.intent.intent_id) { // this.logger.log('[CDS-INTENT] Connector Moved over intent here yes 1 ', this.intent.intent_id) this.connectorIsOverAnIntent = true; // this.logger.log('[CDS-INTENT] Connector Moved over intent connectorIsOverAnIntent ', this.connectorIsOverAnIntent) const intentContentEl = <HTMLElement>document.querySelector(`#intent-content-${e.detail.toId}`); // this.logger.log('[CDS-INTENT] Connector Moved over intent - intentContentEl', intentContentEl) intentContentEl.classList.add("outline-border") } else { this.logger.log('[CDS-INTENT] Connector Moved over intent here yes 2 ') } }, true ); document.addEventListener( "connector-moved-out-of-intent", (e: CustomEvent) => { // this.logger.log('[CDS-INTENT] Connector Moved out of intent e ', e); if (e.detail.toId === this.intent.intent_id) { // this.logger.log('[CDS-INTENT] Connector Moved out of intent e id ', e.detail.toId) const intentContentEl = <HTMLElement>document.querySelector(`#intent-content-${e.detail.toId}`); // this.logger.log('[CDS-INTENT] Connector Moved over intent - intentContentEl', intentContentEl) intentContentEl.classList.remove("outline-border") } this.connectorIsOverAnIntent = false; // this.logger.log('[CDS-INTENT] Connector Moved out of intent connectorIsOverAnIntent ', this.connectorIsOverAnIntent) }, true ); }
// ---------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L316-L374
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.setIntentSelected
private setIntentSelected() { this.listOfActions = null; this.formSize = 0; this.questionCount = 0; try { if (this.intent) { this.logger.log("setIntentSelected:: ", this.intent.actions); // this.patchAllActionsId(); this.patchAttributesPosition(); // this.listOfActions = this.intent.actions.filter(function(obj) { // return obj._tdActionType !== TYPE_ACTION.INTENT; // }); this.listOfActions = this.intent.actions; // this.logger.log("[CDS-INTENT] listOfActions: ", this.listOfActions); // this.form = this.intent.form; // this.actions = this.intent.actions; // this.answer = this.intent.answer; if (this.intent.question) { const question_segment = this.intent.question.split(/\r?\n/).filter(element => element); this.questionCount = question_segment.length; // this.question = this.intent.question; } } if (this.intent && this.intent.form && (this.intent.form !== null)) { this.formSize = Object.keys(this.intent.form).length; } else { this.formSize = 0; } } catch (error) { this.logger.error("error: ", error); } }
/** CUSTOM FUNCTIONS */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L380-L411
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.patchAttributesPosition
private patchAttributesPosition() { if (!this.intent.attributes || !this.intent.attributes.position) { this.intent['attributes'] = {}; } if (!this.intent.attributes.position) { this.intent.attributes['position'] = { 'x': 0, 'y': 0 }; } }
/** * patchAttributesPosition * retrocompatibility patch. */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L436-L443
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.getActionParams
getActionParams(action) { const enumKeys = Object.keys(TYPE_ACTION); let keyAction = ''; try { for (const key of enumKeys) { if (TYPE_ACTION[key] === action._tdActionType) { keyAction = key; return ACTIONS_LIST[keyAction]; } } return; } catch (error) { console.error("[CDS-INTENT] getActionParams ERROR: ", error); return; } }
/** getActionParams * Get action parameters from a map to create the header (title, icon) * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L449-L464
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onSelectAction
onSelectAction(action, index: number, idAction) { this.logger.log('[CDS-INTENT] onActionSelected action: ', action); this.logger.log('[CDS-INTENT] onActionSelected index: ', index); this.logger.log('[CDS-INTENT] onActionSelected idAction: ', idAction); this.elementTypeSelected = idAction; // this.intentService.setIntentSelected(this.intent.intent_id); this.intentService.selectAction(this.intent.intent_id, idAction); this.actionSelected.emit({ action: action, index: index, maxLength: this.listOfActions.length }); }
/** EVENTS */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L479-L487
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onSelectQuestion
onSelectQuestion(elementSelected) { this.logger.log('[CDS-INTENT] onSelectQuestion-->', elementSelected, this.intent.question) this.elementTypeSelected = elementSelected; this.intentService.setIntentSelected(this.intent.intent_id) // this.isIntentElementSelected = true; this.questionSelected.emit(this.intent.question); }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L495-L501
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onKeydown
onKeydown(event) { // this.logger.log('[CDS-INTENT] onKeydown: ', event); if (event.key === 'Backspace' || event.key === 'Escape' || event.key === 'Canc') { this.intentService.deleteSelectedAction(); } }
/** * onKeydown * delete selected action by keydown backspace * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L531-L536
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onDragStarted
onDragStarted(event, previousIntentId, index) { this.controllerService.closeActionDetailPanel(); this.logger.log('[CDS-INTENT] onDragStarted event ', event, 'previousIntentId ', previousIntentId); this.logger.log('[CDS-INTENT] onDragStarted index ', index); this.intentService.setPreviousIntentId(previousIntentId); this.isDragging = true; this.logger.log('[CDS-INTENT] isDragging - onDragStarted', this.isDragging) // ---------------------------------- // Hide action arrow on drag started // ---------------------------------- // const actionArrowElem = <HTMLElement>document.querySelector(`#action-arrow-${index}`); // actionArrowElem.style.display = 'none'; // this.logger.log('[CDS-INTENT] onDragStarted actionArrowElem', actionArrowElem) // const actionDragPlaceholderWidth = actionDragPlaceholder.offsetWidth; // this.logger.log('[CDS-INTENT] onDragStarted actionDragPlaceholderWidth', actionDragPlaceholderWidth) // -------------------------------------------------------------------------------------------------- // Bug fix: When an action is dragged, the "drag placeholder" moves up and changes size to full width // -------------------------------------------------------------------------------------------------- const actionDragPlaceholder = <HTMLElement>document.querySelector('.action-drag-placeholder'); this.logger.log('[CDS-INTENT] onDragStarted actionDragPlaceholder', actionDragPlaceholder) const addActionPlaceholderEl = <HTMLElement>document.querySelector('.add--action-placeholder'); this.logger.log('[CDS-INTENT] onDragStarted addActionPlaceholderEl ', addActionPlaceholderEl) const myObserver = new ResizeObserver(entries => { // this will get called whenever div dimension changes entries.forEach(entry => { this.actionDragPlaceholderWidth = entry.contentRect.width this.logger.log('[CDS-INTENT] width actionDragPlaceholderWidth', this.actionDragPlaceholderWidth); if (this.actionDragPlaceholderWidth <= 270) { this.hideActionDragPlaceholder = false; this.logger.log('[CDS-INTENT] Hide action drag placeholder', this.hideActionDragPlaceholder); actionDragPlaceholder.style.opacity = '1'; if (addActionPlaceholderEl) { addActionPlaceholderEl.style.opacity = '0'; } this.logger.log('[CDS-INTENT] HERE 1 !!!! '); } else { this.hideActionDragPlaceholder = true; this.logger.log('[CDS-INTENT] Hide action drag placeholder', this.hideActionDragPlaceholder); actionDragPlaceholder.style.opacity = '0'; if (addActionPlaceholderEl) { addActionPlaceholderEl.style.opacity = '1'; } this.logger.log('[CDS-INTENT] HERE 2 !!!! '); } // this.logger.log('height', entry.contentRect.height); }); }); myObserver.observe(actionDragPlaceholder); }
/** !!! IMPORTANT * when the drag of an action starts, I save the starting intent. * Useful in case I move an action between different intents * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L555-L606
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onDragEnded
onDragEnded(event, index) { this.logger.log('[CDS-INTENT] onDragEnded: ', event, this.intent.intent_id); this.isDragging = false; this.connectorService.updateConnector(this.intent.intent_id); // const previousIntentId = this.intentService.previousIntentId; // if(previousIntentId){ // this.logger.log("[CDS-INTENT] onDropAction previousIntentId: ", previousIntentId); // this.connectorService.updateConnector(previousIntentId); // } // this.connectorService.updateConnector(this.intent.intent_id); }
/** onDragEnded * get the action moved and update its connectors */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L612-L623
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.canEnterDropList
canEnterDropList(action: any) { return (item: CdkDrag<any>) => { // this.logger.log('itemmmmmmmm', item.data, action) return true } }
/** Predicate function that only allows type='intent' to be dropped into a list. */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L627-L632
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onDropAction
async onDropAction(event: CdkDragDrop<string[]>) { this.logger.log('[CDS-INTENT] onDropAction: ', event, this.intent.actions); // this.logger.log('event:', event, 'previousContainer:', event.previousContainer, 'event.container:', event.container); this.controllerService.closeAllPanels(); this.intentService.setIntentSelected(this.intent.intent_id); if (event.previousContainer === event.container) { // moving action in the same intent moveItemInArray(this.intent.actions, event.previousIndex, event.currentIndex); this.intentService.updateIntent(this.intent, null); // const response = await this.intentService.onUpdateIntentWithTimeout(this.intent); } else { try { let action: any = event.previousContainer.data[event.previousIndex]; if (event.previousContainer.data.length > 0) { if (action._tdActionType) { // moving action from another intent this.logger.log("[CDS-INTENT] onDropAction sposto la action tra 2 intent differenti"); this.intentService.moveActionBetweenDifferentIntents(event, action, this.intent.intent_id); this.intentService.updateIntent(this.intent, null); this.connectorService.updateConnectorsOfBlock(this.intent.intent_id) } else if (action.value && action.value.type) { // moving new action in intent from panel elements this.logger.log("[CDS-INTENT] onDropAction aggiungo una nuova action all'intent da panel elements - action ", this.newActionCreated); this.intentService.moveNewActionIntoIntent(event.currentIndex, action, this.intent.intent_id); //this.onSelectAction(newAction, event.currentIndex, newAction._tdActionId) } } } catch (error) { console.error(error); } } }
/** on Drop Action check the three possible cases: * chaimata quando muovo la action in un intent * 1 - moving action in the same intent * 2 - moving action from another intent * 3 - moving new action in intent from panel elements */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L644-L675
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onUpdateAndSaveAction
public async onUpdateAndSaveAction(object) { this.logger.log('[CDS-INTENT] onUpdateAndSaveAction::::', object); let connector = null; // if(object && object.type && object.type === 'connector'){ // connector = object.element; // this.setActionIntent(); // } else if(object && object.type && object.type === 'action'){ // const action = object.element; // if(action && action._tdActionId){ // replaceItemInArrayForKey('_tdActionId', this.intent.actions, action); // } // } // const action = object.element; if(object && object._tdActionId){ replaceItemInArrayForKey('_tdActionId', this.intent.actions, object); } // this.setActionIntentInListOfActions(); this.logger.log('[CDS-INTENT] onUpdateAndSaveAction:::: ', object, this.intent, this.intent.actions); this.intentService.updateIntent(this.intent); // this.intentService.onUpdateIntentWithTimeout(this.intent, 0, true, connector); }
/** onUpdateAndSaveAction: * function called by all actions in @output whenever they are modified! * called when the connector is created or deleted * OR * called when the action is modified * */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L684-L704
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.openActionMenu
openActionMenu(intent: any, calleBy: string) { this.logger.log('[CDS-INTENT] openActionMenu > intent ', intent) this.logger.log('[CDS-INTENT] openActionMenu > calleBy ', calleBy) const openActionMenuElm = this.openActionMenuBtnRef.nativeElement.getBoundingClientRect() let xOffSet = openActionMenuElm.width + 10 // offset = element width + padding if (calleBy === 'add-action-placeholder') { xOffSet = 277 } let buttonXposition = openActionMenuElm.x + xOffSet // 157 let buttonYposition = openActionMenuElm.y // - 10 this.logger.log('[CDS-INTENT] openActionMenu > openActionMenuBtnRef ', openActionMenuElm) this.logger.log('[CDS-INTENT] openActionMenu > buttonXposition ', buttonXposition) const data = { 'x': buttonXposition, 'y': buttonYposition, 'intent': intent, 'addAction': true }; this.intentService.setIntentSelected(this.intent.intent_id); this.showPanelActions.emit(data); }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L735-L750
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsIntentComponent.onOptionIntentControlClicked
onOptionIntentControlClicked(event: 'webhook' | 'delete' | 'test' | 'copy'){ switch(event){ case 'webhook': this.toggleIntentWebhook(this.intent); break; case 'delete': this.onDeleteIntent(this.intent) break; case 'test': this.openTestSiteInPopupWindow() break; case 'copy': this.copyIntent(); break; } }
/** ****************************** * intent controls options: START * ****************************** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/cds-intent.component.ts#L755-L770
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.ngOnInit
ngOnInit(): void { this.initialize(); }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L42-L44
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.initialize
private initialize(){ this.listOfIntents = this.intentService.listOfIntents; if (this.intent.intent_display_name === undefined && this.intent.intent_display_name.trim().length === 0) { this.intentService.setDisplayName(); } else { this.intentName = this.intent.intent_display_name; } this.intentNameAlreadyExist = false; this.intentNameNotHasSpecialCharacters = true; }
/** initialize */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L52-L61
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.checkIntentNameMachRegex
private checkIntentNameMachRegex(intentname) { const regex = /^[ _0-9a-zA-Z]+$/ return regex.test(intentname); }
/** checkIntentNameMachRegex */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L68-L71
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.checkIntentName
private checkIntentName(name: string) { this.intentNameResult = true; this.intentNameAlreadyExist = false; if(!this.intentName || this.intentName.trim().length == 0 || this.intentName === preDisplayName) { this.logger.log("[PANEL-INTENT-HEADER] error 1"); this.intentNameResult = false; } for (let i = 0; i < this.listOfIntents.length; i++) { if (this.listOfIntents[i].intent_display_name === name && this.listOfIntents[i].intent_id !== this.intent.intent_id) { this.intentNameAlreadyExist = true; this.intentNameResult = false; break; } } this.intentNameNotHasSpecialCharacters = this.checkIntentNameMachRegex(name); if(!this.intentNameNotHasSpecialCharacters){ this.logger.log("[PANEL-INTENT-HEADER] error 3"); this.intentNameResult = false; } return this.intentNameResult; }
/** checkIntentName */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L74-L94
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.onSelectIntent
onSelectIntent(event){ this.logger.log("[PANEL-INTENT-HEADER] onSelectIntent",event, this.intent); // this.intentService.setIntentSelected(this.intent.intent_id); }
/******************* EVENT FUNCTIONS *******************/
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L100-L103
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.onMouseUpInput
onMouseUpInput(event){ this.logger.log("[PANEL-INTENT-HEADER] onMouseUpInput"); this.isFocused = true; this.myInput.nativeElement.focus(); }
/** onMouseUpInput */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L106-L110
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.onChangeIntentName
onChangeIntentName(event) { const result = this.checkIntentName(event); this.intent.intent_display_name = event.trim(); if(result){ this.intentName = event; // this.onSaveIntent(); // this.intentService.setIntentSelected(this.intent.intent_id); } }
/** onChangeIntentName */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L113-L121
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.onEnterButtonPressed
onEnterButtonPressed(event) { this.logger.log('[PANEL-INTENT-HEADER] onEnterButtonPressed Intent name: onEnterButtonPressed event', event) // // this.checkIntentName(this.intentName); // // this.onSaveIntent(); // event.target.blur() this.myInput.nativeElement.blur(); // this.intentService.selectIntent(this.intent); }
/** ENTER KEYBOARD EVENT*/
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L132-L139
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.doubleClickFunction
doubleClickFunction(event){ this.logger.log("[PANEL-INTENT-HEADER] doubleClickFunction"); this.myInput.nativeElement.select(); // this.intentService.selectIntent(this.intent); }
/** doubleClickFunction */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L142-L146
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
PanelIntentHeaderComponent.onSaveIntent
onSaveIntent() { this.logger.log("[PANEL-INTENT-HEADER] SALVO!!!"); // this.intentService.setIntentSelected(this.intent.intent_id); this.intent.intent_display_name = this.intentName.trim(); this.intentService.changeIntentName(this.intent); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-intent/panel-intent-header/panel-intent-header.component.ts#L162-L167
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionDetailPanelComponent.addEventListener
addEventListener() { document.addEventListener( "keydown", (e) => { // this.logger.log('[PANEL-INTENT-DETAIL] keydown ', e); var focusedElement = document.activeElement; if (focusedElement.tagName === 'TEXTAREA') { } }, false ); }
// ---------------------------------------------------------
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-action-detail/cds-panel-action-detail.component.ts#L152-L161
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionDetailPanelComponent.onUpdateFormIntentSelected
onUpdateFormIntentSelected($event){ this.elementSelected = $event; this.onSaveIntent() // this.logger.log("onUpdateFormIntentSelected:::: ", $event); }
// EVENT FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-action-detail/cds-panel-action-detail.component.ts#L174-L178
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsActionDetailPanelComponent.onConnectorChange
onConnectorChange(type: 'create' | 'delete', idConnector: string, toIntentId: string){ const fromId = idConnector; let toId = ''; this.connectorService.updateConnectorAttributes(idConnector, null); switch(type){ case 'create': const posId = toIntentId.indexOf("#"); if (posId !== -1) { toId = toIntentId.slice(posId+1); } this.connectorService.deleteConnectorWithIDStartingWith(fromId, false, true); this.connectorService.createNewConnector(fromId, toId); break; case 'delete': this.connectorService.deleteConnectorWithIDStartingWith(fromId, false, true); break; } }
/** * onConnectorChange * @param type * @param idConnector * @param toIntentId * * IMPORTANTE: questa funzione deve SOLO aggiornare i connettori e NON deve salvare e NON deve aggiungere UNDO. */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-action-detail/cds-panel-action-detail.component.ts#L252-L269
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.ngOnInit
ngOnInit(): void { // this.initialize(); }
// SYSTEM FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L63-L65
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.setAttributesFromAction
private setAttributesFromAction(actionAndParameters) { let intent: any = {}; if (actionAndParameters === null) { return null; // invalid intent } if (actionAndParameters.trim().length === 0) { return null; // invalid intent } let parts = actionAndParameters.split("{"); if (parts.length > 0 && parts[0].startsWith("{")) { return null; // invalid intent } else { // this.logger.log('intent 2', actionAndParameters); intent.action = parts[0]; // this.logger.log('intent 3', intent); } if (parts.length > 1) { let attributes = (actionAndParameters.substring(parts[0].length)); // this.logger.log('intent 4', intent); try { intent.attributes = JSON.parse(attributes); // this.logger.log('intent 5', intent); } catch (err) { this.logger.error("error on intent.parameters = JSON.parse(json_string)", err); } } return intent; }
// PRIVATE FUNCTIONS //
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L116-L144
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.checkButtonLabel
private checkButtonLabel(): boolean { try { if (!this.buttonLabel || this.buttonLabel.length === 0) { this.buttonLabel = ''; } if(this.button){ this.button.value = this.buttonLabel; } } catch (error) { this.logger.error('error: ', error); } return true; }
// }
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L156-L168
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onCloseButtonPanel
onCloseButtonPanel() { this.logger.log('[CDS-PANEL-BTN-CONFIG] onCloseButtonPanel' ) this.controllerService.closeButtonPanel(); // this.closeButtonPanel.emit(); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L216-L220
297d30da01d98a1299e7197eb88cff5b2390a386
design-studio
github_2023
Tiledesk
typescript
CdsPanelButtonConfigurationComponent.onChangeTitle
onChangeTitle(text: string) { this.buttonLabel = text; this.checkButtonLabel(); this.checkTypeButton(); // this.checkAndSaveButton(); }
/** */
https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-panel-button-configuration/cds-panel-button-configuration.component.ts#L223-L228
297d30da01d98a1299e7197eb88cff5b2390a386