diff --git a/.gitignore b/.gitignore index f6f0c0d..183f0a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store .vscode goby +goby.exe data custom log diff --git a/goby.go b/goby.go index 3bdc09f..b93bbb4 100644 --- a/goby.go +++ b/goby.go @@ -10,7 +10,7 @@ import ( "github.com/MessageDream/goby/module/setting" ) -const APP_VER = "0.0.1" +const APP_VER = "0.1.0" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/public/js/app.js b/public/js/app.js index be6a97e..c5eb5d0 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -357,7 +357,43 @@ $(".ui.dep_new_release").on("click", function () { }).modal("show"); }); +function rollbackTo(row) { + var app_name = $('#app_name').attr('data-name'); + var dep_name = $('#menu_history').dropdown('get text'); + var label_name = $(row).attr('data-name'); + + swal({ + text: "Are you sure to rollback to this label", + type: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes', + preConfirm: function () { + return new Promise(function (resolve, reject) { + $.ajax({ + url: '/apps/' + app_name + '/deployments/' + dep_name + '/rollback/' + label_name, + type: 'POST', + success: function (data, textStatus) { + resolve({ dep: label_name, label: label_name }); + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + reject(XMLHttpRequest.responseJSON.message); + } + }); + }) + } + }).then(function (info) { + swal({ + title: 'Rolled Back', + text: 'The release of ' + info.dep + 'has been rolled back to ' + info.label, + type: 'success' + }).then(function () { + document.location.reload() + }); + }).catch(alertError); +} function fetchHistory(data, callback, settings) { var app_name = $('#app_name').attr('data-name'); @@ -398,7 +434,9 @@ function fetchHistory(data, callback, settings) { var histories = arr[0]; var metrics = arr[1]; var totalActive = getTotalActiveFromDeploymentMetrics(metrics); - histories.forEach(function (packageObject) { + histories.sort(function (a, b) { + return b.uploadTime - a.uploadTime; + }).forEach(function (packageObject) { if (metrics[packageObject.label]) { packageObject.metrics = { active: metrics[packageObject.label].active, @@ -447,7 +485,7 @@ var table = $('#table_history').dataTable({ "columns": [ { data: "label" }, { data: "appVersion" }, - { data: "isMandatory" }, + // { data: "isMandatory" }, { data: "releaseMethod" }, { data: "uploadTime", @@ -461,13 +499,13 @@ var table = $('#table_history').dataTable({ render: function (data, type, row, meta) { return '
Active:  ' + (data.totalActive != 0 ? (data.active / data.totalActive * 100).toFixed(1) : 0) + '%(' + data.active + ' of ' + data.totalActive + ')' + '
Total:  ' + data.installed + '
Rollbacks:  ' + data.failed + '
'; } + }, + { + data: "label", + render: function (data, type, row, meta) { + return ''; + } } - // ,{ - // data: "label", - // render:function (data, type, row, meta) { - // return ''; - // } - // } ] }).api(); diff --git a/template/.VERSION b/template/.VERSION index 8a9ecc2..6c6aa7c 100644 --- a/template/.VERSION +++ b/template/.VERSION @@ -1 +1 @@ -0.0.1 \ No newline at end of file +0.1.0 \ No newline at end of file diff --git a/template/app/detail/deployments.html b/template/app/detail/deployments.html index c6c43a1..91520f1 100644 --- a/template/app/detail/deployments.html +++ b/template/app/detail/deployments.html @@ -133,12 +133,12 @@ Label App Version - Mandatory - Release Method + + Method Release Time Description Install Metrics - + Operation