This is an automated email from the ASF dual-hosted git repository.

marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git


The following commit(s) were added to refs/heads/main by this push:
     new d3d3b5e  Missed API added (#10)
d3d3b5e is described below

commit d3d3b5e897749c0927943823b8f27951635422d5
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Thu Oct 7 18:28:31 2021 -0400

    Missed API added (#10)
---
 karavan-designer/src/designer/api/KameletApi.tsx | 40 +++---------------------
 1 file changed, 5 insertions(+), 35 deletions(-)

diff --git a/karavan-designer/src/designer/api/KameletApi.tsx 
b/karavan-designer/src/designer/api/KameletApi.tsx
index f3d2fc0..3744d7f 100644
--- a/karavan-designer/src/designer/api/KameletApi.tsx
+++ b/karavan-designer/src/designer/api/KameletApi.tsx
@@ -65,46 +65,11 @@ export const KameletApi = {
         return KameletApi.findKameletByName(uri.split(":")[1]);
     },
 
-    requestKamelet: async (name: string): Promise<Kamelet> => {
-        // const res = await axios("/kamelet/" + name);
-        // const text: string = await res.data;
-        // const fromYaml = yaml.load(text);
-        const fromYaml = '';
-        return KameletApi.jsonToKamelet(JSON.stringify(fromYaml));
-    },
-
     yamlToKamelet: (text: string):Kamelet => {
         const fromYaml = yaml.load(text);
         return KameletApi.jsonToKamelet(JSON.stringify(fromYaml));
     },
 
-    prepareKamelets: () => {
-        Kamelets.splice(0, Kamelets.length);
-        // axios.get('/kamelet',
-        //     {headers: {'Accept': 'application/json'}})
-        //     .then(res => {
-        //         if (res.status === 200) {
-        //             KameletApi.loadKamelets(res.data);
-        //         }
-        //     }).catch(err => {
-        //     console.log(err);
-        // });
-    },
-
-    loadKamelets: (kameletNames: string[]) => {
-        const promises = kameletNames.map((name: string) => 
KameletApi.requestKamelet(name));
-        Promise.all(promises).then(function (list) {
-            const result: Kamelet[] = list as Kamelet[];
-            Kamelets.push(...result.sort((a, b) => {
-                    if (a.spec.definition.title < b.spec.definition.title) {
-                        return -1;
-                    }
-                    return a.spec.definition.title > b.spec.definition.title ? 
1 : 0;
-                })
-            );
-        });
-    },
-
     saveKamelets: (kameletYamls: string[]) => {
         const kamelets:Kamelet[] = kameletYamls.map(text => 
KameletApi.yamlToKamelet(text));
         Kamelets.push(...kamelets.sort((a, b) => {
@@ -114,5 +79,10 @@ export const KameletApi = {
                 return a.spec.definition.title > b.spec.definition.title ? 1 : 
0;
             })
         );
+    },
+
+    saveKamelet: (yaml: string) => {
+        const kamelet:Kamelet = KameletApi.yamlToKamelet(yaml);
+        Kamelets.push(kamelet);
     }
 }
\ No newline at end of file

Reply via email to