blob: d492a5007844569f08902b50a0bde820110081c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
{% extends "layout.html" %}
{% from "loading.html" import loading_block_ui %}
{% block head %}
<script>
$(document).ready(function () {
function changePage(key) {
$('.progressbar li[data-key=' + key + ']').prevAll().addClass('completed');
$('.progressbar li[data-key=' + key + ']').nextAll().removeClass('active completed');
$('.progressbar li[data-key=' + key + ']').addClass('active').removeClass('completed');
$('.config-steps.active').removeClass('active').addClass('o_hide');
$('.config-steps[data-key=' + key + ']').removeClass('o_hide').addClass('active');
}
$('.next-btn').on('click', function (ev) {
changePage($(ev.target).data('key'));
});
$('#config-form').submit(function(e){
e.preventDefault();
$('.loading-block').removeClass('o_hide');
$.ajax({
url: '/step_configure',
type: 'post',
data: $('#config-form').serialize(),
}).done(function (url) {
$('.loading-block').addClass('o_hide');
changePage('done');
if(url) {
if ($('#iotname')[0].defaultValue == $('#iotname')[0].value){
var cpt = 30;
}else{
var cpt = 100;
}
setInterval(function(){
if(cpt === 0){
window.location = url
} else {
$('.redirect-message').html('You will be redirected to <a href="'+ url +'">' + url + '</a> in <b>' + cpt + '</b> seconds');
--cpt;
}
} , 1000);
}
}).fail(function () {
$('.error-message').text('Error in submitting data');
$('.loading-block').addClass('o_hide');
});
});
});
</script>
<style>
.config-steps .title {
font-weight: bold;
margin-bottom: 10px;
}
.progressbar {
counter-reset: step;
z-index: 1;
position: relative;
display: inline-block;
width: 100%;
padding: 0;
}
.progressbar li{
list-style-type: none;
float: left;
width: 33.33%;
position:relative;
text-align: center;
font-size: 0.8rem;
}
.progressbar li:before {
content:counter(step);
counter-increment: step;
height:30px;
width:30px;
line-height: 30px;
border: 2px solid #ddd;
display:block;
text-align: center;
margin: 0 auto 6px auto;
border-radius: 50%;
background-color: white;
color: #ddd;
font-size: 1rem;
}
.progressbar li:after {
content:'';
position: absolute;
width:100%;
height:2px;
background-color: #ddd;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content:none;
}
.progressbar li.active, .progressbar li.completed {
color:#875A7B;
}
.progressbar li:last-child:before {
content: '✔';
}
.progressbar li.active:before {
border-color:#875A7B;
background-color:#875A7B;
color: #fff;
}
.progressbar li.completed:before{
border-color:#875A7B;
background-color: #fff;
color: #875A7B;
}
.progressbar li.active + li:after{
background-color:#875A7B;
}
.footer-buttons {
display: inline-block;
width: 100%;
margin-top: 20px;
}
</style>
{% endblock %}
{% block content %}
<h2 class="text-center">Configure IoT Box</h2>
<ul class="progressbar">
<li class="active" data-key="server">Connect to Odoo</li>
<li data-key="wifi">Connect to Internet</li>
<li data-key="done">Done</li>
</ul>
<form id="config-form" style="margin-top: 20px;" action='/step_configure' method='POST'>
<div>
<div class="config-steps active" data-key="server">
<table align="center">
<tr>
<td>IoT Box Name</td>
<td><input type="text" id="iotname" name="iotname" value="{{ hostname }}"></td>
</tr>
<tr>
<td>Server token</td>
<td><input type="text" name="token" value="{{ server }}" placeholder="Paste your copied token here"></td>
</tr>
</table>
<div class="text-center font-small" style="margin: 10px auto;">
Server token is not mandatory for the community version.
</div>
<div class="footer-buttons">
<a class="btn next-btn" style="float: right" data-key="wifi">Next</a>
</div>
</div>
<div class="config-steps wifi-step o_hide" data-key="wifi">
<table align="center">
<tr>
<td>Wifi Network</td>
<td>
<select name="essid">
{% for id in ssid -%}
<option value="{{ id }}">{{ id }}</option>
{%- endfor %}
</select>
</td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" placeholder="Optional"/></td>
</tr>
<input type="hidden" name="persistent" value="True"/>
</table>
<div class="footer-buttons">
<a class="btn next-btn" data-key="server">Previous</a>
<input class="btn" style="float: right" type="submit" value="Connect"/>
</div>
</div>
<div class="config-steps o_hide" data-key="done">
<h3 class="text-center" style="margin: 0;">✔ Nice! Your configuration is done.</h3>
<p class="text-center redirect-message" />
</div>
</div>
{{ loading_block_ui(loading_message) }}
</form>
{% endblock %}
|