Browse Source

add load and release collection

nameczz 4 years ago
parent
commit
b97ed0deee

+ 12 - 0
client/src/http/Collection.ts

@@ -39,6 +39,18 @@ export class CollectionHttp extends BaseModel implements CollectionView {
     return super.delete({ path: `${this.COLLECTIONS_URL}/${collectionName}` });
   }
 
+  static loadCollection(collectionName: string) {
+    return super.update({
+      path: `${this.COLLECTIONS_URL}/${collectionName}/load`,
+    });
+  }
+
+  static releaseCollection(collectionName: string) {
+    return super.update({
+      path: `${this.COLLECTIONS_URL}/${collectionName}/release`,
+    });
+  }
+
   get _autoId() {
     return this.autoID;
   }

+ 1 - 0
client/src/i18n/cn/success.ts

@@ -3,6 +3,7 @@ const successTrans = {
   create: `{{name}} has been created`,
   load: `{{name}} has been loaded`,
   delete: `{{name}} successfully deleted`,
+  release: `{{name}} has been released`,
 };
 
 export default successTrans;

+ 1 - 0
client/src/i18n/en/success.ts

@@ -3,6 +3,7 @@ const successTrans = {
   create: `{{name}} has been created`,
   load: `{{name}} has been loaded`,
   delete: `{{name}} successfully deleted`,
+  release: `{{name}} has been released`,
 };
 
 export default successTrans;

+ 13 - 3
client/src/pages/collections/Collections.tsx

@@ -42,7 +42,7 @@ const useStyles = makeStyles((theme: Theme) => ({
 
 const Collections = () => {
   useNavigationHook(ALL_ROUTER_TYPES.COLLECTIONS);
-  const { handleAction } = useDialogHook({ type: 'partition' });
+  const { handleAction } = useDialogHook({ type: 'collection' });
   const [collections, setCollections] = useState<CollectionView[]>([]);
   const {
     pageSize,
@@ -116,9 +116,19 @@ const Collections = () => {
     fetchData();
   };
 
-  const handleRelease = async (data: CollectionView) => {};
+  const handleRelease = async (data: CollectionView) => {
+    const res = await CollectionHttp.releaseCollection(data._name);
+    openSnackBar(successTrans('release', { name: t('collection') }));
+    fetchData();
+    return res;
+  };
 
-  const handleLoad = async (data: CollectionView) => {};
+  const handleLoad = async (data: CollectionView) => {
+    const res = await CollectionHttp.loadCollection(data._name);
+    openSnackBar(successTrans('load', { name: t('collection') }));
+    fetchData();
+    return res;
+  };
 
   const handleDelete = async () => {
     for (const item of selectedCollections) {