diff --git a/apps/cloud/src/app/@core/services/toastr.service.ts b/apps/cloud/src/app/@core/services/toastr.service.ts
index efece2a6a..e84bfa92b 100644
--- a/apps/cloud/src/app/@core/services/toastr.service.ts
+++ b/apps/cloud/src/app/@core/services/toastr.service.ts
@@ -5,6 +5,7 @@ import { TranslateService } from '@ngx-translate/core'
import { ConfirmSnackBar } from '@metad/components/confirm'
import { catchError, EMPTY, map, merge, Observable, take, takeUntil, tap } from 'rxjs'
import { SnackProcessingComponent } from '../../@theme/snack/processing'
+import { getErrorMessage } from '../types'
@Injectable({
providedIn: 'root'
@@ -46,19 +47,18 @@ export class ToastrService {
}
danger(error: any, title: string = 'PAC.TOASTR.TITLE.ERROR', translationParams: Object = {}) {
- let displayMessage = ''
-
- if (error instanceof HttpErrorResponse && typeof error.error.message === 'string') {
- displayMessage = error.error.message
- }
- // 等同于 HttpErrorResponse ?
- else if (error.error && error.error.message && typeof error.error.message === 'string') {
- displayMessage = error.error.message
- } else if (error.message && typeof error.message === 'string') {
- displayMessage = error.message
- } else {
- displayMessage = error
- }
+ const displayMessage = getErrorMessage(error)
+ // if (error instanceof HttpErrorResponse && typeof error.error.message === 'string') {
+ // displayMessage = error.error.message
+ // }
+ // // 等同于 HttpErrorResponse ?
+ // else if (error.error && error.error.message && typeof error.error.message === 'string') {
+ // displayMessage = error.error.message
+ // } else if (error.message && typeof error.message === 'string') {
+ // displayMessage = error.message
+ // } else {
+ // displayMessage = error
+ // }
this._snackBar.open(
this.getTranslation(displayMessage, translationParams),
diff --git a/apps/cloud/src/app/@core/types.ts b/apps/cloud/src/app/@core/types.ts
index 250fef122..91c90e5a5 100644
--- a/apps/cloud/src/app/@core/types.ts
+++ b/apps/cloud/src/app/@core/types.ts
@@ -1,6 +1,5 @@
import { HttpErrorResponse } from '@angular/common/http'
-import { IProject, ISubscription, IUser } from '@metad/contracts'
-import { StorySubscription } from '@metad/story/core'
+import { IProject, IUser } from '@metad/contracts'
import { enUS, zhCN } from 'date-fns/locale'
import ShortUniqueId from 'short-unique-id'
export * from '@metad/contracts'
@@ -62,10 +61,6 @@ export enum MenuCatalog {
IndicatorApp
}
-export function convertStorySubscriptionResult(result: ISubscription): StorySubscription {
- return result
-}
-
export function getErrorMessage(err: any): string {
let error: string
if (typeof err === 'string') {
@@ -81,6 +76,11 @@ export function getErrorMessage(err: any): string {
error = JSON.stringify(err)
}
+ // Stringify error object
+ if (error && typeof error !== 'string') {
+ error = JSON.stringify(error)
+ }
+
return error
}
diff --git a/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.html b/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.html
index 7c8de8f18..ab41f4cd4 100644
--- a/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.html
+++ b/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.html
@@ -1,4 +1,6 @@
-
-
+
+
\ No newline at end of file
diff --git a/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.ts b/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.ts
index e32a81559..098685cd5 100644
--- a/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.ts
+++ b/apps/cloud/src/app/@shared/user/forms/basic-info/basic-info-form.component.ts
@@ -1,4 +1,4 @@
-import { Component, ElementRef, forwardRef, Input, ViewChild } from '@angular/core'
+import { Component, ElementRef, forwardRef, inject, Input, ViewChild } from '@angular/core'
import { ControlValueAccessor, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'
import { ITag, IUser } from '@metad/contracts'
import { FormlyFieldConfig } from '@ngx-formly/core'
@@ -7,6 +7,7 @@ import { firstValueFrom, map } from 'rxjs'
import { LANGUAGES, MatchValidator, RoleService, Store } from '../../../../@core'
import { TranslationBaseComponent } from '../../../language/translation-base.component'
+
@Component({
selector: 'pac-user-basic-info-form',
templateUrl: 'basic-info-form.component.html',
@@ -20,6 +21,10 @@ import { TranslationBaseComponent } from '../../../language/translation-base.com
]
})
export class BasicInfoFormComponent extends TranslationBaseComponent implements ControlValueAccessor {
+ readonly #store = inject(Store)
+ readonly #roleService = inject(RoleService)
+ readonly #authService = inject(AuthService)
+
UPLOADER_PLACEHOLDER = 'FORM.PLACEHOLDERS.UPLOADER_PLACEHOLDER'
@ViewChild('imagePreview')
@@ -33,7 +38,7 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
@Input() public createdById: string
@Input() public selectedTags: ITag[]
- private readonly roles$ = this.roleService.getAll().pipe(map(({ items }) => items))
+ readonly roles$ = this.#roleService.getAll().pipe(map(({ items }) => items))
//Fields for the form
public form = new FormGroup({})
@@ -41,13 +46,6 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
fields: FormlyFieldConfig[] = []
onChange: (value: any) => any
- constructor(
- private readonly store: Store,
- private readonly roleService: RoleService,
- private readonly authService: AuthService,
- ) {
- super()
- }
writeValue(obj: any): void {
if (obj) {
@@ -165,7 +163,7 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
}
],
validators: {
- validation: this.password ? [ MatchValidator.mustMatch('password', 'repeatPassword') ] : []
+ validation: this.password ? [ MatchValidator.mustMatch('password', 'confirmPassword') ] : []
}
},
{
@@ -187,14 +185,14 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
async registerUser(organizationId?: string, createdById?: string) {
if (this.form.valid) {
- const { tenant } = this.store.user
+ const { tenant } = this.#store.user
const user: IUser = {
...this.model,
tenantId: tenant.id
}
return await firstValueFrom(
- this.authService.register({
+ this.#authService.register({
user,
password: this.model.password,
confirmPassword: this.model.confirmPassword,
diff --git a/apps/cloud/src/app/@shared/user/forms/index.ts b/apps/cloud/src/app/@shared/user/forms/index.ts
index 1d8a8be27..19bf1afff 100644
--- a/apps/cloud/src/app/@shared/user/forms/index.ts
+++ b/apps/cloud/src/app/@shared/user/forms/index.ts
@@ -4,4 +4,4 @@ export { BasicInfoFormComponent } from './basic-info/basic-info-form.component'
export const COMPONENTS = [BasicInfoFormComponent]
-export * from './user-forms.module'
+export * from './user-forms.module'
\ No newline at end of file
diff --git a/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.html b/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.html
index 6320d76f6..b3f800f6f 100644
--- a/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.html
+++ b/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.html
@@ -7,14 +7,16 @@
-
diff --git a/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.ts b/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.ts
index bd1efee69..25fb1e5e1 100644
--- a/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.ts
+++ b/apps/cloud/src/app/features/setting/users/user-basic/user-basic.component.ts
@@ -1,9 +1,9 @@
-import { Component, Input, OnInit, effect } from '@angular/core'
+import { Component, Input, OnInit, ViewChild, effect } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { UsersService } from '@metad/cloud/state'
import { IUserUpdateInput, LanguagesEnum } from '@metad/contracts'
import { NgmCommonModule } from '@metad/ocap-angular/common'
-import { UserFormsModule } from 'apps/cloud/src/app/@shared/user/forms'
+import { BasicInfoFormComponent, UserFormsModule } from 'apps/cloud/src/app/@shared/user/forms'
import { ToastrService, User } from '../../../../@core'
import { CreatedByPipe, MaterialModule, SharedModule, TranslationBaseComponent } from '../../../../@shared'
import { PACEditUserComponent } from '../edit-user/edit-user.component'
@@ -27,6 +27,8 @@ import { PACEditUserComponent } from '../edit-user/edit-user.component'
export class UserBasicComponent extends TranslationBaseComponent implements OnInit {
@Input() allowRoleChange: boolean
+ @ViewChild('userBasicInfo') userBasicInfo: BasicInfoFormComponent
+
user: User
constructor(
private readonly userComponent: PACEditUserComponent,
@@ -72,9 +74,11 @@ export class UserBasicComponent extends TranslationBaseComponent implements OnIn
}
try {
- await this.userService.update(this.user.id, request).then(() => {
- this._toastrService.success(`PAC.NOTES.USERS.USER_UPDATED`, { name: new CreatedByPipe().transform(this.user) })
- })
- } catch (error) {}
+ await this.userService.update(this.user.id, request)
+ this._toastrService.success(`PAC.NOTES.USERS.USER_UPDATED`, { name: new CreatedByPipe().transform(this.user) })
+ this.userBasicInfo.form.markAsPristine()
+ } catch (error) {
+ this._toastrService.danger(error)
+ }
}
}
diff --git a/apps/cloud/src/app/features/setting/users/users.component.html b/apps/cloud/src/app/features/setting/users/users.component.html
index e93b8bbac..fde243c4e 100644
--- a/apps/cloud/src/app/features/setting/users/users.component.html
+++ b/apps/cloud/src/app/features/setting/users/users.component.html
@@ -50,6 +50,7 @@
+
diff --git a/apps/cloud/src/app/features/setting/users/users.component.ts b/apps/cloud/src/app/features/setting/users/users.component.ts
index 386f425cb..2914444fa 100644
--- a/apps/cloud/src/app/features/setting/users/users.component.ts
+++ b/apps/cloud/src/app/features/setting/users/users.component.ts
@@ -6,7 +6,7 @@ import { Subject, firstValueFrom, map } from 'rxjs'
import { Group, IUser, ROUTE_ANIMATIONS_ELEMENTS, routeAnimations } from '../../../@core/index'
import { MaterialModule, SharedModule, UserMutationComponent, userLabel } from '../../../@shared'
import { InviteMutationComponent } from '../../../@shared/invite'
-import { TranslationBaseComponent } from '../../../@shared/language/translation-base.component'
+import { TranslationBaseComponent } from '../../../@shared/'
@Component({
diff --git a/apps/cloud/src/app/services/story-public.service.ts b/apps/cloud/src/app/services/story-public.service.ts
index a6c481bbf..260950f69 100644
--- a/apps/cloud/src/app/services/story-public.service.ts
+++ b/apps/cloud/src/app/services/story-public.service.ts
@@ -17,11 +17,11 @@ import { PACNotificationDestinationsService } from '../@core'
import {
convertStoryPointResult,
convertStoryResult,
- convertStorySubscriptionResult,
ID,
IStory,
ISubscription
} from '../@core/types'
+import { convertStorySubscriptionResult } from './types'
@Injectable()
export class StoryPublicService implements NxStoryStore {
diff --git a/apps/cloud/src/app/services/story.service.ts b/apps/cloud/src/app/services/story.service.ts
index 8220787a4..9f699a033 100644
--- a/apps/cloud/src/app/services/story.service.ts
+++ b/apps/cloud/src/app/services/story.service.ts
@@ -31,9 +31,9 @@ import {
ISubscription,
convertStoryPointResult,
convertStoryResult,
- convertStorySubscriptionResult,
convertStoryWidgetResult
} from '../@core/types'
+import { convertStorySubscriptionResult } from './types'
@Injectable()
export class StoryStoreService extends ComponentStore<{ entities?: Array }> implements NxStoryStore {
diff --git a/apps/cloud/src/app/services/types.ts b/apps/cloud/src/app/services/types.ts
new file mode 100644
index 000000000..4ddbcecdb
--- /dev/null
+++ b/apps/cloud/src/app/services/types.ts
@@ -0,0 +1,6 @@
+import { StorySubscription } from '@metad/story/core'
+import { ISubscription } from '../@core'
+
+export function convertStorySubscriptionResult(result: ISubscription): StorySubscription {
+ return result
+}
diff --git a/packages/analytics/src/core/prepare.ts b/packages/analytics/src/core/prepare.ts
index 354e826d5..1335cf38f 100644
--- a/packages/analytics/src/core/prepare.ts
+++ b/packages/analytics/src/core/prepare.ts
@@ -28,6 +28,7 @@ export function prepare() {
DEFAULT_FEATURES.forEach((feature) => {
const index = features.findIndex((item) => item.code === feature.code)
if (index > -1) {
+ features[index].children ??= []
features[index].children.push(...feature.children)
} else {
features.push(feature as IFeatureCreateInput)