Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ if (!/localhost/.test(document.location.host)) {
enableProdMode();
}

let modulePrefix = '';
// @ts-ignore
if (window && window.config?.packageConfigPaths) {
modulePrefix = '/app';
}

config({
floatingActionButtonConfig: {
position: {
Expand All @@ -36,14 +30,14 @@ config({

loadMessages({
en: {
'dxChat-textareaPlaceholder': 'Enter a prompt...',
'dxChat-textareaPlaceholder': 'Ask AI Assistant...',
},
});

@Component({
selector: 'demo-app',
templateUrl: `.${modulePrefix}/app.component.html`,
styleUrls: [`.${modulePrefix}/app.component.css`],
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [AiService],
imports: [
AiAssistantComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@
[onItemClick]="onSuggestionClick"
></dxo-chat-suggestions>

<div
class="dx-chat-messagelist-empty-view"
*dxTemplate="let data of 'emptyViewTemplate'"
>
<ng-container *dxTemplate="let data of 'emptyViewTemplate'">
<div
class="dx-chat-messagelist-empty-image dx-ai-chat__empty-image"
></div>
Expand All @@ -58,7 +55,7 @@
class="ai-chat-empty-prompt"
[innerHTML]="emptyViewPromptHtml"
></div>
</div>
</ng-container>
</dx-chat>
</div>
</dx-popup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,15 @@ import {
CLASSES, chatSuggestions, EMPTY_VIEW_MESSAGE, EMPTY_VIEW_PROMPT,
} from '../../data';

let modulePrefix = '';
// @ts-ignore
if (window && window.config?.packageConfigPaths) {
modulePrefix = '/app';
}

@Component({
selector: 'app-ai-assistant',
imports: [
DxPopupModule,
DxChatModule,
DxSpeedDialActionModule,
],
templateUrl: `.${modulePrefix}/components/ai-assistant/ai-assistant.component.html`,
styleUrls: [`.${modulePrefix}/components/ai-assistant/ai-assistant.component.css`],
templateUrl: './ai-assistant.component.html',
styleUrls: ['./ai-assistant.component.css'],
})
export class AiAssistantComponent {
@Input() disabled = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="form-container" class="form-container">
<div id="form-container">
<dx-form
[formData]="formData"
[colCount]="3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@ import type { AIIntegration } from 'devextreme-angular/common/ai-integration';
import { DxButtonTypes } from 'devextreme-angular/ui/button';
import { employee, formFieldsConfig, type Employee } from '../../data';

let modulePrefix = '';
// @ts-ignore
if (window && window.config?.packageConfigPaths) {
modulePrefix = '/app';
}

@Component({
selector: 'app-employee-form',
imports: [CommonModule, DxFormModule, DxToastModule],
templateUrl: `.${modulePrefix}/components/employee-form/employee-form.component.html`,
styleUrls: [`.${modulePrefix}/components/employee-form/employee-form.component.css`],
templateUrl: './employee-form.component.html',
styleUrls: ['./employee-form.component.css'],
})
export class EmployeeFormComponent {
@Input({ required: true }) aiIntegration!: AIIntegration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
min-height: 360px;
}

::ng-deep .priority-badge {
.priority-badge {
border-radius: 24px;
padding: 2px 8px;
display: inline-block;
text-align: center;
}

.priority-badge--high {
background: #f1bbbc;
}

.priority-badge--normal {
background: #f9e2ae;
}

.priority-badge--low {
background: #9fd89f;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
></dxi-data-grid-column>

<div *dxTemplate="let data of 'priorityTemplate'">
<div class="priority-badge" [style.background]="colors[data.value]">{{
data.value
}}</div>
<div
[class]="'priority-badge priority-badge--' + data.value.toLowerCase()"
>{{ data.value }}</div
>
</div>
</dx-data-grid>
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import { Component, ViewChild } from '@angular/core';
import { DxDataGridModule, DxDataGridComponent } from 'devextreme-angular/ui/data-grid';
import {
colors, tasks, type ColumnFilterExpression, type Task,
} from '../../data';

let modulePrefix = '';
// @ts-ignore
if (window && window.config?.packageConfigPaths) {
modulePrefix = '/app';
}
import { tasks, type ColumnFilterExpression, type Task } from '../../data';

@Component({
selector: 'app-task-grid',
imports: [DxDataGridModule],
templateUrl: `.${modulePrefix}/components/task-grid/task-grid.component.html`,
styleUrls: [`.${modulePrefix}/components/task-grid/task-grid.component.css`],
templateUrl: './task-grid.component.html',
styleUrls: ['./task-grid.component.css'],
})
export class TaskGridComponent {
@ViewChild(DxDataGridComponent) private dxDataGrid!: DxDataGridComponent;

readonly tasks = tasks;

readonly colors = colors;

readonly completionEditorOptions = {
elementAttr: { 'aria-label': 'Completed' },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const AI_SERVICE_CONFIG = {
apiKey: 'DEMO',
};

export const EMPTY_VIEW_MESSAGE = 'How can I help with this page?';
export const EMPTY_VIEW_MESSAGE = 'AI Assistant is ready to help you';

export const EMPTY_VIEW_PROMPT = 'Update employee <b>Form</b> fields.\nFilter or sort tasks, display or hide <b>DataGrid</b> columns, or clear all filters and sorting.';

Expand All @@ -145,12 +145,6 @@ export const FORM_ACTION_TYPES = new Set<FormActionType>(['clear_field', 'clear_

export const titles = ['Mr.', 'Mrs.', 'Ms.'];

export const colors: Record<TaskPriority, string> = {
High: '#F1BBBC',
Normal: '#F9E2AE',
Low: '#9FD89F',
};

export const states = ['California', 'New York', 'Texas'];

export const positions = [
Expand Down
10 changes: 5 additions & 5 deletions apps/demos/Demos/Chat/PageLevelAIAssistant/React/AiAssistant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { routeMessage } from './chat-router.ts';
import { emptyViewMessage } from './data.ts';
import type { AiAssistantProps, PushMessage } from './data.ts';

const chatStore = new ArrayStore<ChatTypes.Message, number>({ key: 'id' });
const chatDataSource = new DataSource({ store: chatStore, paginate: false });
const chatSuggestionItems = [
{ text: 'Show Completed Tasks', prompt: 'Show Completed Tasks' },
{ text: 'Change State to Texas', prompt: 'Change State to Texas' },
Expand All @@ -35,14 +33,16 @@ export default function AiAssistant({ formRef, gridRef, aiIntegration }: AiAssis
const clearButtonInstance = useRef<ReturnType<ButtonRef['instance']> | null>(null);
const [visible, setVisible] = useState(false);
const [disabled, setDisabled] = useState(false);
const [chatStore] = useState(() => new ArrayStore<ChatTypes.Message, number>({ key: 'id' }));
const [chatDataSource] = useState(() => new DataSource({ store: chatStore, paginate: false }));

const updateClearButtonState = useCallback((): void => {
clearButtonInstance.current?.option('disabled', chatDataSource.items().length === 0);
}, []);
}, [chatDataSource]);

const pushMessage: PushMessage = useCallback((message) => {
chatStore.push([{ type: 'insert', data: { id: Date.now() + Math.random(), timestamp: new Date(), ...message } }]);
}, []);
}, [chatStore]);

const handleUserMessage = useCallback((message: ChatTypes.Message): void => {
const form = formRef.current?.instance();
Expand Down Expand Up @@ -80,7 +80,7 @@ export default function AiAssistant({ formRef, gridRef, aiIntegration }: AiAssis
chatStore.clear();
chatDataSource.reload();
updateClearButtonState();
}, [updateClearButtonState]);
}, [chatStore, chatDataSource, updateClearButtonState]);

const onPopupShowing = useCallback((): void => setVisible(true), []);
const onPopupHiding = useCallback((): void => setVisible(false), []);
Expand Down
2 changes: 1 addition & 1 deletion apps/demos/Demos/Chat/PageLevelAIAssistant/React/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TaskGrid from './TaskGrid.tsx';
import AiAssistant from './AiAssistant.tsx';
import { aiIntegration } from './service.ts';

loadMessages({ en: { 'dxChat-textareaPlaceholder': 'Enter a prompt...' } });
loadMessages({ en: { 'dxChat-textareaPlaceholder': 'Ask AI Assistant...' } });
config({
editorStylingMode: 'filled',
floatingActionButtonConfig: {
Expand Down
2 changes: 1 addition & 1 deletion apps/demos/Demos/Chat/PageLevelAIAssistant/React/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class ChatCommandError extends Error {
}
}

export const emptyViewMessage = 'How can I help with this page?';
export const emptyViewMessage = 'AI Assistant is ready to help you';

export const employee: Employee = {
ID: 1,
Expand Down
27 changes: 15 additions & 12 deletions apps/demos/Demos/Chat/PageLevelAIAssistant/ReactJs/AiAssistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { ArrayStore, DataSource } from 'devextreme-react/common/data';
import { routeMessage } from './chat-router.js';
import { emptyViewMessage } from './data.js';

const chatStore = new ArrayStore({ key: 'id' });
const chatDataSource = new DataSource({ store: chatStore, paginate: false });
const chatSuggestionItems = [
{ text: 'Show Completed Tasks', prompt: 'Show Completed Tasks' },
{ text: 'Change State to Texas', prompt: 'Change State to Texas' },
Expand Down Expand Up @@ -37,17 +35,22 @@ export default function AiAssistant({ formRef, gridRef, aiIntegration }) {
const clearButtonInstance = useRef(null);
const [visible, setVisible] = useState(false);
const [disabled, setDisabled] = useState(false);
const [chatStore] = useState(() => new ArrayStore({ key: 'id' }));
const [chatDataSource] = useState(() => new DataSource({ store: chatStore, paginate: false }));
const updateClearButtonState = useCallback(() => {
clearButtonInstance.current?.option('disabled', chatDataSource.items().length === 0);
}, []);
const pushMessage = useCallback((message) => {
chatStore.push([
{
type: 'insert',
data: { id: Date.now() + Math.random(), timestamp: new Date(), ...message },
},
]);
}, []);
}, [chatDataSource]);
const pushMessage = useCallback(
(message) => {
chatStore.push([
{
type: 'insert',
data: { id: Date.now() + Math.random(), timestamp: new Date(), ...message },
},
]);
},
[chatStore],
);
const handleUserMessage = useCallback(
(message) => {
const form = formRef.current?.instance();
Expand Down Expand Up @@ -93,7 +96,7 @@ export default function AiAssistant({ formRef, gridRef, aiIntegration }) {
chatStore.clear();
chatDataSource.reload();
updateClearButtonState();
}, [updateClearButtonState]);
}, [chatStore, chatDataSource, updateClearButtonState]);
const onPopupShowing = useCallback(() => setVisible(true), []);
const onPopupHiding = useCallback(() => setVisible(false), []);
const onClearButtonInitialized = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion apps/demos/Demos/Chat/PageLevelAIAssistant/ReactJs/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TaskGrid from './TaskGrid.js';
import AiAssistant from './AiAssistant.js';
import { aiIntegration } from './service.js';

loadMessages({ en: { 'dxChat-textareaPlaceholder': 'Enter a prompt...' } });
loadMessages({ en: { 'dxChat-textareaPlaceholder': 'Ask AI Assistant...' } });
config({
editorStylingMode: 'filled',
floatingActionButtonConfig: {
Expand Down
2 changes: 1 addition & 1 deletion apps/demos/Demos/Chat/PageLevelAIAssistant/ReactJs/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ChatCommandError extends Error {
Object.setPrototypeOf(this, ChatCommandError.prototype);
}
}
export const emptyViewMessage = 'How can I help with this page?';
export const emptyViewMessage = 'AI Assistant is ready to help you';
export const employee = {
ID: 1,
Prefix: 'Mr.',
Expand Down
2 changes: 1 addition & 1 deletion apps/demos/Demos/Chat/PageLevelAIAssistant/Vue/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ config({

loadMessages({
en: {
'dxChat-textareaPlaceholder': 'Enter a prompt...',
'dxChat-textareaPlaceholder': 'Ask AI Assistant...',
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div
id="form-container"
class="form-container"
>
<DxForm
ref="formRef"
Expand Down
19 changes: 15 additions & 4 deletions apps/demos/Demos/Chat/PageLevelAIAssistant/Vue/TaskGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
/>
<template #priority-cell="{ data }">
<div
class="priority-badge"
:style="{ background: colors[data.value as TaskPriority] }"
:class="['priority-badge', `priority-badge--${data.value.toLowerCase()}`]"
>{{ data.value }}</div>
</template>
<DxColumn
Expand All @@ -49,8 +48,8 @@
<script setup lang="ts">
import { ref } from 'vue';
import { DxDataGrid, DxColumn, DxFilterRow, DxHeaderFilter } from 'devextreme-vue/data-grid';
import { colors, tasks } from './data.ts';
import type { ColumnFilterExpression, Task, TaskPriority } from './data.ts';
import { tasks } from './data.ts';
import type { ColumnFilterExpression, Task } from './data.ts';

const dataGridRef = ref<InstanceType<typeof DxDataGrid>>();

Expand Down Expand Up @@ -91,4 +90,16 @@ defineExpose({
display: inline-block;
text-align: center;
}

.priority-badge--high {
background: #f1bbbc;
}

.priority-badge--normal {
background: #f9e2ae;
}

.priority-badge--low {
background: #9fd89f;
}
</style>
8 changes: 1 addition & 7 deletions apps/demos/Demos/Chat/PageLevelAIAssistant/Vue/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const AI_SERVICE_CONFIG = {
export const MAX_PROMPT_SIZE = 20000;
export const RATE_LIMIT_RETRY_DELAY_MS = 30000;

export const EMPTY_VIEW_MESSAGE = 'How can I help with this page?';
export const EMPTY_VIEW_MESSAGE = 'AI Assistant is ready to help you';

export const EMPTY_VIEW_PROMPT = 'Update employee <b>Form</b> fields.\nFilter or sort tasks, display or hide <b>DataGrid</b> columns, or clear all filters and sorting.';

Expand All @@ -154,12 +154,6 @@ export const FORM_ACTION_TYPES = new Set<FormActionType>(['clear_field', 'clear_

export const titles = ['Mr.', 'Mrs.', 'Ms.'];

export const colors: Record<TaskPriority, string> = {
High: '#F1BBBC',
Normal: '#F9E2AE',
Low: '#9FD89F',
};

export const states = ['California', 'New York', 'Texas'];

export const positions = [
Expand Down
Loading
Loading