+ <script>
+ var instance_type = '{{ type }}';
+ var instance_id = '{{ instance_id }}';
+ $(document).ready(function () {
+ var table = $('#operations_table').DataTable({
+ responsive: true,
+ "ajax": {
+ "url": "/instances/" + instance_type + "/" +instance_id + "/operation",
+ "dataSrc": function (json) {
+ return json['operations'];
+ },
+ statusCode: {
+ 401: function(){
+ console.log("no auth");
+ moveToLogin(window.location.pathname);
+ }
+ },
+ "error": function(hxr, error, thrown){
+ console.log(error);
+ }
+
+ },
+ "columns": [
+ {
+ "render": function (data, type, row) {
+ return row["_id"];
+ },
+ "targets": 0
+ },
+ {
+ "render": function (data, type, row) {
+ return row['lcmOperationType'];
+ },
+ "targets": 1
+ },
+ {
+ "render": function (data, type, row) {
+
+ if(row["operationState"] === 'FAILED')
+ return '<span class="label label-danger">'+ row["operationState"] +'</span>';
+ else if(row["operationState"] === 'PROCESSING')
+ return '<span class="label label-warning">'+ row["operationState"] +'</span>';
+ else if(row["operationState"] === 'COMPLETED')
+ return '<span class="label label-success">'+ row["operationState"] +'</span>';
+ else
+ return row["operationState"];
+ },
+ "targets": 2
+ },
+ {
+ "render": function (data, type, row) {
+ return moment.unix(row['startTime']).format('YYYY-MM-DD hh:mm:ss a')
+ },
+ "targets": 3
+ },
+ {
+ "render": function (data, type, row) {
+ return moment.unix(row['statusEnteredTime']).format('YYYY-MM-DD hh:mm:ss a')
+ },
+ "targets": 4
+ },
+ {
+ "render": function (data, type, row) {
+ return '<div class="btn-group">\n' +
+ ' <button type="button" class="btn btn-default"\n' +
+ ' onclick="javascript:showOperationDetails(\''+row["nsInstanceId"]+'\', \''+row["_id"]+'\')"\n' +
+ ' data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info">\n' +
+ ' <i class="fa fa-info"></i>\n' +
+ ' </button>\n' +
+ ' </div>';
+ },
+ "targets": 5
+ }
+ ]
+ });
+
+
+ setInterval(function () {
+ table.ajax.reload();
+ }, 10000);
+ });
+
+ </script>
+