Skip to content

Commit

Permalink
Merge pull request #55 from meta-d/develop
Browse files Browse the repository at this point in the history
v2.7.1
  • Loading branch information
meta-d authored Oct 9, 2024
2 parents cd73702 + aba24d5 commit 0f76a65
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 37 deletions.
4 changes: 2 additions & 2 deletions apps/cloud/src/app/@core/services/toastr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { NgmConfirmSnackBar } from '@metad/ocap-angular/common'
export class ToastrService {
constructor(private readonly _snackBar: MatSnackBar, private readonly translateService: TranslateService) {}

success(message: any, translationParams: Object = {}, title?: string) {
success(message: any, translationParams: Object = {}, title?: string, titleParams?: Object) {
let displayMessage = ''

if (message && message.message && typeof message.message === 'string') {
Expand All @@ -24,7 +24,7 @@ export class ToastrService {

return this._snackBar.open(
this.getTranslation(displayMessage, translationParams),
this.getTranslation(title || 'PAC.TOASTR.TITLE.SUCCESS'),
this.getTranslation(title || 'PAC.TOASTR.TITLE.SUCCESS', titleParams),
{ duration: 2000 }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,38 @@
<ngm-analytical-card [title]="data().title"
[dataSettings]="data().dataSettings"
[chartSettings]="chartSettings()"
[slicers]="data().slicers"
/>
[slicers]="slicers()"
>
<button mat-icon-button ngmAction displayDensity="cosy" class="ngm-menu-trigger"
[color]="slicers() ? 'accent':''"
[matMenuTriggerFor]="filtersMenu"
#mt="matMenuTrigger"
[class.active]="mt.menuOpen"
>
<mat-icon fontSet="material-icons-outlined">filter_alt</mat-icon>
</button>
</ngm-analytical-card>

<mat-menu #filtersMenu="matMenu" class="pac-widget__slicer-menu">
<div class="text-base font-semibold">{{ 'PAC.ChatBI.Slicers' | translate: {Default: "Slicers"} }}</div>
<ngm-slicers class="overflow-hidden" inline editable
[slicers]="slicers()"
[dataSettings]="data().dataSettings"
[limit]="5"
[capacities]="[
SlicersCapacity.Variable,
SlicersCapacity.CombinationSlicer,
SlicersCapacity.AdvancedSlicer
]"
(valueChange)="updateSlicers($event)"
(click)="$event.stopPropagation()"
/>
</mat-menu>
}
@case ('KPI') {
<pac-widget-kpi displayDensity="compact" [title]="data().title"
[dataSettings]="data().dataSettings"
[slicers]="data().slicers"
[slicers]="slicers()"
[options]="{
showToolbar: true,
shortNumber: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { DragDropModule } from '@angular/cdk/drag-drop'
import { CommonModule } from '@angular/common'
import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'
import { ChangeDetectionStrategy, Component, computed, inject, input, model } from '@angular/core'
import { toSignal } from '@angular/core/rxjs-interop'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
import { CopilotChatMessage } from '@metad/copilot'
import { AnalyticalCardModule } from '@metad/ocap-angular/analytical-card'
import { NgmCommonModule } from '@metad/ocap-angular/common'
import { NgmSelectionModule, SlicersCapacity } from '@metad/ocap-angular/selection'
import { ISlicer } from '@metad/ocap-core'
import { NxWidgetKpiComponent } from '@metad/story/widgets/kpi'
import { TranslateModule } from '@ngx-translate/core'
import { MarkdownModule } from 'ngx-markdown'
Expand All @@ -32,6 +34,7 @@ import { ChatService } from '../chat.service'
AvatarComponent,
ChatLoadingComponent,
AnalyticalCardModule,
NgmSelectionModule,
NxWidgetKpiComponent
],
selector: 'pac-chat-component-message',
Expand All @@ -40,12 +43,18 @@ import { ChatService } from '../chat.service'
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ChatComponentMessageComponent {
SlicersCapacity = SlicersCapacity

readonly #store = inject(Store)
readonly chatService = inject(ChatService)

readonly message = input<CopilotChatMessage>()

readonly data = computed(() => this.message()?.data as any)
readonly _slicers = model<ISlicer[]>([])
readonly slicers = computed(() =>
this._slicers() ?? this.data()?.slicers
)

readonly primaryTheme = toSignal(this.#store.primaryTheme$)

Expand All @@ -55,4 +64,8 @@ export class ChatComponentMessageComponent {
theme: this.primaryTheme()
}
})

updateSlicers(slicers: ISlicer[]) {
this._slicers.set(slicers)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '../../../@core'
import { AvatarComponent, MaterialModule, TranslationBaseComponent, UserProfileInlineComponent } from '../../../@shared'


@Component({
standalone: true,
selector: 'pac-settings-knowledgebases',
Expand All @@ -40,7 +41,7 @@ export class KnowledgebaseHomeComponent extends TranslationBaseComponent {
KnowledgebasePermission = KnowledgebasePermission

readonly knowledgebaseService = inject(KnowledgebaseService)
readonly _toastrService = inject(ToastrService)
readonly #toastr = inject(ToastrService)
readonly #store = inject(Store)
readonly #router = inject(Router)
readonly #route = inject(ActivatedRoute)
Expand Down Expand Up @@ -88,10 +89,10 @@ export class KnowledgebaseHomeComponent extends TranslationBaseComponent {
.subscribe({
next: (result) => {
this.refresh()
this._toastrService.success('Created knowledgebase', 'Success')
this.#toastr.success('PAC.Messages.CreatedSuccessfully', {}, 'PAC.KEY_WORDS.Knowledgebase', {Default: 'Knowledgebase'})
},
error: (error) => {
this._toastrService.error(error, 'Error')
this.#toastr.error(error, 'Error')
}
})
}
Expand All @@ -115,10 +116,10 @@ export class KnowledgebaseHomeComponent extends TranslationBaseComponent {
.subscribe({
next: () => {
this.refresh()
this._toastrService.success('PAC.Messages.DeletedSuccessfully', 'Deleted Successfully')
this.#toastr.success('PAC.Messages.DeletedSuccessfully', {Default: 'Deleted Successfully'})
},
error: (error) => {
this._toastrService.error(getErrorMessage(error), 'Error')
this.#toastr.error(getErrorMessage(error), 'Error')
}
})
}
Expand Down
1 change: 1 addition & 0 deletions apps/cloud/src/assets/i18n/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"Secondary": "",
"Embedding": "嵌入",
"Open": "打开",
"Knowledgebase": "知识库",
"Knowledgebases": "知识库",
"Empty": "无数据",
"Toolset": "工具集",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/adapter",
"version": "2.7.0",
"version": "2.7.1",
"dependencies": {
"@sap/hana-client": "^2.20.20",
"axios": "^0.21.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/analytics",
"version": "2.7.0",
"version": "2.7.1",
"type": "commonjs",
"license": "MIT",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ ${createAgentStepsInstructions(
*/
createCubeContextTool(context: CopilotToolContext, dsCoreService: DSCoreService) {
// Maximum waiting time of tool call
const { toolMaximumWaitTime = DefaultToolMaximumWaitTime } = context.roleContext
const { toolMaximumWaitTime = DefaultToolMaximumWaitTime } = context.roleContext ?? {}
return tool(
async ({ cubes }): Promise<string> => {
this.logger.debug(`Tool 'getCubeContext' params:`, JSON.stringify(cubes))
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/ocap-angular",
"version": "2.7.0",
"version": "2.7.1",
"keywords": [
"metad",
"ocap",
Expand All @@ -20,7 +20,7 @@
"@angular/core": "^17.0.0",
"@angular/material": "^17.0.0",
"@angular/material-date-fns-adapter": "^17.0.0",
"@metad/ocap-core": "^2.3.0",
"@metad/ocap-core": "^2.7.0",
"@ngx-translate/core": "^15.0.0",
"langchain": "0.2.10",
"lodash-es": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/server-auth",
"version": "2.7.0",
"version": "2.7.1",
"type": "commonjs",
"dependencies": {
"@nestjs/common": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/server-common",
"version": "2.7.0",
"version": "2.7.1",
"type": "commonjs",
"dependencies": {
"@nestjs/typeorm": "^8.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/server-config",
"version": "2.7.0",
"version": "2.7.1",
"type": "commonjs",
"dependencies": {
"@nestjs/common": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/copilot-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/copilot-angular",
"version": "2.7.0",
"version": "2.7.1",
"peerDependencies": {
"@angular/common": "^17.3.0",
"@angular/core": "^17.3.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/copilot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/copilot",
"version": "2.7.0",
"version": "2.7.1",
"peerDependencies": {
"nanoid": "^4.0.2",
"ollama": "^0.5.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/ocap-core",
"version": "2.7.0",
"version": "2.7.1",
"dependencies": {
"tslib": "^2.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/duckdb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/ocap-duckdb",
"version": "2.7.0",
"version": "2.7.1",
"keywords": [
"metad",
"ocap",
Expand Down
2 changes: 1 addition & 1 deletion packages/echarts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/ocap-echarts",
"version": "2.7.0",
"version": "2.7.1",
"keywords": [
"metad",
"ocap",
Expand Down
2 changes: 1 addition & 1 deletion packages/server-ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/server-ai",
"version": "2.7.0",
"version": "2.7.1",
"type": "commonjs",
"dependencies": {
"@langchain/anthropic": "0.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/server-core",
"version": "2.7.0",
"version": "2.7.1",
"type": "commonjs",
"dependencies": {
"@casl/ability": "^5.4.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IsString, IsNotEmpty } from 'class-validator';
import { TenantOrganizationBaseEntity, User } from '../core/entities/internal';

@Entity('user_organization')
@Index(['tenantId', 'organizationId', 'userId'], {unique: true})
export class UserOrganization
extends TenantOrganizationBaseEntity
implements IUserOrganization {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { IUser, IUserOrganization, RolesEnum } from '@metad/contracts';
import { IOrganization, IUser, IUserOrganization, RolesEnum } from '@metad/contracts';
import { TenantAwareCrudService } from './../core/crud';
import { Organization, User, UserOrganization } from './../core/entities/internal';
import { Organization, UserOrganization } from './../core/entities/internal';

@Injectable()
export class UserOrganizationService extends TenantAwareCrudService<UserOrganization> {
Expand All @@ -17,20 +17,27 @@ export class UserOrganizationService extends TenantAwareCrudService<UserOrganiza
super(userOrganizationRepository);
}

/**
* Adds a user to all organizations within a specific tenant.
*
* @param userId The unique identifier of the user to be added to the organizations.
* @param tenantId The unique identifier of the tenant whose organizations the user will be added to.
* @returns A promise that resolves to an array of IUserOrganization, where each element represents the user's association with an organization in the tenant.
*/
async addUserToOrganization(
user: IUser,
organizationId: string
organizationId: IOrganization['id']
): Promise<IUserOrganization | IUserOrganization[]> {
const roleName: string = user.role.name;

if (roleName === RolesEnum.SUPER_ADMIN)
return this._addUserToAllOrganizations(user.id, user.tenant.id);
/** If role is SUPER_ADMIN, add user to all organizations in the tenant */
if (user.role.name === RolesEnum.SUPER_ADMIN) {
return await this._addUserToAllOrganizations(user.id, user.tenantId);
}

const entity: IUserOrganization = new UserOrganization();
entity.organizationId = organizationId;
entity.tenantId = user.tenantId;
entity.userId = user.id;
return await this.create(entity);
return await this.repository.save(entity)
}

private async _addUserToAllOrganizations(
Expand Down
2 changes: 1 addition & 1 deletion packages/sql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/ocap-sql",
"version": "2.7.0",
"version": "2.7.1",
"keywords": [
"metad",
"ocap",
Expand Down
2 changes: 1 addition & 1 deletion packages/store/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/store",
"version": "2.7.0",
"version": "2.7.1",
"keywords": [
"metad",
"ocap",
Expand Down
2 changes: 1 addition & 1 deletion packages/xmla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metad/ocap-xmla",
"version": "2.7.0",
"version": "2.7.1",
"scripts": {
"docs": "yarn typedoc"
},
Expand Down

0 comments on commit 0f76a65

Please sign in to comment.