Skip to content

Commit

Permalink
Update AI Translator configuration to match the new format #8023
Browse files Browse the repository at this point in the history
  • Loading branch information
edloidas committed Nov 5, 2024
1 parent 60d306d commit 459fe73
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
4 changes: 3 additions & 1 deletion modules/app/src/main/resources/services/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ function handleGet() {
appServiceUrl: portal.serviceUrl({service: 'applications'}),
exportServiceUrl: portal.serviceUrl({service: 'export'}),
aiContentOperatorServiceUrl: portal.serviceUrl({service: 'rest', application: 'com.enonic.app.ai.contentoperator'}),
aiTranslatorServiceUrl: portal.serviceUrl({service: 'rest', application: 'com.enonic.app.ai.translator'}),
aiTranslatorRestServiceUrl: portal.serviceUrl({service: 'rest', application: 'com.enonic.app.ai.translator'}),
aiTranslatorWsServiceUrl: portal.serviceUrl(
{service: 'ws', application: 'com.enonic.app.ai.translator', type: 'websocket'}),
},
theme: 'light',
/* Remove in CS/lib-admin-ui 5.0 */
Expand Down
6 changes: 5 additions & 1 deletion modules/lib/src/main/resources/assets/js/app/ai/AI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export class AI {
AiTranslatorCompletedEvent.on(this.translatorCompletedEventListener);

this.getContentOperator()?.setup({serviceUrl: CONFIG.getString('services.aiContentOperatorServiceUrl')});
this.getTranslator()?.setup({serviceUrl: CONFIG.getString('services.aiTranslatorServiceUrl')});
this.getTranslator()?.setup({
restServiceUrl: CONFIG.getString('services.aiTranslatorRestServiceUrl'),
wsServiceUrl: CONFIG.getString('services.aiTranslatorWsServiceUrl')
});

void new IsAuthenticatedRequest().sendAndParse().then((loginResult: LoginResult) => {
const currentUser = loginResult.getUser();
Expand Down Expand Up @@ -193,6 +196,7 @@ export class AI {
private createContentData(): ContentData | undefined {
// TODO: Add structuredClone, when target upgraded to ES2022
return this.currentData || (this.content && {
contentId: this.content.getContentId().toString(),
fields: this.content.getContentData().toJson(),
topic: this.content.getDisplayName(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface AiData {
}

export interface ContentData {
contentId: string;
fields: PropertyArrayJson[];
topic: string;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface EnonicAiTranslatorSetupData {
serviceUrl: string;
restServiceUrl: string;
wsServiceUrl: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {MinimizeWizardPanelEvent} from '@enonic/lib-admin-ui/app/wizard/Minimize
import {WizardHeader} from '@enonic/lib-admin-ui/app/wizard/WizardHeader';
import {WizardPanel} from '@enonic/lib-admin-ui/app/wizard/WizardPanel';
import {WizardStep} from '@enonic/lib-admin-ui/app/wizard/WizardStep';
import {WizardStepsPanel} from '@enonic/lib-admin-ui/app/wizard/WizardStepsPanel';
import {Application} from '@enonic/lib-admin-ui/application/Application';
import {ApplicationConfig} from '@enonic/lib-admin-ui/application/ApplicationConfig';
import {ApplicationEvent} from '@enonic/lib-admin-ui/application/ApplicationEvent';
Expand Down Expand Up @@ -54,6 +55,7 @@ import {AiTranslatorOpenDialogEvent} from '../ai/event/outgoing/AiTranslatorOpen
import {MovedContentItem} from '../browse/MovedContentItem';
import {CompareStatus} from '../content/CompareStatus';
import {Content, ContentBuilder} from '../content/Content';
import {ContentDiff} from '../content/ContentDiff';
import {ContentIconUrlResolver} from '../content/ContentIconUrlResolver';
import {ContentId} from '../content/ContentId';
import {ContentName} from '../content/ContentName';
Expand All @@ -63,6 +65,7 @@ import {ContentSummary} from '../content/ContentSummary';
import {ContentSummaryAndCompareStatus} from '../content/ContentSummaryAndCompareStatus';
import {ContentUnnamed} from '../content/ContentUnnamed';
import {ExtraData} from '../content/ExtraData';
import {PageTemplate} from '../content/PageTemplate';
import {Site} from '../content/Site';
import {WorkflowState} from '../content/WorkflowState';
import {XData} from '../content/XData';
Expand All @@ -73,6 +76,7 @@ import {ContentNamedEvent} from '../event/ContentNamedEvent';
import {ContentRequiresSaveEvent} from '../event/ContentRequiresSaveEvent';
import {ContentServerChangeItem} from '../event/ContentServerChangeItem';
import {ContentServerEventsHandler} from '../event/ContentServerEventsHandler';
import {InspectEvent} from '../event/InspectEvent';
import {ContentType} from '../inputtype/schema/ContentType';
import {ImageErrorEvent} from '../inputtype/ui/selector/image/ImageErrorEvent';
import {Descriptor} from '../page/Descriptor';
Expand Down Expand Up @@ -101,6 +105,7 @@ import {ApplicationAddedEvent} from '../site/ApplicationAddedEvent';
import {ApplicationRemovedEvent} from '../site/ApplicationRemovedEvent';
import {SiteModel} from '../site/SiteModel';
import {UrlAction} from '../UrlAction';
import {ContentDiffHelper} from '../util/ContentDiffHelper';
import {ContentHelper} from '../util/ContentHelper';
import {PageHelper} from '../util/PageHelper';
import {UrlHelper} from '../util/UrlHelper';
Expand All @@ -120,6 +125,7 @@ import {ContentWizardHeader} from './ContentWizardHeader';
import {ContentWizardPanelParams} from './ContentWizardPanelParams';
import {ContentWizardStep} from './ContentWizardStep';
import {ContentWizardStepForm} from './ContentWizardStepForm';
import {ContentWizardStepsPanel} from './ContentWizardStepsPanel';
import {ContentWizardToolbar} from './ContentWizardToolbar';
import {ContentWizardToolbarPublishControls} from './ContentWizardToolbarPublishControls';
import {DisplayNameResolver} from './DisplayNameResolver';
Expand All @@ -134,6 +140,7 @@ import {PageComponentsView} from './PageComponentsView';
import {PageComponentsWizardStep} from './PageComponentsWizardStep';
import {PageComponentsWizardStepForm} from './PageComponentsWizardStepForm';
import {PageEventsManager} from './PageEventsManager';
import {PageNavigationEventSource} from './PageNavigationEventData';
import {PermissionHelper} from './PermissionHelper';
import {PersistNewContentRoutine} from './PersistNewContentRoutine';
import {ThumbnailUploaderEl} from './ThumbnailUploaderEl';
Expand All @@ -142,13 +149,6 @@ import {WorkflowStateManager, WorkflowStateStatus} from './WorkflowStateManager'
import {XDataWizardStep} from './XDataWizardStep';
import {XDataWizardStepForm} from './XDataWizardStepForm';
import {XDataWizardStepForms} from './XDataWizardStepForms';
import {PageTemplate} from '../content/PageTemplate';
import {InspectEvent} from '../event/InspectEvent';
import {PageNavigationEventSource} from './PageNavigationEventData';
import {WizardStepsPanel} from '@enonic/lib-admin-ui/app/wizard/WizardStepsPanel';
import {ContentWizardStepsPanel} from './ContentWizardStepsPanel';
import {ContentDiffHelper} from '../util/ContentDiffHelper';
import {ContentDiff} from '../content/ContentDiff';

export type FormContextName = 'content' | 'xdata' | 'live';

Expand Down Expand Up @@ -314,6 +314,7 @@ export class ContentWizardPanel
this.workflowStateManager = new WorkflowStateManager(this);
this.debouncedEnonicAiDataChangedHandler = AppHelper.debounce(() => {
AI.get().setCurrentData({
contentId: this.getPersistedItem()?.getContentId().toString() ?? '',
fields: this.contentWizardStepForm.getData().toJson(),
topic: this.getWizardHeader().getDisplayName(),
});
Expand Down

0 comments on commit 459fe73

Please sign in to comment.