1.0.6 • Published 2 years ago

pod-space-folder v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

pod-space-folder

This library was generated with tsdx.

This package prepare file management ui for specific userGroupHash based on podspace endpoints.

❗⚠️❗ Warning:

This package designed for react apps

usage

npm i pod-space-folder --save

import PodSpaceFolder from 'pod-space-folder';";
const App = () => {

 const handleError = (error: Error) => {
  //you can handle errors of package requests to podspace server
  console.log(error);
 };

 const onRefresh = (): Promise<string | null> => {
  return new Promise(async (resolve, reject) => {
   // on 401 status error code you should refresh token
   await RefreshToken();
   resolve(newRefreshToken);
  });
 };

 const onSuccess = (fileHash: string, userGroupHash: string): Promise<boolean> => {
  return new Promise(async (resolve, reject) => {
   // share hash of uploaded file to usergroupHash with your bussiness token
   // resolve promise with true if share request is successfull and false if not
   resolve(true);
  });
 };

 const onSelect = (file: IFile) => {
  console.log(file);
 };

  return (
	<div>
	 <PodSpaceFolder
      userToken={''}
      userGroupHash={''}
      handleError={handleError}
      onSuccess={onSuccess}
      podspaceApi={''} // podspace backend server
      onRefresh={onRefresh}
      onSelect={onSelect} // return selected file details
      // You can define your menu for each file in list
      menu={[
       {
        text: 'first title',
        onClick: (file: IFile) => console.log(file),
        icon: <AppleIcon />,//
       },
       {
        text: 'second title',
        onClick: (file: IFile) => console.log(file),
        icon: <AccessAlarmIcon />,
       },
       {
        text: 'third title',
        onClick: (file: IFile) => console.log(file),
        icon: <AcUnitIcon />,
       },
      ]}
     />
    </div>
  );

};

Interfaces (if you using typescript):

	declare interface IFile {

		hash: string;

		name: string;

		type: string;

		parentHash: string;

		owner: IUser;

		uploader: IUser;

		attributes: string[];

		created: number;

		updated: number;

		extension: string;

		size: number;

		metaData: string;

		version: number;

		thumbnail: 'WAITING_FOR_THUMBNAIL' | string;

		uploadTime?: number;

	}



	declare interface IUser {

		avatar: string;

		name: string;

		roles: ERoles[];

		ssoId: number;

		username: string;

	}



	enum ERoles {

		USER_ROLE = 'USER_ROLE',

		USER_GROUP_MANAGER_ROLE = 'USER_GROUP_MANAGER_ROLE',

		ADMIN_ROLE = 'ADMIN_ROLE',

	}

;)

1.0.6

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.3.9

3 years ago

0.3.8

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.7

3 years ago

0.2.3

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.0

3 years ago