summaryrefslogtreecommitdiff
path: root/addons/hw_posbox_homepage/views/upgrade_page.html
blob: 81fe2c3b3dd081cb7a4df20f1688a09f7b8fc039 (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
{% extends "layout.html" %}
{% from "loading.html" import loading_block_ui %}
{% block head %}
    <script type="text/javascript" src="/web/static/lib/jquery/jquery.js"></script>
    <script>
        $(function() {
            var updating = false;
            $('#upgrade').click(function() {
                if (!updating) {
                    updating = true;
                    $('.loading-block').removeClass('o_hide');
                    $.ajax({
                        url:'/hw_proxy/perform_upgrade/'
                    }).done(function() {
                        $('.message-title').text('Upgrade successful');
                        var cpt = 25;
                        setInterval(function() {
                            --cpt;
                            if (cpt === 0) {location.reload();}
                            $('.message-status').text('Restarting the IoTBox.  Available in ' + cpt);
                        } , 1000);
                    }).fail(function() {
                        $('.error-message').text('Upgrade Failed');
                    });
                }
            });
            $('#flash').click(async function() {
                if (confirm('Are you sure you want to flash your IoT Box?\nThe box will be unavailable for ~30 min\nDo not turn off the box or close this page during the flash.\nThis page will reaload when your box is ready.')) {
                    $('.loading-block').removeClass('o_hide');
                    $('.message-title').text('IoTBox perform a self flashing it take a lot of time (~30min).');
                    $('.message-status').text('Prepare space for IoTBox.');
                    try {
                        await $.ajax({url: '/hw_proxy/perform_flashing_create_partition/'}).promise();
                        $('.message-status').text('Prepare new boot partition.');
                        await $.ajax({url: '/hw_proxy/perform_flashing_download_raspios/'}).promise();
                        $('.message-status').text('Download file for new boot partition.');
                        await $.ajax({url: '/hw_proxy/perform_flashing_copy_raspios/'}).promise();
                        $('.message-status').text('Prepare to restart and installation of the new version of the IoT Box.');
                        setTimeout(function() {
                        $('.message-status').text('The auto flash is almost finished - the page will be automatically reloaded');
                        setInterval(function() {
                            $.ajax({
                                url: '/hw_proxy/get_version',
                                timeout: 4000,
                            }).done(function(version) {
                                if (version == {{ flashToVersion }}) {
                                    window.location = '/';
                                }
                            });
                        } , 2000);
                    }, 240000);
                    }
                    catch(error) {
                        $('.loading-block').addClass('o_hide');
                        $('.error-message').text(error.responseText);
                    }
                }
            });
        });
    </script>
    <style>
        .commit-details {
            background: #f1f1f1;
            padding: 10px 10px 0 10px;
            border-radius: 5px;
        }
    </style>
{% endblock %}
{% block content %}
    <h2 class="text-center">IoT Box Software Upgrade</h2>
    <p>
        This tool will help you perform an upgrade of the IoTBox's software over the internet.
        However the preferred method to upgrade the IoTBox is to flash the sd-card with
        the <a href='https://nightly.odoo.com/master/iotbox/iotbox-latest.zip'>latest image</a>. The upgrade
        procedure is explained into to the
        <a href='https://www.odoo.com/documentation/14.0/applications/productivity/iot.html'>IoTBox manual</a>
    </p>
    <p>
        To upgrade the IoTBox, click on the upgrade button. The upgrade will take a few minutes. <b>Do not reboot</b> the IoTBox during the upgrade.
    </p>
    <div class="commit-details">
        <div style="padding-bottom: 5px; font-weight: bold;">
            Latest patch:
        </div>
        <pre style="margin: 0;padding: 15px 0; overflow: auto;">{{ commit|safe }}</pre>
    </div>
    <div class="text-center" style="margin: 15px auto;">
        {% if flashToVersion %}
            <a class="btn" href='#' id='flash'>Upgrade to {{ flashToVersion }}</a>
        {% else %}
            <a class="btn" href='#' id='upgrade'>Upgrade</a>
        {% endif %}
    </div>
    {{ loading_block_ui(loading_message) }}
{% endblock %}