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

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/>.
-->
17 18
<script src="backup.js"></script>
<script type="text/javascript">
19

20 21 22 23
    function check_gpg() {
        exec("which gpg", function(error, stdout, stderr) {
            if(error) {
                $("#gpg-alert").show();
Efthymia Bika's avatar
Efthymia Bika committed
24
            } else {
25
                $("#gpg-alert").hide();
Efthymia Bika's avatar
Efthymia Bika committed
26
            }
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
        });
    }
    if(process.platform != "win32") {
        check_gpg();
    }

    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);
            } else {
                clouds = new Object();
Efthymia Bika's avatar
Efthymia Bika committed
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
        }
        if(Object.keys(clouds).length == 0) {
            $("#cloud-alert").show();
        }
    }

    load_data_from_file(BACKUP_CONF_FILE, render_backup_sets);

    function go_to_backup(backup) {
        selected_backup = backup;
        $("#backup-tab-link").trigger("click");
    }

    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);
                }
            });
        });
    }

    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);
            } else {
                backups = new Object();
Efthymia Bika's avatar
Efthymia Bika committed
87
            }
88 89 90 91 92 93 94 95
        }
        if(Object.keys(backups).length == 0) {
            $("#backup-alert").show();
        }
        var ul = $("<ul></ul>")
            .attr("class", "small-block-grid-4")
            .attr("id", "backup_list");
        $.each(backups, function(i, backup) {
Efthymia Bika's avatar
Efthymia Bika committed
96 97
            var li = $("<div></div>")
                .attr("class", "backup-box")
98 99 100 101 102 103 104 105 106 107 108 109 110 111
                .attr("id", "box_" + backup.name);
            var a = $("<a>" + backup.cloud + "/" + backup.name + "</a>")
                .attr("href", "#")
                .attr("id", "box_a_" + backup.name)
                .attr("class", "left")
                .attr("onclick", "go_to_backup('" +
                    backup.cloud + "/" + backup.name + "')");
            li.append(a);

            var a_del = $("<a><i class='fa fa-trash-o delete_icon'></i></a>")
                .attr("href", "#")
                .attr("class", "right")
                .click(function() {
                    show_delete_modal(backup);
112
                });
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
            li.append(a_del);

            li.append("<br>");
            var local_dir = $("<span>" + backup.local_dir + "</span>");
            li.append(local_dir);

            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);
128
            }
129 130 131
            if(typeof backup.last_status != 'undefined') {
                li.append("<br>");
                li.append("<br>");
Efthymia Bika's avatar
Efthymia Bika committed
132 133 134 135 136
                var status_class = (backup.last_status == "Failed") ?
                    "fail-span" : "succeed-span";
                var status_p = $("<span>Status : <i class='" + status_class
                        + "'> " + backup.last_status +
                        "</i>&nbsp;&nbsp;</span>");
137 138 139 140 141 142
                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
143
                }
Efthymia Bika's avatar
Efthymia Bika committed
144
            }
Efthymia Bika's avatar
Efthymia Bika committed
145 146 147
            var extLi = $("<li></li>");
            extLi.append(li);
            ul.append(extLi);
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
            $("#backup-table").append(ul);
        });

    }
    window.setInterval(function() {
        render_backup_sets("");
    }, 3000);

</script>

<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>
<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
            <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>
        </span>
    </div>
</div>
<div class="row">
    <div class="small-12 columns" id="backup-table">
    </div>
</div>
<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>

<script type="text/javascript">
    $(document).foundation();
</script>