36 changed files with 1596 additions and 52 deletions
@ -0,0 +1,7 @@ |
|||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityClaimDto |
||||
|
{ |
||||
|
public string Type { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourceCreateDto |
||||
|
{ |
||||
|
[Required] |
||||
|
[StringLength(IdentityResourceConsts.NameMaxLength)] |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
[StringLength(IdentityResourceConsts.DisplayNameMaxLength)] |
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
[StringLength(IdentityResourceConsts.DescriptionMaxLength)] |
||||
|
public string Description { get; set; } |
||||
|
|
||||
|
public bool Enabled { get; set; } |
||||
|
|
||||
|
public bool Required { get; set; } |
||||
|
|
||||
|
public bool Emphasize { get; set; } |
||||
|
|
||||
|
public bool ShowInDiscoveryDocument { get; set; } |
||||
|
|
||||
|
public List<IdentityClaimDto> UserClaims { get; set; } |
||||
|
|
||||
|
public IdentityResourceCreateDto() |
||||
|
{ |
||||
|
Enabled = true; |
||||
|
Required = false; |
||||
|
ShowInDiscoveryDocument = false; |
||||
|
UserClaims = new List<IdentityClaimDto>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourceDto : FullAuditedEntityDto<Guid> |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
|
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
|
||||
|
public string Description { get; set; } |
||||
|
|
||||
|
public string ConcurrencyStamp { get; set; } |
||||
|
|
||||
|
public bool Enabled { get; set; } |
||||
|
|
||||
|
public bool Required { get; set; } |
||||
|
|
||||
|
public bool Emphasize { get; set; } |
||||
|
|
||||
|
public bool ShowInDiscoveryDocument { get; set; } |
||||
|
|
||||
|
public List<IdentityClaimDto> UserClaims { get; set; } |
||||
|
|
||||
|
public List<IdentityResourcePropertyDto> Properties { get; set; } |
||||
|
|
||||
|
public IdentityResourceDto() |
||||
|
{ |
||||
|
UserClaims = new List<IdentityClaimDto>(); |
||||
|
Properties = new List<IdentityResourcePropertyDto>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourceGetByIdInputDto : EntityDto<Guid> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourceGetByPagedInputDto : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public string Filter { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourcePropertyCreateDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public Guid IdentityResourceId { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[StringLength(2000)] |
||||
|
public string ConcurrencyStamp { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[StringLength(100)] |
||||
|
public string Key { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[StringLength(2000)] |
||||
|
public string Value { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourcePropertyDto |
||||
|
{ |
||||
|
public string Key { get; set; } |
||||
|
|
||||
|
public string Value { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourcePropertyGetByKeyDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public Guid IdentityResourceId { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[StringLength(100)] |
||||
|
public string Key { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public class IdentityResourceUpdateDto |
||||
|
{ |
||||
|
[Required] |
||||
|
public Guid Id { get; set; } |
||||
|
|
||||
|
[Required] |
||||
|
[StringLength(2000)] |
||||
|
public string ConcurrencyStamp { get; set; } |
||||
|
|
||||
|
[StringLength(IdentityResourceConsts.NameMaxLength)] |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
[StringLength(IdentityResourceConsts.DisplayNameMaxLength)] |
||||
|
public string DisplayName { get; set; } |
||||
|
|
||||
|
[StringLength(IdentityResourceConsts.DescriptionMaxLength)] |
||||
|
public string Description { get; set; } |
||||
|
|
||||
|
public bool Enabled { get; set; } |
||||
|
|
||||
|
public bool Required { get; set; } |
||||
|
|
||||
|
public bool Emphasize { get; set; } |
||||
|
|
||||
|
public bool ShowInDiscoveryDocument { get; set; } |
||||
|
|
||||
|
public List<IdentityClaimDto> UserClaims { get; set; } |
||||
|
|
||||
|
public IdentityResourceUpdateDto() |
||||
|
{ |
||||
|
Enabled = true; |
||||
|
Required = false; |
||||
|
ShowInDiscoveryDocument = false; |
||||
|
UserClaims = new List<IdentityClaimDto>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
public interface IIdentityResourceAppService : IApplicationService |
||||
|
{ |
||||
|
Task<IdentityResourceDto> GetAsync(IdentityResourceGetByIdInputDto identityResourceGetById); |
||||
|
|
||||
|
Task<PagedResultDto<IdentityResourceDto>> GetAsync(IdentityResourceGetByPagedInputDto identityResourceGetByPaged); |
||||
|
|
||||
|
Task<IdentityResourceDto> CreateAsync(IdentityResourceCreateDto identityResourceCreate); |
||||
|
|
||||
|
Task<IdentityResourceDto> UpdateAsync(IdentityResourceUpdateDto identityResourceUpdate); |
||||
|
|
||||
|
Task DeleteAsync(IdentityResourceGetByIdInputDto identityResourceGetById); |
||||
|
|
||||
|
Task<IdentityResourcePropertyDto> AddPropertyAsync(IdentityResourcePropertyCreateDto identityResourcePropertyCreate); |
||||
|
|
||||
|
Task DeletePropertyAsync(IdentityResourcePropertyGetByKeyDto identityResourcePropertyGetByKey); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,121 @@ |
|||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
[Authorize(AbpIdentityServerPermissions.IdentityResources.Default)] |
||||
|
public class IdentityResourceAppService : AbpIdentityServerAppServiceBase, IIdentityResourceAppService |
||||
|
{ |
||||
|
protected IIdentityResourceRepository IdentityResourceRepository { get; } |
||||
|
|
||||
|
public IdentityResourceAppService( |
||||
|
IIdentityResourceRepository identityResourceRepository) |
||||
|
{ |
||||
|
IdentityResourceRepository = identityResourceRepository; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IdentityResourceDto> GetAsync(IdentityResourceGetByIdInputDto identityResourceGetById) |
||||
|
{ |
||||
|
var identityResource = await IdentityResourceRepository.GetAsync(identityResourceGetById.Id); |
||||
|
|
||||
|
return ObjectMapper.Map<IdentityResource, IdentityResourceDto>(identityResource); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<IdentityResourceDto>> GetAsync(IdentityResourceGetByPagedInputDto identityResourceGetByPaged) |
||||
|
{ |
||||
|
var identityResources = await IdentityResourceRepository.GetListAsync(identityResourceGetByPaged.Sorting, |
||||
|
identityResourceGetByPaged.SkipCount, identityResourceGetByPaged.MaxResultCount, true); |
||||
|
var identityResourceCount = await IdentityResourceRepository.GetCountAsync(); |
||||
|
|
||||
|
return new PagedResultDto<IdentityResourceDto>(identityResourceCount, |
||||
|
ObjectMapper.Map<List<IdentityResource>, List<IdentityResourceDto>>(identityResources)); |
||||
|
} |
||||
|
|
||||
|
[Authorize(AbpIdentityServerPermissions.IdentityResources.Create)] |
||||
|
public virtual async Task<IdentityResourceDto> CreateAsync(IdentityResourceCreateDto identityResourceCreate) |
||||
|
{ |
||||
|
var identityResourceExists = await IdentityResourceRepository.CheckNameExistAsync(identityResourceCreate.Name); |
||||
|
if (identityResourceExists) |
||||
|
{ |
||||
|
throw new UserFriendlyException(L[AbpIdentityServerErrorConsts.IdentityResourceNameExisted, identityResourceCreate.Name]); |
||||
|
} |
||||
|
var identityResource = new IdentityResource(GuidGenerator.Create(), identityResourceCreate.Name, identityResourceCreate.DisplayName, |
||||
|
identityResourceCreate.Description, identityResourceCreate.Enabled, identityResourceCreate.Required, identityResourceCreate.Emphasize, |
||||
|
identityResourceCreate.ShowInDiscoveryDocument); |
||||
|
foreach(var claim in identityResourceCreate.UserClaims) |
||||
|
{ |
||||
|
identityResource.AddUserClaim(claim.Type); |
||||
|
} |
||||
|
identityResource = await IdentityResourceRepository.InsertAsync(identityResource); |
||||
|
|
||||
|
return ObjectMapper.Map<IdentityResource, IdentityResourceDto>(identityResource); |
||||
|
} |
||||
|
|
||||
|
[Authorize(AbpIdentityServerPermissions.IdentityResources.Update)] |
||||
|
public virtual async Task<IdentityResourceDto> UpdateAsync(IdentityResourceUpdateDto identityResourceUpdate) |
||||
|
{ |
||||
|
var identityResource = await IdentityResourceRepository.GetAsync(identityResourceUpdate.Id); |
||||
|
identityResource.ConcurrencyStamp = identityResourceUpdate.ConcurrencyStamp; |
||||
|
identityResource.Name = identityResourceUpdate.Name ?? identityResource.Name; |
||||
|
identityResource.DisplayName = identityResourceUpdate.DisplayName ?? identityResource.DisplayName; |
||||
|
identityResource.Description = identityResourceUpdate.Description ?? identityResource.Description; |
||||
|
identityResource.Enabled = identityResourceUpdate.Enabled; |
||||
|
identityResource.Emphasize = identityResourceUpdate.Emphasize; |
||||
|
identityResource.ShowInDiscoveryDocument = identityResourceUpdate.ShowInDiscoveryDocument; |
||||
|
if (identityResourceUpdate.UserClaims.Count > 0) |
||||
|
{ |
||||
|
identityResource.RemoveAllUserClaims(); |
||||
|
foreach (var claim in identityResourceUpdate.UserClaims) |
||||
|
{ |
||||
|
identityResource.AddUserClaim(claim.Type); |
||||
|
} |
||||
|
} |
||||
|
identityResource = await IdentityResourceRepository.UpdateAsync(identityResource); |
||||
|
|
||||
|
return ObjectMapper.Map<IdentityResource, IdentityResourceDto>(identityResource); |
||||
|
} |
||||
|
|
||||
|
[Authorize(AbpIdentityServerPermissions.IdentityResources.Delete)] |
||||
|
public virtual async Task DeleteAsync(IdentityResourceGetByIdInputDto identityResourceGetById) |
||||
|
{ |
||||
|
await IdentityResourceRepository.DeleteAsync(identityResourceGetById.Id); |
||||
|
} |
||||
|
|
||||
|
[Authorize(AbpIdentityServerPermissions.IdentityResources.Properties.Create)] |
||||
|
public virtual async Task<IdentityResourcePropertyDto> AddPropertyAsync(IdentityResourcePropertyCreateDto identityResourcePropertyCreate) |
||||
|
{ |
||||
|
var identityResource = await IdentityResourceRepository.GetAsync(identityResourcePropertyCreate.IdentityResourceId); |
||||
|
|
||||
|
if (identityResource.Properties.ContainsKey(identityResourcePropertyCreate.Key)) |
||||
|
{ |
||||
|
throw new UserFriendlyException(L[AbpIdentityServerErrorConsts.IdentityResourcePropertyExisted, identityResourcePropertyCreate.Key]); |
||||
|
} |
||||
|
identityResource.ConcurrencyStamp = identityResourcePropertyCreate.ConcurrencyStamp; |
||||
|
identityResource.Properties.Add(identityResourcePropertyCreate.Key, identityResourcePropertyCreate.Value); |
||||
|
|
||||
|
await IdentityResourceRepository.UpdateAsync(identityResource); |
||||
|
return new IdentityResourcePropertyDto |
||||
|
{ |
||||
|
Key = identityResourcePropertyCreate.Key, |
||||
|
Value = identityResourcePropertyCreate.Value |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
[Authorize(AbpIdentityServerPermissions.IdentityResources.Properties.Delete)] |
||||
|
public virtual async Task DeletePropertyAsync(IdentityResourcePropertyGetByKeyDto identityResourcePropertyGetByKey) |
||||
|
{ |
||||
|
var identityResource = await IdentityResourceRepository.GetAsync(identityResourcePropertyGetByKey.IdentityResourceId); |
||||
|
|
||||
|
if (!identityResource.Properties.ContainsKey(identityResourcePropertyGetByKey.Key)) |
||||
|
{ |
||||
|
throw new UserFriendlyException(L[AbpIdentityServerErrorConsts.IdentityResourcePropertyNotFound, identityResourcePropertyGetByKey.Key]); |
||||
|
} |
||||
|
identityResource.Properties.Remove(identityResourcePropertyGetByKey.Key); |
||||
|
await IdentityResourceRepository.UpdateAsync(identityResource); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,66 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IdentityServer.IdentityResources |
||||
|
{ |
||||
|
[RemoteService(Name = AbpIdentityServerConsts.RemoteServiceName)] |
||||
|
[Area("IdentityServer")] |
||||
|
[Route("api/IdentityServer/IdentityResources")] |
||||
|
public class IdentityResourceController : AbpController, IIdentityResourceAppService |
||||
|
{ |
||||
|
protected IIdentityResourceAppService IdentityResourceAppService { get; } |
||||
|
public IdentityResourceController( |
||||
|
IIdentityResourceAppService identityResourceAppService) |
||||
|
{ |
||||
|
IdentityResourceAppService = identityResourceAppService; |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("{Id}")] |
||||
|
public virtual async Task<IdentityResourceDto> GetAsync(IdentityResourceGetByIdInputDto identityResourceGetById) |
||||
|
{ |
||||
|
return await IdentityResourceAppService.GetAsync(identityResourceGetById); |
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
public virtual async Task<PagedResultDto<IdentityResourceDto>> GetAsync(IdentityResourceGetByPagedInputDto identityResourceGetByPaged) |
||||
|
{ |
||||
|
return await IdentityResourceAppService.GetAsync(identityResourceGetByPaged); |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
public virtual async Task<IdentityResourceDto> CreateAsync(IdentityResourceCreateDto identityResourceCreate) |
||||
|
{ |
||||
|
return await IdentityResourceAppService.CreateAsync(identityResourceCreate); |
||||
|
} |
||||
|
|
||||
|
[HttpPut] |
||||
|
public virtual async Task<IdentityResourceDto> UpdateAsync(IdentityResourceUpdateDto identityResourceUpdate) |
||||
|
{ |
||||
|
return await IdentityResourceAppService.UpdateAsync(identityResourceUpdate); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
public virtual async Task DeleteAsync(IdentityResourceGetByIdInputDto identityResourceGetById) |
||||
|
{ |
||||
|
await IdentityResourceAppService.DeleteAsync(identityResourceGetById); |
||||
|
} |
||||
|
|
||||
|
[HttpPost] |
||||
|
[Route("Properties")] |
||||
|
public virtual async Task<IdentityResourcePropertyDto> AddPropertyAsync(IdentityResourcePropertyCreateDto identityResourcePropertyCreate) |
||||
|
{ |
||||
|
return await IdentityResourceAppService.AddPropertyAsync(identityResourcePropertyCreate); |
||||
|
} |
||||
|
|
||||
|
[HttpDelete] |
||||
|
[Route("Properties")] |
||||
|
public virtual async Task DeletePropertyAsync(IdentityResourcePropertyGetByKeyDto identityResourcePropertyGetByKey) |
||||
|
{ |
||||
|
await IdentityResourceAppService.DeletePropertyAsync(identityResourcePropertyGetByKey); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
@echo off |
||||
|
cls |
||||
|
|
||||
|
start .\start-identity-server.bat --run |
||||
|
start .\start-apigateway-admin.cmd --run |
||||
|
start .\start-apigateway-host.cmd --run |
||||
@ -0,0 +1,245 @@ |
|||||
|
import ApiService from './serviceBase' |
||||
|
import { pagerFormat } from '@/utils/index' |
||||
|
import { FullAuditedEntityDto, PagedResultDto, PagedAndSortedResultRequestDto } from './types' |
||||
|
|
||||
|
/** 远程服务地址 */ |
||||
|
const serviceUrl = process.env.VUE_APP_BASE_API |
||||
|
|
||||
|
/** 身份资源Api接口 */ |
||||
|
export default class IdentityResourceService { |
||||
|
/** |
||||
|
* 获取身份资源 |
||||
|
* @param id 身份资源标识 |
||||
|
* @returns 返回类型为 IdentityResource 的对象 |
||||
|
*/ |
||||
|
public static getIdentityResourceById(id: string) { |
||||
|
let _url = '/api/IdentityServer/IdentityResources/' |
||||
|
_url += id |
||||
|
return ApiService.Get<IdentityResource>(_url, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取身份资源列表 |
||||
|
* @param payload 分页查询过滤对象 |
||||
|
* @returns 返回类型为 IdentityResource 的对象列表 |
||||
|
*/ |
||||
|
public static getIdentityResources(payload: IdentityResourceGetByPaged) { |
||||
|
let _url = '/api/IdentityServer/IdentityResources' |
||||
|
_url += '?filter=' + payload.filter |
||||
|
_url += '&sorting=' + payload.sorting |
||||
|
_url += '&skipCount=' + pagerFormat(payload.skipCount) |
||||
|
_url += '&maxResultCount=' + payload.maxResultCount |
||||
|
return ApiService.Get<PagedResultDto<IdentityResource>>(_url, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建身份资源 |
||||
|
* @param payload 类型为 IdentityResourceCreate 的对象 |
||||
|
* @returns 返回类型为 IdentityResource 的对象 |
||||
|
*/ |
||||
|
public static createIdentityResource(payload: IdentityResourceCreate) { |
||||
|
const _url = '/api/IdentityServer/IdentityResources' |
||||
|
return ApiService.Post<IdentityResource>(_url, payload, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 变更身份资源 |
||||
|
* @param payload 类型为 IdentityResourceUpdate 的对象 |
||||
|
* @returns 返回类型为 IdentityResource 的对象 |
||||
|
*/ |
||||
|
public static updateIdentityResource(payload: IdentityResourceUpdate) { |
||||
|
const _url = '/api/IdentityServer/IdentityResources' |
||||
|
return ApiService.Put<IdentityResource>(_url, payload, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除身份资源 |
||||
|
* @param id 身份资源标识 |
||||
|
*/ |
||||
|
public static deleteIdentityResource(id: string) { |
||||
|
let _url = '/api/IdentityServer/IdentityResources' |
||||
|
_url += '?id=' + id |
||||
|
return ApiService.Delete(_url, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建身份资源属性 |
||||
|
* @param payload 类型为 IdentityPropertyCreate 的对象 |
||||
|
* @returns 返回类型为 IdentityProperty 的对象 |
||||
|
*/ |
||||
|
public static createProperty(payload: IdentityPropertyCreate) { |
||||
|
const _url = '/api/IdentityServer/IdentityResources/Properties' |
||||
|
return ApiService.Post<IdentityProperty>(_url, payload, serviceUrl) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除身份资源属性 |
||||
|
* @param identityResourceId 身份资源标识 |
||||
|
* @param key 身份资源属性键 |
||||
|
*/ |
||||
|
public static deleteProperty(identityResourceId: string, key: string) { |
||||
|
let _url = '/api/IdentityServer/IdentityResources/Properties' |
||||
|
_url += '?identityResourceId=' + identityResourceId |
||||
|
_url += '&key=' + key |
||||
|
return ApiService.Delete(_url, serviceUrl) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 身份资源用户声明 */ |
||||
|
export class IdentityClaim { |
||||
|
/** 用户声明 */ |
||||
|
type = '' |
||||
|
} |
||||
|
|
||||
|
/** 身份资源属性 */ |
||||
|
export class IdentityProperty { |
||||
|
/** 键 */ |
||||
|
key = '' |
||||
|
/** 值 */ |
||||
|
value = '' |
||||
|
} |
||||
|
|
||||
|
/** 身份资源属性创建对象 */ |
||||
|
export class IdentityPropertyCreate { |
||||
|
/** 身份资源标识 */ |
||||
|
identityResourceId = '' |
||||
|
/** 键 */ |
||||
|
key = '' |
||||
|
/** 值 */ |
||||
|
value = '' |
||||
|
/** 并发令牌 */ |
||||
|
concurrencyStamp = '' |
||||
|
|
||||
|
/** 返回一个空对象 */ |
||||
|
public static empty() { |
||||
|
return new IdentityPropertyCreate() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 身份资源分页查询对象 */ |
||||
|
export class IdentityResourceGetByPaged extends PagedAndSortedResultRequestDto { |
||||
|
/** 过滤参数 */ |
||||
|
filter = '' |
||||
|
|
||||
|
/** 返回一个空对象 */ |
||||
|
public static empty() { |
||||
|
return new IdentityResourceGetByPaged() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 身份资源创建对象 */ |
||||
|
export class IdentityResourceCreate { |
||||
|
/** 名称 */ |
||||
|
name = '' |
||||
|
/** 显示名称 */ |
||||
|
displayName? = '' |
||||
|
/** 说明 */ |
||||
|
description? = '' |
||||
|
/** 启用 */ |
||||
|
enabled = true |
||||
|
/** 必须 */ |
||||
|
required = false |
||||
|
/** 强调 */ |
||||
|
emphasize = false |
||||
|
/** 在发现文档显示 */ |
||||
|
showInDiscoveryDocument = false |
||||
|
/** 用户声明 */ |
||||
|
userClaims = new Array<IdentityClaim>() |
||||
|
|
||||
|
/** 返回一个空对象 */ |
||||
|
public static empty() { |
||||
|
return new IdentityResourceCreate() |
||||
|
} |
||||
|
|
||||
|
/** 创建身份资源 */ |
||||
|
public static create(identityResource: IdentityResource) { |
||||
|
let resource = new IdentityResourceCreate() |
||||
|
resource.description = identityResource.description |
||||
|
resource.displayName = identityResource.displayName |
||||
|
resource.emphasize = identityResource.emphasize |
||||
|
resource.enabled = identityResource.enabled |
||||
|
resource.name = identityResource.name |
||||
|
resource.required = identityResource.required |
||||
|
resource.showInDiscoveryDocument = identityResource.showInDiscoveryDocument |
||||
|
resource.userClaims = identityResource.userClaims |
||||
|
return resource |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 身份资源变更对象 */ |
||||
|
export class IdentityResourceUpdate { |
||||
|
/** 身份资源标识 */ |
||||
|
id = '' |
||||
|
/** 名称 */ |
||||
|
name = '' |
||||
|
/** 显示名称 */ |
||||
|
displayName? = '' |
||||
|
/** 说明 */ |
||||
|
description? = '' |
||||
|
/** 启用 */ |
||||
|
enabled = true |
||||
|
/** 必须 */ |
||||
|
required = false |
||||
|
/** 强调 */ |
||||
|
emphasize = false |
||||
|
/** 在发现文档显示 */ |
||||
|
showInDiscoveryDocument = false |
||||
|
/** 并发令牌 */ |
||||
|
concurrencyStamp = '' |
||||
|
/** 用户声明 */ |
||||
|
userClaims = new Array<IdentityClaim>() |
||||
|
|
||||
|
/** 返回一个空对象 */ |
||||
|
public static empty() { |
||||
|
return new IdentityResourceUpdate() |
||||
|
} |
||||
|
|
||||
|
/** 创建身份资源 */ |
||||
|
public static create(identityResource: IdentityResource) { |
||||
|
let resource = new IdentityResourceUpdate() |
||||
|
resource.concurrencyStamp = identityResource.concurrencyStamp |
||||
|
resource.description = identityResource.description |
||||
|
resource.displayName = identityResource.displayName |
||||
|
resource.emphasize = identityResource.emphasize |
||||
|
resource.enabled = identityResource.enabled |
||||
|
resource.id = identityResource.id |
||||
|
resource.name = identityResource.name |
||||
|
resource.required = identityResource.required |
||||
|
resource.showInDiscoveryDocument = identityResource.showInDiscoveryDocument |
||||
|
resource.userClaims = identityResource.userClaims |
||||
|
return resource |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** 身份资源对象 */ |
||||
|
export class IdentityResource extends FullAuditedEntityDto { |
||||
|
/** 身份资源标识 */ |
||||
|
id!: string |
||||
|
/** 名称 */ |
||||
|
name!: string |
||||
|
/** 显示名称 */ |
||||
|
displayName?: string |
||||
|
/** 说明 */ |
||||
|
description?: string |
||||
|
/** 并发令牌 */ |
||||
|
concurrencyStamp!: string |
||||
|
/** 启用 */ |
||||
|
enabled!: boolean |
||||
|
/** 必须 */ |
||||
|
required!: boolean |
||||
|
/** 强调 */ |
||||
|
emphasize!: boolean |
||||
|
/** 在发现文档显示 */ |
||||
|
showInDiscoveryDocument!: boolean |
||||
|
/** 用户声明 */ |
||||
|
userClaims!: IdentityClaim[] |
||||
|
/** 属性 */ |
||||
|
properties!: IdentityProperty[] |
||||
|
|
||||
|
/** 返回一个空对象 */ |
||||
|
public static empty() { |
||||
|
const resource = new IdentityResource() |
||||
|
resource.enabled = true |
||||
|
return resource |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,196 @@ |
|||||
|
<template> |
||||
|
<div class="app-container"> |
||||
|
<div class="filter-container"> |
||||
|
<el-form |
||||
|
ref="formIdentityResource" |
||||
|
label-width="120px" |
||||
|
:model="identityResource" |
||||
|
:rules="identityResourceRules" |
||||
|
> |
||||
|
<el-form-item |
||||
|
prop="enabled" |
||||
|
:label="$t('identityServer.enabledResource')" |
||||
|
> |
||||
|
<el-switch |
||||
|
v-model="identityResource.enabled" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="name" |
||||
|
:label="$t('identityServer.resourceName')" |
||||
|
> |
||||
|
<el-input |
||||
|
v-model="identityResource.name" |
||||
|
:readonly="isEdit" |
||||
|
:placeholder="$t('pleaseInputBy', {key: $t('identityServer.resourceName')})" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="displayName" |
||||
|
:label="$t('identityServer.resourceDisplayName')" |
||||
|
> |
||||
|
<el-input |
||||
|
v-model="identityResource.displayName" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="description" |
||||
|
:label="$t('identityServer.resourceDescription')" |
||||
|
> |
||||
|
<el-input |
||||
|
v-model="identityResource.description" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="required" |
||||
|
:label="$t('identityServer.identityResourceRequired')" |
||||
|
> |
||||
|
<el-switch |
||||
|
v-model="identityResource.required" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="emphasize" |
||||
|
:label="$t('identityServer.identityResourceEmphasize')" |
||||
|
> |
||||
|
<el-switch |
||||
|
v-model="identityResource.emphasize" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="showInDiscoveryDocument" |
||||
|
:label="$t('identityServer.identityResourceShowInDiscoveryDocument')" |
||||
|
> |
||||
|
<el-switch |
||||
|
v-model="identityResource.showInDiscoveryDocument" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="userClaims" |
||||
|
:label="$t('identityServer.resourceUserClaims')" |
||||
|
> |
||||
|
<el-input-tag-ex |
||||
|
v-model="identityResource.userClaims" |
||||
|
label="type" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button |
||||
|
class="cancel" |
||||
|
style="width:100px" |
||||
|
@click="onCancel" |
||||
|
> |
||||
|
{{ $t('global.cancel') }} |
||||
|
</el-button> |
||||
|
<el-button |
||||
|
class="confirm" |
||||
|
type="primary" |
||||
|
style="width:100px" |
||||
|
@click="onSaveIdentityResource" |
||||
|
> |
||||
|
{{ $t('global.confirm') }} |
||||
|
</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts"> |
||||
|
import IdentityResourceService, { IdentityResourceCreate, IdentityResourceUpdate, IdentityResource } from '@/api/identityresources' |
||||
|
import { Component, Prop, Vue, Watch } from 'vue-property-decorator' |
||||
|
import ElInputTagEx from '@/components/InputTagEx/index.vue' |
||||
|
|
||||
|
@Component({ |
||||
|
name: 'IdentityResourceCreateOrEditForm', |
||||
|
components: { |
||||
|
ElInputTagEx |
||||
|
} |
||||
|
}) |
||||
|
export default class extends Vue { |
||||
|
@Prop({ default: '' }) |
||||
|
private identityResourceId!: string |
||||
|
|
||||
|
private identityResource: IdentityResource |
||||
|
private identityResourceRules = { |
||||
|
name: [ |
||||
|
{ required: true, message: this.l('pleaseInputBy', { key: this.l('identityServer.resourceName') }), trigger: 'blur' } |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
get isEdit() { |
||||
|
if (this.identityResource.id) { |
||||
|
return true |
||||
|
} |
||||
|
return false |
||||
|
} |
||||
|
|
||||
|
constructor() { |
||||
|
super() |
||||
|
this.identityResource = IdentityResource.empty() |
||||
|
} |
||||
|
|
||||
|
@Watch('identityResourceId', { immediate: true }) |
||||
|
private onIdentityResourceIdChanged() { |
||||
|
if (this.identityResourceId) { |
||||
|
IdentityResourceService.getIdentityResourceById(this.identityResourceId).then(resource => { |
||||
|
this.identityResource = resource |
||||
|
}) |
||||
|
} else { |
||||
|
this.identityResource = IdentityResource.empty() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private onSaveIdentityResource() { |
||||
|
const frmIdentityResource = this.$refs.formIdentityResource as any |
||||
|
frmIdentityResource.validate((valid: boolean) => { |
||||
|
if (valid) { |
||||
|
if (this.isEdit) { |
||||
|
const updateIdentityResource = IdentityResourceUpdate.create(this.identityResource) |
||||
|
IdentityResourceService.updateIdentityResource(updateIdentityResource).then(resource => { |
||||
|
this.identityResource = resource |
||||
|
const successMessage = this.l('identityServer.updateIdentityResourceSuccess', { name: resource.name }) |
||||
|
this.$message.success(successMessage) |
||||
|
frmIdentityResource.resetFields() |
||||
|
this.$emit('closed', true) |
||||
|
}) |
||||
|
} else { |
||||
|
const createIdentityResource = IdentityResourceCreate.create(this.identityResource) |
||||
|
IdentityResourceService.createIdentityResource(createIdentityResource).then(resource => { |
||||
|
this.identityResource = resource |
||||
|
const successMessage = this.l('identityServer.createIdentityResourceSuccess', { name: resource.name }) |
||||
|
this.$message.success(successMessage) |
||||
|
this.resetFields() |
||||
|
this.$emit('closed', true) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
private onCancel() { |
||||
|
this.resetFields() |
||||
|
this.$emit('closed', false) |
||||
|
} |
||||
|
|
||||
|
public resetFields() { |
||||
|
this.identityResource = IdentityResource.empty() |
||||
|
} |
||||
|
|
||||
|
private l(name: string, values?: any[] | { [key: string]: any }) { |
||||
|
return this.$t(name, values).toString() |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.confirm { |
||||
|
position: absolute; |
||||
|
right: 10px; |
||||
|
} |
||||
|
.cancel { |
||||
|
position: absolute; |
||||
|
right: 120px; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,173 @@ |
|||||
|
<template> |
||||
|
<div class="app-container"> |
||||
|
<div class="filter-container"> |
||||
|
<el-form |
||||
|
v-if="checkPermission(['IdentityServer.IdentityResources.Properties.Create'])" |
||||
|
ref="formIdentityProperty" |
||||
|
label-width="100px" |
||||
|
:model="identityProperty" |
||||
|
:rules="identityPropertyRules" |
||||
|
> |
||||
|
<el-form-item |
||||
|
prop="key" |
||||
|
:label="$t('identityServer.propertyKey')" |
||||
|
> |
||||
|
<el-input |
||||
|
v-model="identityProperty.key" |
||||
|
:placeholder="$t('pleaseInputBy', {key: $t('identityServer.propertyKey')})" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
<el-form-item |
||||
|
prop="value" |
||||
|
:label="$t('identityServer.propertyValue')" |
||||
|
> |
||||
|
<el-input |
||||
|
v-model="identityProperty.value" |
||||
|
:placeholder="$t('pleaseInputBy', {key: $t('identityServer.propertyValue')})" |
||||
|
/> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item |
||||
|
style="text-align: center;" |
||||
|
label-width="0px" |
||||
|
> |
||||
|
<el-button |
||||
|
type="primary" |
||||
|
style="width:180px" |
||||
|
@click="onSaveIdentityProperty" |
||||
|
> |
||||
|
{{ $t('identityServer.createIdentityProperty') }} |
||||
|
</el-button> |
||||
|
</el-form-item> |
||||
|
<el-divider /> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
<el-table |
||||
|
row-key="key" |
||||
|
:data="identityResource.properties" |
||||
|
border |
||||
|
fit |
||||
|
highlight-current-row |
||||
|
style="width: 100%;" |
||||
|
> |
||||
|
<el-table-column |
||||
|
:label="$t('identityServer.propertyKey')" |
||||
|
prop="key" |
||||
|
sortable |
||||
|
width="200px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span>{{ row.key }}</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('identityServer.propertyValue')" |
||||
|
prop="value" |
||||
|
sortable |
||||
|
min-width="400px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span>{{ row.value }}</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('operaActions')" |
||||
|
align="center" |
||||
|
width="150px" |
||||
|
fixed="right" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<el-button |
||||
|
:disabled="!checkPermission(['IdentityServer.Clients.Properties.Delete'])" |
||||
|
size="mini" |
||||
|
type="primary" |
||||
|
@click="handleDeleteIdentityProperty(row.key, row.value)" |
||||
|
> |
||||
|
{{ $t('identityServer.deleteProperty') }} |
||||
|
</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts"> |
||||
|
import IdentityResourceService, { IdentityResource, IdentityPropertyCreate } from '@/api/identityresources' |
||||
|
import { Component, Vue, Prop } from 'vue-property-decorator' |
||||
|
import { checkPermission } from '@/utils/permission' |
||||
|
|
||||
|
@Component({ |
||||
|
name: 'IdentityPropertyEditForm', |
||||
|
methods: { |
||||
|
checkPermission |
||||
|
} |
||||
|
}) |
||||
|
export default class extends Vue { |
||||
|
@Prop({ default: () => IdentityResource.empty() }) |
||||
|
private identityResource!: IdentityResource |
||||
|
|
||||
|
private identityProperty: IdentityPropertyCreate |
||||
|
private identityPropertyRules = { |
||||
|
key: [ |
||||
|
{ required: true, message: this.l('pleaseInputBy', { key: this.l('identityServer.propertyKey') }), trigger: 'blur' } |
||||
|
], |
||||
|
value: [ |
||||
|
{ required: true, message: this.l('pleaseInputBy', { key: this.l('identityServer.propertyValue') }), trigger: 'blur' } |
||||
|
] |
||||
|
} |
||||
|
|
||||
|
constructor() { |
||||
|
super() |
||||
|
this.identityProperty = IdentityPropertyCreate.empty() |
||||
|
} |
||||
|
|
||||
|
private handleDeleteIdentityProperty(key: string) { |
||||
|
this.$confirm(this.l('identityServer.deleteIdentityPropertyByKey', { key: key }), |
||||
|
this.l('identityServer.deleteProperty'), { |
||||
|
callback: (action) => { |
||||
|
if (action === 'confirm') { |
||||
|
IdentityResourceService.deleteProperty(this.identityResource.id, key).then(() => { |
||||
|
const deletePropertyIndex = this.identityResource.properties.findIndex(p => p.key === key && p.value === key) |
||||
|
this.identityResource.properties.splice(deletePropertyIndex, 1) |
||||
|
this.$message.success(this.l('identityServer.deleteIdentityPropertySuccess', { key: key })) |
||||
|
this.$emit('closed', true) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
private onSaveIdentityProperty() { |
||||
|
const frmIdentityProperty = this.$refs.formIdentityProperty as any |
||||
|
frmIdentityProperty.validate((valid: boolean) => { |
||||
|
if (valid) { |
||||
|
this.identityProperty.identityResourceId = this.identityResource.id |
||||
|
this.identityProperty.concurrencyStamp = this.identityResource.concurrencyStamp |
||||
|
IdentityResourceService.createProperty(this.identityProperty).then(property => { |
||||
|
this.identityResource.properties.push(property) |
||||
|
const successMessage = this.l('identityServer.createIdentityPropertySuccess', { key: this.identityProperty.key }) |
||||
|
this.$message.success(successMessage) |
||||
|
this.resetFields() |
||||
|
this.$emit('closed', true) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
public resetFields() { |
||||
|
this.identityProperty = IdentityPropertyCreate.empty() |
||||
|
} |
||||
|
|
||||
|
private l(name: string, values?: any[] | { [key: string]: any }) { |
||||
|
return this.$t(name, values).toString() |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.full-select { |
||||
|
width: 100%; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,367 @@ |
|||||
|
<template> |
||||
|
<div class="app-container"> |
||||
|
<div class="filter-container"> |
||||
|
<label |
||||
|
class="radio-label" |
||||
|
style="padding-left:10px;" |
||||
|
>{{ $t('global.queryFilter') }}</label> |
||||
|
<el-input |
||||
|
v-model="identityResourceGetPagedFilter.filter" |
||||
|
:placeholder="$t('filterString')" |
||||
|
style="width: 250px;margin-left: 10px;" |
||||
|
class="filter-item" |
||||
|
/> |
||||
|
<el-button |
||||
|
class="filter-item" |
||||
|
style="margin-left: 10px; text-alignt" |
||||
|
type="primary" |
||||
|
@click="handleGetIdentityResources" |
||||
|
> |
||||
|
{{ $t('global.searchList') }} |
||||
|
</el-button> |
||||
|
<el-button |
||||
|
class="filter-item" |
||||
|
type="primary" |
||||
|
:disabled="!checkPermission(['IdentityServer.IdentityResources.Create'])" |
||||
|
@click="handleShowEditIdentityResourceForm" |
||||
|
> |
||||
|
{{ $t('identityServer.createIdentityResource') }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<el-table |
||||
|
v-loading="identityResourceListLoading" |
||||
|
row-key="id" |
||||
|
:data="identityResourceList" |
||||
|
border |
||||
|
fit |
||||
|
highlight-current-row |
||||
|
style="width: 100%;" |
||||
|
@sort-change="handleSortChange" |
||||
|
> |
||||
|
<el-table-column |
||||
|
:label="$t('global.name')" |
||||
|
prop="name" |
||||
|
sortable |
||||
|
width="150px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span>{{ row.name }}</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('global.displayName')" |
||||
|
prop="displayName" |
||||
|
sortable |
||||
|
width="200px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span>{{ row.displayName }}</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('global.status')" |
||||
|
prop="enabled" |
||||
|
sortable |
||||
|
width="140px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<el-tag :type="row.enabled | statusFilter"> |
||||
|
{{ formatStatusText(row.enabled) }} |
||||
|
</el-tag> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('global.description')" |
||||
|
prop="description" |
||||
|
sortable |
||||
|
width="200px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span>{{ row.description }}</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('global.creationTime')" |
||||
|
prop="creationTime" |
||||
|
width="170px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span> |
||||
|
<el-tag> |
||||
|
{{ row.creationTime | datetimeFilter }} |
||||
|
</el-tag> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('global.lastModificationTime')" |
||||
|
prop="lastModificationTime" |
||||
|
width="170px" |
||||
|
align="center" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<span> |
||||
|
<el-tag type="warning"> |
||||
|
{{ row.lastModificationTime | datetimeFilter }} |
||||
|
</el-tag> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
<el-table-column |
||||
|
:label="$t('global.operaActions')" |
||||
|
align="center" |
||||
|
width="250px" |
||||
|
fixed="right" |
||||
|
> |
||||
|
<template slot-scope="{row}"> |
||||
|
<el-button |
||||
|
:disabled="!checkPermission(['IdentityServer.IdentityResources.Update'])" |
||||
|
size="mini" |
||||
|
type="primary" |
||||
|
@click="handleShowEditIdentityResourceForm(row)" |
||||
|
> |
||||
|
{{ $t('identityServer.updateIdentityResource') }} |
||||
|
</el-button> |
||||
|
<el-dropdown |
||||
|
class="options" |
||||
|
@command="handleCommand" |
||||
|
> |
||||
|
<el-button |
||||
|
v-permission="['IdentityServer.IdentityResources']" |
||||
|
size="mini" |
||||
|
type="info" |
||||
|
> |
||||
|
{{ $t('global.otherOpera') }}<i class="el-icon-arrow-down el-icon--right" /> |
||||
|
</el-button> |
||||
|
<el-dropdown-menu slot="dropdown"> |
||||
|
<el-dropdown-item |
||||
|
:command="{key: 'property', row}" |
||||
|
:disabled="!checkPermission(['IdentityServer.IdentityResources.Properties'])" |
||||
|
> |
||||
|
{{ $t('identityServer.identityResourceProperties') }} |
||||
|
</el-dropdown-item> |
||||
|
<el-dropdown-item |
||||
|
divided |
||||
|
:command="{key: 'delete', row}" |
||||
|
:disabled="!checkPermission(['IdentityServer.IdentityResources.Delete'])" |
||||
|
> |
||||
|
{{ $t('identityServer.deleteIdentityResource') }} |
||||
|
</el-dropdown-item> |
||||
|
</el-dropdown-menu> |
||||
|
</el-dropdown> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
</el-table> |
||||
|
|
||||
|
<Pagination |
||||
|
v-show="identityResourceListCount>0" |
||||
|
:total="identityResourceListCount" |
||||
|
:page.sync="identityResourceGetPagedFilter.skipCount" |
||||
|
:limit.sync="identityResourceGetPagedFilter.maxResultCount" |
||||
|
@pagination="handleGetIdentityResources" |
||||
|
@sort-change="handleSortChange" |
||||
|
/> |
||||
|
|
||||
|
<el-dialog |
||||
|
v-el-draggable-dialog |
||||
|
width="800px" |
||||
|
:visible.sync="showEditIdentityResourceDialog" |
||||
|
:title="editIdentityResourceTitle" |
||||
|
custom-class="modal-form" |
||||
|
:show-close="false" |
||||
|
:close-on-click-modal="false" |
||||
|
:close-on-press-escape="false" |
||||
|
@closed="handleIdentityResourceEditFormClosed" |
||||
|
> |
||||
|
<IdentityResourceCreateOrEditForm |
||||
|
ref="formIdentityResource" |
||||
|
:identity-resource-id="editIdentityResource.id" |
||||
|
@closed="handleIdentityResourceEditFormClosed" |
||||
|
/> |
||||
|
</el-dialog> |
||||
|
|
||||
|
<el-dialog |
||||
|
v-el-draggable-dialog |
||||
|
width="800px" |
||||
|
:visible.sync="showEditIdentityPropertyDialog" |
||||
|
:title="$t('identityServer.identityResourceProperties')" |
||||
|
custom-class="modal-form" |
||||
|
:show-close="false" |
||||
|
@closed="handleIdentityPropertyEditFormClosed" |
||||
|
> |
||||
|
<IdentityPropertyEditForm |
||||
|
ref="formIdentityProperty" |
||||
|
:identity-resource="editIdentityResource" |
||||
|
@closed="handleIdentityPropertyEditFormClosed" |
||||
|
/> |
||||
|
</el-dialog> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts"> |
||||
|
import { checkPermission } from '@/utils/permission' |
||||
|
import { Component, Vue } from 'vue-property-decorator' |
||||
|
import { dateFormat } from '@/utils/index' |
||||
|
import Pagination from '@/components/Pagination/index.vue' |
||||
|
import IdentityPropertyEditForm from './components/IdentityResourcePropertyEditForm.vue' |
||||
|
import IdentityResourceCreateOrEditForm from './components/IdentityResourceCreateOrEditForm.vue' |
||||
|
import IdentityResourceService, { IdentityResource, IdentityResourceGetByPaged } from '@/api/identityresources' |
||||
|
|
||||
|
@Component({ |
||||
|
name: 'IdentityServerIdentityResource', |
||||
|
components: { |
||||
|
Pagination, |
||||
|
IdentityPropertyEditForm, |
||||
|
IdentityResourceCreateOrEditForm |
||||
|
}, |
||||
|
methods: { |
||||
|
checkPermission |
||||
|
}, |
||||
|
filters: { |
||||
|
statusFilter(status: boolean) { |
||||
|
if (status) { |
||||
|
return 'success' |
||||
|
} |
||||
|
return 'warning' |
||||
|
}, |
||||
|
datetimeFilter(val: string) { |
||||
|
const date = new Date(val) |
||||
|
return dateFormat(date, 'YYYY-mm-dd HH:MM') |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
export default class extends Vue { |
||||
|
private editIdentityResource: IdentityResource |
||||
|
private identityResourceListCount: number |
||||
|
private editIdentityResourceTitle: any |
||||
|
private identityResourceList: IdentityResource[] |
||||
|
private identityResourceListLoading: boolean |
||||
|
private identityResourceGetPagedFilter: IdentityResourceGetByPaged |
||||
|
|
||||
|
private showEditIdentityPropertyDialog: boolean |
||||
|
private showEditIdentityResourceDialog: boolean |
||||
|
|
||||
|
constructor() { |
||||
|
super() |
||||
|
this.identityResourceListCount = 0 |
||||
|
this.editIdentityResourceTitle = '' |
||||
|
this.identityResourceListLoading = false |
||||
|
this.editIdentityResource = IdentityResource.empty() |
||||
|
this.identityResourceList = new Array<IdentityResource>() |
||||
|
this.identityResourceGetPagedFilter = new IdentityResourceGetByPaged() |
||||
|
|
||||
|
this.showEditIdentityPropertyDialog = false |
||||
|
this.showEditIdentityResourceDialog = false |
||||
|
} |
||||
|
|
||||
|
mounted() { |
||||
|
this.handleGetIdentityResources() |
||||
|
} |
||||
|
|
||||
|
private handleGetIdentityResources() { |
||||
|
this.identityResourceListLoading = true |
||||
|
IdentityResourceService.getIdentityResources(this.identityResourceGetPagedFilter).then(resources => { |
||||
|
this.identityResourceList = resources.items |
||||
|
this.identityResourceListCount = resources.totalCount |
||||
|
}).finally(() => { |
||||
|
this.identityResourceListLoading = false |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
private handleSortChange(column: any) { |
||||
|
this.identityResourceGetPagedFilter.sorting = column.prop |
||||
|
} |
||||
|
|
||||
|
private handleShowEditIdentityResourceForm(resource: IdentityResource) { |
||||
|
this.editIdentityResource = IdentityResource.empty() |
||||
|
if (resource) { |
||||
|
this.editIdentityResource = resource |
||||
|
this.editIdentityResourceTitle = this.l('identityServer.updateIdentityResourceByName', { name: this.editIdentityResource.name }) |
||||
|
} else { |
||||
|
this.editIdentityResourceTitle = this.l('identityServer.createIdentityResource') |
||||
|
} |
||||
|
this.showEditIdentityResourceDialog = true |
||||
|
} |
||||
|
|
||||
|
private handleIdentityResourceEditFormClosed(changed: boolean) { |
||||
|
this.reset(changed) |
||||
|
} |
||||
|
|
||||
|
private handleIdentityPropertyEditFormClosed(changed: boolean) { |
||||
|
this.reset(changed) |
||||
|
} |
||||
|
|
||||
|
private handleDeleteIdentityResource(id: string, name: string) { |
||||
|
this.$confirm(this.l('identityServer.deleteIdentityResourceByName', { name: name }), |
||||
|
this.l('identityServer.deleteIdentityResource'), { |
||||
|
callback: (action) => { |
||||
|
if (action === 'confirm') { |
||||
|
IdentityResourceService.deleteIdentityResource(id).then(() => { |
||||
|
this.$message.success(this.l('identityServer.deleteIdentityResourceSuccess', { name: name })) |
||||
|
this.handleGetIdentityResources() |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
private handleCommand(command: {key: string, row: IdentityResource}) { |
||||
|
this.editIdentityResource = command.row |
||||
|
switch (command.key) { |
||||
|
case 'property' : |
||||
|
this.showEditIdentityPropertyDialog = true |
||||
|
break |
||||
|
case 'delete' : |
||||
|
this.handleDeleteIdentityResource(command.row.id, command.row.name) |
||||
|
break |
||||
|
default: break |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private l(name: string, values?: any[] | { [key: string]: any }) { |
||||
|
return this.$t(name, values).toString() |
||||
|
} |
||||
|
|
||||
|
private formatStatusText(status: boolean) { |
||||
|
let statusText = '' |
||||
|
if (status) { |
||||
|
statusText = this.l('enabled') |
||||
|
} else { |
||||
|
statusText = this.l('disbled') |
||||
|
} |
||||
|
return statusText |
||||
|
} |
||||
|
|
||||
|
private reset(changed: boolean) { |
||||
|
this.editIdentityResourceTitle = '' |
||||
|
this.editIdentityResource = IdentityResource.empty() |
||||
|
this.showEditIdentityResourceDialog = false |
||||
|
this.showEditIdentityPropertyDialog = false |
||||
|
if (changed) { |
||||
|
this.handleGetIdentityResources() |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.roleItem { |
||||
|
width: 40px; |
||||
|
} |
||||
|
.options { |
||||
|
vertical-align: top; |
||||
|
margin-left: 20px; |
||||
|
} |
||||
|
.el-dropdown + .el-dropdown { |
||||
|
margin-left: 15px; |
||||
|
} |
||||
|
.el-icon-arrow-down { |
||||
|
font-size: 12px; |
||||
|
} |
||||
|
</style> |
||||
Loading…
Reference in new issue