mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-21 20:28:11 +01:00
added dav client
This commit is contained in:
parent
816d189422
commit
f062b2dd41
1 changed files with 54 additions and 0 deletions
54
src/davClient.js
Normal file
54
src/davClient.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
|
||||||
|
const DAV_VERDIGADO_NAMESPACE = "{http://verdigado.com/ns}";
|
||||||
|
|
||||||
|
const DAV_PROPERTIES = {
|
||||||
|
ORGANIZATION_FOLDER_ID_PROPERTYNAME: DAV_VERDIGADO_NAMESPACE + "organization-folder-id",
|
||||||
|
ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME: DAV_VERDIGADO_NAMESPACE + "organization-folder-resource-id",
|
||||||
|
ORGANIZATION_FOLDER_RESOURCE_MANAGER_PERMISSIONS_PROPERTYNAME: DAV_VERDIGADO_NAMESPACE + "organization-folder-resource-user-has-manager-permissions",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @member {OC.Files.Client} client
|
||||||
|
*/
|
||||||
|
let client
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {OC.Files.Client} filesClient files dav client
|
||||||
|
*/
|
||||||
|
export function initFilesClient(filesClient) {
|
||||||
|
client = filesClient
|
||||||
|
client.addFileInfoParser((response) => {
|
||||||
|
const data = {};
|
||||||
|
const props = response.propStat[0].properties;
|
||||||
|
|
||||||
|
const organizationFolderId = props[DAV_PROPERTIES.ORGANIZATION_FOLDER_ID_PROPERTYNAME];
|
||||||
|
if (typeof organizationFolderId !== 'undefined') {
|
||||||
|
data.organizationFolderId = parseInt(organizationFolderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const organizationFolderResourceId = props[DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME];
|
||||||
|
if (typeof organizationFolderResourceId !== 'undefined') {
|
||||||
|
data.organizationFolderResourceId = parseInt(organizationFolderResourceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userManagerPermissions = props[DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_MANAGER_PERMISSIONS_PROPERTYNAME];
|
||||||
|
if (typeof userManagerPermissions !== 'undefined') {
|
||||||
|
data.userManagerPermissions = userManagerPermissions === "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
(function(OC) {
|
||||||
|
Object.assign(OC.Files.Client, DAV_PROPERTIES)
|
||||||
|
})(window.OC)
|
||||||
|
|
||||||
|
export async function getFolderProperties(path) {
|
||||||
|
return client.getFileInfo(path, {
|
||||||
|
properties: [DAV_PROPERTIES.ORGANIZATION_FOLDER_ID_PROPERTYNAME, DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME, DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_MANAGER_PERMISSIONS_PROPERTYNAME],
|
||||||
|
}).then((status, fileInfo) => {
|
||||||
|
return {status, fileInfo};
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue