Browse Source

Merge pull request #1612 from abpframework/refactor/change-action-names

Refactor/change action names
pull/1616/head
Mehmet Erim 7 years ago
committed by GitHub
parent
commit
a557658e3d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      npm/ng-packs/packages/account/src/lib/components/login/login.component.ts
  2. 6
      npm/ng-packs/packages/account/src/lib/components/tenant-box/tenant-box.component.ts
  3. 2
      npm/ng-packs/packages/core/src/lib/actions/config.actions.ts
  4. 4
      npm/ng-packs/packages/core/src/lib/actions/loader.actions.ts
  5. 6
      npm/ng-packs/packages/core/src/lib/actions/profile.actions.ts
  6. 4
      npm/ng-packs/packages/core/src/lib/actions/session.actions.ts
  7. 6
      npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts
  8. 10
      npm/ng-packs/packages/core/src/lib/states/config.state.ts
  9. 12
      npm/ng-packs/packages/core/src/lib/states/profile.state.ts
  10. 10
      npm/ng-packs/packages/core/src/lib/states/session.state.ts
  11. 4
      npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts
  12. 26
      npm/ng-packs/packages/identity/src/lib/actions/identity.actions.ts
  13. 18
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  14. 24
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts
  15. 4
      npm/ng-packs/packages/identity/src/lib/resolvers/roles.resolver.ts
  16. 4
      npm/ng-packs/packages/identity/src/lib/resolvers/users.resolver.ts
  17. 4
      npm/ng-packs/packages/identity/src/lib/services/identity.service.ts
  18. 82
      npm/ng-packs/packages/identity/src/lib/states/identity.state.ts
  19. 4
      npm/ng-packs/packages/permission-management/src/lib/actions/permission-management.actions.ts
  20. 13
      npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts
  21. 16
      npm/ng-packs/packages/permission-management/src/lib/states/permission-management.state.ts
  22. 20
      npm/ng-packs/packages/tenant-management/src/lib/actions/tenant-management.actions.ts
  23. 22
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts
  24. 6
      npm/ng-packs/packages/tenant-management/src/lib/resolvers/tenants.resolver.ts
  25. 10
      npm/ng-packs/packages/tenant-management/src/lib/services/tenant-management.service.ts
  26. 44
      npm/ng-packs/packages/tenant-management/src/lib/states/tenant-management.state.ts
  27. 4
      npm/ng-packs/packages/theme-basic/src/lib/actions/layout.actions.ts
  28. 14
      npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts
  29. 4
      npm/ng-packs/packages/theme-basic/src/lib/components/change-password/change-password.component.ts
  30. 6
      npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.ts
  31. 13
      npm/ng-packs/packages/theme-basic/src/lib/states/layout.state.ts
  32. 6
      npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts
  33. 14
      npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.ts

4
npm/ng-packs/packages/account/src/lib/components/login/login.component.ts

@ -1,4 +1,4 @@
import { ConfigGetAppConfiguration, ConfigState } from '@abp/ng.core';
import { GetAppConfiguration, ConfigState } from '@abp/ng.core';
import { Component, Inject, Optional } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Navigate } from '@ngxs/router-plugin';
@ -47,7 +47,7 @@ export class LoginComponent {
this.oauthService.fetchTokenUsingPasswordFlow(this.form.get('username').value, this.form.get('password').value),
)
.pipe(
switchMap(() => this.store.dispatch(new ConfigGetAppConfiguration())),
switchMap(() => this.store.dispatch(new GetAppConfiguration())),
tap(() => {
const redirectUrl = snq(() => window.history.state).redirectUrl || (this.options || {}).redirectUrl || '/';
this.store.dispatch(new Navigate([redirectUrl]));

6
npm/ng-packs/packages/account/src/lib/components/tenant-box/tenant-box.component.ts

@ -1,4 +1,4 @@
import { ABP, SessionSetTenant, SessionState } from '@abp/ng.core';
import { ABP, SetTenant, SessionState } from '@abp/ng.core';
import { ToasterService } from '@abp/ng.theme.shared';
import { Component, OnInit } from '@angular/core';
import { Store } from '@ngxs/store';
@ -57,10 +57,10 @@ export class TenantBoxComponent implements OnInit {
});
this.tenant = {} as ABP.BasicItem;
}
this.store.dispatch(new SessionSetTenant(success ? this.tenant : null));
this.store.dispatch(new SetTenant(success ? this.tenant : null));
});
} else {
this.store.dispatch(new SessionSetTenant(null));
this.store.dispatch(new SetTenant(null));
this.tenantName = null;
this.isModalVisible = false;
}

2
npm/ng-packs/packages/core/src/lib/actions/config.actions.ts

@ -5,6 +5,6 @@ export class PatchRouteByName {
constructor(public name: string, public newValue: Partial<ABP.Route>) {}
}
export class ConfigGetAppConfiguration {
export class GetAppConfiguration {
static readonly type = '[Config] Get App Configuration';
}

4
npm/ng-packs/packages/core/src/lib/actions/loader.actions.ts

@ -1,11 +1,11 @@
import { HttpRequest } from '@angular/common/http';
export class LoaderStart {
export class StartLoader {
static readonly type = '[Loader] Start';
constructor(public payload: HttpRequest<any>) {}
}
export class LoaderStop {
export class StopLoader {
static readonly type = '[Loader] Stop';
constructor(public payload: HttpRequest<any>) {}
}

6
npm/ng-packs/packages/core/src/lib/actions/profile.actions.ts

@ -1,15 +1,15 @@
import { Profile } from '../models';
export class ProfileGet {
export class GetProfile {
static readonly type = '[Profile] Get';
}
export class ProfileUpdate {
export class UpdateProfile {
static readonly type = '[Profile] Update';
constructor(public payload: Profile.Response) {}
}
export class ProfileChangePassword {
export class ChangePassword {
static readonly type = '[Profile] Change Password';
constructor(public payload: Profile.ChangePasswordRequest) {}
}

4
npm/ng-packs/packages/core/src/lib/actions/session.actions.ts

@ -1,10 +1,10 @@
import { ABP } from '../models';
export class SessionSetLanguage {
export class SetLanguage {
static readonly type = '[Session] Set Language';
constructor(public payload: string) {}
}
export class SessionSetTenant {
export class SetTenant {
static readonly type = '[Session] Set Tenant';
constructor(public payload: ABP.BasicItem) {}
}

6
npm/ng-packs/packages/core/src/lib/interceptors/api.interceptor.ts

@ -3,7 +3,7 @@ import { HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http'
import { OAuthService } from 'angular-oauth2-oidc';
import { Store } from '@ngxs/store';
import { SessionState } from '../states';
import { LoaderStart, LoaderStop } from '../actions/loader.actions';
import { StartLoader, StopLoader } from '../actions/loader.actions';
import { finalize } from 'rxjs/operators';
@Injectable()
@ -11,7 +11,7 @@ export class ApiInterceptor implements HttpInterceptor {
constructor(private oAuthService: OAuthService, private store: Store) {}
intercept(request: HttpRequest<any>, next: HttpHandler) {
this.store.dispatch(new LoaderStart(request));
this.store.dispatch(new StartLoader(request));
const headers = {} as any;
@ -36,6 +36,6 @@ export class ApiInterceptor implements HttpInterceptor {
setHeaders: headers,
}),
)
.pipe(finalize(() => this.store.dispatch(new LoaderStop(request))));
.pipe(finalize(() => this.store.dispatch(new StopLoader(request))));
}
}

10
npm/ng-packs/packages/core/src/lib/states/config.state.ts

@ -1,10 +1,10 @@
import { State, Selector, createSelector, Action, StateContext, Store } from '@ngxs/store';
import { Config, ABP } from '../models';
import { ConfigGetAppConfiguration, PatchRouteByName } from '../actions/config.actions';
import { GetAppConfiguration, PatchRouteByName } from '../actions/config.actions';
import { ApplicationConfigurationService } from '../services/application-configuration.service';
import { tap, switchMap } from 'rxjs/operators';
import snq from 'snq';
import { SessionSetLanguage } from '../actions';
import { SetLanguage } from '../actions';
import { SessionState } from './session.state';
import { of } from 'rxjs';
import { setChildRoute, sortRoutes, organizeRoutes } from '../utils/route-utils';
@ -161,7 +161,7 @@ export class ConfigState {
constructor(private appConfigurationService: ApplicationConfigurationService, private store: Store) {}
@Action(ConfigGetAppConfiguration)
@Action(GetAppConfiguration)
addData({ patchState, dispatch }: StateContext<Config.State>) {
return this.appConfigurationService.getConfiguration().pipe(
tap(configuration =>
@ -172,9 +172,7 @@ export class ConfigState {
switchMap(configuration =>
this.store.selectSnapshot(SessionState.getLanguage)
? of(null)
: dispatch(
new SessionSetLanguage(snq(() => configuration.setting.values['Abp.Localization.DefaultLanguage'])),
),
: dispatch(new SetLanguage(snq(() => configuration.setting.values['Abp.Localization.DefaultLanguage']))),
),
);
}

12
npm/ng-packs/packages/core/src/lib/states/profile.state.ts

@ -1,5 +1,5 @@
import { State, Action, StateContext, Selector } from '@ngxs/store';
import { ProfileGet, ProfileChangePassword, ProfileUpdate } from '../actions/profile.actions';
import { GetProfile, ChangePassword, UpdateProfile } from '../actions/profile.actions';
import { Profile } from '../models/profile';
import { ProfileService } from '../services/profile.service';
import { tap } from 'rxjs/operators';
@ -16,7 +16,7 @@ export class ProfileState {
constructor(private profileService: ProfileService) {}
@Action(ProfileGet)
@Action(GetProfile)
profileGet({ patchState }: StateContext<Profile.State>) {
return this.profileService.get().pipe(
tap(profile =>
@ -27,8 +27,8 @@ export class ProfileState {
);
}
@Action(ProfileUpdate)
profileUpdate({ patchState }: StateContext<Profile.State>, { payload }: ProfileUpdate) {
@Action(UpdateProfile)
profileUpdate({ patchState }: StateContext<Profile.State>, { payload }: UpdateProfile) {
return this.profileService.update(payload).pipe(
tap(profile =>
patchState({
@ -38,8 +38,8 @@ export class ProfileState {
);
}
@Action(ProfileChangePassword)
changePassword(_, { payload }: ProfileChangePassword) {
@Action(ChangePassword)
changePassword(_, { payload }: ChangePassword) {
return this.profileService.changePassword(payload, true);
}
}

10
npm/ng-packs/packages/core/src/lib/states/session.state.ts

@ -1,5 +1,5 @@
import { Action, Selector, State, StateContext } from '@ngxs/store';
import { SessionSetLanguage, SessionSetTenant } from '../actions/session.actions';
import { SetLanguage, SetTenant } from '../actions/session.actions';
import { ABP, Session } from '../models';
@State<Session.State>({
@ -19,15 +19,15 @@ export class SessionState {
constructor() {}
@Action(SessionSetLanguage)
sessionSetLanguage({ patchState }: StateContext<Session.State>, { payload }: SessionSetLanguage) {
@Action(SetLanguage)
setLanguage({ patchState }: StateContext<Session.State>, { payload }: SetLanguage) {
patchState({
language: payload,
});
}
@Action(SessionSetTenant)
sessionSetTenantId({ patchState }: StateContext<Session.State>, { payload }: SessionSetTenant) {
@Action(SetTenant)
setTenantId({ patchState }: StateContext<Session.State>, { payload }: SetTenant) {
patchState({
tenant: payload,
});

4
npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts

@ -1,12 +1,12 @@
import { Injector } from '@angular/core';
import { Store } from '@ngxs/store';
import { ConfigGetAppConfiguration } from '../actions/config.actions';
import { GetAppConfiguration } from '../actions/config.actions';
export function getInitialData(injector: Injector) {
const fn = function() {
const store: Store = injector.get(Store);
return store.dispatch(new ConfigGetAppConfiguration()).toPromise();
return store.dispatch(new GetAppConfiguration()).toPromise();
};
return fn;

26
npm/ng-packs/packages/identity/src/lib/actions/identity.actions.ts

@ -1,57 +1,57 @@
import { Identity } from '../models/identity';
import { ABP } from '@abp/ng.core';
export class IdentityGetRoles {
export class GetRoles {
static readonly type = '[Identity] Get Roles';
constructor(public payload?: ABP.PageQueryParams) {}
}
export class IdentityGetRoleById {
export class GetRoleById {
static readonly type = '[Identity] Get Role By Id';
constructor(public payload: string) {}
}
export class IdentityDeleteRole {
export class DeleteRole {
static readonly type = '[Identity] Delete Role';
constructor(public payload: string) {}
}
export class IdentityAddRole {
static readonly type = '[Identity] Add Role';
export class CreateRole {
static readonly type = '[Identity] Create Role';
constructor(public payload: Identity.RoleSaveRequest) {}
}
export class IdentityUpdateRole {
export class UpdateRole {
static readonly type = '[Identity] Update Role';
constructor(public payload: Identity.RoleItem) {}
}
export class IdentityGetUsers {
export class GetUsers {
static readonly type = '[Identity] Get Users';
constructor(public payload?: ABP.PageQueryParams) {}
}
export class IdentityGetUserById {
export class GetUserById {
static readonly type = '[Identity] Get User By Id';
constructor(public payload: string) {}
}
export class IdentityDeleteUser {
export class DeleteUser {
static readonly type = '[Identity] Delete User';
constructor(public payload: string) {}
}
export class IdentityAddUser {
static readonly type = '[Identity] Add User';
export class CreateUser {
static readonly type = '[Identity] Create User';
constructor(public payload: Identity.UserSaveRequest) {}
}
export class IdentityUpdateUser {
export class UpdateUser {
static readonly type = '[Identity] Update User';
constructor(public payload: Identity.UserSaveRequest & { id: string }) {}
}
export class IdentityGetUserRoles {
export class GetUserRoles {
static readonly type = '[Identity] Get User Roles';
constructor(public payload: string) {}
}

18
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts

@ -5,13 +5,7 @@ import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'
import { Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { finalize, pluck } from 'rxjs/operators';
import {
IdentityAddRole,
IdentityDeleteRole,
IdentityGetRoleById,
IdentityGetRoles,
IdentityUpdateRole,
} from '../../actions/identity.actions';
import { CreateRole, DeleteRole, GetRoleById, GetRoles, UpdateRole } from '../../actions/identity.actions';
import { Identity } from '../../models/identity';
import { IdentityState } from '../../states/identity.state';
@ -75,7 +69,7 @@ export class RolesComponent {
onEdit(id: string) {
this.store
.dispatch(new IdentityGetRoleById(id))
.dispatch(new GetRoleById(id))
.pipe(pluck('IdentityState', 'selectedRole'))
.subscribe(selectedRole => {
this.selected = selectedRole;
@ -89,8 +83,8 @@ export class RolesComponent {
this.store
.dispatch(
this.selected.id
? new IdentityUpdateRole({ ...this.form.value, id: this.selected.id })
: new IdentityAddRole(this.form.value),
? new UpdateRole({ ...this.form.value, id: this.selected.id })
: new CreateRole(this.form.value),
)
.subscribe(() => {
this.isModalVisible = false;
@ -104,7 +98,7 @@ export class RolesComponent {
})
.subscribe((status: Toaster.Status) => {
if (status === Toaster.Status.confirm) {
this.store.dispatch(new IdentityDeleteRole(id));
this.store.dispatch(new DeleteRole(id));
}
});
}
@ -119,7 +113,7 @@ export class RolesComponent {
get() {
this.loading = true;
this.store
.dispatch(new IdentityGetRoles(this.pageQuery))
.dispatch(new GetRoles(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
}

24
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -7,12 +7,12 @@ import { Observable } from 'rxjs';
import { finalize, pluck, switchMap, take } from 'rxjs/operators';
import snq from 'snq';
import {
IdentityAddUser,
IdentityDeleteUser,
IdentityGetUserById,
IdentityGetUserRoles,
IdentityGetUsers,
IdentityUpdateUser,
CreateUser,
DeleteUser,
GetUserById,
GetUserRoles,
GetUsers,
UpdateUser,
} from '../../actions/identity.actions';
import { Identity } from '../../models/identity';
import { IdentityState } from '../../states/identity.state';
@ -99,9 +99,9 @@ export class UsersComponent {
onEdit(id: string) {
this.store
.dispatch(new IdentityGetUserById(id))
.dispatch(new GetUserById(id))
.pipe(
switchMap(() => this.store.dispatch(new IdentityGetUserRoles(id))),
switchMap(() => this.store.dispatch(new GetUserRoles(id))),
pluck('IdentityState'),
take(1),
)
@ -124,12 +124,12 @@ export class UsersComponent {
this.store
.dispatch(
this.selected.id
? new IdentityUpdateUser({
? new UpdateUser({
...this.form.value,
id: this.selected.id,
roleNames: mappedRoleNames,
})
: new IdentityAddUser({
: new CreateUser({
...this.form.value,
roleNames: mappedRoleNames,
}),
@ -146,7 +146,7 @@ export class UsersComponent {
})
.subscribe((status: Toaster.Status) => {
if (status === Toaster.Status.confirm) {
this.store.dispatch(new IdentityDeleteUser(id));
this.store.dispatch(new DeleteUser(id));
}
});
}
@ -161,7 +161,7 @@ export class UsersComponent {
get() {
this.loading = true;
this.store
.dispatch(new IdentityGetUsers(this.pageQuery))
.dispatch(new GetUsers(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
}

4
npm/ng-packs/packages/identity/src/lib/resolvers/roles.resolver.ts

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Store } from '@ngxs/store';
import { IdentityGetRoles } from '../actions/identity.actions';
import { GetRoles } from '../actions/identity.actions';
import { Identity } from '../models/identity';
import { IdentityState } from '../states/identity.state';
@ -11,6 +11,6 @@ export class RoleResolver implements Resolve<Identity.State> {
resolve() {
const roles = this.store.selectSnapshot(IdentityState.getRoles);
return roles && roles.length ? null : this.store.dispatch(new IdentityGetRoles());
return roles && roles.length ? null : this.store.dispatch(new GetRoles());
}
}

4
npm/ng-packs/packages/identity/src/lib/resolvers/users.resolver.ts

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Store } from '@ngxs/store';
import { IdentityGetUsers } from '../actions/identity.actions';
import { GetUsers } from '../actions/identity.actions';
import { Identity } from '../models/identity';
import { IdentityState } from '../states/identity.state';
@ -11,6 +11,6 @@ export class UserResolver implements Resolve<Identity.State> {
resolve() {
const users = this.store.selectSnapshot(IdentityState.getUsers);
return users && users.length ? null : this.store.dispatch(new IdentityGetUsers());
return users && users.length ? null : this.store.dispatch(new GetUsers());
}
}

4
npm/ng-packs/packages/identity/src/lib/services/identity.service.ts

@ -37,7 +37,7 @@ export class IdentityService {
return this.rest.request<null, Identity.RoleItem>(request);
}
addRole(body: Identity.RoleSaveRequest): Observable<Identity.RoleItem> {
createRole(body: Identity.RoleSaveRequest): Observable<Identity.RoleItem> {
const request: Rest.Request<Identity.RoleSaveRequest> = {
method: 'POST',
url: '/api/identity/roles',
@ -97,7 +97,7 @@ export class IdentityService {
return this.rest.request<null, null>(request);
}
addUser(body: Identity.UserSaveRequest): Observable<Identity.UserItem> {
createUser(body: Identity.UserSaveRequest): Observable<Identity.UserItem> {
const request: Rest.Request<Identity.UserSaveRequest> = {
method: 'POST',
url: '/api/identity/users',

82
npm/ng-packs/packages/identity/src/lib/states/identity.state.ts

@ -1,17 +1,17 @@
import { Action, Selector, State, StateContext } from '@ngxs/store';
import { switchMap, tap, pluck } from 'rxjs/operators';
import {
IdentityAddRole,
IdentityAddUser,
IdentityDeleteRole,
IdentityDeleteUser,
IdentityGetRoleById,
IdentityGetRoles,
IdentityGetUserById,
IdentityGetUsers,
IdentityUpdateRole,
IdentityUpdateUser,
IdentityGetUserRoles,
CreateRole,
CreateUser,
DeleteRole,
DeleteUser,
GetRoleById,
GetRoles,
GetUserById,
GetUsers,
UpdateRole,
UpdateUser,
GetUserRoles,
} from '../actions/identity.actions';
import { Identity } from '../models/identity';
import { IdentityService } from '../services/identity.service';
@ -43,8 +43,8 @@ export class IdentityState {
constructor(private identityService: IdentityService) {}
@Action(IdentityGetRoles)
getRoles({ patchState }: StateContext<Identity.State>, { payload }: IdentityGetRoles) {
@Action(GetRoles)
getRoles({ patchState }: StateContext<Identity.State>, { payload }: GetRoles) {
return this.identityService.getRoles(payload).pipe(
tap(roles =>
patchState({
@ -54,8 +54,8 @@ export class IdentityState {
);
}
@Action(IdentityGetRoleById)
getRole({ patchState }: StateContext<Identity.State>, { payload }: IdentityGetRoleById) {
@Action(GetRoleById)
getRole({ patchState }: StateContext<Identity.State>, { payload }: GetRoleById) {
return this.identityService.getRoleById(payload).pipe(
tap(selectedRole =>
patchState({
@ -65,26 +65,26 @@ export class IdentityState {
);
}
@Action(IdentityDeleteRole)
deleteRole({ dispatch }: StateContext<Identity.State>, { payload }: IdentityGetRoleById) {
return this.identityService.deleteRole(payload).pipe(switchMap(() => dispatch(new IdentityGetRoles())));
@Action(DeleteRole)
deleteRole({ dispatch }: StateContext<Identity.State>, { payload }: GetRoleById) {
return this.identityService.deleteRole(payload).pipe(switchMap(() => dispatch(new GetRoles())));
}
@Action(IdentityAddRole)
addRole({ dispatch }: StateContext<Identity.State>, { payload }: IdentityAddRole) {
return this.identityService.addRole(payload).pipe(switchMap(() => dispatch(new IdentityGetRoles())));
@Action(CreateRole)
addRole({ dispatch }: StateContext<Identity.State>, { payload }: CreateRole) {
return this.identityService.createRole(payload).pipe(switchMap(() => dispatch(new GetRoles())));
}
@Action(IdentityUpdateRole)
updateRole({ getState, dispatch }: StateContext<Identity.State>, { payload }: IdentityUpdateRole) {
return dispatch(new IdentityGetRoleById(payload.id)).pipe(
@Action(UpdateRole)
updateRole({ getState, dispatch }: StateContext<Identity.State>, { payload }: UpdateRole) {
return dispatch(new GetRoleById(payload.id)).pipe(
switchMap(() => this.identityService.updateRole({ ...getState().selectedRole, ...payload })),
switchMap(() => dispatch(new IdentityGetRoles())),
switchMap(() => dispatch(new GetRoles())),
);
}
@Action(IdentityGetUsers)
getUsers({ patchState }: StateContext<Identity.State>, { payload }: IdentityGetUsers) {
@Action(GetUsers)
getUsers({ patchState }: StateContext<Identity.State>, { payload }: GetUsers) {
return this.identityService.getUsers(payload).pipe(
tap(users =>
patchState({
@ -94,8 +94,8 @@ export class IdentityState {
);
}
@Action(IdentityGetUserById)
getUser({ patchState }: StateContext<Identity.State>, { payload }: IdentityGetUserById) {
@Action(GetUserById)
getUser({ patchState }: StateContext<Identity.State>, { payload }: GetUserById) {
return this.identityService.getUserById(payload).pipe(
tap(selectedUser =>
patchState({
@ -105,26 +105,26 @@ export class IdentityState {
);
}
@Action(IdentityDeleteUser)
deleteUser({ dispatch }: StateContext<Identity.State>, { payload }: IdentityGetUserById) {
return this.identityService.deleteUser(payload).pipe(switchMap(() => dispatch(new IdentityGetUsers())));
@Action(DeleteUser)
deleteUser({ dispatch }: StateContext<Identity.State>, { payload }: GetUserById) {
return this.identityService.deleteUser(payload).pipe(switchMap(() => dispatch(new GetUsers())));
}
@Action(IdentityAddUser)
addUser({ dispatch }: StateContext<Identity.State>, { payload }: IdentityAddUser) {
return this.identityService.addUser(payload).pipe(switchMap(() => dispatch(new IdentityGetUsers())));
@Action(CreateUser)
addUser({ dispatch }: StateContext<Identity.State>, { payload }: CreateUser) {
return this.identityService.createUser(payload).pipe(switchMap(() => dispatch(new GetUsers())));
}
@Action(IdentityUpdateUser)
updateUser({ getState, dispatch }: StateContext<Identity.State>, { payload }: IdentityUpdateUser) {
return dispatch(new IdentityGetUserById(payload.id)).pipe(
@Action(UpdateUser)
updateUser({ getState, dispatch }: StateContext<Identity.State>, { payload }: UpdateUser) {
return dispatch(new GetUserById(payload.id)).pipe(
switchMap(() => this.identityService.updateUser({ ...getState().selectedUser, ...payload })),
switchMap(() => dispatch(new IdentityGetUsers())),
switchMap(() => dispatch(new GetUsers())),
);
}
@Action(IdentityGetUserRoles)
getUserRoles({ patchState }: StateContext<Identity.State>, { payload }: IdentityGetUserRoles) {
@Action(GetUserRoles)
getUserRoles({ patchState }: StateContext<Identity.State>, { payload }: GetUserRoles) {
return this.identityService.getUserRoles(payload).pipe(
pluck('items'),
tap(selectedUserRoles =>

4
npm/ng-packs/packages/permission-management/src/lib/actions/permission-management.actions.ts

@ -1,11 +1,11 @@
import { PermissionManagement } from '../models/permission-management';
export class PermissionManagementGetPermissions {
export class GetPermissions {
static readonly type = '[PermissionManagement] Get Permissions';
constructor(public payload: PermissionManagement.GrantedProvider) {}
}
export class PermissionManagementUpdatePermissions {
export class UpdatePermissions {
static readonly type = '[PermissionManagement] Update Permissions';
constructor(public payload: PermissionManagement.GrantedProvider & PermissionManagement.UpdateRequest) {}
}

13
npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts

@ -12,10 +12,7 @@ import {
import { Select, Store } from '@ngxs/store';
import { from, Observable } from 'rxjs';
import { map, pluck, take } from 'rxjs/operators';
import {
PermissionManagementGetPermissions,
PermissionManagementUpdatePermissions,
} from '../actions/permission-management.actions';
import { GetPermissions, UpdatePermissions } from '../actions/permission-management.actions';
import { PermissionManagement } from '../models/permission-management';
import { PermissionManagementState } from '../states/permission-management.state';
@ -151,6 +148,8 @@ export class PermissionManagementComponent implements OnInit, OnChanges {
onClickSelectThisTab() {
this.selectedGroupPermissions$.pipe(take(1)).subscribe(permissions => {
permissions.forEach(permission => {
if (permission.isGranted && permission.grantedProviders.length > 0) return;
const index = this.permissions.findIndex(per => per.name === permission.name);
this.permissions = [
@ -189,7 +188,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges {
if (changedPermissions.length) {
this.store
.dispatch(
new PermissionManagementUpdatePermissions({
new UpdatePermissions({
providerKey: this.providerKey,
providerName: this.providerName,
permissions: changedPermissions,
@ -209,9 +208,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges {
}
this.store
.dispatch(
new PermissionManagementGetPermissions({ providerKey: this.providerKey, providerName: this.providerName }),
)
.dispatch(new GetPermissions({ providerKey: this.providerKey, providerName: this.providerName }))
.pipe(pluck('PermissionManagementState', 'permissionRes'))
.subscribe((permissionRes: PermissionManagement.Response) => {
this.selectedGroup = permissionRes.groups[0];

16
npm/ng-packs/packages/permission-management/src/lib/states/permission-management.state.ts

@ -1,8 +1,5 @@
import { State, Action, StateContext, Selector } from '@ngxs/store';
import {
PermissionManagementGetPermissions,
PermissionManagementUpdatePermissions,
} from '../actions/permission-management.actions';
import { GetPermissions, UpdatePermissions } from '../actions/permission-management.actions';
import { PermissionManagement } from '../models/permission-management';
import { PermissionManagementService } from '../services/permission-management.service';
import { tap } from 'rxjs/operators';
@ -24,11 +21,8 @@ export class PermissionManagementState {
constructor(private permissionManagementService: PermissionManagementService) {}
@Action(PermissionManagementGetPermissions)
permissionManagementGet(
{ patchState }: StateContext<PermissionManagement.State>,
{ payload }: PermissionManagementGetPermissions,
) {
@Action(GetPermissions)
permissionManagementGet({ patchState }: StateContext<PermissionManagement.State>, { payload }: GetPermissions) {
return this.permissionManagementService.getPermissions(payload).pipe(
tap(permissionResponse =>
patchState({
@ -38,8 +32,8 @@ export class PermissionManagementState {
);
}
@Action(PermissionManagementUpdatePermissions)
permissionManagementUpdate(_, { payload }: PermissionManagementUpdatePermissions) {
@Action(UpdatePermissions)
permissionManagementUpdate(_, { payload }: UpdatePermissions) {
return this.permissionManagementService.updatePermissions(payload);
}
}

20
npm/ng-packs/packages/tenant-management/src/lib/actions/tenant-management.actions.ts

@ -1,27 +1,27 @@
import { TenantManagement } from '../models/tenant-management';
import { ABP } from '@abp/ng.core';
export class TenantManagementGet {
static readonly type = '[TenantManagement] Get';
export class GetTenants {
static readonly type = '[TenantManagement] Get Tenant';
constructor(public payload?: ABP.PageQueryParams) {}
}
export class TenantManagementGetById {
static readonly type = '[TenantManagement] Get By Id';
export class GetTenantById {
static readonly type = '[TenantManagement] Get Tenant By Id';
constructor(public payload: string) {}
}
export class TenantManagementAdd {
static readonly type = '[TenantManagement] Add';
export class CreateTenant {
static readonly type = '[TenantManagement] Create Tenant';
constructor(public payload: TenantManagement.AddRequest) {}
}
export class TenantManagementUpdate {
static readonly type = '[TenantManagement] Update';
export class UpdateTenant {
static readonly type = '[TenantManagement] Update Tenant';
constructor(public payload: TenantManagement.UpdateRequest) {}
}
export class TenantManagementDelete {
static readonly type = '[TenantManagement] Delete';
export class DeleteTenant {
static readonly type = '[TenantManagement] Delete Tenant';
constructor(public payload: string) {}
}

22
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts

@ -6,11 +6,11 @@ import { Select, Store } from '@ngxs/store';
import { Observable, Subject } from 'rxjs';
import { debounceTime, finalize, pluck, switchMap, take } from 'rxjs/operators';
import {
TenantManagementAdd,
TenantManagementDelete,
TenantManagementGet,
TenantManagementGetById,
TenantManagementUpdate,
CreateTenant,
DeleteTenant,
GetTenants,
GetTenantById,
UpdateTenant,
} from '../../actions/tenant-management.actions';
import { TenantManagementService } from '../../services/tenant-management.service';
import { TenantManagementState } from '../../states/tenant-management.state';
@ -103,7 +103,7 @@ export class TenantsComponent {
onEditConnectionString(id: string) {
this.store
.dispatch(new TenantManagementGetById(id))
.dispatch(new GetTenantById(id))
.pipe(
pluck('TenantManagementState', 'selectedItem'),
switchMap(selected => {
@ -127,7 +127,7 @@ export class TenantsComponent {
onEditTenant(id: string) {
this.store
.dispatch(new TenantManagementGetById(id))
.dispatch(new GetTenantById(id))
.pipe(pluck('TenantManagementState', 'selectedItem'))
.subscribe(selected => {
this.selected = selected;
@ -167,8 +167,8 @@ export class TenantsComponent {
this.store
.dispatch(
this.selected.id
? new TenantManagementUpdate({ ...this.tenantForm.value, id: this.selected.id })
: new TenantManagementAdd(this.tenantForm.value),
? new UpdateTenant({ ...this.tenantForm.value, id: this.selected.id })
: new CreateTenant(this.tenantForm.value),
)
.subscribe(() => {
this.isModalVisible = false;
@ -182,7 +182,7 @@ export class TenantsComponent {
})
.subscribe((status: Toaster.Status) => {
if (status === Toaster.Status.confirm) {
this.store.dispatch(new TenantManagementDelete(id));
this.store.dispatch(new DeleteTenant(id));
}
});
}
@ -197,7 +197,7 @@ export class TenantsComponent {
get() {
this.loading = true;
this.store
.dispatch(new TenantManagementGet(this.pageQuery))
.dispatch(new GetTenants(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
}

6
npm/ng-packs/packages/tenant-management/src/lib/resolvers/tenants.resolver.ts

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Store } from '@ngxs/store';
import { TenantManagementGet } from '../actions/tenant-management.actions';
import { GetTenants } from '../actions/tenant-management.actions';
import { TenantManagement } from '../models/tenant-management';
import { TenantManagementState } from '../states/tenant-management.state';
@ -11,8 +11,6 @@ export class TenantsResolver implements Resolve<TenantManagement.State> {
resolve() {
const data = this.store.selectSnapshot(TenantManagementState.get);
return data && data.length
? null
: this.store.dispatch(new TenantManagementGet());
return data && data.length ? null : this.store.dispatch(new GetTenants());
}
}

10
npm/ng-packs/packages/tenant-management/src/lib/services/tenant-management.service.ts

@ -9,7 +9,7 @@ import { TenantManagement } from '../models/tenant-management';
export class TenantManagementService {
constructor(private rest: RestService) {}
get(params = {} as ABP.PageQueryParams): Observable<TenantManagement.Response> {
getTenant(params = {} as ABP.PageQueryParams): Observable<TenantManagement.Response> {
const request: Rest.Request<null> = {
method: 'GET',
url: '/api/multi-tenancy/tenants',
@ -19,7 +19,7 @@ export class TenantManagementService {
return this.rest.request<null, TenantManagement.Response>(request);
}
getById(id: string): Observable<ABP.BasicItem> {
getTenantById(id: string): Observable<ABP.BasicItem> {
const request: Rest.Request<null> = {
method: 'GET',
url: `/api/multi-tenancy/tenants/${id}`,
@ -28,7 +28,7 @@ export class TenantManagementService {
return this.rest.request<null, ABP.BasicItem>(request);
}
delete(id: string): Observable<null> {
deleteTenant(id: string): Observable<null> {
const request: Rest.Request<null> = {
method: 'DELETE',
url: `/api/multi-tenancy/tenants/${id}`,
@ -37,7 +37,7 @@ export class TenantManagementService {
return this.rest.request<null, null>(request);
}
add(body: TenantManagement.AddRequest): Observable<ABP.BasicItem> {
createTenant(body: TenantManagement.AddRequest): Observable<ABP.BasicItem> {
const request: Rest.Request<TenantManagement.AddRequest> = {
method: 'POST',
url: `/api/multi-tenancy/tenants`,
@ -47,7 +47,7 @@ export class TenantManagementService {
return this.rest.request<TenantManagement.AddRequest, ABP.BasicItem>(request);
}
update(body: TenantManagement.UpdateRequest): Observable<ABP.BasicItem> {
updateTenant(body: TenantManagement.UpdateRequest): Observable<ABP.BasicItem> {
const url = `/api/multi-tenancy/tenants/${body.id}`;
delete body.id;

44
npm/ng-packs/packages/tenant-management/src/lib/states/tenant-management.state.ts

@ -1,11 +1,11 @@
import { Action, Selector, State, StateContext } from '@ngxs/store';
import { switchMap, tap } from 'rxjs/operators';
import {
TenantManagementAdd,
TenantManagementDelete,
TenantManagementGet,
TenantManagementGetById,
TenantManagementUpdate,
CreateTenant,
DeleteTenant,
GetTenants,
GetTenantById,
UpdateTenant,
} from '../actions/tenant-management.actions';
import { TenantManagement } from '../models/tenant-management';
import { TenantManagementService } from '../services/tenant-management.service';
@ -28,9 +28,9 @@ export class TenantManagementState {
constructor(private tenantManagementService: TenantManagementService) {}
@Action(TenantManagementGet)
get({ patchState }: StateContext<TenantManagement.State>, { payload }: TenantManagementGet) {
return this.tenantManagementService.get(payload).pipe(
@Action(GetTenants)
get({ patchState }: StateContext<TenantManagement.State>, { payload }: GetTenants) {
return this.tenantManagementService.getTenant(payload).pipe(
tap(result =>
patchState({
result,
@ -39,9 +39,9 @@ export class TenantManagementState {
);
}
@Action(TenantManagementGetById)
getById({ patchState }: StateContext<TenantManagement.State>, { payload }: TenantManagementGetById) {
return this.tenantManagementService.getById(payload).pipe(
@Action(GetTenantById)
getById({ patchState }: StateContext<TenantManagement.State>, { payload }: GetTenantById) {
return this.tenantManagementService.getTenantById(payload).pipe(
tap(selectedItem =>
patchState({
selectedItem,
@ -50,21 +50,21 @@ export class TenantManagementState {
);
}
@Action(TenantManagementDelete)
delete({ dispatch }: StateContext<TenantManagement.State>, { payload }: TenantManagementDelete) {
return this.tenantManagementService.delete(payload).pipe(switchMap(() => dispatch(new TenantManagementGet())));
@Action(DeleteTenant)
delete({ dispatch }: StateContext<TenantManagement.State>, { payload }: DeleteTenant) {
return this.tenantManagementService.deleteTenant(payload).pipe(switchMap(() => dispatch(new GetTenants())));
}
@Action(TenantManagementAdd)
add({ dispatch }: StateContext<TenantManagement.State>, { payload }: TenantManagementAdd) {
return this.tenantManagementService.add(payload).pipe(switchMap(() => dispatch(new TenantManagementGet())));
@Action(CreateTenant)
add({ dispatch }: StateContext<TenantManagement.State>, { payload }: CreateTenant) {
return this.tenantManagementService.createTenant(payload).pipe(switchMap(() => dispatch(new GetTenants())));
}
@Action(TenantManagementUpdate)
update({ dispatch, getState }: StateContext<TenantManagement.State>, { payload }: TenantManagementUpdate) {
return dispatch(new TenantManagementGetById(payload.id)).pipe(
switchMap(() => this.tenantManagementService.update({ ...getState().selectedItem, ...payload })),
switchMap(() => dispatch(new TenantManagementGet())),
@Action(UpdateTenant)
update({ dispatch, getState }: StateContext<TenantManagement.State>, { payload }: UpdateTenant) {
return dispatch(new GetTenantById(payload.id)).pipe(
switchMap(() => this.tenantManagementService.updateTenant({ ...getState().selectedItem, ...payload })),
switchMap(() => dispatch(new GetTenants())),
);
}
}

4
npm/ng-packs/packages/theme-basic/src/lib/actions/layout.actions.ts

@ -1,11 +1,11 @@
import { Layout } from '../models/layout';
export class LayoutAddNavigationElement {
export class AddNavigationElement {
static readonly type = '[Layout] Add Navigation Element';
constructor(public payload: Layout.NavigationElement | Layout.NavigationElement[]) {}
}
export class LayoutRemoveNavigationElementByName {
export class RemoveNavigationElementByName {
static readonly type = '[Layout] Remove Navigation ElementByName';
constructor(public name: string) {}
}

14
npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts

@ -1,10 +1,10 @@
import {
ABP,
ApplicationConfiguration,
ConfigGetAppConfiguration,
GetAppConfiguration,
ConfigState,
eLayoutType,
SessionSetLanguage,
SetLanguage,
SessionState,
takeUntilDestroy,
} from '@abp/ng.core';
@ -26,7 +26,7 @@ import compare from 'just-compare';
import { fromEvent, Observable } from 'rxjs';
import { debounceTime, filter, map } from 'rxjs/operators';
import snq from 'snq';
import { LayoutAddNavigationElement } from '../../actions';
import { AddNavigationElement } from '../../actions';
import { Layout } from '../../models/layout';
import { LayoutState } from '../../states';
@ -114,7 +114,7 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
if (navigations.indexOf('LanguageRef') < 0) {
this.store.dispatch(
new LayoutAddNavigationElement([
new AddNavigationElement([
{ element: this.languageRef, order: 4, name: 'LanguageRef' },
{ element: this.currentUserRef, order: 5, name: 'CurrentUserRef' },
]),
@ -146,8 +146,8 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
ngOnDestroy() {}
onChangeLang(cultureName: string) {
this.store.dispatch(new SessionSetLanguage(cultureName));
this.store.dispatch(new ConfigGetAppConfiguration());
this.store.dispatch(new SetLanguage(cultureName));
this.store.dispatch(new GetAppConfiguration());
}
logout() {
@ -157,7 +157,7 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
state: { redirectUrl: this.store.selectSnapshot(RouterState).state.url },
}),
);
this.store.dispatch(new ConfigGetAppConfiguration());
this.store.dispatch(new GetAppConfiguration());
}
}

4
npm/ng-packs/packages/theme-basic/src/lib/components/change-password/change-password.component.ts

@ -1,4 +1,4 @@
import { ProfileChangePassword } from '@abp/ng.core';
import { ChangePassword } from '@abp/ng.core';
import { ToasterService } from '@abp/ng.theme.shared';
import {
Component,
@ -63,7 +63,7 @@ export class ChangePasswordComponent implements OnInit, OnChanges {
this.store
.dispatch(
new ProfileChangePassword({
new ChangePassword({
currentPassword: this.form.get('password').value,
newPassword: this.form.get('newPassword').value,
}),

6
npm/ng-packs/packages/theme-basic/src/lib/components/profile/profile.component.ts

@ -1,4 +1,4 @@
import { Profile, ProfileGet, ProfileState, ProfileUpdate } from '@abp/ng.core';
import { Profile, GetProfile, ProfileState, UpdateProfile } from '@abp/ng.core';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Select, Store } from '@ngxs/store';
@ -36,7 +36,7 @@ export class ProfileComponent implements OnChanges {
buildForm() {
this.store
.dispatch(new ProfileGet())
.dispatch(new GetProfile())
.pipe(
withLatestFrom(this.profile$),
take(1),
@ -55,7 +55,7 @@ export class ProfileComponent implements OnChanges {
onSubmit() {
if (this.form.invalid) return;
this.store.dispatch(new ProfileUpdate(this.form.value)).subscribe(() => {
this.store.dispatch(new UpdateProfile(this.form.value)).subscribe(() => {
this.visible = false;
this.form.reset();
});

13
npm/ng-packs/packages/theme-basic/src/lib/states/layout.state.ts

@ -1,5 +1,5 @@
import { State, Action, StateContext, Selector } from '@ngxs/store';
import { LayoutAddNavigationElement, LayoutRemoveNavigationElementByName } from '../actions/layout.actions';
import { AddNavigationElement, RemoveNavigationElementByName } from '../actions/layout.actions';
import { Layout } from '../models/layout';
import { TemplateRef } from '@angular/core';
import snq from 'snq';
@ -14,8 +14,8 @@ export class LayoutState {
return navigationElements;
}
@Action(LayoutAddNavigationElement)
layoutAddAction({ getState, patchState }: StateContext<Layout.State>, { payload = [] }: LayoutAddNavigationElement) {
@Action(AddNavigationElement)
layoutAddAction({ getState, patchState }: StateContext<Layout.State>, { payload = [] }: AddNavigationElement) {
let { navigationElements } = getState();
if (!Array.isArray(payload)) {
@ -43,11 +43,8 @@ export class LayoutState {
});
}
@Action(LayoutRemoveNavigationElementByName)
layoutRemoveAction(
{ getState, patchState }: StateContext<Layout.State>,
{ name }: LayoutRemoveNavigationElementByName,
) {
@Action(RemoveNavigationElementByName)
layoutRemoveAction({ getState, patchState }: StateContext<Layout.State>, { name }: RemoveNavigationElementByName) {
let { navigationElements } = getState();
const index = navigationElements.findIndex(element => element.name === name);

6
npm/ng-packs/packages/theme-shared/src/lib/components/button/button.component.ts

@ -1,4 +1,4 @@
import { LoaderStart, LoaderStop } from '@abp/ng.core';
import { StartLoader, StopLoader } from '@abp/ng.core';
import { Component, Input, OnInit } from '@angular/core';
import { Actions, ofActionSuccessful } from '@ngxs/store';
import { filter } from 'rxjs/operators';
@ -40,8 +40,8 @@ export class ButtonComponent implements OnInit {
if (this.requestType || this.requestURLContainSearchValue) {
this.actions
.pipe(
ofActionSuccessful(LoaderStart, LoaderStop),
filter((event: LoaderStart | LoaderStop) => {
ofActionSuccessful(StartLoader, StopLoader),
filter((event: StartLoader | StopLoader) => {
let condition = true;
if (this.requestType) {
if (!Array.isArray(this.requestType)) this.requestType = [this.requestType];

14
npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.ts

@ -1,9 +1,9 @@
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { StartLoader, StopLoader } from '@abp/ng.core';
import { Component, Input, OnDestroy } from '@angular/core';
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
import { takeUntilDestroy } from '@ngx-validate/core';
import { Actions, ofActionSuccessful } from '@ngxs/store';
import { LoaderStart, LoaderStop } from '@abp/ng.core';
import { filter } from 'rxjs/operators';
import { Router, NavigationStart, NavigationEnd } from '@angular/router';
import { takeUntilDestroy } from '@ngx-validate/core';
@Component({
selector: 'abp-loader-bar',
@ -25,7 +25,7 @@ export class LoaderBarComponent implements OnDestroy {
isLoading: boolean = false;
@Input()
filter = (action: LoaderStart | LoaderStop) => action.payload.url.indexOf('openid-configuration') < 0;
filter = (action: StartLoader | StopLoader) => action.payload.url.indexOf('openid-configuration') < 0;
progressLevel: number = 0;
@ -34,12 +34,12 @@ export class LoaderBarComponent implements OnDestroy {
constructor(private actions: Actions, private router: Router) {
actions
.pipe(
ofActionSuccessful(LoaderStart, LoaderStop),
ofActionSuccessful(StartLoader, StopLoader),
filter(this.filter),
takeUntilDestroy(this),
)
.subscribe(action => {
if (action instanceof LoaderStart) this.startLoading();
if (action instanceof StartLoader) this.startLoading();
else this.stopLoading();
});

Loading…
Cancel
Save