repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
rsbuild | github_2023 | web-infra-dev | typescript | findRuleId | const findRuleId = (chain: RspackChain, defaultId: string) => {
let id = defaultId;
let index = 0;
while (chain.module.rules.has(id)) {
id = `${defaultId}-${++index}`;
}
return id;
}; | // Find a unique rule id for the sass rule, | https://github.com/web-infra-dev/rsbuild/blob/eabd31dfe3b5d99dcaae40c825152468798f864f/packages/plugin-sass/src/index.ts#L86-L93 | eabd31dfe3b5d99dcaae40c825152468798f864f |
rsbuild | github_2023 | web-infra-dev | typescript | dedupeSvgoPlugins | const dedupeSvgoPlugins = (config: SvgoConfig): SvgoConfig => {
if (!config.plugins) {
return config;
}
let mergedPlugins: SvgoPluginConfig[] = [];
for (const plugin of config.plugins) {
if (typeof plugin === 'string') {
const exist = mergedPlugins.find(
(item) =>
item === plugin || (typeof item === 'object' && item.name === plugin),
);
if (!exist) {
mergedPlugins.push(plugin);
}
continue;
}
const strIndex = mergedPlugins.findIndex(
(item) => typeof item === 'string' && item === plugin.name,
);
if (strIndex !== -1) {
mergedPlugins[strIndex] = plugin;
continue;
}
let isMerged = false;
mergedPlugins = mergedPlugins.map((item) => {
if (typeof item === 'object' && item.name === plugin.name) {
isMerged = true;
return deepmerge<SvgoPluginConfig>(item, plugin);
}
return item;
});
if (!isMerged) {
mergedPlugins.push(plugin);
}
}
config.plugins = mergedPlugins;
return config;
}; | /**
* Dedupe SVGO plugins config.
*
* @example
* Input:
* {
* plugins: [
* { name: 'preset-default', params: { foo: true }],
* { name: 'preset-default', params: { bar: true }],
* ]
* }
* Output:
* {
* plugins: [
* { name: 'preset-default', params: { foo: true, bar: true }],
* ]
* }
*/ | https://github.com/web-infra-dev/rsbuild/blob/eabd31dfe3b5d99dcaae40c825152468798f864f/packages/plugin-svgr/src/index.ts#L81-L128 | eabd31dfe3b5d99dcaae40c825152468798f864f |
rsbuild | github_2023 | web-infra-dev | typescript | matchBundlerPlugin | const matchBundlerPlugin = async (pluginName: string, index?: number) => {
const config = await unwrapConfig(index);
return matchPlugin(config, pluginName) as BundlerPluginInstance;
}; | /** Match rspack/webpack plugin by constructor name. */ | https://github.com/web-infra-dev/rsbuild/blob/eabd31dfe3b5d99dcaae40c825152468798f864f/scripts/test-helper/src/index.ts#L95-L99 | eabd31dfe3b5d99dcaae40c825152468798f864f |
weblangchain | github_2023 | langchain-ai | typescript | getBaseRetriever | const getBaseRetriever = () => {
return new TavilySearchAPIRetriever({
k: 6,
includeRawContent: true,
includeImages: true,
});
}; | /**
* Override with your own retriever if desired.
*/ | https://github.com/langchain-ai/weblangchain/blob/5812e83cd13efb58a26b05cc150284eddfc20e16/nextjs/app/api/chat/stream_log/route.ts#L79-L85 | 5812e83cd13efb58a26b05cc150284eddfc20e16 |
recce | github_2023 | DataRecce | typescript | getScales | function getScales(
{ datasets, min = 0, max = 0, type, binEdges }: HistogramChartProps["data"],
hideAxis = false
) {
const isDatetime = type === "datetime";
const [base, current] = datasets;
const maxCount = Math.max(...current.counts, ...base.counts);
const newLabels = binEdges
.map((v, i) => formatDisplayedBinItem(binEdges, i))
.slice(0, -1); // exclude last
//swap x-scale when histogram is datetime
const xScaleDate: ScaleOptions = {
display: hideAxis ? false : true,
type: "timeseries", // each datum is spread w/ equal distance
min,
max,
adapters: {
date: {},
},
time: {
minUnit: "day",
},
grid: { display: false },
ticks: {
minRotation: 30,
maxRotation: 30,
maxTicksLimit: 8,
},
};
/**
* NOTE: Category doesn't accept (min/max) -- will distort scales!
*/
const xScaleCategory: ScaleOptions = {
display: hideAxis ? false : true,
type: "category", //Linear doesn't understand bins!
grid: { display: false },
ticks: {
callback(val, index) {
return newLabels[index];
},
},
stacked: true,
};
const xScaleBase = isDatetime ? xScaleDate : xScaleCategory;
const yScaleBase: ScaleOptions = {
display: hideAxis ? false : true,
type: "linear",
max: maxCount, //NOTE: do not add `min` since if they are equal nothing gets displayed sometimes
border: { dash: [2, 2] },
grid: {
color: "lightgray",
},
ticks: {
maxTicksLimit: 8,
callback: function (val, index) {
//slow, but necessary since chart-data is a number and can be hard to display
return formatAsAbbreviatedNumber(val);
},
},
beginAtZero: true,
};
return { x: xScaleBase, y: yScaleBase };
} | /**
* get x, y scales for histogram (dynamic based on datetime or not)
*/ | https://github.com/DataRecce/recce/blob/ca01a92ba92bb7dcec0d1fe47aeed728024da667/js/src/components/charts/HistogramChart.tsx#L195-L260 | ca01a92ba92bb7dcec0d1fe47aeed728024da667 |
recce | github_2023 | DataRecce | typescript | formatDisplayedBinItem | function formatDisplayedBinItem(binEdges: number[], currentIndex: number) {
const startEdge = binEdges[currentIndex];
const endEdge = binEdges[currentIndex + 1];
const formattedStart = formatAsAbbreviatedNumber(startEdge);
const formattedEnd = formatAsAbbreviatedNumber(endEdge);
const result = `${formattedStart} - ${formattedEnd}`;
return result;
} | /**
* @returns a formatted, abbreviated, histogram bin display text
*/ | https://github.com/DataRecce/recce/blob/ca01a92ba92bb7dcec0d1fe47aeed728024da667/js/src/components/charts/HistogramChart.tsx#L264-L273 | ca01a92ba92bb7dcec0d1fe47aeed728024da667 |
decode-formdata | github_2023 | fabian-hiller | typescript | addArrayItemPaths | const addArrayItemPaths = (templateName: string, parentPath?: string) => {
// Get präfix path and suffix paths
const [präfixPath, ...suffixPaths] = templateName.split('.$.');
// Create path to array value
const arrayPath = parentPath ? `${parentPath}.${präfixPath}` : präfixPath;
// Get array by path
const array = getPathObject(
arrayPath.split('.'),
templateName.split('.'),
values
);
// Add value path of each array item
for (let index = 0; index < array.length; index++) {
// Create path to index value
const indexPath = `${arrayPath}.${index}`;
// Continue execution if it is an nested array
if (suffixPaths.length > 1) {
addArrayItemPaths(suffixPaths.join('.$.'), indexPath);
// Otherwise add final array path
} else {
paths.push(`${indexPath}.${suffixPaths[0]}`);
}
}
}; | // Create recusive function to add path of each array item | https://github.com/fabian-hiller/decode-formdata/blob/266b067a8b4315d82708cbe7916fb44efb720f8c/src/utils/getValuePaths/getValuePaths.ts#L18-L46 | 266b067a8b4315d82708cbe7916fb44efb720f8c |
design-studio | github_2023 | Tiledesk | typescript | AppComponent.signInWithCustomToken | signInWithCustomToken(token) {
// this.isOnline = false;
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN token', token)
this.tiledeskAuthService.signInWithCustomToken(token).then((user: any) => {
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN AUTLOGIN user', user)
}).catch(error => {
this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::', error)
})
} | /** NOT IN USE */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/app.component.ts#L121-L130 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | AppComponent.setLanguage | setLanguage(currentUser) {
// const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
this.logger.log('[APP-COMP] - setLanguage current_user uid: ', currentUser);
let currentUserId = ''
if (currentUser) {
currentUserId = currentUser.uid;
this.logger.log('[APP-COMP] - setLanguage current_user uid: ', currentUserId);
}
// this.translate.setDefaultLang('en');
// this.translate.use('en');
const browserLang = this.translate.getBrowserLang();
this.logger.log('[APP-COMP] browserLang: ', browserLang);
const stored_preferred_lang = localStorage.getItem(currentUserId + '_lang');
this.logger.log('[APP-COMP] stored_preferred_lang: ', stored_preferred_lang);
let chat_lang = ''
if (browserLang && !stored_preferred_lang) {
chat_lang = browserLang
} else if (browserLang && stored_preferred_lang) {
chat_lang = stored_preferred_lang
}
// if (tranlatedLanguage.includes(chat_lang)) {
// this.logger.log('[APP-COMP] tranlatedLanguage includes', chat_lang, ': ', tranlatedLanguage.includes(chat_lang))
// this.translate.setDefaultLang(chat_lang)
// this.translate.use(chat_lang);
// }
// else {
// this.logger.log('[APP-COMP] tranlatedLanguage not includes', chat_lang, ': ', tranlatedLanguage.includes(chat_lang))
// chat_lang = 'en'
// this.translate.setDefaultLang('en');
// this.translate.use('en');
// }
this.lang=chat_lang
this.translate.setDefaultLang('en');
this.translate.use('en');
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/app.component.ts#L134-L174 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | AppComponent.initAuthentication | initAuthentication() {
const tiledeskToken = localStorage.getItem('tiledesk_token')
let serverBaseURL = this.appConfigService.getConfig().apiUrl
this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
// const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
// this.logger.log('[APP-COMP] >>> initAuthentication currentUser ', currentUser)
if (tiledeskToken) {
this.logger.log('[APP-COMP] >>> initAuthentication I LOG IN WITH A TOKEN EXISTING IN THE LOCAL STORAGE OR WITH A TOKEN PASSED IN THE URL PARAMETERS <<<')
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
//this.updateStoredCurrentUser()
this.projectService.initialize(serverBaseURL);
this.multiChannelService.initialize(serverBaseURL)
this.userService.initialize(serverBaseURL)
this.uploadService.initialize();
this.IS_ONLINE = true;
}).catch(error => {
this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::', error)
if(error.status && error.status === 401){
// this.goToUnauthDashboardPage()
}
})
} else {
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
this.IS_ONLINE = false;
this.goToDashboardLogin()
}
} | /**------- AUTHENTICATION FUNCTIONS --> START <--- +*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/app.component.ts#L267-L299 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | TextEditableDivComponent.ngAfterViewInit | ngAfterViewInit() {
this.getTextArea();
} | // --------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-base-element/text-editable-div/text-editable-div.component.ts#L69-L71 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | TextEditableDivComponent.openSetattributePopover | openSetattributePopover() {
// this.logger.log('openSetattributePopover setattributepopover ', this.setattributepopover)
this.logger.log('openSetattributePopover setattributepopover is Open ', this.setattributepopover.isOpen())
this.setattributepopover.open()
// this.seCursorAtEnd()
const position = this.elTextarea.selectionStart
this.logger.log(position)
} | // ------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-base-element/text-editable-div/text-editable-div.component.ts#L80-L87 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | TextEditableDivComponent.calculatingRemainingCharacters | private calculatingRemainingCharacters() {
if (this.textLimitBtn) {
this.leftCharsText = calculatingRemainingCharacters(this.text, this.textLimit);
this.logger.log('this.leftCharsText::: ', this.textLimit, this.leftCharsText, (this.textLimit / 10));
if (this.leftCharsText < (this.textLimit / 10)) {
this.alertCharsText = true;
} else {
this.alertCharsText = false;
}
}
} | // --------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-base-element/text-editable-div/text-editable-div.component.ts#L177-L187 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | TextEditableDivComponent.onAddCustomAttribute | onAddCustomAttribute() { } | // } | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-base-element/text-editable-div/text-editable-div.component.ts#L328-L328 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | TextEditableDivComponent._setCaret | _setCaret(imputEle, timestamp, length) {
// var el = document.getElementById("editable")
this.logger.log('setCaret length ', length)
let el = imputEle
let range = document.createRange()
let sel = window.getSelection()
// this.logger.log('setCaret el.childNodes[2]', el.childNodes[2])
this.logger.log('setCaret el.childNodes', el.childNodes)
el.childNodes.forEach((childNode, index) => {
this.logger.log('childNode', childNode, 'index', index)
this.logger.log('childNode id', childNode.id, 'String(timestamp)', String(timestamp))
if (childNode.id === String(timestamp)) {
this.logger.log('---- >>>>> childNode', childNode, 'index ', index)
// range.setStart(el.childNodes[index], length)
// setTimeout(() => {
range.setStart(childNode, 1)
// }, 500);
// this.saveSelection(imputEle, 0, 'setCaret')
}
});
range.collapse(true)
sel.removeAllRanges()
sel.addRange(range)
// el.focus();
} | // background: #ffdc66; | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-base-element/text-editable-div/text-editable-div.component.ts#L334-L365 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | TextEditableDivComponent.onInput | onInput(calledBy) {
this.logger.log('[TEXT-EDITABLE-DIV] onInput calledBy ', calledBy);
let imputEle = this.elementRef.nativeElement.querySelector('#content-editable') //document.querySelector('[contenteditable]'), //document.querySelector('[contenteditable]'),
// text = contenteditable.textContent;
// for (let i = 0; i < text.length; i++) {
// let code = text.charCodeAt(i);
// this.logger.log('text --->>> ', code)
// }
// this.logger.log('[TEXT-EDITABLE-DIV] contenteditable innerHtml', contenteditable.innerHTML)
// this.logger.log('[TEXT-EDITABLE-DIV] onInput text ', text)
// // this.text = text;
// this.textChanged.emit(text)
if (this.textLimitBtn && imputEle.textContent.length > this.textLimit) {
imputEle.textContent = imputEle.textContent.substring(0, this.textLimit);
let fommattedActionSubject = this.splitText(imputEle.textContent);
imputEle.innerHTML = fommattedActionSubject;
this.placeCaretAtEnd(imputEle);
}
this.calculatingRemainingCharacters();
// this.text = imputEle.textContent;
this.logger.log('[TEXT-EDITABLE-DIV] onInputActionSubject text ', this.text);
this.textChanged.emit(this.text);
if (calledBy === 'template') {
this.savedSelection = this.saveSelection(imputEle, 2, 'onInput');
this.logger.log('[TEXT-EDITABLE-DIV] savedSelection onInput ', this.savedSelection)
}
} | // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-base-element/text-editable-div/text-editable-div.component.ts#L420-L453 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsChatbotDetailsComponent.getTranslations | getTranslations() {
let keys = [
'CDSSetting.UpdateBotError',
'CDSSetting.UpdateBotSuccess',
'CDSSetting.NotAValidJSON',
'CDSSetting.AnErrorOccurredWhilDeletingTheAnswer',
'CDSSetting.AnswerSuccessfullyDeleted',
'Done',
'CDSSetting.ThereHasBeenAnErrorProcessing',
'CDSSetting.FileUploadedSuccessfully',
'CDSSetting.AnErrorOccurredUpdatingProfile',
'CDSSetting.UserProfileUpdated',
'CDSSetting.SlugAlreadyExists'
]
this.translate.get(keys).subscribe((text)=>{
this.translationsMap.set('CDSSetting.UpdateBotError', text['CDSSetting.UpdateBotError'])
.set('CDSSetting.UpdateBotSuccess', text['CDSSetting.UpdateBotSuccess'])
.set('CDSSetting.NotAValidJSON', text['CDSSetting.NotAValidJSON'])
.set('CDSSetting.AnErrorOccurredWhilDeletingTheAnswer', text['CDSSetting.AnErrorOccurredWhilDeletingTheAnswer'])
.set('CDSSetting.AnswerSuccessfullyDeleted', text['CDSSetting.AnswerSuccessfullyDeleted'])
.set('Done', text['Done'])
.set('CDSSetting.ThereHasBeenAnErrorProcessing', text['CDSSetting.ThereHasBeenAnErrorProcessing'])
.set('CDSSetting.FileUploadedSuccessfully', text['CDSSetting.FileUploadedSuccessfully'])
.set('CDSSetting.ThereHasBeenAnErrorProcessing', text['CDSSetting.AnErrorOccurredUpdatingProfile'])
.set('CDSSetting.ThereHasBeenAnErrorProcessing', text['CDSSetting.UserProfileUpdated'])
.set('CDSSetting.SlugAlreadyExists', text['CDSSetting.SlugAlreadyExists'])
})
} | // ------------------------------------------ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/cds-chatbot-details.component.ts#L85-L117 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailCommunityComponent.createNewTag | createNewTag = (newTag: string) => {
this.logger.log("Create New TAG Clicked -> newTag: " + newTag)
var index = this.tagsList.findIndex(t => t.tag === newTag);
if (index === -1) {
this.logger.log("Create New TAG Clicked - Tag NOT exist")
this.tagsList.push(newTag)
this.logger.log("Create New TAG Clicked - chatbot tag tagsList : ", this.tagsList)
let self = this;
this.logger.log(' this.ngSelect', this.ngSelect)
if (this.ngSelect) {
this.ngSelect.close()
this.ngSelect.blur()
}
self.selectedChatbot.tags = this.tagsList
// self.updateChatbot(self.selectedChatbot)
} else {
this.logger.log("Create New TAG Clicked - Tag already exist ")
}
} | // -------------------------------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/community/community.component.ts#L135-L157 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailCommunityComponent.publishOnCommunity | publishOnCommunity() {
this.logger.log('[CDS-DETAIL-COMMUNITY] hasPersonalCmntyInfo (2)' , this.hasPersonalCmntyInfo)
this.logger.log('openDialog')
const dialogRef = this.dialog.open(CdsPublishOnCommunityModalComponent, {
data: {
chatbot: this.selectedChatbot,
projectId: this.project._id,
personalCmntyInfo: this.hasPersonalCmntyInfo
},
});
dialogRef.afterClosed().subscribe(result => {
this.logger.log(`Dialog result: ${result}`);
if (result === 'has-published-on-cmnty') {
if (!isDevMode()) {
try {
window['analytics'].track("Publish on community", {
"type": "organic",
"first_name": this.user.firstname,
"last_name": this.user.lastname,
"email": this.user.email,
'userId': this.user.uid,
'botId': this.selectedChatbot._id,
'bot_name': this.selectedChatbot.name,
},
{ "context": {
"groupId": this.project._id
}
});
} catch (err) {
this.logger.error('track signup event error', err);
}
}
}
});
} | // are you sure to publish on the community without your Personal information | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/community/community.component.ts#L173-L210 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailCommunityComponent.onChangeUserWebsite | onChangeUserWebsite(event) {
this.logger.log('[CDS-DETAIL-COMMUNITY] onChangeUserWebsite > event', event)
} | // ----------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/community/community.component.ts#L367-L369 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailBotDetailComponent.checkImageExists | checkImageExists(image_url, callBack) {
const img = new Image();
img.src = image_url;
img.onload = function () {
callBack(true);
};
img.onerror = function () {
callBack(false);
};
} | // } | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/detail/detail.component.ts#L348-L357 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailBotDetailComponent.upload | upload(event) {
this.logger.log('[CDS-CHATBOT-DTLS] BOT PROFILE IMAGE upload')
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.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 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.uploadSingle(that.selectedFiles.item(0)) //GABBBBBBBB
};
}
}, 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-chatbot-details/detail/detail.component.ts#L417-L477 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailBotDetailComponent.deleteBotProfileImage | deleteBotProfileImage() {
// const file = event.target.files[0]
this.logger.log('[CDS-CHATBOT-DTLS] BOT PROFILE IMAGE (FAQ-COMP) deleteBotProfileImage')
this.uploadService.deleteProfile(this.selectedChatbot._id, this.selectedChatbot.imageURL).then((result)=>{
// this.botProfileImageExist = false;
this.selectedChatbot.imageURL = null
this.imageURL = null;
const delete_bot_image_btn = <HTMLElement>document.querySelector('#cds-delete-bot-img-btn');
delete_bot_image_btn.blur();
}).catch((error)=> {
this.logger.error('[CDS-CHATBOT-DTLS] BOT PROFILE IMAGE (FAQ-COMP) deleteUserProfileImage ERORR:', error)
})
} | // --------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/detail/detail.component.ts#L512-L524 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailDeveloperComponent.onChangeWebhookUrl | onChangeWebhookUrl(event) {
this.logger.log('onChangeWebhookUrl ', event);
this.validateUrl(event)
} | //FULFILMENT section: start | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/developer/developer.component.ts#L68-L71 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailImportExportComponent.exportChatbotToJSON | exportChatbotToJSON() {
// const exportFaqToJsonBtnEl = <HTMLElement>document.querySelector('.export-chatbot-to-json-btn');
// exportFaqToJsonBtnEl.blur();
this.faqService.exportChatbotToJSON(this.id_faq_kb).subscribe((faq: any) => {
// this.logger.log('[TILEBOT] - EXPORT CHATBOT TO JSON - FAQS', faq)
// this.logger.log('[TILEBOT] - EXPORT FAQ TO JSON - FAQS INTENTS', faq.intents)
if (faq) {
downloadObjectAsJson(faq, faq.name);
}
}, (error) => {
this.logger.error('[TILEBOT] - EXPORT BOT TO JSON - ERROR', error);
}, () => {
this.logger.log('[TILEBOT] - EXPORT BOT TO JSON - COMPLETE');
});
} | // -------------------------------------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/import-export/import-export.component.ts#L42-L56 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailImportExportComponent.fileChangeUploadChatbotFromJSON | fileChangeUploadChatbotFromJSON(event) {
this.logger.log('[TILEBOT] - fileChangeUploadChatbotFromJSON $event ', event);
let fileJsonToUpload = ''
// this.logger.log('[TILEBOT] - fileChangeUploadChatbotFromJSON $event target', event.target);
const selectedFile = event.target.files[0];
const fileReader = new FileReader();
fileReader.readAsText(selectedFile, "UTF-8");
fileReader.onload = () => {
fileJsonToUpload = JSON.parse(fileReader.result as string)
this.logger.log('fileJsonToUpload CHATBOT', fileJsonToUpload);
}
fileReader.onerror = (error) => {
this.logger.log(error);
}
this.faqService.importChatbotFromJSON(this.id_faq_kb, fileJsonToUpload).subscribe((res: any) => {
this.logger.log('[TILEBOT] - IMPORT CHATBOT FROM JSON - ', res)
}, (error) => {
this.logger.error('[TILEBOT] - IMPORT CHATBOT FROM JSON- ERROR', error);
this.notify.showWidgetStyleUpdateNotification(this.translationsMap.get('CDSSetting.ThereHasBeenAnErrorProcessing'), 4, 'report_problem');
}, () => {
this.logger.log('[TILEBOT] - IMPORT CHATBOT FROM JSON - COMPLETE');
});
} | // -------------------------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/import-export/import-export.component.ts#L65-L91 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailImportExportComponent.presentModalImportIntentsFromJson | presentModalImportIntentsFromJson() {
this.displayImportJSONModal = "block"
} | // -------------------------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/import-export/import-export.component.ts#L97-L99 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CDSDetailImportExportComponent.onCloseModal | onCloseModal() {
this.displayDeleteFaqModal = 'none';
this.displayInfoModal = 'none';
} | // CLOSE MODAL WITHOUT SAVE THE UPDATES OR WITHOUT CONFIRM THE DELETION | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-chatbot-details/import-export/import-export.component.ts#L167-L170 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsDashboardComponent.executeAsyncFunctionsInSequence | async executeAsyncFunctionsInSequence() {
this.logger.log('[CDS DSHBRD] executeAsyncFunctionsInSequence -------------> ');
try {
const getTranslations = await this.getTranslations();
this.logger.log('[CDS DSHBRD] Risultato 1:', getTranslations);
const getUrlParams = await this.getUrlParams();
this.logger.log('[CDS DSHBRD] Risultato 2:', getUrlParams);
const getCurrentProject = await this.dashboardService.getCurrentProject();
this.logger.log('[CDS DSHBRD] Risultato 3:', getCurrentProject);
this.project = this.dashboardService.project;
this.initialize();
const getBotById = await this.dashboardService.getBotById();
this.logger.log('[CDS DSHBRD] Risultato 4:', getBotById, this.selectedChatbot);
const getDefaultDepartmentId = await this.dashboardService.getDeptsByProjectId();
this.logger.log('[CDS DSHBRD] Risultato 5:', getDefaultDepartmentId);
if (getTranslations && getUrlParams && getBotById && getCurrentProject && getDefaultDepartmentId) {
this.logger.log('[CDS DSHBRD] Ho finito di inizializzare la dashboard');
this.selectedChatbot = this.dashboardService.selectedChatbot;
this.initFinished = true;
}
} catch (error) {
console.error('error: ', error);
}
} | /**
* execute Async Functions In Sequence
* Le funzioni async sono gestite in maniera sincrona ed eseguite in coda
* da aggiungere un loader durante il processo e se tutte vanno a buon fine
* possiamo visualizzare lo stage completo
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-dashboard.component.ts#L136-L159 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsDashboardComponent.getTranslations | private async getTranslations(): Promise<boolean> {
return new Promise((resolve, reject) => {
// this.translateCreateFaqSuccessMsg();
// this.translateCreateFaqErrorMsg();
// this.translateUpdateFaqSuccessMsg();
// this.translateUpdateFaqErrorMsg();
// this.translateWarningMsg();
// this.translateAreYouSure();
// this.translateErrorDeleting();
// this.translateDone();
// this.translateErrorOccurredDeletingAnswer();
// this.translateAnswerSuccessfullyDeleted();
resolve(true);
});
} | /** GET TRANSLATIONS */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-dashboard.component.ts#L162-L176 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsDashboardComponent.hideShowWidget | private hideShowWidget(status: "hide" | "show") {
try {
if (window && window['tiledesk']) {
this.logger.log('[CDS DSHBRD] HIDE WIDGET ', window['tiledesk'])
if (status === 'hide') {
window['tiledesk'].hide();
} else if (status === 'show') {
window['tiledesk'].show();
}
}
} catch (error) {
this.logger.error('tiledesk_widget_hide ERROR', error)
}
} | /** hideShowWidget */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-dashboard.component.ts#L194-L207 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsDashboardComponent.onToggleSidebarWith | onToggleSidebarWith(IS_OPEN) {
this.IS_OPEN_SIDEBAR = IS_OPEN;
} | /** onToggleSidebarWith */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-dashboard.component.ts#L213-L215 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsDashboardComponent.goBack | goBack() {
let dashbordBaseUrl = this.appConfigService.getConfig().dashboardBaseUrl + '#/project/'+ this.dashboardService.projectID + '/bots/my-chatbots/all'
window.open(dashbordBaseUrl, '_self')
// this.location.back()
// this.router.navigate(['project/' + this.project._id + '/bots/my-chatbots/all']);
this.hideShowWidget('show');
} | /** Go back to previous page */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-dashboard.component.ts#L218-L224 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsDashboardComponent.onClickItemList | onClickItemList(event: SIDEBAR_PAGES) {
this.logger.log('[CDS DSHBRD] active section-->', event);
if(event !== SIDEBAR_PAGES.INTENTS){
// this.connectorService.initializeConnectors();
// this.eventTestItOutHeader.next(null);
}
this.activeSidebarSection = event;
} | /** SIDEBAR OUTPUT EVENTS */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-dashboard.component.ts#L230-L237 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.ngOnDestroy | ngOnDestroy() {
if (this.subscriptionListOfIntents) {
this.subscriptionListOfIntents.unsubscribe();
}
if (this.subscriptionOpenDetailPanel) {
this.subscriptionOpenDetailPanel.unsubscribe();
}
if (this.subscriptionOpenAddActionMenu) {
this.subscriptionOpenAddActionMenu.unsubscribe();
}
if (this.subscriptionOpenButtonPanel) {
this.subscriptionOpenButtonPanel.unsubscribe();
}
if (this.subscriptionOpenWidgetPanel) {
this.subscriptionOpenWidgetPanel.unsubscribe();
}
if (this.subscriptionUndoRedo) {
this.subscriptionUndoRedo.unsubscribe();
}
if (this.subscriptionUndoRedo) {
this.subscriptionUndoRedo.unsubscribe();
}
document.removeEventListener("connector-drawn", this.listenerConnectorDrawn, false);
document.removeEventListener("moved-and-scaled", this.listnerMovedAndScaled, false);
document.removeEventListener("start-dragging", this.listnerStartDragging, false);
document.removeEventListener("keydown", this.listnerKeydown, false);
document.removeEventListener("connector-selected", this.listnerConnectorSelected, false);
document.removeEventListener("connector-updated", this.listnerConnectorUpdated, false);
document.removeEventListener("connector-deleted", this.listnerConnectorDeleted, false);
document.removeEventListener("connector-created", this.listnerConnectorCreated, false);
document.removeEventListener("connector-draft-released", this.listnerConnectorDraftReleased, false);
document.removeEventListener("end-dragging", this.listnerEndDragging, false);
document.removeEventListener("dragged", this.listnerDragged, false);
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L146-L179 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.ngAfterViewInit | ngAfterViewInit() {
this.logger.log("[CDS-CANVAS] •••• ngAfterViewInit ••••");
//this.addEventListener();
this.stageService.initializeStage();
this.stageService.setDrawer();
this.connectorService.initializeConnectors();
this.changeDetectorRef.detectChanges();
setTimeout(() => {
this.showStageForLimitTime();
}, 20000);
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L182-L192 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.getParamsFromURL | private getParamsFromURL(){
this.route.queryParams.subscribe(params => {
console.log('[CDS-CANVAS] Block params:', params);
this.blockId = params['blockid'];
if (this.blockId) {
console.log('[CDS-CANVAS] Block ID:', this.blockId);
}
this.blockName = params['blockname'];
if (this.blockName) {
console.log('[CDS-CANVAS] Block NAME:', this.blockName);
}
});
} | /**
* getParamsFromURL
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L197-L209 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.initLoadingStage | initLoadingStage(){
this.stageService.loaded = false;
this.totElementsOnTheStage = 0;
this.countRenderedElements = 0;
this.renderedAllIntents = false;
this.renderedAllElements = false;
this.loadingProgress = 0;
this.mapOfConnectors = [];
this.mapOfIntents = [];
this.labelInfoLoading = 'Loading';
this.logger.log("[CDS-CANVAS3] initLoadingStage ••••", this.stageService.loaded);
} | /**
* initLoadingStage
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L214-L225 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onIntentRendered | onIntentRendered(intentID) {
if(this.stageService.loaded === false && this.renderedAllElements === false){
// this.logger.log("[CDS-CANVAS3] ••••onIntentRendered ••••", this.stageService.loaded);
this.labelInfoLoading = 'CDSCanvas.intentsProgress';
if(this.mapOfIntents[intentID] && this.mapOfIntents[intentID].shown === false) {
this.mapOfIntents[intentID].shown = true;
this.countRenderedElements++;
this.loadingProgress += (this.countRenderedElements/this.totElementsOnTheStage)*100;
}
this.logger.log("[CDS-CANVAS3] •••• onIntentRendered •••• ", intentID, this.countRenderedElements);
const allShownTrue = Object.values(this.mapOfIntents).every(intent => intent.shown === true);
if(allShownTrue){
this.onAllIntentsRendered();
}
}
} | /**
*
* @param intentID
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L232-L247 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.setSubscriptions | private setSubscriptions(){
this.subscriptionUndoRedo = this.intentService.behaviorUndoRedo.subscribe((undoRedo: any) => {
this.logger.log('[cds-panel-intent-list] --- AGGIORNATO undoRedo ',undoRedo);
if (undoRedo) {
this.stateUndoRedo = undoRedo;
}
});
/** SUBSCRIBE TO THE LIST OF INTENTS **
* Creo una sottoscrizione all'array di INTENT per averlo sempre aggiornato
* ad ogni modifica (aggiunta eliminazione di un intent)
*/
this.subscriptionListOfIntents = this.intentService.getIntents().subscribe(intents => {
this.logger.log("[CDS-CANVAS] --- AGGIORNATO ELENCO INTENTS", intents);
this.listOfIntents = intents;
// if(intents.length > 0 || (intents.length == 0 && this.listOfIntents.length>0)){
// this.listOfIntents = this.intentService.hiddenEmptyIntents(intents);
// }
});
/** SUBSCRIBE TO THE STATE INTENT DETAIL PANEL */
// this.subscriptionOpenDetailPanel = this.controllerService.isOpenIntentDetailPanel$.subscribe((element: Intent) => {
// if (element) {
// this.closeAllPanels();
// this.IS_OPEN_PANEL_ACTION_DETAIL = true;
// this.removeConnectorDraftAndCloseFloatMenu();
// } else {
// this.IS_OPEN_PANEL_ACTION_DETAIL = false;
// }
// this.logger.log('[CDS-CANVAS] isOpenActionDetailPanel ', element, this.IS_OPEN_PANEL_ACTION_DETAIL);
// });
/** SUBSCRIBE TO THE STATE ACTION DETAIL PANEL */
this.subscriptionOpenDetailPanel = this.controllerService.isOpenActionDetailPanel$.subscribe((element: { type: TYPE_INTENT_ELEMENT, element: Action | string | Form }) => {
this.elementIntentSelected = element;
if (element.type) {
this.closeAllPanels();
this.IS_OPEN_PANEL_ACTION_DETAIL = true;
this.intentService.inactiveIntent();
this.removeConnectorDraftAndCloseFloatMenu();
// setTimeout(() => {
// this.IS_OPEN_PANEL_ACTION_DETAIL = true;
// }, 0);
} else {
this.IS_OPEN_PANEL_ACTION_DETAIL = false;
}
this.logger.log('[CDS-CANVAS] isOpenActionDetailPanel ', element, this.IS_OPEN_PANEL_ACTION_DETAIL);
});
/** SUBSCRIBE TO THE STATE ACTION REPLY BUTTON PANEL */
this.subscriptionOpenButtonPanel = this.controllerService.isOpenButtonPanel$.subscribe((button: Button) => {
this.buttonSelected = button;
if (button) {
this.closeAllPanels();
this.closeActionDetailPanel();
// this.IS_OPEN_PANEL_WIDGET = false;
this.removeConnectorDraftAndCloseFloatMenu();
setTimeout(() => {
this.IS_OPEN_PANEL_BUTTON_CONFIG = true;
}, 0);
} else {
this.IS_OPEN_PANEL_BUTTON_CONFIG = false;
}
});
/** SUBSCRIBE TO THE STATE ACTION DETAIL PANEL */
this.subscriptionOpenAddActionMenu = this.controllerService.isOpenAddActionMenu$.subscribe((menu: any) => {
if (menu) {
this.closeAllPanels();
this.closeActionDetailPanel()
} else {
this.IS_OPEN_ADD_ACTIONS_MENU = false;
}
});
} | // --------------------------------------------------------- // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L331-L408 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.initialize | private async initialize(){
this.id_faq_kb = this.dashboardService.id_faq_kb;
this.listOfIntents = [];
const getAllIntents = await this.intentService.getAllIntents(this.id_faq_kb);
if (getAllIntents) {
this.listOfIntents = this.intentService.listOfIntents;
this.initListOfIntents();
this.initLoadingStage();
this.intentService.setStartIntent();
this.mapOfIntents = await this.intentService.setMapOfIntents();
this.mapOfConnectors = await this.connectorService.setMapOfConnectors(this.listOfIntents);
const numIntents = Object.values(this.mapOfIntents).length;
const numConnectors = Object.values(this.mapOfConnectors).length;
this.totElementsOnTheStage = numIntents+numConnectors;
this.logger.log('[CDS-CANVAS3] totElementsOnTheStage ::', this.stageService.loaded, numIntents, numConnectors);
// scaleAndcenterStageOnCenterPosition(this.listOfIntents)
}
this.subscriptionOpenWidgetPanel = this.intentService.BStestiTout.pipe(skip(1)).subscribe((event) => this.onTestItOut(event));
// ---------------------------------------
// load localstorage
// ---------------------------------------
let copyPasteTEMP = JSON.parse(localStorage.getItem('copied_items'));
this.logger.log('[CDS-CANVAS] copyPasteTEMP', copyPasteTEMP);
if(copyPasteTEMP){
this.intentService.arrayCOPYPAST = copyPasteTEMP['copy'];
}
} | /** initialize */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L411-L438 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.closeAllPanels | private closeAllPanels(){
this.IS_OPEN_PANEL_WIDGET = false;
// this.IS_OPEN_PANEL_ACTION_DETAIL = false;
this.IS_OPEN_PANEL_INTENT_DETAIL = false;
this.IS_OPEN_PANEL_BUTTON_CONFIG = false;
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
this.IS_OPEN_CONTEXT_MENU = false;
this.intentService.inactiveIntent();
} | /** closeAllPanels */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L442-L450 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.getIntentPosition | getIntentPosition(intentId: string) {
return this.intentService.getIntentPosition(intentId);
} | /** getIntentPosition: call from html */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L456-L458 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.initListOfIntents | private initListOfIntents() {
this.listOfIntents.forEach(intent => {
if (intent.actions) {
intent.actions = intent.actions.filter(obj => obj !== null);
}
});
this.refreshIntents();
} | /** initListOfIntents */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L461-L468 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.refreshIntents | private refreshIntents() {
this.setDragAndListnerEventToElements();
if(this.renderedAllIntents === true){
this.connectorService.createConnectors(this.listOfIntents);
}
} | /** SET DRAG STAGE AND CREATE CONNECTORS *
* set drag and listner on intents,
* create connectors
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L474-L479 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.setListnerEvents | setListnerEvents(){
/** LISTENER OF TILEDESK STAGE */
/** triggers when a connector is drawn on the stage */
this.listenerConnectorDrawn = (e: CustomEvent) => {
const connector = e.detail.connector;
this.checkAllConnectors(connector);
};
document.addEventListener("connector-drawn", this.listenerConnectorDrawn, false);
/** moved-and-scaled **
* fires when I move the stage (move or scale it):
* - set the scale
* - close
* - delete the drawn connector and close the float menu if it is open
*/
this.listnerMovedAndScaled = (e: CustomEvent) => {
const el = e.detail;
this.connectorService.tiledeskConnectors.scale = e.detail.scale;
this.removeConnectorDraftAndCloseFloatMenu();
};
document.addEventListener("moved-and-scaled", this.listnerMovedAndScaled, false);
/** start-dragging */
this.listnerStartDragging = (e: CustomEvent) => {
const el = e.detail.element;
this.logger.log('[CDS-CANVAS] start-dragging ', el);
this.removeConnectorDraftAndCloseFloatMenu();
this.intentService.setIntentSelectedById(el.id);
this.startDraggingPosition = { x: el.offsetLeft, y: el.offsetTop };
el.style.zIndex = 2;
};
document.addEventListener("start-dragging", this.listnerStartDragging, false);
/** dragged **
* the event fires when I move an intent on the stage:
* move the connectors attached to the intent
* remove any dotted connectors and close the float menu if it is open
* update the position of the selected intent
*/
this.listnerDragged = (e: CustomEvent) => {
const el = e.detail.element;
const x = e.detail.x;
const y = e.detail.y;
this.connectorService.moved(el, x, y);
this.intentService.setIntentSelectedPosition(el.offsetLeft, el.offsetTop);
};
document.addEventListener("dragged", this.listnerDragged, false);
/** end-dragging */
this.listnerEndDragging = (e: CustomEvent) => {
const el = e.detail.element;
this.logger.log('[CDS-CANVAS] end-dragging ', el);
el.style.zIndex = 1;
this.logger.log('[CDS-CANVAS] end-dragging ', this.intentService.intentSelected.attributes.position);
this.logger.log('[CDS-CANVAS] end-dragging ', this.startDraggingPosition);
let position = this.intentService.intentSelected.attributes.position;
if(this.startDraggingPosition.x === position.x && this.startDraggingPosition.y === position.y){
this.onIntentSelected(this.intentService.intentSelected);
}
this.intentService.updateIntentSelected();
};
document.addEventListener("end-dragging", this.listnerEndDragging, false);
/** connector-draft-released **
* it only fires when a connector is NOT created, that is when I drop the dotted connector in a point that is not "connectable"
* if I drop it on the stage and 'e.detail' is complete with the start and end position of the connector I can open the float menu
* otherwise
* I remove the dotted connector
*/
this.listnerConnectorDraftReleased = (e: CustomEvent) => {
this.logger.log("[CDS-CANVAS] connector-draft-released :: ", e.detail);
if(!e || !e.detail) return;
const detail = e.detail;
const arrayOfClass = detail.target.classList.value.split(' ');
if (detail.target && arrayOfClass.includes("receiver-elements-dropped-on-stage") && detail.toPoint && detail.menuPoint) {
this.logger.log("[CDS-CANVAS] ho rilasciato il connettore tratteggiato nello stage (nell'elemento con classe 'receiver_elements_dropped_on_stage') e quindi apro il float menu");
this.openFloatMenuOnConnectorDraftReleased(detail);
} else {
this.logger.log("[CDS-CANVAS] ho rilasciato in un punto qualsiasi del DS ma non sullo stage quindi non devo aprire il menu", detail);
this.removeConnectorDraftAndCloseFloatMenu();
}
};
document.addEventListener("connector-draft-released", this.listnerConnectorDraftReleased, false);
/** connector-created **
* fires when a connector is created:
* add the connector to the connector list (addConnectorToList)
* notify actions that connectors have changed (onChangedConnector) to update the dots
*/
this.listnerConnectorCreated = (e: CustomEvent) => {
this.logger.log("[CDS-CANVAS] connector-created:", e);
const connector = e.detail.connector;
connector['created'] = true;
delete connector['deleted'];
this.connectorService.addConnectorToList(connector);
this.intentService.onChangedConnector(connector);
};
document.addEventListener("connector-created", this.listnerConnectorCreated, false);
/** connector-deleted **
* fires when a connector is deleted:
* delete the connector from the connector list (deleteConnectorToList)
* notify actions that connectors have changed (onChangedConnector) to update the dots
*/
this.listnerConnectorDeleted = (e: CustomEvent) => {
this.logger.log("[CDS-CANVAS] connector-deleted:", e);
const connector = e.detail.connector;
connector['deleted'] = true;
delete connector['created'];
// const intentId = this.connectorSelected.id.split('/')[0];
// let intent = this.intentService.getIntentFromId(intentId);
// if(intent.attributes && intent.attributes.connectors && intent.attributes.connectors[this.connectorSelected.id]){
// delete intent.attributes.connectors[this.connectorSelected.id];
// }
// this.connectorService.updateConnectorAttributes(this.connectorSelected.id, event);
this.connectorService.deleteConnectorToList(connector.id);
this.intentService.onChangedConnector(connector);
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
};
document.addEventListener("connector-deleted", this.listnerConnectorDeleted, false);
/** connector-updated **
* fires when a connector is updated:
*/
this.listnerConnectorUpdated = (e: CustomEvent) => {
this.logger.log("[CDS-CANVAS] connector-updated:", e);
const connector = e.detail.connector;
// if(connector.notify)
connector['updated'] = true;
this.intentService.onChangedConnector(connector);
};
document.addEventListener("connector-updated", this.listnerConnectorUpdated, false);
/** connector-selected **
* fires when a connector is selected:
* unselect action and intent (unselectAction)
*/
this.listnerConnectorSelected = (e: CustomEvent) => {
//console.log("[CDS-CANVAS] connector-selected:", e, e.detail.mouse_pos);
this.closeAllPanels();
this.closeActionDetailPanel();
this.IS_OPEN_PANEL_CONNECTOR_MENU = true;
this.mousePosition = e.detail.mouse_pos;
this.mousePosition.x -= -10;
this.mousePosition.y -= 25;
//this.connectorSelected = e.detail.connector;
this.setConnectorSelected(e.detail.connector.id);
// this.IS_OPEN_ADD_ACTIONS_MENU = true;
// this.positionFloatMenu = e.detail.mouse_pos;
this.intentService.unselectAction();
};
document.addEventListener("connector-selected", this.listnerConnectorSelected, false);
/** keydown
* check if Ctrl (Windows) or Command (Mac) and Z were pressed at the same time
*/
this.listnerKeydown = (e) => {
this.logger.log('[CDS-CANVAS] keydown ', e);
var focusedElement = document.activeElement;
if (focusedElement.tagName === 'TEXTAREA') {
return;
}
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'z') {
e.preventDefault();
// Evita il comportamento predefinito, ad esempio la navigazione indietro nella cronologia del browser
this.logger.log("Hai premuto Ctrl+ALT+Z (o Command+Alt+Z)!");
this.intentService.restoreLastREDO();
} else if ((e.ctrlKey || e.metaKey) && e.key === "z") {
// Impedisci il comportamento predefinito (ad esempio, l'undo in un campo di testo)
e.preventDefault();
this.logger.log("Hai premuto Ctrl+Z (o Command+Z)!");
this.intentService.restoreLastUNDO();
}
};
document.addEventListener("keydown", this.listnerKeydown, false);
} | // --------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L484-L662 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.openFloatMenuOnConnectorDraftReleased | private openFloatMenuOnConnectorDraftReleased(detail){
this.logger.log("[CDS CANVAS] ho rilasciato in un punto qualsiasi dello stage e quindi apro il float menu", detail);
this.positionFloatMenu = this.stageService.physicPointCorrector(detail.menuPoint);
let marginLeft = this.IS_OPEN_INTENTS_LIST?290:60;
this.positionFloatMenu.x = this.positionFloatMenu.x+marginLeft;
detail.menuPoint = this.positionFloatMenu;
this.closeAllPanels();
this.closeActionDetailPanel();
this.IS_OPEN_ADD_ACTIONS_MENU = true;
this.hasClickedAddAction = false;
// this.IS_OPEN_PANEL_WIDGET = false;
// this.controllerService.closeActionDetailPanel();
this.connectorService.createConnectorDraft(detail);
this.logger.log('[CDS CANVAS] OPEN MENU hasClickedAddAction', this.hasClickedAddAction);
} | /** openFloatMenuOnConnectorDraftReleased */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L731-L745 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.setDragAndListnerEventToElements | private setDragAndListnerEventToElements() {
this.logger.log("[CDS CANVAS] AGGIORNO ELENCO LISTNER");
this.listOfIntents.forEach(intent => {
this.intentService.setDragAndListnerEventToElement(intent.intent_id);
});
} | /** setDragAndListnerEventToElements */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L748-L753 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.removeConnectorDraftAndCloseFloatMenu | private removeConnectorDraftAndCloseFloatMenu() {
this.connectorService.removeConnectorDraft();
this.IS_OPEN_ADD_ACTIONS_MENU = false;
this.IS_OPEN_CONTEXT_MENU = false;
} | /** removeConnectorDraftAndCloseFloatMenu */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L780-L784 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.posCenterIntentSelected | private posCenterIntentSelected(intent) {
if(intent && intent.intent_id){
var stageElement = document.getElementById(intent.intent_id);
this.stageService.centerStageOnPosition(stageElement);
}
} | /** posCenterIntentSelected */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L787-L792 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.deleteIntent | private async deleteIntent(intent) {
this.logger.log('[CDS-CANVAS] deleteIntent', intent);
// this.intentSelected = null;
this.intentService.setIntentSelectedById();
this.intentService.deleteIntentNew(intent);
// return
// this.intentService.deleteIntentToListOfIntents(intent.intent_id);
// this.intentService.refreshIntents();
// IMPORTANTE operazione SUCCESSIVA! al delete cancello tutti i connettori IN e OUT dell'intent eliminato e salvo la modifica
// this.connectorService.deleteConnectorsOfBlock(intent.intent_id, true, false);
} | /** Delete Intent **
* deleteIntentToListOfIntents: per cancellare l'intent dalla lista degli intents (listOfIntents), quindi in automatico per rimuovere l'intent dallo stage
* refreshIntents: fa scattare l'evento e aggiorna l'elenco degli intents (listOfIntents) in tutti i componenti sottoscritti, come cds-panel-intent-list
* deleteIntent: chiamo il servizio per eliminare l'intent da remoto (il servizio è asincrono e non restituisce nulla, quindi ingnoro l'esito)
* in deleteIntent: aggiungo l'azione ad UNDO/REDO
* deleteConnectorsOfBlock: elimino i connettori in Ingresso verso intent eliminato e in Uscita dallo stesso, e salvo in automatico gli intent modificati (quelli ai quali ho eliminato il connettore in uscita)
*
* ATTENZIONE: è necessario mantenere l'ordine per permettere ad UNDO/REDO di salvare in maniera corretta
*
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L819-L830 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onToogleSidebarIntentsList | onToogleSidebarIntentsList() {
this.logger.log('[CDS-CANVAS] onToogleSidebarIntentsList ')
this.IS_OPEN_INTENTS_LIST = !this.IS_OPEN_INTENTS_LIST;
this.removeConnectorDraftAndCloseFloatMenu();
this.logger.log('[CDS-CANVAS] onToogleSidebarIntentsList this.IS_OPEN_INTENTS_LIST ', this.IS_OPEN_INTENTS_LIST)
} | /** onToogleSidebarIntentsList */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L839-L844 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onDroppedElementToStage | async onDroppedElementToStage(event: CdkDragDrop<string[]>) {
this.logger.log('[CDS-CANVAS] droppedElementOnStage:: ', event);
let pos = this.connectorService.tiledeskConnectors.logicPoint(event.dropPoint);
pos.x = pos.x - 132;
let action: any = event.previousContainer.data[event.previousIndex];
if (action.value && action.value.type) {
this.logger.log('[CDS-CANVAS] ho draggato una action da panel element sullo stage');
this.closeAllPanels();
this.closeActionDetailPanel();
// this.removeConnectorDraftAndCloseFloatMenu();
this.createNewIntentFromPanelElement(pos, action.value.type);
} else if (action) {
this.logger.log('[CDS-CANVAS] ho draggato una action da un intent sullo stage');
let prevIntentOfaction = this.listOfIntents.find((intent) => intent.actions.some((act) => act._tdActionId === action._tdActionId));
prevIntentOfaction.actions = prevIntentOfaction.actions.filter((act) => act._tdActionId !== action._tdActionId);
this.connectorService.deleteConnectorsFromActionByActionId(action._tdActionId);
this.connectorService.updateConnector(prevIntentOfaction.intent_id);
this.intentService.refreshIntent(prevIntentOfaction);
this.listOfIntents = this.listOfIntents.map(obj => obj.intent_id === prevIntentOfaction.intent_id ? prevIntentOfaction : obj);
this.createNewIntentDraggingActionFromAnotherIntent(pos, action);
// this.intentService.refreshIntents();
// // this.updateIntent(intentPrevious, 0, false);
}
} | /** onDroppedElementToStage **
* chiamata quando aggiungo (droppandola) una action sullo stage da panel element
* oppure
* chiamata quando aggiungo (droppandola) una action sullo stage spostandola da un altro intent
* */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L851-L874 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.createNewIntentFromConnectorDraft | async createNewIntentFromConnectorDraft(typeAction, connectorDraft){
const toPoint = connectorDraft.toPoint;
const newAction = this.intentService.createNewAction(typeAction);
let intent = this.intentService.createNewIntent(this.id_faq_kb, newAction, toPoint);
this.intentService.addNewIntentToListOfIntents(intent);
this.removeConnectorDraftAndCloseFloatMenu();
const fromId = connectorDraft.fromId;
const toId = intent.intent_id;
this.logger.log('[CDS-CANVAS] sto per creare il connettore ', connectorDraft, fromId, toId);
const resp = await this.connectorService.createConnectorFromId(fromId, toId, true, null); //Sync
if(resp){
// aggiorno action di partenza
let splitFromId = fromId.split('/');
let intent_id = splitFromId[0];
let prevIntent = this.intentService.prevListOfIntent.find((obj) => obj.intent_id === intent_id);
let nowIntent = this.listOfIntents.find((obj) => obj.intent_id === prevIntent.intent_id);
let pos = this.listOfIntents.length-1;
this.logger.log('[CDS-CANVAS] sto per chiamare settingAndSaveNewIntent ', prevIntent, nowIntent);
this.settingAndSaveNewIntent(pos, intent, nowIntent, prevIntent);
// this.logger.log("[CDS-CANVAS] sto per aggiornare l'intent ", nowIntent);
// this.updateIntent(nowIntent, 0, false);
}
} | /**
* createNewIntentFromConnectorDraft
* @param typeAction
* @param connectorDraft
* chiamata quando trascino un connettore sullo stage e creo un intent al volo
* createNewAction: creo una action a partire dal tipo di action selezionata
* createNewIntent: creo un intent dalla action creata in precedenza
* addNewIntentToListOfIntents: aggiungo il nuovo intent alla lista degli intent
* removeConnectorDraftAndCloseFloatMenu: rimuovo il connettore tratteggiato dallo stage e chiudo il menu
* createConnectorFromId: crea il nuovo connettore passando fromId e toId
* attendi che il connettore sia creato e quindi procedi al salvataggio, calcolando l'intent nello stato precedente e quello nello stato attuale
* settingAndSaveNewIntent: chiamo la funzione per salvare in maniera asincrona l'intent creato
* aggiorno la stato dell'intent di partenza
*
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L891-L913 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.createNewIntentFromPanelElement | async createNewIntentFromPanelElement(pos, typeAction){
const newAction = this.intentService.createNewAction(typeAction);
let intent = this.intentService.createNewIntent(this.id_faq_kb, newAction, pos);
this.intentService.addNewIntentToListOfIntents(intent);
const newIntent = await this.settingAndSaveNewIntent(pos, intent, null, null);
} | /**
* createNewIntentFromPanelElement
* @param pos
* @param typeAction
* chiamata quando trascino un'azione sullo stage dal menu
* createNewAction: creo una action a partire dal tipo di action selezionata
* createNewIntent: creo un intent dalla action creata in precedenza
* addNewIntentToListOfIntents: aggiungo il nuovo intent alla lista degli intent
* settingAndSaveNewIntent: chiamo la funzione per salvare in maniera asincrona l'intent creato
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L927-L932 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.createNewIntentDraggingActionFromAnotherIntent | async createNewIntentDraggingActionFromAnotherIntent(pos, action){
// let nowIntent = this.listOfIntents.find((intent) => intent.actions.some((act) => act._tdActionId === action._tdActionId));
let prevIntent = this.intentService.prevListOfIntent.find((intent) => intent.actions.some((act) => act._tdActionId === action._tdActionId));
let nowIntent = this.listOfIntents.find((obj) => obj.intent_id === prevIntent.intent_id);
// let nowIntent = this.listOfIntents.find((intent) => intent.actions.some((act) => act._tdActionId === action._tdActionId));
this.logger.log('[CDS-CANVAS] createNewIntentDraggingActionFromAnotherIntent: ', prevIntent, nowIntent, this.listOfIntents);
let intent = this.intentService.createNewIntent(this.id_faq_kb, action, pos);
this.intentService.addNewIntentToListOfIntents(intent);
const newIntent = await this.settingAndSaveNewIntent(pos, intent, nowIntent, prevIntent);
// if (newIntent) {
// // this.logger.log('[CDS-CANVAS] cancello i connettori della action draggata');
// // this.connectorService.deleteConnectorsFromActionByActionId(action._tdActionId);
// // const elementID = this.intentService.previousIntentId;
// // this.logger.log("[CDS-CANVAS] aggiorno i connettori dell'intent", elementID);
// // this.connectorService.updateConnector(elementID);
// }
} | /**
* createNewIntentDraggingActionFromAnotherIntent
* @param pos
* @param action
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L941-L957 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.settingAndSaveNewIntent | private async settingAndSaveNewIntent(pos, intent, nowIntent, prevIntent) {
this.logger.log('[CDS-CANVAS] sto per configurare il nuovo intent creato con pos e action ::: ', pos, intent, nowIntent, prevIntent);
intent.id = INTENT_TEMP_ID;
this.intentService.setDragAndListnerEventToElement(intent.intent_id);
this.intentService.setIntentSelected(intent.intent_id);
// this.intentSelected = intent;
const savedIntent = await this.intentService.saveNewIntent(intent, nowIntent, prevIntent);
} | /** createNewIntentWithNewAction
* chiamata quando trascino un connettore sullo stage e creo un intent al volo
* oppure
* chiamata quando aggiungo (droppandola) una action sullo stage da panel element
* oppure
* chiamata quando aggiungo (droppandola) una action sullo stage spostandola da un altro intent
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L970-L977 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onMouseOverActionMenuSx | onMouseOverActionMenuSx(event: boolean) {
this.logger.log('[CDS-CANVAS] onMouseOverActionMenuSx ', event)
// if (event === true) {
// this.IS_OPEN_PANEL_WIDGET = false;
// // this.isOpenAddActionsMenu = false
// // @ Remove connectors of the float context menu
// if (!this.hasClickedAddAction) {
// this.removeConnectorDraftAndCloseFloatMenu();
// }
// }
} | /** Close WHEN THE ACTION LEFT MENU IS CLICKED **
* - actions context menu (static & float)
* - test widget
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L991-L1001 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onHideActionPlaceholderOfActionPanel | onHideActionPlaceholderOfActionPanel(event){
this.logger.log('[CDS-CANVAS] onHideActionPlaceholderOfActionPanel event : ', event);
// this.hideActionPlaceholderOfActionPanel = event
} | /** onHideActionPlaceholderOfActionPanel */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1004-L1007 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onSelectIntent | onSelectIntent(intent: Intent) {
this.logger.log('[CDS-CANVAS] onSelectIntent::: ', intent);
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
this.intentService.setIntentSelected(intent.intent_id);
this.posCenterIntentSelected(intent);
this.closeAllPanels();
this.closeActionDetailPanel();
} | /** onSelectIntent */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1016-L1025 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onDeleteIntent | onDeleteIntent(intent: Intent) {
// this.intentService.setIntentSelected(intent.intent_id);
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
this.closeAllPanels();
this.closeActionDetailPanel();
this.deleteIntent(intent);
// swal({
// title: this.translate.instant('AreYouSure'),
// text: "The block " + intent.intent_display_name + " will be deleted",
// icon: "warning",
// buttons: ["Cancel", "Delete"],
// dangerMode: true,
// }).then((WillDelete) => {
// if (WillDelete) {
// this.closeAllPanels();
// this.deleteIntent(intent);
// }
// })
} | /** onDeleteIntent */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1028-L1048 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onIntentSelected | onIntentSelected(intent){
if (intent.intent_display_name === 'start' || intent.intent_display_name === 'defaultFallback') {
return;
}
this.logger.log('[CDS-CANVAS] onIntentSelected ', intent.intent_id);
this.closeAllPanels();
this.removeConnectorDraftAndCloseFloatMenu();
this.intentService.setIntentSelectedById(intent.intent_id);
this.closeActionDetailPanel();
setTimeout(() => {
this.elementIntentSelected = intent;
if(this.elementIntentSelected){
}
this.IS_OPEN_PANEL_INTENT_DETAIL = true;
}, 0);
} | // --------------------------------------------------------- // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1058-L1074 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onActionSelected | onActionSelected(event) {
this.logger.log('[CDS-CANVAS] onActionSelected from PANEL INTENT - action ', event.action, ' - index ', event.index);
// CHIUDI TUTTI I PANNELLI APERTI
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
//this.intentService.setIntentSelectedById(intent_id);
// this.intentSelected = this.listOfIntents.find(el => el.intent_id === this.intentService.intentSelected.intent_id);
this.controllerService.openActionDetailPanel(TYPE_INTENT_ELEMENT.ACTION, event.action);
} | /** onActionSelected **
* @ Close WHEN AN ACTION IS SELECTED FROM AN INTENT
* - actions context menu (static & float)
* - button configuration panel
* - test widget
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1082-L1091 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onQuestionSelected | onQuestionSelected(question: string) {
this.logger.log('[CDS-CANVAS] onQuestionSelected from PANEL INTENT - question ', question);
// CHIUDI TUTTI I PANNELLI APERTI
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
//this.intentService.setIntentSelectedById(intent_id);
// this.intentSelected = this.listOfIntents.find(el => el.intent_id === this.intentService.intentSelected.intent_id);
this.controllerService.openActionDetailPanel(TYPE_INTENT_ELEMENT.QUESTION, question);
} | /** onQuestionSelected **
* @ Close WHEN THE QUESTION DETAIL PANEL IS OPENED
* - actions context menu (static & float)
* - button configuration panel
* - test widget
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1099-L1108 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onIntentFormSelected | onIntentFormSelected(intentform: Form) {
// CHIUDI TUTTI I PANNELLI APERTI
if (!this.hasClickedAddAction) {
this.removeConnectorDraftAndCloseFloatMenu();
}
//this.intentService.setIntentSelectedById(intent_id);
// this.intentSelected = this.listOfIntents.find(el => el.intent_id === this.intentService.intentSelected.intent_id);
this.controllerService.openActionDetailPanel(TYPE_INTENT_ELEMENT.FORM, intentform);
} | /** onIntentFormSelected **
* @ Close WHEN THE FORM DETAIL PANEL IS OPENED
* - actions context menu (static & float)
* - button configuration panel
* - test widget
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1116-L1124 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onShowPanelActions | onShowPanelActions(event) {
this.logger.log('[CDS-CANVAS] showPanelActions event:: ', event);
this.closeAllPanels();
this.closeActionDetailPanel();
// this.controllerService.closeActionDetailPanel();
// this.controllerService.closeButtonPanel();
this.hasClickedAddAction = event.addAction;
this.logger.log('[CDS-CANVAS] showPanelActions hasClickedAddAction:: ', this.hasClickedAddAction);
const pos = { 'x': event.x, 'y': event.y }
// this.intentSelected = event.intent;
this.intentService.setIntentSelectedById(event.intent.intent_id);
this.positionFloatMenu = pos;
this.logger.log('[CDS-CANVAS] showPanelActions positionFloatMenu ', this.positionFloatMenu);
this.IS_OPEN_ADD_ACTIONS_MENU = true;
this.intentService.inactiveIntent();
} | // ------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1134-L1149 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onTestItOut | onTestItOut(intent: Intent) {
// this.testItOut.emit(true);
this.testitOutFirstClick = true;
this.logger.log('[CDS-CANVAS] onTestItOut intent ', intent);
this.IS_OPEN_PANEL_WIDGET = true
this.intentService.startTestWithIntent(intent)
// if(typeof event === "boolean"){
// this.IS_OPEN_PANEL_WIDGET = true;
// } else {
// this.IS_OPEN_PANEL_WIDGET = !this.IS_OPEN_PANEL_WIDGET;
// }
if(this.IS_OPEN_PANEL_WIDGET){
this.controllerService.closeActionDetailPanel();
this.controllerService.closeButtonPanel();
// this.intentService.setLiveActiveIntent(null);
this.controllerService.closeAddActionMenu();
this.connectorService.removeConnectorDraft();
}
if(intent){
// this.intentSelected = intent;
this.intentService.setIntentSelectedById(intent.intent_id);
this.intentService.setIntentSelected(intent.intent_id);
}
} | // ------------------------------------------------------- | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1159-L1183 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onActionDeleted | onActionDeleted(event){
// onActionDeleted
} | /** onActionDeleted */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1186-L1188 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onOptionClicked | async onOptionClicked(option: OPTIONS){
switch(option){
case OPTIONS.ZOOM_IN: {
const result = await this.stageService.zoom('in');
if (result) {
this.connectorService.tiledeskConnectors.scale = this.stageService.getScale();
}
break;
}
case OPTIONS.ZOOM_OUT: {
const result = await this.stageService.zoom('out');
if (result) {
this.connectorService.tiledeskConnectors.scale = this.stageService.getScale();
}
break;
}
case OPTIONS.CENTER: {
const result = await this.stageService.scaleAndCenter(this.listOfIntents);
if (result) {
this.connectorService.tiledeskConnectors.scale = this.stageService.getScale();
}
break;
}
case OPTIONS.UNDO: {
this.intentService.restoreLastUNDO();
break;
}
case OPTIONS.REDO: {
this.intentService.restoreLastREDO();
break;
}
}
} | // --------------------------------------------------------- // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1195-L1227 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onSaveButton | onSaveButton(button: Button) {
this.logger.log('onSaveButton: ', this.intentService.intentSelected);
// this.intentService.onUpdateIntentFromActionPanel(this.intentService.intentSelected);
this.intentService.updateIntent(this.intentService.intentSelected);
// const arrayId = button.__idConnector.split("/");
// const intentIdIntentToUpdate = arrayId[0] ? arrayId[0] : null;
// this.logger.log('onSaveButton: ', button, intentIdIntentToUpdate, this.listOfIntents, this.intentService.intentSelected);
// if (intentIdIntentToUpdate) {
// this.intentSelected = this.listOfIntents.find(obj => obj.intent_id === intentIdIntentToUpdate);
// // forse conviene fare come in onSavePanelIntentDetail passando intent aggiornato (con action corretta)!!!!
// // this.intentService.onUpdateIntentWithTimeout(this.intentSelected, 0, true);
// this.intentService.onUpdateIntentFromActionPanel(this.intentService.intentSelected);
// }
} | /** onSaveButton */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1234-L1248 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onSavePanelIntentDetail | onSavePanelIntentDetail(intentSelected: any) {
this.logger.log('[CDS-CANVAS] onSavePanelIntentDetail intentSelected ', intentSelected)
if (intentSelected && intentSelected != null) {
// this.intentSelected = intentSelected;
this.intentService.setIntentSelectedByIntent(intentSelected);
// this.intentService.onUpdateIntentFromActionPanel(intentSelected);
this.intentService.updateIntent(intentSelected);
} else {
// this.onOpenDialog();
}
} | /** onSavePanelIntentDetail */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1256-L1267 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onAddActionFromActionMenu | async onAddActionFromActionMenu(event) {
this.logger.log('[CDS-CANVAS] onAddActionFromActionMenu:: ', event);
this.IS_OPEN_ADD_ACTIONS_MENU = true;
const connectorDraft = this.connectorService.connectorDraft;
if (connectorDraft && connectorDraft.toPoint && !this.hasClickedAddAction) {
this.logger.log("[CDS-CANVAS] ho trascinato il connettore e sto per creare un intent");
this.createNewIntentFromConnectorDraft(event.type, connectorDraft);
// this.removeConnectorDraftAndCloseFloatMenu();
}
else if (this.hasClickedAddAction) {
this.logger.log("[CDS-CANVAS] ho premuto + quindi creo una nuova action e la aggiungo all'intent");
const newAction = this.intentService.createNewAction(event.type);
// this.intentSelected.actions.push(newAction);
this.intentService.addActionToIntentSelected(newAction);
// this.intentService.updateIntentSelected();
// this.updateIntent(this.intentSelected, 0, true);
this.controllerService.closeAddActionMenu();
}
} | /** chiamata quando premo + sull'intent per aggiungere una nuova action */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1279-L1299 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.setConnectorSelected | setConnectorSelected(idConnector){
this.connectorSelected = {};
const intentId = idConnector.split('/')[0];
let intent = this.intentService.getIntentFromId(intentId);
this.connectorSelected = {
id: idConnector
}
try {
if(intent.attributes.connectors && intent.attributes.connectors[idConnector]){
this.connectorSelected = intent.attributes.connectors[idConnector];
}
} catch (error) {
this.logger.log("Error: ", error);
}
} | /**
* setConnectorSelected
* @param idConnector
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1307-L1321 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onAddActionFromConnectorMenu | async onAddActionFromConnectorMenu(event) {
if(event.type === "delete"){
const intentId = this.connectorSelected.id.split('/')[0];
let intent = this.intentService.getIntentFromId(intentId);
if(intent.attributes && intent.attributes.connectors && intent.attributes.connectors[this.connectorSelected.id]){
delete intent.attributes.connectors[this.connectorSelected.id];
}
this.connectorService.updateConnectorAttributes(this.connectorSelected.id, event);
this.connectorService.deleteConnector( this.connectorSelected.id, true, true);
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
}
if(event.type === "line-text"){
this.logger.log('[CDS-CANVAS] line-text:: ', this.connectorSelected);
if(this.connectorSelected && this.connectorSelected.id){
const intentId = this.connectorSelected.id.split('/')[0];
let intent = this.intentService.getIntentFromId(intentId);
if(!intent.attributes.connectors){
intent.attributes['connectors'] = {};
}
if(!intent.attributes.connectors[this.connectorSelected.id]){
intent.attributes.connectors[this.connectorSelected.id] = {};
}
intent.attributes.connectors[this.connectorSelected.id]['id'] = this.connectorSelected.id;
intent.attributes.connectors[this.connectorSelected.id]['label'] = event.label;
this.intentService.updateIntent(intent);
this.connectorService.updateConnectorAttributes(this.connectorSelected.id, event);
}
this.IS_OPEN_PANEL_CONNECTOR_MENU = false;
}
} | /**
* onAddActionFromConnectorMenu
* @param event
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1328-L1358 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsCanvasComponent.onShowContextMenu | public onShowContextMenu(event: MouseEvent): void {
event.preventDefault();
this.logger.log('[CDS-CANVAS] onShowContextMenu:: ', event);
// this.showCustomMenu(x, y);
// Recupera l'elemento che ha scatenato l'evento
const targetElement = event.target as HTMLElement;
const customAttributeValue = targetElement.getAttribute('custom-attribute');
if(customAttributeValue === 'tds_container'){
// sto incollando sullo stage
this.positionContextMenu.x = event.clientX;
this.positionContextMenu.y = event.offsetY;
this.IS_OPEN_CONTEXT_MENU = true;
this.logger.log('Attributi dell\'elemento premuto:', customAttributeValue);
}
} | // --------------------------------------------------------- // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/cds-canvas.component.ts#L1362-L1378 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.ngOnInit | ngOnInit(): void {
this.logger.log('ActionDTMFFormComponent ngOnInit', this.action, this.intentSelected);
// // this.logger.log('ngOnInit panel-response::: ', this.typeAction);
this.typeAction = (this.action._tdActionType === TYPE_ACTION.RANDOM_REPLY ? TYPE_ACTION.RANDOM_REPLY : TYPE_ACTION.REPLY);
try {
this.element = Object.values(ACTIONS_LIST).find(item => item.type === this.action._tdActionType);
if(this.action._tdActionTitle && this.action._tdActionTitle != ""){
this.dataInput = this.action._tdActionTitle;
}
this.logger.log('ActionDTMFFormComponent action:: ', this.element);
} catch (error) {
this.logger.log("error ", error);
}
this.action._tdActionId = this.action._tdActionId?this.action._tdActionId:generateShortUID();
this.idAction = this.intentSelected.intent_id+'/'+this.action._tdActionId;
// this.initialize();
this.changeDetectorRef.detectChanges();
} | // SYSTEM FUNCTIONS // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L71-L89 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.ngOnChanges | ngOnChanges(changes: SimpleChanges): void {
if(this.action && this.intentSelected) this.initialize();
} | /**
*
* @param changes
* IMPORTANT! serve per aggiornare il dettaglio della action nel pannello
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L98-L100 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.initialize | private initialize() {
this.openCardButton = false;
this.arrayResponses = [];
this.intentName = '';
this.intentNameResult = true;
this.textGrabbing = false;
if (this.action) {
try {
this.arrayResponses = this.action.attributes.commands;
} catch (error) {
this.logger.log('error:::', error);
}
}
this.scrollToBottom();
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L109-L123 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.scrollToBottom | scrollToBottom(): void {
setTimeout(() => {
try {
this.scrollContainer.nativeElement.scrollTop = this.scrollContainer.nativeElement.scrollHeight;
this.scrollContainer.nativeElement.animate({ scrollTop: 0 }, '500');
} catch (error) {
this.logger.log('scrollToBottom ERROR: ', error);
}
}, 300);
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L127-L136 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.mouseDown | mouseDown() {
this.textGrabbing = true;
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L144-L146 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.mouseUp | mouseUp() {
this.textGrabbing = false;
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L149-L151 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.drop | drop(event: CdkDragDrop<string[]>) {
// this.logger.log( 'DROP REPLY ---> ',event, this.arrayResponses);
this.textGrabbing = false;
try {
let currentPos = event.currentIndex*2+1;
let previousPos = event.previousIndex*2+1;
const waitCur = this.arrayResponses[currentPos-1];
const msgCur = this.arrayResponses[currentPos];
const waitPre = this.arrayResponses[previousPos-1];
const msgPre = this.arrayResponses[previousPos];
this.arrayResponses[currentPos-1] = waitPre;
this.arrayResponses[currentPos] = msgPre;
this.arrayResponses[previousPos-1] = waitCur;
this.arrayResponses[previousPos] = msgCur;
// this.logger.log( 'DROP REPLY ---> ', this.arrayResponses);
this.connectorService.updateConnector(this.intentSelected.intent_id);
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.intentSelected};
this.onUpdateAndSaveAction(element);
} catch (error) {
this.logger.log('drop ERROR', error);
}
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L154-L175 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onMoveUpResponse | onMoveUpResponse(index: number) {
if(index<2)return;
try {
let from = index - 1;
let to = from - 2;
this.arrayResponses.splice(to, 0, this.arrayResponses.splice(from, 1)[0]);
from = index;
to = from - 2;
this.arrayResponses.splice(to, 0, this.arrayResponses.splice(from, 1)[0]);
// this.logger.log( 'onMoveUpResponse ---> ', this.arrayResponses);
this.connectorService.updateConnector(this.intentSelected.intent_id);
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.onUpdateAndSaveAction(element);
} catch (error) {
this.logger.log('onAddNewResponse ERROR', error);
}
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L180-L196 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onMoveDownResponse | onMoveDownResponse(index: number) {
if(index === this.arrayResponses.length-1)return;
try {
let from = index;
let to = from + 2;
this.arrayResponses.splice(to, 0, this.arrayResponses.splice(from, 1)[0]);
from = index - 1;
to = from + 2;
this.arrayResponses.splice(to, 0, this.arrayResponses.splice(from, 1)[0]);
// this.logger.log( 'onMoveUpResponse ---> ', this.arrayResponses);
this.connectorService.updateConnector(this.intentSelected.intent_id);
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.onUpdateAndSaveAction(element);
} catch (error) {
this.logger.log('onAddNewResponse ERROR', error);
}
} | /** */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L199-L215 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onAddNewActionReply | onAddNewActionReply(ele) {
this.logger.log('onAddNewActionReply: ', ele);
try {
let message = new Message(ele.message.type, ele.message.text);
if (ele.message.attributes) {
message.attributes = ele.message.attributes;
}
if (ele.message.metadata) {
message.metadata = ele.message.metadata;
}
const wait = new Wait();
let command = new Command(ele.type);
command.message = message;
this.arrayResponses.splice(this.arrayResponses.length-2, 0, wait)
this.arrayResponses.splice(this.arrayResponses.length-2, 0, command)
this.arrayResponses.join();
this.scrollToBottom();
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.onUpdateAndSaveAction(element);
} catch (error) {
this.logger.log('onAddNewResponse ERROR', error);
}
} | /** onAddNewActionReply */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L219-L241 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onDeleteActionReply | onDeleteActionReply(index: number) {
this.logger.log('onDeleteActionReply: ', this.arrayResponses[index]);
// !!! cancello tutti i connettori di una action
var intentId = this.idAction.substring(0, this.idAction.indexOf('/'));
try {
let buttons = this.arrayResponses[index].message.attributes.attachment.buttons;
buttons.forEach(button => {
this.logger.log('button: ', button);
if(button.__isConnected){
this.connectorService.deleteConnectorFromAction(intentId, button.__idConnector);
// this.connectorService.deleteConnector(button.__idConnector);
}
});
} catch (error) {
this.logger.log('onAddNewResponse ERROR', error);
}
// cancello l'elemento wait precedente
this.logger.log('**** arrayResponses: ', this.arrayResponses, 'index-1: ', (index-1));
const wait = this.arrayResponses[index-1];
this.logger.log('wait: ', wait);
if( wait && wait.type === this.typeCommand.WAIT){
this.arrayResponses.splice(index-1, 2);
} else {
this.arrayResponses.splice(index, 1);
}
this.logger.log('onDeleteActionReply', this.arrayResponses);
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.onUpdateAndSaveAction(element);
} | /** onDeleteActionReply */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L245-L273 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onChangeActionReply | onChangeActionReply(event) {
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.logger.log('onChangeActionReply ************', element);
this.onUpdateAndSaveAction(element);
} | /** onChangingReplyAction */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L276-L280 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onConnectorChangeReply | onConnectorChangeReply(event){
this.logger.log('onConnectorChangeReply ************', event);
this.updateAndSaveAction.emit({type: TYPE_UPDATE_ACTION.ACTION, element: this.action});
this.onConnectorChange.emit(event)
} | /** onConnectorChangeReply */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L283-L287 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onCreateNewButton | onCreateNewButton(index){
this.logger.log('[ActionDTMFForm] onCreateNewButton: ', index);
try {
if(!this.arrayResponses[index].message.attributes || !this.arrayResponses[index].message.attributes.attachment){
this.arrayResponses[index].message.attributes = new MessageAttributes();
}
} catch (error) {
this.logger.error('error: ', error);
}
let buttonSelected = this.createNewButton();
if(buttonSelected){
this.arrayResponses[index].message.attributes.attachment.buttons.push(buttonSelected);
this.logger.log('[ActionDTMFForm] onCreateNewButton: ', this.action, this.arrayResponses);
// this.intentService.setIntentSelected(this.intentSelected.intent_id);
this.intentService.selectAction(this.intentSelected.intent_id, this.action._tdActionId);
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.onUpdateAndSaveAction(element);
}
} | /** onCreateNewButton */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L294-L312 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onDeleteButton | onDeleteButton(event){
let button = event.buttons[event.index];
event.buttons.splice(event.index, 1);
var intentId = this.idAction.substring(0, this.idAction.indexOf('/'));
this.connectorService.deleteConnectorFromAction(intentId, button.__idConnector);
this.updateAndSaveAction.emit({type: TYPE_UPDATE_ACTION.ACTION, element: this.action});
} | /** onDeleteButton */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L338-L344 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onUpdateAndSaveAction | public async onUpdateAndSaveAction(element) {
this.logger.log('[ActionDTMFForm] onUpdateAndSaveAction:::: ', this.action, element);
// this.connectorService.updateConnector(this.intentSelected.intent_id);
this.updateAndSaveAction.emit(this.action);
} | /** onUpdateAndSaveAction:
* function called by all actions in @output whenever they are modified!
* 1 - update connectors
* 2 - update intent
* */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L352-L356 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onChangeIntentName | onChangeIntentName(name: string) {
name.toString();
try {
this.intentName = name.replace(/[^A-Z0-9_]+/ig, "");
} catch (error) {
this.logger.log('name is not a string', error)
}
} | /** onChangeIntentName */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L361-L368 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onBlurIntentName | onBlurIntentName(name: string) {
this.intentNameResult = true;
} | /** onBlurIntentName */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L371-L373 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onDisableInputMessage | onDisableInputMessage() {
try {
this.action.attributes.disableInputMessage = !this.action.attributes.disableInputMessage;
this.updateAndSaveAction.emit({type: TYPE_UPDATE_ACTION.ACTION, element: this.action});
} catch (error) {
this.logger.log("Error: ", error);
}
} | /** onDisableInputMessage */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L376-L383 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onOpenButtonPanel | onOpenButtonPanel(buttonSelected) {
this.logger.log('onOpenButtonPanel 2 :: ', buttonSelected);
// this.intentService.setIntentSelected(this.intentSelected.intent_id);
this.intentService.selectAction(this.intentSelected.intent_id, this.action._tdActionId);
this.controllerService.openButtonPanel(buttonSelected);
} | /** appdashboard-button-configuration-panel: onOpenButtonPanel */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L387-L392 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onSaveButton | onSaveButton(button) {
// this.logger.log('onSaveButton :: ', button, this.response);
// this.generateCommandsWithWaitOfElements();
} | /** appdashboard-button-configuration-panel: Save button */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L405-L408 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDTMFFormComponent.onCloseButtonPanel | onCloseButtonPanel() {
this.logger.log('onCloseButtonPanel :: ');
this.openCardButton = false;
} | /** appdashboard-button-configuration-panel: Close button panel */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-form/cds-action-dtmf-form.component.ts#L413-L416 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionDtmfMenuComponent.onCreateNewButton | public override async onCreateNewButton(event){
let index = event.index;
let buttonValue = event.option
this.logger.log('[ActionDTMFForm] onCreateNewButton: ', index);
try {
if(!this.arrayResponses[index].message.attributes || !this.arrayResponses[index].message.attributes.attachment){
this.arrayResponses[index].message.attributes = new MessageAttributes();
}
} catch (error) {
this.logger.error('error: ', error);
}
let buttonSelected = this.createNewButtonOption(index, buttonValue);
if(buttonSelected){
this.arrayResponses[index].message.attributes.attachment.buttons.push(buttonSelected);
this.logger.log('[ActionDTMFForm] onCreateNewButton: ', this.action, this.arrayResponses);
// this.intentService.setIntentSelected(this.intentSelected.intent_id);
this.intentService.selectAction(this.intentSelected.intent_id, this.action._tdActionId);
const element = {type: TYPE_UPDATE_ACTION.ACTION, element: this.action};
this.onUpdateAndSaveAction(element);
}
} | /** onCreateNewButton */ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-dtmf-menu/cds-action-dtmf-menu.component.ts#L44-L64 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionVoiceComponent.ngOnInit | ngOnInit(): void {
this.logger.log('ActionDTMFFormComponent ngOnInit', this.action, this.intentSelected);
// // this.logger.log('ngOnInit panel-response::: ', this.typeAction);
this.typeAction = (this.action._tdActionType === TYPE_ACTION.RANDOM_REPLY ? TYPE_ACTION.RANDOM_REPLY : TYPE_ACTION.REPLY);
try {
this.element = Object.values(ACTIONS_LIST).find(item => item.type === this.action._tdActionType);
if(this.action._tdActionTitle && this.action._tdActionTitle != ""){
this.dataInput = this.action._tdActionTitle;
}
this.logger.log('ActionDTMFFormComponent action:: ', this.element);
} catch (error) {
this.logger.log("error ", error);
}
this.action._tdActionId = this.action._tdActionId?this.action._tdActionId:generateShortUID();
this.idAction = this.intentSelected.intent_id+'/'+this.action._tdActionId;
// this.initialize();
this.changeDetectorRef.detectChanges();
} | // SYSTEM FUNCTIONS // | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-voice-base/cds-action-voice.component.ts#L71-L89 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
design-studio | github_2023 | Tiledesk | typescript | CdsActionVoiceComponent.ngOnChanges | ngOnChanges(changes: SimpleChanges): void {
if(this.action && this.intentSelected) this.initialize();
} | /**
*
* @param changes
* IMPORTANT! serve per aggiornare il dettaglio della action nel pannello
*/ | https://github.com/Tiledesk/design-studio/blob/297d30da01d98a1299e7197eb88cff5b2390a386/src/app/chatbot-design-studio/cds-dashboard/cds-canvas/actions/list-voice/cds-action-voice-base/cds-action-voice.component.ts#L98-L100 | 297d30da01d98a1299e7197eb88cff5b2390a386 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.