activity.html 8.13 KB
Newer Older
Giorgos Korfiatis's avatar
Giorgos Korfiatis committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<!--
Copyright (C) 2015 GRNET S.A.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
Efthymia Bika's avatar
Efthymia Bika committed
17 18 19
        <script src="backup.js"></script>
        <script type="text/javascript">

20 21 22 23 24 25 26 27 28 29 30 31 32
            function check_gpg() {
                exec("which gpg", function(error, stdout, stderr) {
                    if(error) {
                        $("#gpg-alert").show();
                    } else {
                        $("#gpg-alert").hide();
                    }
                });
            }
            if(process.platform != "win32") {
                check_gpg();
            }

Efthymia Bika's avatar
Efthymia Bika committed
33 34 35 36 37 38 39 40 41
            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 != "") {
42
                        clouds = JSON.parse(data);
Efthymia Bika's avatar
Efthymia Bika committed
43
                    } else {
44
                        clouds = new Object();
Efthymia Bika's avatar
Efthymia Bika committed
45 46
                    }
                }
47
                if(Object.keys(clouds).length == 0) {
Efthymia Bika's avatar
Efthymia Bika committed
48 49 50 51 52 53
                    $("#cloud-alert").show();
                }
            }

            load_data_from_file(BACKUP_CONF_FILE, render_backup_sets);

Efthymia Bika's avatar
Efthymia Bika committed
54 55 56 57 58
            function go_to_backup(backup) {
                selected_backup = backup;
                $("#backup-tab-link").trigger("click");
            }

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
            function show_delete_modal(backup) {
                $("#del-modal-p").html("<p>Are you sure you want to delete "
                    + backup.cloud + "/" +  backup.name + '?</p>' +
                    "<p>NOTE: To actually remove backup sets from remote" +
                    " container you have to manually purge it.</p>");
                $("#delete-modal").foundation("reveal", "open");
                var i = 0;
                $("#delete-modal").on('close.fndtn.reveal', function(e) {
                    if(e.namespace !== "fndtn.reveal") return;
                    i++;
                    $(this).click(function(event) {
                        // event is fired more than once so have to check
                        if(event.target.id == "del-modal-accept" && i == 1) {
                            delete_backup(backup);
                        }
                    });
                });
            }

Efthymia Bika's avatar
Efthymia Bika committed
78 79 80 81 82 83
            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 != "") {
84
                        backups = JSON.parse(data);
Efthymia Bika's avatar
Efthymia Bika committed
85
                    } else {
86
                        backups = new Object();
Efthymia Bika's avatar
Efthymia Bika committed
87 88
                    }
                }
89
                if(Object.keys(backups).length == 0) {
Efthymia Bika's avatar
Efthymia Bika committed
90 91
                    $("#backup-alert").show();
                }
Efthymia Bika's avatar
Efthymia Bika committed
92
                var ul = $("<ul></ul>")
93
                    .attr("class", "small-block-grid-4")
Efthymia Bika's avatar
Efthymia Bika committed
94
                    .attr("id", "backup_list");
Efthymia Bika's avatar
Efthymia Bika committed
95 96
                $.each(backups, function(i, backup) {
                    var li = $("<li></li>")
Efthymia Bika's avatar
Efthymia Bika committed
97 98
                        .attr("class", "clearfix backup-box")
                        .attr("id", "box_" + backup.name);
Efthymia Bika's avatar
Efthymia Bika committed
99
                    var a = $("<a>" + backup.cloud + "/" + backup.name + "</a>")
Efthymia Bika's avatar
Efthymia Bika committed
100
                        .attr("href", "#")
Efthymia Bika's avatar
Efthymia Bika committed
101
                        .attr("id", "box_a_" + backup.name)
Efthymia Bika's avatar
Efthymia Bika committed
102
                        .attr("class", "left")
Efthymia Bika's avatar
Efthymia Bika committed
103
                        .attr("onclick", "go_to_backup('" + backup.cloud + "/" + backup.name + "')");
Efthymia Bika's avatar
Efthymia Bika committed
104 105
                    li.append(a);

Efthymia Bika's avatar
Efthymia Bika committed
106
                    var a_del = $("<a><i class='fa fa-trash-o delete_icon'></i></a>")
Efthymia Bika's avatar
Efthymia Bika committed
107 108 109
                        .attr("href", "#")
                        .attr("class", "right")
                        .click(function() {
110
                            show_delete_modal(backup);
Efthymia Bika's avatar
Efthymia Bika committed
111 112 113
                        });
                    li.append(a_del);

114 115 116 117 118 119 120 121 122 123
                    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
124 125 126
                    if(typeof backup.last_status != 'undefined') {
                        li.append("<br>");
                        li.append("<br>");
127
                        var status_p = $("<span>Status : " + backup.last_status + "&nbsp;&nbsp;</span>");
Efthymia Bika's avatar
Efthymia Bika committed
128 129 130 131 132 133 134 135
                        li.append(status_p);
                        var loader = $("<i></i>")
                            .attr("class", "fa fa-spinner fa-pulse");
                        li.append(loader);
                        if(backup.last_status != "Running") {
                            loader.hide();
                        }
                    }
Efthymia Bika's avatar
Efthymia Bika committed
136
                    ul.append(li);
Efthymia Bika's avatar
Efthymia Bika committed
137
                    $("#backup-table").append(ul);
Efthymia Bika's avatar
Efthymia Bika committed
138
                });
Efthymia Bika's avatar
Efthymia Bika committed
139

Efthymia Bika's avatar
Efthymia Bika committed
140
            }
Efthymia Bika's avatar
Efthymia Bika committed
141 142 143
            window.setInterval(function() {
                render_backup_sets("");
            }, 3000);
Efthymia Bika's avatar
Efthymia Bika committed
144 145 146

        </script>

147 148 149 150 151 152 153 154 155 156 157 158 159
        <div class="row">
            <div class="small-12 columns panel alert hide" id="gpg-alert">
                <span>
                    <i class="fa fa-exclamation-circle"></i>
                    BaaS uses <a href="#"
                        onclick="gui.Shell.openExternal('https://www.gnupg.org/download/index.html');">
                        GnuPG</a>
                    in order to encrypt your backups, though
                    no gpg installation was found on your system.
                    You must install gpg separately.
                </span>
            </div>
        </div>
Efthymia Bika's avatar
Efthymia Bika committed
160 161 162 163 164
        <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
165 166 167 168 169 170 171 172 173 174 175 176
                    <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
177 178 179 180
                </span>
            </div>
        </div>
        <div class="row">
Efthymia Bika's avatar
Efthymia Bika committed
181
            <div class="small-12 columns" id="backup-table">
Efthymia Bika's avatar
Efthymia Bika committed
182 183
            </div>
        </div>
184 185 186 187 188 189 190 191 192 193 194 195 196 197
        <div id="delete-modal" class="reveal-modal medium"
            data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
            <p id="del-modal-p"></p>
            <a id="del-modal-cancel" class="button radius small"
                onclick="$('#delete-modal').foundation('reveal', 'close');">
                Cancel
            </a>
            <a id="del-modal-accept" class="button radius small alert right"
                onclick="$('#delete-modal').foundation('reveal', 'close');">
                Delete
            </a>
            <a class="close-reveal-modal" aria-label="Close">&#215;</a>
        </div>

Efthymia Bika's avatar
Efthymia Bika committed
198 199 200
        <script type="text/javascript">
            $(document).foundation();
        </script>