File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ export async function saveAgent(agent) {
4444    await  axios . put ( url ,  agent ) ; 
4545} 
4646
47+ /** 
48+  * Refresh agent data 
49+  */ 
4750export  async  function  refreshAgents ( )  { 
4851    const  url  =  endpoints . agentRefreshUrl ; 
4952    await  axios . post ( url ) ; 
Original file line number Diff line number Diff line change 11<script >
2- 	import  { Alert , Button ,  Col ,  Row  } from  ' @sveltestrap/sveltestrap'  ; 
2+ 	import  { Alert , Button  } from  ' @sveltestrap/sveltestrap'  ; 
33	import  Breadcrumb  from  ' $lib/common/Breadcrumb.svelte'  ; 
44	import  HeadTitle  from  ' $lib/common/HeadTitle.svelte'  ; 
5-   import  { onMount  } from  ' svelte'  ; 
65	import  { refreshAgents  } from  ' $lib/services/agent-service'  ; 
76
8-   /**  @type  {import('$types').AgentModel[]}  */  
9-   let  agents =  []; 
107  let  isLoading =  false ; 
118  let  isComplete =  false ; 
9+   let  isError =  false ; 
10+   const  duration  =  3000 ; 
1211
1312  const  refreshAgentData  =  () =>  { 
1413    isLoading =  true ; 
1716      isLoading =  false ; 
1817      setTimeout (() =>  { 
1918        isComplete =  false ; 
20-       }, 3000 ); 
19+       }, duration ); 
2120    }).catch (err  =>  { 
2221      isLoading =  false ; 
22+       isComplete =  false ; 
23+       isError =  true ; 
24+       setTimeout (() =>  { 
25+         isError =  false ; 
26+       }, duration); 
2327    }); 
2428  }; 
2529
26-   onMount (async  () =>  { 
27-     agents =  await  getAgents ({ 
28-       isEvaluator:  false  
29-     }); 
30-   }); 
3130 </script >
3231
3332<HeadTitle  title =" MongoDB"   />
34- 
3533<Breadcrumb  title =" MongoDB"   pagetitle =" Setting"   />
3634
3735{#if  isLoading }
4240
4341{#if  isComplete }
4442  <Alert  color =" success"  >
45-     <div >Update comppleted!</div >
43+     <div >Update completed!</div >
44+   </Alert >
45+ {/if }
46+ 
47+ {#if  isError }
48+   <Alert  color =" danger"  >
49+     <div >Error!</div >
4650  </Alert >
4751{/if }
4852
4953<h3 >Migrate agents from file repository to MongoDB</h3 >
50- <Button  color ="primary"  on:click ={() =>  refreshAgentData ()}>
54+ <Button  color ="primary"  on:click ={() =>  refreshAgentData ()}  disabled ={ isComplete   ||   isError } >
5155  <i  class =" bx bx-copy"   /> Start Migration
5256</Button >
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments