Skip to content

Commit

Permalink
Merge pull request #18 from xpert-ai/develop
Browse files Browse the repository at this point in the history
Version 3.0.9
  • Loading branch information
tiven-w authored Jan 2, 2025
2 parents cf468a4 + edf1539 commit d0fcc37
Show file tree
Hide file tree
Showing 130 changed files with 2,178 additions and 1,559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<ul>
@for (variable of variables(); track variable.name) {
<li cdkMenuItem class="max-w-sm space-x-2 truncate" (click)="selectVariable(variable)">
{{ variable.name }} <span class="px-1 text-sm rounded-md bg-gray-50 text-primary-300">{{variable.type}}</span> <span class="text-sm italic">{{variable.description}}</span>
{{ variable.name }} <span class="px-1 text-sm rounded-md bg-gray-50 text-primary-300">{{variable.type}}</span> <span class="text-sm italic">{{variable.description | i18n}}</span>
</li>
}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
input,
model,
numberAttribute,
signal,
TemplateRef,
ViewChild,
ViewContainerRef
Expand All @@ -23,6 +22,7 @@ import { MatDialog } from '@angular/material/dialog'
import { MatTooltipModule } from '@angular/material/tooltip'
import { NgmHighlightVarDirective } from '@metad/ocap-angular/common'
import { TranslateModule } from '@ngx-translate/core'
import { NgmI18nPipe } from '@metad/ocap-angular/core'
import { CopilotPromptGeneratorComponent } from '../prompt-generator/generator.component'
import { TStateVariable } from '../../../@core'

Expand All @@ -32,7 +32,7 @@ import { TStateVariable } from '../../../@core'
styleUrls: ['./editor.component.scss'],
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [CommonModule, CdkMenuModule, FormsModule, TranslateModule, MatTooltipModule, NgmHighlightVarDirective]
imports: [CommonModule, CdkMenuModule, FormsModule, TranslateModule, MatTooltipModule, NgmI18nPipe, NgmHighlightVarDirective]
})
export class CopilotPromptEditorComponent {
readonly #dialog = inject(MatDialog)
Expand Down Expand Up @@ -82,9 +82,6 @@ export class CopilotPromptEditorComponent {
}

onPromptChange(editor: HTMLDivElement) {
// console.log(editor.children)
// console.log(editor.innerHTML)
// console.log(formatInnerHTML(editor.innerHTML))
this.prompt.set(formatInnerHTML(editor.innerHTML))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="ngm-theme-dark dark w-[300px] shrink-0 flex flex-col justify-start overflow-auto bg-bluegray-700 text-white p-4 group">
<div class="w-full flex justify-start items-center mb-4" cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
<div class="w-full flex justify-start items-center mb-4 cursor-move" cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
<span class="text-lg pointer-events-none">
{{ 'PAC.Xpert.PublishThirdPlatforms' | translate: { Default: 'Publish to third-party platforms' } }}
</span>
Expand Down Expand Up @@ -49,7 +49,7 @@
</ng-template>

<div class="grow relative flex flex-col w-[600px] overflow-auto">
<div class="!border-b-black/5 shrink-0 border-b border-b-gray-100 py-4 sticky top-0 z-10 bg-slate-50"
<div class="!border-b-black/5 shrink-0 border-b border-b-gray-100 py-4 sticky top-0 z-10 bg-slate-50 cursor-move"
cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
<div class="flex justify-between items-center pl-6 pr-5 h-6">
<div>{{ 'PAC.Xpert.PublishTo' | translate: { Default: 'Publish to ' } }} {{integration()?.provider || '?'}}</div>
Expand Down
12 changes: 4 additions & 8 deletions apps/cloud/src/app/@theme/header/user/user.component.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<button
class="inline-flex items-center rounded-3xl py-1 pr-2.5 pl-1 text-sm text-gray-700 hover:bg-gray-200 mobile:px-1"
type="button"
<button type="button" class="inline-flex items-center rounded-3xl py-1 pr-2.5 pl-1 text-sm text-gray-700 hover:bg-gray-200 mobile:px-1"
[cdkMenuTriggerFor]="menu"
>

@if (user().imageUrl) {
<div class="w-8 h-8 rounded-full overflow-hidden flex items-center">
<img class="avatar h-auto w-full" [src]="user().imageUrl || '/assets/images/avatar-default.svg'" />
</div>
} @else {
<div class="shrink-0 flex items-center rounded-full bg-primary-600 sm:mr-2 mr-0"
style="width: 32px; height: 32px; font-size: 32px; line-height: 32px"
<div class="hidden sm:flex shrink-0 items-center rounded-full bg-primary-600 sm:mr-2 mr-0"
style="width: 32px; height: 32px; font-size: 32px; line-height: 32px"
>
<div
class="text-center text-white scale-[0.4]"
<div class="text-center text-white scale-[0.4]"
style="width: 32px; height: 32px; font-size: 32px; line-height: 32px"
>
{{firstLetter()}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@
/>
}

<!-- @if (['thinking', 'answering'].includes(message().status) && answering()) {
<pac-chat-loading />
} -->

<div class="absolute left-0 bottom-2 flex justify-end gap-1">
<div class="absolute left-0 bottom-2 flex justify-end items-center gap-1">
<div class="hidden group-hover:block p-0.5 rounded-lg bg-white border-[0.5px] border-gray-100 shadow-sm shrink-0">
<div class="shrink-0 w-6 h-6 p-1 flex items-center justify-center rounded-md font-medium pressable
bg-components-card-bg text-gray-500 hover:bg-gray-50 cursor-pointer hover:text-gray-700"
Expand All @@ -170,15 +166,15 @@

@if (getFeedback(message().id); as feedback) {
@if (feedback.rating === eFeedbackRatingEnum.LIKE) {
<div class="flex items-center justify-center m-1 w-6 h-6 rounded-md cursor-pointer bg-primary-100 text-primary-500 hover:bg-primary-100 hover:text-primary-600"
<div class="flex items-center justify-center mx-1 w-6 h-6 rounded-md cursor-pointer bg-primary-100 text-primary-500 hover:bg-primary-100 hover:text-primary-600"
[matTooltip]="'PAC.KEY_WORDS.CancelLike' | translate: {Default: 'Cancel like'}"
matTooltipPosition="above"
(click)="cancelFeedback(message(), feedback.id)"
>
<i class="ri-thumb-up-line"></i>
</div>
} @else if (feedback.rating === eFeedbackRatingEnum.DISLIKE) {
<div class="flex items-center justify-center m-1 w-6 h-6 rounded-md cursor-pointer bg-red-100 text-red-500 hover:bg-red-200 hover:text-red-600"
<div class="flex items-center justify-center mx-1 w-6 h-6 rounded-md cursor-pointer bg-red-100 text-red-500 hover:bg-red-200 hover:text-red-600"
[matTooltip]="'PAC.KEY_WORDS.CancelDislike' | translate: {Default: 'Cancel dislike'}"
matTooltipPosition="above"
(click)="cancelFeedback(message(), feedback.id)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:host {
@apply relative w-full flex flex-col items-stretch lg:w-[800px] max-w-full pt-4 lg:pt-8;
@apply w-full flex flex-col items-stretch lg:w-[800px] max-w-full pt-4 lg:pt-8;
}

// Copilot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ export class ChatInputComponent {

if (event.key === 'Enter') {
event.preventDefault()
setTimeout(() => {
this.ask(this.prompt().trim())
})
const text = this.prompt()?.trim()
if (text) {
setTimeout(() => {
this.ask(text)
})
}
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,6 @@
}
}
@case ('Indicators') {
<div class="dark flex flex-col items-stretch">
@for (indicator of indicators(); track indicator.indicator) {
<ngm-indicator class="indicator min-h-[75px] border-t border-solid dark:border-neutral-800 border-transparent bg-components-card-bg p-4 cursor-pointer hover:bg-components-panel-bg first:rounded-t-xl last:rounded-b-xl"
[class.active]="indicatorExplorer() === indicator.indicator"
[dataSettings]="indicator" [indicatorCode]="indicator.indicator"
[lookBack]="12"
[timeGranularity]="eTimeGranularity.Month"
[tagType]="indicatorTagType()"
(click)="toggleIndicator(indicator.indicator)"
(toggleTag)="toggleIndicatorTagType()"
/>
@if (indicatorExplorer() === indicator.indicator) {
<ngm-indicator-explorer class="ngm-indicator-explorer last:rounded-b-xl"
[dataSettings]="indicator"
[indicatorCode]="indicator.indicator"
[lookBack]="12"
periodName="6M"
[primaryTheme]="'dark'"
/>
}
}
</div>
<pac-chat-component-indicators [indicators]="indicators()" class="dark"/>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ import { RouterModule } from '@angular/router'
import { AnalyticalCardModule } from '@metad/ocap-angular/analytical-card'
import { NgmCommonModule } from '@metad/ocap-angular/common'
import { NgmDSCoreService } from '@metad/ocap-angular/core'
import { NgmIndicatorComponent, NgmIndicatorExplorerComponent } from '@metad/ocap-angular/indicator'
import { NgmIndicatorComponent } from '@metad/ocap-angular/indicator'
import { NgmSelectionModule, SlicersCapacity } from '@metad/ocap-angular/selection'
import { DataSettings, Indicator, IndicatorTagEnum, TimeGranularity } from '@metad/ocap-core'
import { DataSettings, Indicator, TimeGranularity } from '@metad/ocap-core'
import { StoryExplorerComponent } from '@metad/story'
import { ExplainComponent } from '@metad/story/story'
import { NxWidgetKpiComponent } from '@metad/story/widgets/kpi'
import { TranslateModule } from '@ngx-translate/core'
import { compact, uniq } from 'lodash-es'
import { MarkdownModule } from 'ngx-markdown'
import { Store } from '../../../@core'
import { ChatComponentIndicatorsComponent } from './indicators/indicators.component'

@Component({
standalone: true,
Expand All @@ -49,7 +50,7 @@ import { Store } from '../../../@core'
AnalyticalCardModule,
NxWidgetKpiComponent,
NgmIndicatorComponent,
NgmIndicatorExplorerComponent
ChatComponentIndicatorsComponent
],
selector: 'pac-chat-component-message',
templateUrl: './component-message.component.html',
Expand All @@ -69,7 +70,7 @@ export class ChatComponentMessageComponent {
readonly message = input<any>()

// Outputs
readonly register = output<{id: string; indicators?: Indicator[]}[]>()
readonly register = output<{ id: string; indicators?: Indicator[] }[]>()

// States
readonly data = computed(() => this.message()?.data as any)
Expand All @@ -92,18 +93,16 @@ export class ChatComponentMessageComponent {

readonly explains = signal<any[]>([])

readonly indicatorExplorer = signal<string>(null)
readonly indicatorTagType = signal<IndicatorTagEnum>(IndicatorTagEnum.MOM)

constructor() {
effect(
() => {
if (this.dataSource()) {
this.register.emit([{
id: this.dataSource(),
indicators: this.indicators()
}])
// this.homeComponent.registerSemanticModel(this.dataSource())
this.register.emit([
{
id: this.dataSource(),
indicators: this.indicators()
}
])
}
},
{ allowSignalWrites: true }
Expand All @@ -112,10 +111,7 @@ export class ChatComponentMessageComponent {
effect(
() => {
if (this.dataSources()) {
this.register.emit(this.dataSources().map((id) => ({id})))
// this.dataSources().forEach((dataSource) => {
// this.homeComponent.registerSemanticModel(dataSource)
// })
this.register.emit(this.dataSources().map((id) => ({ id })))
}
},
{ allowSignalWrites: true }
Expand All @@ -136,20 +132,6 @@ export class ChatComponentMessageComponent {
})
}

toggleIndicatorTagType() {
this.indicatorTagType.update((tagType) => {
if (IndicatorTagEnum[tagType + 1]) {
return tagType + 1
} else {
return IndicatorTagEnum[IndicatorTagEnum[0]] // Ensure to start from 0
}
})
}

toggleIndicator(indicator: string) {
this.indicatorExplorer.update((state) => state === indicator ? null : indicator)
}

openExplorer() {
this.#dialog
.open(StoryExplorerComponent, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@for (indicator of showIndicators(); track indicator.indicator; let last = $last) {
<ngm-indicator class="indicator min-h-[75px] border-t border-solid dark:border-neutral-800 border-transparent bg-components-card-bg p-4 cursor-pointer hover:bg-components-panel-bg first:rounded-t-xl"
[class.active]="indicatorExplorer() === indicator.indicator"
[class.last]="last"
[class.has-more]="hasMore()"
[dataSettings]="indicator"
[indicatorCode]="indicator.indicator"
[lookBack]="12"
[timeGranularity]="eTimeGranularity.Month"
[tagType]="indicatorTagType()"
(click)="toggleIndicator(indicator.indicator)"
(toggleTag)="toggleIndicatorTagType()"
/>
@if (indicatorExplorer() === indicator.indicator) {
<ngm-indicator-explorer class="ngm-indicator-explorer last:rounded-b-xl"
[dataSettings]="indicator"
[indicatorCode]="indicator.indicator"
[lookBack]="12"
periodName="6M"
[primaryTheme]="'dark'"
/>
}
}

@if (indicators()?.length > pageSize()) {
<div class="flex justify-center gap-1">
@if (hasMore()) {
<button type="button" class="btn pressable justify-center" [matTooltip]="'PAC.Chat.ShowMoreIndicators' | translate: {Default: 'Show more indicators'}"
(click)="showMore()">
<i class="ri-arrow-down-wide-line"></i>
</button>
}
@if (showIndicators()?.length > pageSize()) {
<button type="button" class="btn pressable justify-center" [matTooltip]="'PAC.Chat.ShowLessIndicators' | translate: {Default: 'Show less indicators'}"
(click)="showLess()">
<i class="ri-arrow-up-wide-line"></i>
</button>
}
</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:host {
@apply flex flex-col items-stretch;
}

.indicator.last:not(.has-more):not(.active) {
@apply rounded-b-xl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { DragDropModule } from '@angular/cdk/drag-drop'
import { CdkMenuModule } from '@angular/cdk/menu'
import { CommonModule } from '@angular/common'
import { ChangeDetectionStrategy, Component, computed, input, signal } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { MatTooltipModule } from '@angular/material/tooltip'
import { RouterModule } from '@angular/router'
import { NgmIndicatorComponent, NgmIndicatorExplorerComponent } from '@metad/ocap-angular/indicator'
import { DataSettings, IndicatorTagEnum, TimeGranularity } from '@metad/ocap-core'
import { TranslateModule } from '@ngx-translate/core'

@Component({
standalone: true,
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
DragDropModule,
CdkMenuModule,
RouterModule,
TranslateModule,
MatTooltipModule,

NgmIndicatorComponent,
NgmIndicatorExplorerComponent
],
selector: 'pac-chat-component-indicators',
templateUrl: './indicators.component.html',
styleUrl: 'indicators.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ChatComponentIndicatorsComponent {
eTimeGranularity = TimeGranularity

// Inputs
readonly indicators = input<Array<DataSettings & { indicator: string }>>()

// States
readonly pageSize = signal(5)
readonly pageNo = signal(0)

readonly showIndicators = computed(() => {
return this.indicators()?.slice(0, (this.pageNo() + 1) * this.pageSize())
})

readonly hasMore = computed(() => this.indicators().length > (this.pageNo() + 1) * this.pageSize())

readonly indicatorExplorer = signal<string>(null)
readonly indicatorTagType = signal<IndicatorTagEnum>(IndicatorTagEnum.MOM)

toggleIndicatorTagType() {
this.indicatorTagType.update((tagType) => {
if (IndicatorTagEnum[tagType + 1]) {
return tagType + 1
} else {
return IndicatorTagEnum[IndicatorTagEnum[0]] // Ensure to start from 0
}
})
}

toggleIndicator(indicator: string) {
this.indicatorExplorer.update((state) => (state === indicator ? null : indicator))
}

showMore() {
this.pageNo.update((currentPage) => currentPage + 1)
}

showLess() {
this.pageNo.update((currentPage) => currentPage - 1)
}
}
Loading

0 comments on commit d0fcc37

Please sign in to comment.