Skip to content

Commit

Permalink
Merge pull request #3 from MessageDream/web
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayden Zhao committed Jul 24, 2017
2 parents 0c56dc7 + 628a0e9 commit 3cf83c2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
.vscode
goby
goby.exe
data
custom
log
Expand Down
2 changes: 1 addition & 1 deletion goby.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
54 changes: 46 additions & 8 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -447,7 +485,7 @@ var table = $('#table_history').dataTable({
"columns": [
{ data: "label" },
{ data: "appVersion" },
{ data: "isMandatory" },
// { data: "isMandatory" },
{ data: "releaseMethod" },
{
data: "uploadTime",
Expand All @@ -461,13 +499,13 @@ var table = $('#table_history').dataTable({
render: function (data, type, row, meta) {
return '<div class="ui list"><div class="item"><i class="attach icon"></i><div class="content"> Active:&nbsp;&nbsp;' + (data.totalActive != 0 ? (data.active / data.totalActive * 100).toFixed(1) : 0) + '%(' + data.active + '&nbsp;of&nbsp;' + data.totalActive + ')' + '</div></div><div class="item"><i class="download icon"></i><div class="content">Total:&nbsp;&nbsp;' + data.installed + '</div></div><div class="item"><i class="undo icon"></i><div class="content">Rollbacks:&nbsp;&nbsp;' + data.failed + ' </div></div></div>';
}
},
{
data: "label",
render: function (data, type, row, meta) {
return '<button class="ui button ' + (row.appVersion ? ' disabled ' : ' ') + ' blueli inverted tiny pkg_rollback" onclick="rollbackTo(this)" data-name="' + data + '">Rollback to this</button>';
}
}
// ,{
// data: "label",
// render:function (data, type, row, meta) {
// return '<button class="ui button blueli inverted tiny pkg_rollback" data-name="'+data+'">Rollback</button>';
// }
// }
]
}).api();

Expand Down
2 changes: 1 addition & 1 deletion template/.VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.1.0
6 changes: 3 additions & 3 deletions template/app/detail/deployments.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@
<tr>
<th>Label</th>
<th>App Version</th>
<th>Mandatory</th>
<th>Release Method</th>
<!-- <th>Mandatory</th> -->
<th>Method</th>
<th>Release Time</th>
<th>Description </th>
<th>Install Metrics</th>
<!-- <th>Operation</th> -->
<th>Operation</th>
</tr>
</thead>
</table>
Expand Down

0 comments on commit 3cf83c2

Please sign in to comment.