@@ -28,16 +28,28 @@ <h1 class="mb-5 text-center">{{ title }}</h1>
2828 < user-config class ="col-md-4 order-md-2 mb-4 "> </ user-config >
2929 < vpn-setup class ="col-md-8 order-md-1 "
3030 v-bind:extra_args ="extra_args "
31- v-on:submit ="set_step( 'provider'); update_extra_args "> </ vpn-setup >
31+ v-on:submit ="step = 'provider' "> </ vpn-setup >
3232 </ div >
3333 </ transition >
3434 < transition name ="fade ">
3535 < provider-setup v-if ="step == 'provider' "
3636 v-bind:extra_args ="extra_args "
37- v-on:submit ="update_extra_args "
38- v-on:back ="set_step( 'setup') ">
37+ v-on:submit ="step = 'command' "
38+ v-on:back ="step = 'setup' ">
3939 </ provider-setup >
4040 </ transition >
41+ < transition name ="fade ">
42+ < command-preview v-if ="step == 'command' "
43+ v-bind:extra_args ="extra_args "
44+ v-on:submit ="start(); step = 'running'; "
45+ v-on:back ="step = 'provider' ">
46+ </ command-preview >
47+ </ transition >
48+ < transition name ="fade ">
49+ < status-running v-if ="step == 'running' "
50+ v-on:submit ="stop(); step = 'setup'; ">
51+ </ status-running >
52+ </ transition >
4153 </ div >
4254
4355 < script >
@@ -47,7 +59,7 @@ <h1 class="mb-5 text-center">{{ title }}</h1>
4759 playbook : { } ,
4860 step : 'setup' ,
4961 extra_args : {
50- server_name : "algo" ,
62+ server_name : 'algo2' ,
5163 ondemand_cellular : false ,
5264 ondemand_wifi : false ,
5365 dns_adblocking : false ,
@@ -65,13 +77,32 @@ <h1 class="mb-5 text-center">{{ title }}</h1>
6577 'user-config' : window . httpVueLoader ( '/static/user-config.vue' ) ,
6678 'vpn-setup' : window . httpVueLoader ( '/static/vpn-setup.vue' ) ,
6779 'provider-setup' : window . httpVueLoader ( '/static/provider-setup.vue' ) ,
80+ 'command-preview' : window . httpVueLoader ( '/static/command-preview.vue' ) ,
81+ 'status-running' : window . httpVueLoader ( '/static/status-running.vue' ) ,
82+ } ,
83+ created ( ) {
84+ fetch ( "/playbook" )
85+ . then ( r => r . json ( ) )
86+ . then ( data => {
87+ if ( data . status === 'running' ) {
88+ this . step = 'running' ;
89+ }
90+ } ) ;
6891 } ,
6992 methods : {
70- set_step : function ( step ) {
71- this . step = step ;
93+ start : function ( ) {
94+ fetch ( "/playbook" , {
95+ method : "POST" ,
96+ body : JSON . stringify ( this . extra_args ) ,
97+ headers : {
98+ "Content-Type" : "application/json"
99+ }
100+ } ) ;
72101 } ,
73- update_extra_args : function ( extra_args ) {
74- Object . assign ( this . extra_args , extra_args ) ;
102+ stop ( ) {
103+ fetch ( "/playbook" , {
104+ method : "DELETE"
105+ } ) ;
75106 }
76107 }
77108 } )
0 commit comments