activity.html 4.63 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
                    var a = $("<a>" + backup.cloud + "/" + backup.name + "</a>")
Efthymia Bika's avatar
Efthymia Bika committed
55
                        .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
                        .attr("onclick", "go_to_backup('" + backup.cloud + "/" + backup.name + "')");
Efthymia Bika's avatar
Efthymia Bika committed
59
60
                    li.append(a);

Efthymia Bika's avatar
Efthymia Bika committed
61
                    var a_del = $("<a><i class='fa fa-trash-o delete_icon'></i></a>")
Efthymia Bika's avatar
Efthymia Bika committed
62
63
64
                        .attr("href", "#")
                        .attr("class", "right")
                        .click(function() {
Efthymia Bika's avatar
Efthymia Bika committed
65
                            if(confirm("Are you sure you want to delete " + backup.cloud + "/" +  backup.name + '?' +
Efthymia Bika's avatar
Efthymia Bika committed
66
67
                                "\nNOTE: To actually remove backup sets from remote" +
                                " container you have to manually purge it.")) {
Efthymia Bika's avatar
Efthymia Bika committed
68
69
70
71
72
                                delete_backup(backup);
                            }
                        });
                    li.append(a_del);

73
74
75
76
77
78
79
80
81
82
                    if(typeof backup.first_backup != 'undefined') {
                        li.append("<br>");
                        var first = new Date(backup.first_backup).toLocaleString();
                        var first_p = $("<span>First : " + first + " </span>");
                        li.append(first_p);
                        li.append("<br>");
                        var last = new Date(backup.last_backup).toLocaleString();
                        var last_p = $("<span>Last : " + last + " </span>");
                        li.append(last_p);
                    }
Efthymia Bika's avatar
Efthymia Bika committed
83
                    ul.append(li);
Efthymia Bika's avatar
Efthymia Bika committed
84
                    $("#backup-table").append(ul);
Efthymia Bika's avatar
Efthymia Bika committed
85
                });
Efthymia Bika's avatar
Efthymia Bika committed
86

Efthymia Bika's avatar
Efthymia Bika committed
87
88
89
90
91
92
93
94
95
96
97
            }

        </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
98
99
100
101
102
103
104
105
106
107
108
109
                    <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
110
111
112
113
                </span>
            </div>
        </div>
        <div class="row">
Efthymia Bika's avatar
Efthymia Bika committed
114
            <div class="small-12 columns" id="backup-table">
Efthymia Bika's avatar
Efthymia Bika committed
115
116
117
118
119
120
121
            </div>
        </div>
        <script type="text/javascript">
            $(document).foundation();
        </script>
    </body>
</html>