activity.html 3.89 KB
Newer Older
Efthymia Bika's avatar
Efthymia Bika committed
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
<!DOCTYPE html>
<html>
    <head>
        <script src="backup.js"></script>
        <script type="text/javascript">

            if(typeof clouds === 'undefined') {
                load_data_from_file(CLOUDS_CONF_FILE, show_cloud_msg);
            } else {
                show_cloud_msg(clouds);
            }

            function show_cloud_msg(data) {
                if(typeof clouds === 'undefined') {
                    if(data != "") {
                        clouds = JSON.parse(data).clouds;
                    } else {
                        clouds = [];
                    }
                }
                if(clouds.length == 0) {
                    $("#cloud-alert").show();
                }
            }

            load_data_from_file(BACKUP_CONF_FILE, render_backup_sets);

            function render_backup_sets(data) {
                $("#backup_list").remove();
                // backups is undefined the first time, when
                // reading data from file
                if(typeof backups === 'undefined') {
                    if(data != "") {
                        backups = JSON.parse(data).backups;
                    } else {
                        backups = [];
                    }
                }
Efthymia Bika's avatar
Efthymia Bika committed
39 40 41
                if(backups.length == 0) {
                    $("#backup-alert").show();
                }
Efthymia Bika's avatar
Efthymia Bika committed
42
                var ul = $("<ul></ul>")
Efthymia Bika's avatar
Efthymia Bika committed
43 44
                    .attr("class", "no-bullet")
                    .attr("id", "backup_list");
Efthymia Bika's avatar
Efthymia Bika committed
45 46
                $.each(backups, function(i, backup) {
                    var li = $("<li></li>")
Efthymia Bika's avatar
Efthymia Bika committed
47 48
                        .attr("class", "clearfix backup-box")
                        .attr("id", "box_" + backup.name);
Efthymia Bika's avatar
Efthymia Bika committed
49 50
                    var a = $("<a>" + backup.name + "</a>")
                        .attr("href", "#")
Efthymia Bika's avatar
Efthymia Bika committed
51
                        .attr("id", "box_a_" + backup.name)
Efthymia Bika's avatar
Efthymia Bika committed
52 53
                        .attr("class", "left")
                        .click(function() {
Efthymia Bika's avatar
Efthymia Bika committed
54
                            $("#backup-tab-link").trigger("click");
Efthymia Bika's avatar
Efthymia Bika committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
                            load_backup(backup);
                        });
                    li.append(a);

                    var a_del = $("<a><i class='fa fa-times-circle delete_icon'></i></a>")
                        .attr("href", "#")
                        .attr("class", "right")
                        .click(function() {
                            if(confirm("Are you sure you want to delete " + backup.name + '?' +
                                "\nNOTE: To actually remove backup sets from remote container you have to manually purge it.")) {
                                delete_backup(backup);
                            }
                        });
                    li.append(a_del);

                    ul.append(li);
Efthymia Bika's avatar
Efthymia Bika committed
71
                    $("#backup-table").append(ul);
Efthymia Bika's avatar
Efthymia Bika committed
72 73 74 75 76 77 78 79 80 81 82 83
                });
            }

        </script>
    </head>

    <body>
        <div class="row">
            <div class="small-12 columns panel hide" id="cloud-alert">
                <span>
                    <i class="fa fa-exclamation-circle"></i>
                    No cloud settings found. To start you must set a
Efthymia Bika's avatar
Efthymia Bika committed
84 85 86 87 88 89 90 91 92 93 94 95
                    <a onclick="$('#cloud-settings-link').trigger('click');">
                    cloud configuration.</a>
                </span>
            </div>
        </div>
        <div class="row">
            <div class="small-12 columns panel hide" id="backup-alert">
                <span>
                    <i class="fa fa-exclamation-circle"></i>
                    No backup sets found.
                    <a onclick="$('#backup-tab-link').trigger('click');">
                    Create a new one.</a>
Efthymia Bika's avatar
Efthymia Bika committed
96 97 98 99
                </span>
            </div>
        </div>
        <div class="row">
Efthymia Bika's avatar
Efthymia Bika committed
100
            <div class="small-12 columns" id="backup-table">
Efthymia Bika's avatar
Efthymia Bika committed
101 102 103 104 105 106 107
            </div>
        </div>
        <script type="text/javascript">
            $(document).foundation();
        </script>
    </body>
</html>