activity.html 4 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
<!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 != "") {
16
                        clouds = JSON.parse(data);
Efthymia Bika's avatar
Efthymia Bika committed
17
                    } else {
18
                        clouds = new Object();
Efthymia Bika's avatar
Efthymia Bika committed
19
20
                    }
                }
21
                if(Object.keys(clouds).length == 0) {
Efthymia Bika's avatar
Efthymia Bika committed
22
23
24
25
26
27
                    $("#cloud-alert").show();
                }
            }

            load_data_from_file(BACKUP_CONF_FILE, render_backup_sets);

Efthymia Bika's avatar
Efthymia Bika committed
28
29
30
31
32
            function go_to_backup(backup) {
                selected_backup = backup;
                $("#backup-tab-link").trigger("click");
            }

Efthymia Bika's avatar
Efthymia Bika committed
33
34
35
36
37
38
            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 != "") {
39
                        backups = JSON.parse(data);
Efthymia Bika's avatar
Efthymia Bika committed
40
                    } else {
41
                        backups = new Object();
Efthymia Bika's avatar
Efthymia Bika committed
42
43
                    }
                }
44
                if(Object.keys(backups).length == 0) {
Efthymia Bika's avatar
Efthymia Bika committed
45
46
                    $("#backup-alert").show();
                }
Efthymia Bika's avatar
Efthymia Bika committed
47
                var ul = $("<ul></ul>")
Efthymia Bika's avatar
Efthymia Bika committed
48
49
                    .attr("class", "no-bullet")
                    .attr("id", "backup_list");
Efthymia Bika's avatar
Efthymia Bika committed
50
51
                $.each(backups, function(i, backup) {
                    var li = $("<li></li>")
Efthymia Bika's avatar
Efthymia Bika committed
52
53
                        .attr("class", "clearfix backup-box")
                        .attr("id", "box_" + backup.name);
Efthymia Bika's avatar
Efthymia Bika committed
54
55
                    var a = $("<a>" + backup.name + "</a>")
                        .attr("href", "#")
Efthymia Bika's avatar
Efthymia Bika committed
56
                        .attr("id", "box_a_" + backup.name)
Efthymia Bika's avatar
Efthymia Bika committed
57
                        .attr("class", "left")
Efthymia Bika's avatar
Efthymia Bika committed
58
59
                        .attr("onclick", "go_to_backup('" + backup.name + "')");

Efthymia Bika's avatar
Efthymia Bika committed
60
61
62
63
64
65
66
                    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 + '?' +
Efthymia Bika's avatar
Efthymia Bika committed
67
68
                                "\nNOTE: To actually remove backup sets from remote" +
                                " container you have to manually purge it.")) {
Efthymia Bika's avatar
Efthymia Bika committed
69
70
71
72
73
74
                                delete_backup(backup);
                            }
                        });
                    li.append(a_del);

                    ul.append(li);
Efthymia Bika's avatar
Efthymia Bika committed
75
                    $("#backup-table").append(ul);
Efthymia Bika's avatar
Efthymia Bika committed
76
                });
Efthymia Bika's avatar
Efthymia Bika committed
77

Efthymia Bika's avatar
Efthymia Bika committed
78
79
80
81
82
83
84
85
86
87
88
            }

        </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
89
90
91
92
93
94
95
96
97
98
99
100
                    <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
101
102
103
104
                </span>
            </div>
        </div>
        <div class="row">
Efthymia Bika's avatar
Efthymia Bika committed
105
            <div class="small-12 columns" id="backup-table">
Efthymia Bika's avatar
Efthymia Bika committed
106
107
108
109
110
111
112
            </div>
        </div>
        <script type="text/javascript">
            $(document).foundation();
        </script>
    </body>
</html>