@ -0,0 +1,51 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
||||
|
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
Easy ChatGPT Access |
||||
|
=================== |
||||
|
This module enables easy access to the ChatGPT dialog box from the systray icon. |
||||
|
|
||||
|
Features |
||||
|
======== |
||||
|
* Access ChatGPT from systray icon. |
||||
|
* Able to copy the AI generated text into clipboard. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No Additional configuration is needed. |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
Affero General Public License, v3.0 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developer: (V18) Unnimaya CO, Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Unnimaya CO(odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
@ -0,0 +1,53 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################### |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
||||
|
# Author: Unnimaya CO (odoo@cybrosys.com) |
||||
|
# |
||||
|
# You can modify it under the terms of the GNU AFFERO |
||||
|
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
||||
|
# (AGPL v3) along with this program. |
||||
|
# If not, see <http://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
############################################################################### |
||||
|
{ |
||||
|
'name': 'Easy ChatGPT Access', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Extra Tools', |
||||
|
'summary': 'Access ChatGPT from systray.', |
||||
|
'description': """This module enables easy access to the ChatGPT dialog box |
||||
|
from the systray icon and allows copying the generated text to the |
||||
|
clipboard.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['web'], |
||||
|
'assets': { |
||||
|
'web.assets_backend': [ |
||||
|
'web/static/lib/jquery/jquery.js', |
||||
|
('include', 'web_editor.assets_wysiwyg'), |
||||
|
'easy_chatgpt_access/static/src/xml/chatgpt_button_views.xml', |
||||
|
'easy_chatgpt_access/static/src/xml/chatgpt_prompt_dialog.xml', |
||||
|
'easy_chatgpt_access/static/src/js/chatgpt_button.js', |
||||
|
'easy_chatgpt_access/static/src/js/wysiwyg.js', |
||||
|
'easy_chatgpt_access/static/src/js/ChatGPTPromptDialog.js', |
||||
|
'easy_chatgpt_access/static/src/js/chatgpt_dialog.js', |
||||
|
], |
||||
|
}, |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
||||
|
|
@ -0,0 +1,6 @@ |
|||||
|
## Module <easy_chatgpt_access> |
||||
|
|
||||
|
#### 29.11.2024 |
||||
|
#### Version 18.0.1.0.0 |
||||
|
##### ADD |
||||
|
- Initial Commit for Easy ChatGPT Access |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 456 KiB |
After Width: | Height: | Size: 240 KiB |
After Width: | Height: | Size: 347 KiB |
After Width: | Height: | Size: 352 KiB |
After Width: | Height: | Size: 233 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 741 KiB |
After Width: | Height: | Size: 63 KiB |
@ -0,0 +1,14 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import { ChatGPTPromptDialog } from '@web_editor/js/wysiwyg/widgets/chatgpt_prompt_dialog'; |
||||
|
//Default props are extended to include a 'systray' object with an 'insert' property set to true.
|
||||
|
ChatGPTPromptDialog.defaultProps = { |
||||
|
...ChatGPTPromptDialog.defaultProps, |
||||
|
systray: { |
||||
|
insert: true, |
||||
|
} |
||||
|
} |
||||
|
// Adds an optional `systray` property of type Object to `ChatGPTPromptDialog`.
|
||||
|
ChatGPTPromptDialog.props = { |
||||
|
...ChatGPTPromptDialog.props, |
||||
|
systray: { type: Object, optional: true }, |
||||
|
} |
@ -0,0 +1,146 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import { registry } from "@web/core/registry"; |
||||
|
import { Component, onWillStart, useState } from "@odoo/owl"; |
||||
|
import { Wysiwyg } from "@web_editor/js/wysiwyg/wysiwyg"; |
||||
|
import { QWebPlugin } from '@web_editor/js/backend/QWebPlugin'; |
||||
|
let stripHistoryIds; |
||||
|
|
||||
|
import { session } from "@web/session"; |
||||
|
|
||||
|
/* Export new class SystrayIcon by extending Component */ |
||||
|
export class SystrayIcon extends Component { |
||||
|
static components = { Wysiwyg } |
||||
|
setup() { |
||||
|
this.state = useState({ |
||||
|
open: false, |
||||
|
}) |
||||
|
this.odoo_version = session.isEnterprise() ? 'Enterprise' : 'Community'; |
||||
|
onWillStart(async() => await this._lazyloadWysiwyg()) |
||||
|
}; |
||||
|
// Lazily loads the Wysiwyg module and its dependencies if not already loaded.
|
||||
|
async _lazyloadWysiwyg() { |
||||
|
let wysiwygModule = await odoo.loader.modules.get('@web_editor/js/wysiwyg/wysiwyg'); |
||||
|
this.MoveNodePlugin = (await odoo.loader.modules.get('@web_editor/js/wysiwyg/MoveNodePlugin'))?.MoveNodePlugin; |
||||
|
// Otherwise, load the module.
|
||||
|
if (!wysiwygModule) { |
||||
|
await loadBundle('web_editor.backend_assets_wysiwyg'); |
||||
|
wysiwygModule = await odoo.loader.modules.get('@web_editor/js/wysiwyg/wysiwyg'); |
||||
|
this.MoveNodePlugin = (await odoo.loader.modules.get('@web_editor/js/wysiwyg/MoveNodePlugin')).MoveNodePlugin; |
||||
|
} |
||||
|
stripHistoryIds = wysiwygModule.stripHistoryIds; |
||||
|
this.Wysiwyg = wysiwygModule.Wysiwyg; |
||||
|
} |
||||
|
/** |
||||
|
* Retrieves Wysiwyg properties. |
||||
|
* @returns {object} An object containing Wysiwyg properties. |
||||
|
*/ |
||||
|
get wysiwygProps() { |
||||
|
return { |
||||
|
startWysiwyg: this.startWysiwyg.bind(this), |
||||
|
editingValue: undefined, |
||||
|
options: this.wysiwygOptions |
||||
|
} |
||||
|
} |
||||
|
// Include the 'open' parameter in the object to enable loading the prompt dialog from the Systray.
|
||||
|
get wysiwygOptions() { |
||||
|
return { |
||||
|
value: "", |
||||
|
allowCommandVideo: false, |
||||
|
autostart: false, |
||||
|
collaborationChannel: undefined, |
||||
|
editorPlugins: [QWebPlugin, this.MoveNodePlugin], |
||||
|
field_id: "", |
||||
|
height: undefined, |
||||
|
inIframe: false, |
||||
|
iframeCssAssets: undefined, |
||||
|
iframeHtmlClass: undefined, |
||||
|
linkOptions: { |
||||
|
forceNewWindow: true, |
||||
|
}, |
||||
|
maxHeight: undefined, |
||||
|
mediaModalParams: { |
||||
|
noVideos: true, |
||||
|
useMediaLibrary: true, |
||||
|
}, |
||||
|
minHeight: undefined, |
||||
|
noAttachment: undefined, |
||||
|
onDblClickEditableMedia: this._onDblClickEditableMedia.bind(this), |
||||
|
onWysiwygBlur: this._onWysiwygBlur.bind(this), |
||||
|
placeholder: "", |
||||
|
resizable: false, |
||||
|
snippets: undefined, |
||||
|
tabsize: 0, |
||||
|
document, |
||||
|
openPrompt: this.state.open, |
||||
|
systray: { |
||||
|
insert: false, |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
* Opens an image in fullscreen mode on double-click. |
||||
|
*/ |
||||
|
_onDblClickEditableMedia(ev) { |
||||
|
const el = ev.currentTarget; |
||||
|
if (el.nodeName === 'IMG' && el.src) { |
||||
|
this.wysiwyg.showImageFullscreen(el.src); |
||||
|
} |
||||
|
} |
||||
|
_onWysiwygBlur() { |
||||
|
// Avoid save on blur if the html field is in inline mode.
|
||||
|
if (!this.props.isInlineStyle) { |
||||
|
this.commitChanges(); |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
* Initializes and starts the WYSIWYG editor with optional features. |
||||
|
* |
||||
|
* @param {Object} wysiwyg - The WYSIWYG editor instance to be started. |
||||
|
* |
||||
|
* This function: |
||||
|
* - Sets up the WYSIWYG editor instance. |
||||
|
* - Adds a CSS class to the editable area. |
||||
|
* - Optionally adds a code view button to the toolbar if `this.props.codeview` is true. |
||||
|
* - Sets up event listeners for editor history steps and collaborative editing, triggering a "FIELD_IS_DIRTY" event. |
||||
|
*/ |
||||
|
async startWysiwyg(wysiwyg) { |
||||
|
this.wysiwyg = wysiwyg; |
||||
|
await this.wysiwyg.startEdition(); |
||||
|
wysiwyg.$editable[0].classList.add("odoo-editor-qweb"); |
||||
|
if (this.props.codeview) { |
||||
|
const $codeviewButtonToolbar = $(` |
||||
|
<div id="codeview-btn-group" class="btn-group"> |
||||
|
<button class="o_codeview_btn btn btn-primary"> |
||||
|
<i class="fa fa-code"></i> |
||||
|
</button> |
||||
|
</div> |
||||
|
`);
|
||||
|
this.wysiwyg.toolbarEl.append($codeviewButtonToolbar[0]); |
||||
|
$codeviewButtonToolbar.click(this.toggleCodeView.bind(this)); |
||||
|
} |
||||
|
this.wysiwyg.odooEditor.addEventListener("historyStep", () => |
||||
|
this.props.record.model.bus.trigger("FIELD_IS_DIRTY", this._isDirty()) |
||||
|
); |
||||
|
if (this.props.isCollaborative) { |
||||
|
this.wysiwyg.odooEditor.addEventListener("onExternalHistorySteps", () => |
||||
|
this.props.record.model.bus.trigger("FIELD_IS_DIRTY", this._isDirty()) |
||||
|
); |
||||
|
} |
||||
|
this.isRendered = true; |
||||
|
} |
||||
|
// Onclick event of systray Icon
|
||||
|
_onClick() { |
||||
|
this.state.open = !this.state.open |
||||
|
setTimeout(() => { |
||||
|
this.state.open = false; |
||||
|
}, 500); |
||||
|
}; |
||||
|
}; |
||||
|
session.isEnterprise = function () { |
||||
|
return !!session.server_version_info[5]; |
||||
|
}; |
||||
|
SystrayIcon.template = "systray_icon"; |
||||
|
export const systrayItem = { |
||||
|
Component: SystrayIcon, |
||||
|
}; |
||||
|
registry.category("systray").add("SystrayIcon", systrayItem); |
@ -0,0 +1,41 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import { ChatGPTDialog } from '@web_editor/js/wysiwyg/widgets/chatgpt_dialog'; |
||||
|
import { patch } from "@web/core/utils/patch"; |
||||
|
import { useService } from "@web/core/utils/hooks"; |
||||
|
/** |
||||
|
* Patch ChatGPTDialog for modifying the setup and adding copyMessage function. |
||||
|
* Modifies the setup function to include initialization of the 'action' service. |
||||
|
* Adds the copyMessage function to copy generated AI text into the clipboard and display a notification. |
||||
|
*/ |
||||
|
patch(ChatGPTDialog.prototype, { |
||||
|
setup() { |
||||
|
super.setup(...arguments); |
||||
|
this.action = useService('action'); |
||||
|
this.notification = useService("notification"); |
||||
|
}, |
||||
|
// Copy the generated AI text into clipboard when hitting the Copy button
|
||||
|
copyMessage(ev) { |
||||
|
var content = ev.target.parentElement.children[1].innerText |
||||
|
const message = "Copied to Clipboard!" |
||||
|
var textArea = document.createElement("textarea"); |
||||
|
textArea.value = content; |
||||
|
document.body.appendChild(textArea); |
||||
|
textArea.select(); |
||||
|
var successful = document.execCommand('copy'); |
||||
|
document.body.removeChild(textArea) |
||||
|
this.displayNotification( |
||||
|
("Text copied to Clipboard") |
||||
|
); |
||||
|
return successful; |
||||
|
}, |
||||
|
/** |
||||
|
* Displays a notification with a success message. |
||||
|
*/ |
||||
|
displayNotification(text) { |
||||
|
this.notification.add(text, { |
||||
|
type: 'success', |
||||
|
title: 'Text copied', |
||||
|
sticky: false, |
||||
|
}); |
||||
|
} |
||||
|
}) |
@ -0,0 +1,84 @@ |
|||||
|
/** @odoo-module **/ |
||||
|
import * as OdooEditorLib from "@web_editor/js/editor/odoo-editor/src/OdooEditor"; |
||||
|
import { Wysiwyg } from "@web_editor/js/wysiwyg/wysiwyg"; |
||||
|
import { patch } from "@web/core/utils/patch"; |
||||
|
import { ChatGPTPromptDialog } from '@web_editor/js/wysiwyg/widgets/chatgpt_prompt_dialog'; |
||||
|
import { ChatGPTAlternativesDialog } from '@web_editor/js/wysiwyg/widgets/chatgpt_alternatives_dialog'; |
||||
|
import { _t } from "@web/core/l10n/translation"; |
||||
|
|
||||
|
const preserveCursor = OdooEditorLib.preserveCursor; |
||||
|
const closestElement = OdooEditorLib.closestElement; |
||||
|
/** |
||||
|
* Patch method for modifying the setup and openChatGPTDialog functions of the Wysiwyg class. |
||||
|
* Modifies the setup function to include functionality for handling the opening of the dialog based on the 'openPrompt' prop. |
||||
|
* Modifies the openChatGPTDialog function to include systray options from the component's props in the parameters for opening the dialog. |
||||
|
*/ |
||||
|
patch(Wysiwyg.prototype, { |
||||
|
// Extends the setup method of the superclass and adds functionality to handle the opening
|
||||
|
// of the dialog based on the 'openPrompt' prop.
|
||||
|
setup() { |
||||
|
super.setup(...arguments); |
||||
|
owl.useEffect((openPrompt) => { |
||||
|
if (openPrompt) { |
||||
|
this.openChatGPTDialog() |
||||
|
} |
||||
|
}, () => [this.props.options?.openPrompt]) |
||||
|
}, |
||||
|
// Modifies this function for loading the dialog box from systray icon
|
||||
|
openChatGPTDialog(mode = 'prompt') { |
||||
|
const restore = preserveCursor(this.odooEditor.document); |
||||
|
const params = { |
||||
|
insert: content => { |
||||
|
this.odooEditor.historyPauseSteps(); |
||||
|
const insertedNodes = this.odooEditor.execCommand('insert', content); |
||||
|
this.odooEditor.historyUnpauseSteps(); |
||||
|
this.notification.add(_t('Your content was successfully generated.'), { |
||||
|
title: _t('Content generated'), |
||||
|
type: 'success', |
||||
|
}); |
||||
|
this.odooEditor.historyStep(); |
||||
|
// Add a frame around the inserted content to highlight it for 2
|
||||
|
// seconds.
|
||||
|
const start = insertedNodes?.length && closestElement(insertedNodes[0]); |
||||
|
const end = insertedNodes?.length && closestElement(insertedNodes[insertedNodes.length - 1]); |
||||
|
if (start && end) { |
||||
|
const divContainer = this.odooEditor.editable.parentElement; |
||||
|
let [parent, left, top] = [start.offsetParent, start.offsetLeft, start.offsetTop - start.scrollTop]; |
||||
|
while (parent && !parent.contains(divContainer)) { |
||||
|
left += parent.offsetLeft; |
||||
|
top += parent.offsetTop - parent.scrollTop; |
||||
|
parent = parent.offsetParent; |
||||
|
} |
||||
|
let [endParent, endTop] = [end.offsetParent, end.offsetTop - end.scrollTop]; |
||||
|
while (endParent && !endParent.contains(divContainer)) { |
||||
|
endTop += endParent.offsetTop - endParent.scrollTop; |
||||
|
endParent = endParent.offsetParent; |
||||
|
} |
||||
|
const div = document.createElement('div'); |
||||
|
div.classList.add('o-chatgpt-content'); |
||||
|
const FRAME_PADDING = 3; |
||||
|
div.style.left = `${left - FRAME_PADDING}px`; |
||||
|
div.style.top = `${top - FRAME_PADDING}px`; |
||||
|
div.style.width = `${Math.max(start.offsetWidth, end.offsetWidth) + (FRAME_PADDING * 2)}px`; |
||||
|
div.style.height = `${endTop + end.offsetHeight - top + (FRAME_PADDING * 2)}px`; |
||||
|
divContainer.prepend(div); |
||||
|
setTimeout(() => div.remove(), 2000); |
||||
|
} |
||||
|
}, |
||||
|
}; |
||||
|
if (mode === 'alternatives') { |
||||
|
params.originalText = this.odooEditor.document.getSelection().toString() || ''; |
||||
|
} |
||||
|
// If systray options are provided in the component's props, they are included
|
||||
|
// in the parameters for opening the dialog.
|
||||
|
if (this.props.options.systray){ |
||||
|
params.systray = this.props.options.systray |
||||
|
} |
||||
|
this.odooEditor.document.getSelection().collapseToEnd(); |
||||
|
this.env.services.dialog.add( |
||||
|
mode === 'prompt' ? ChatGPTPromptDialog : ChatGPTAlternativesDialog, |
||||
|
params, |
||||
|
{ onClose: restore }, |
||||
|
); |
||||
|
} |
||||
|
}) |
@ -0,0 +1,27 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!-- Adding button for loading chatgpt in systray --> |
||||
|
<templates xml:space="preserve"> |
||||
|
<t t-name="systray_icon" owl="1"> |
||||
|
<div style="display: none;"> |
||||
|
<Wysiwyg t-props="wysiwygProps"/> |
||||
|
</div> |
||||
|
<div class="new_icon"> |
||||
|
<div class="icon_div"> |
||||
|
<div class="toggle-icon" role="button"> |
||||
|
<t t-if="this.odoo_version === 'Enterprise'"> |
||||
|
<i id='chatgpt_btn' t-on-click="_onClick" |
||||
|
class="fa fa-magic fa-1.5x" |
||||
|
style="color:black; margin-bottom:10px; padding:6px;" |
||||
|
role="img" aria-label="ChatGPT"/> |
||||
|
</t> |
||||
|
<t t-else=""> |
||||
|
<i id='chatgpt_btn' t-on-click="_onClick" |
||||
|
class="fa fa-magic fa-1.5x" |
||||
|
style="color:white; margin-bottom:10px; padding:14px;" |
||||
|
role="img" aria-label="ChatGPT"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</templates> |
@ -0,0 +1,18 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!-- Replacing the Insert button with the copy button from Systray --> |
||||
|
<templates xml:space="preserve"> |
||||
|
<t t-name="easy_chatgpt_access.ChatGPTPromptDialogInherited" |
||||
|
t-inherit="web_editor.ChatGPTPromptDialog" |
||||
|
t-inherit-mode="extension"> |
||||
|
<xpath expr="//button[hasclass('o-message-insert')]" position="replace"> |
||||
|
<button t-if="message.author === 'assistant' and 'text' in message and message.isError !== true and props.systray.insert" |
||||
|
t-att-data-message-id="message.id" |
||||
|
class="o-message-insert d-block float-end p-1 mb-1 btn btn-info opacity-75 fst-italic ms-3" |
||||
|
t-on-click="insertMessage">Insert</button> |
||||
|
<button t-if="message.author === 'assistant' and 'text' in message and message.isError !== true and !props.systray.insert" |
||||
|
t-att-data-message-id="message.id" |
||||
|
class="o-message-insert d-block float-end p-1 mb-1 btn btn-info opacity-75 fst-italic ms-3" |
||||
|
t-on-click="copyMessage">Copy</button> |
||||
|
</xpath> |
||||
|
</t> |
||||
|
</templates> |