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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user