1+ <template >
2+ <div >
3+
4+ <div class =" form-group" >
5+ <label
6+ >Enter your auth token
7+ <a
8+ href =" https://trailofbits.github.io/algo/cloud-scaleway.html"
9+ title =" https://trailofbits.github.io/algo/cloud-scaleway.html"
10+ target =" _blank"
11+ rel =" noreferrer noopener"
12+ class =" badge bagde-pill badge-primary"
13+ >?</a
14+ ></label
15+ >
16+ <input
17+ type =" text"
18+ class =" form-control"
19+ name =" scaleway_token"
20+ v-bind:disabled =" ui_loading_check || ui_token_from_env"
21+ v-model =" scaleway_token"
22+ />
23+ <p v-if =" ui_token_from_env" >Token was read from the environment</p >
24+ </div >
25+
26+ <div class =" form-group" >
27+ <region-select v-model =" region" v-bind:options =" ui_region_options" >
28+ </region-select >
29+ </div >
30+
31+ <button
32+ class =" btn btn-primary"
33+ type =" button"
34+ v-on:click =" submit"
35+ v-bind:disabled =" !is_valid"
36+ >
37+ Next
38+ </button >
39+ </div >
40+ </template >
41+
42+ <script >
43+ module .exports = {
44+ data : function () {
45+ return {
46+ scaleway_token: null ,
47+ region: null ,
48+ // helper variables
49+ ui_token_from_env: false ,
50+ ui_loading_check: false ,
51+ ui_region_options: [
52+ {value: ' Paris 1' , key: ' par1' },
53+ {value: ' Amsterdam 1' , key: ' ams1' }
54+ ]
55+ };
56+ },
57+ created : function () {
58+ this .check_config ();
59+ },
60+ computed: {
61+ is_valid () {
62+ return this .region && (this .scaleway_token || this .ui_token_from_env );
63+ }
64+ },
65+ methods: {
66+ check_config () {
67+ this .ui_loading_check = true ;
68+ fetch (" /scaleway_config" )
69+ .then (r => r .json ())
70+ .then (response => {
71+ if (response .ok ) {
72+ this .ui_token_from_env = true ;
73+ }
74+ })
75+ .finally (() => {
76+ this .ui_loading_check = false ;
77+ });
78+ },
79+ submit () {
80+ if (this .ui_token_from_env ) {
81+ this .$emit (" submit" , {
82+ region: this .region
83+ });
84+ } else {
85+ this .$emit (" submit" , {
86+ scaleway_token: this .scaleway_token ,
87+ region: this .region
88+ });
89+ }
90+ },
91+ },
92+ components: {
93+ " region-select" : window .httpVueLoader (" /static/region-select.vue" )
94+ },
95+ };
96+ </script >
0 commit comments