feat(manager/users/share): Enhance device sharing functionality and update related APIs and UI components
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { API_THINGS_SEARCH } from '@/constants/api';
|
||||
import {
|
||||
API_SHARE_THING,
|
||||
API_THING_POLICY,
|
||||
API_THINGS_SEARCH,
|
||||
} from '@/constants/api';
|
||||
import { request } from '@umijs/max';
|
||||
|
||||
export async function apiSearchThings(
|
||||
@@ -28,3 +32,43 @@ export async function apiSearchThings(
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function apiGetThingPolicyByUser(
|
||||
params: Partial<MasterModel.SearchPaginationBody>,
|
||||
userId: string,
|
||||
) {
|
||||
return request<MasterModel.ThingPolicyResponse>(
|
||||
`${API_THING_POLICY}/${userId}`,
|
||||
{
|
||||
params: params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export async function apiDeleteUserThingPolicy(
|
||||
thing_id: string,
|
||||
user_id: string,
|
||||
) {
|
||||
return request(`${API_SHARE_THING}/${thing_id}/share`, {
|
||||
method: 'DELETE',
|
||||
data: {
|
||||
policies: ['read', 'write', 'delete'],
|
||||
user_ids: [user_id],
|
||||
},
|
||||
getResponse: true,
|
||||
});
|
||||
}
|
||||
export async function apiShareThingToUser(
|
||||
thing_id: string,
|
||||
user_id: string,
|
||||
policies: string[],
|
||||
) {
|
||||
return request(`${API_SHARE_THING}/${thing_id}/share`, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
policies: policies,
|
||||
user_ids: [user_id],
|
||||
},
|
||||
getResponse: true,
|
||||
});
|
||||
}
|
||||
|
||||
27
src/services/master/typings.d.ts
vendored
27
src/services/master/typings.d.ts
vendored
@@ -160,21 +160,24 @@ declare namespace MasterModel {
|
||||
}
|
||||
|
||||
// Thing Policy
|
||||
interface ThingPolicyResponse {
|
||||
total?: number;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
order?: string;
|
||||
direction?: string;
|
||||
metadata?: null;
|
||||
things?: ThingPolicy[];
|
||||
}
|
||||
|
||||
interface ThingPolicy {
|
||||
next_page_token?: string;
|
||||
relations?: Relation[];
|
||||
policies?: Policy[];
|
||||
thing_id?: string;
|
||||
thing_name?: string;
|
||||
external_id?: string;
|
||||
}
|
||||
|
||||
interface Relation {
|
||||
id?: string;
|
||||
actions?: Action[];
|
||||
}
|
||||
|
||||
enum Action {
|
||||
Delete = 'delete',
|
||||
Read = 'read',
|
||||
Write = 'write',
|
||||
}
|
||||
type Policy = 'read' | 'delete' | 'write';
|
||||
|
||||
// Group
|
||||
|
||||
|
||||
Reference in New Issue
Block a user