Skip to content

Commit c64f79e

Browse files
authored
Merge pull request #1266 from getting2vinod/topic-ci-cd-dashboard
Added CICD Dashboard Server Setting
2 parents 3f82c4f + ec6c155 commit c64f79e

File tree

5 files changed

+301
-23
lines changed

5 files changed

+301
-23
lines changed

client/htmls/private/ajax/Settings/cicddashboardserverList.html

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55
</style>
66

7-
<div id="gitHubListLoader" style="display:none">
7+
<div id="cicddashboardserverListLoader" style="display:none">
88
<img class="center-block" style="height: 50px; width: 50px; margin-top: 20%; margin-left: 48%;margin-bottom: 10%; position: absolute;" src="img/loading.gif" />
99
</div>
1010
<div class="row">
@@ -17,7 +17,7 @@ <h5 class="widget-title widgetColor">
1717
<div class="widget-toolbar no-border">
1818
<div>
1919
<!--new button for adding a new item-->
20-
<a href="#modalForGitEdit" type="reset" data-backdrop="false" data-toggle="modal" class="btn btn-minier btn-primary addGitHub">
20+
<a href="#modalForcicddashboardserverEdit" type="reset" data-backdrop="false" data-toggle="modal" class="btn btn-minier btn-primary addcicddashboardServer">
2121
<i class="ace-icon ace-icon fa fa-plus bigger-110"></i>&nbsp;New
2222
</a>
2323
</div>
@@ -26,7 +26,7 @@ <h5 class="widget-title widgetColor">
2626
<div class="widget-body">
2727
<div class="widget-main widgetHeight">
2828
<div class="col-md-12 table-responsive tablePadding">
29-
<table id="gitTable" class="tableData table table-striped table-bordered table-hover dataTable no-footer textCenter" cellpadding="5px">
29+
<table id="cicdDashboardServerTable" class="tableData table table-striped table-bordered table-hover dataTable no-footer textCenter" cellpadding="5px">
3030
<thead>
3131
<tr class="rowCustomStyle">
3232
<td>Server Name</td>
@@ -56,24 +56,24 @@ <h5 class="widget-title widgetColor">
5656
<div class="modal fade" id="modalForcicddashboardServerEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
5757
<div class="modal-dialog " style="">
5858
<div class="modal-content">
59-
<form role="form" id="gitHubRepoForn">
59+
<form role="form" id="cicddashboardServerForm" autocomplete="off">
6060
<div class="modal-header">
6161
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
6262
<h4 class="modal-title">
6363
</h4>
6464
</div>
6565
<div class="modal-body">
6666
<fieldset class="fieldsetCustom">
67-
<div class="col-lg-6 col-md-6 col-xs-6">
68-
<label for="dashboardName">CICD Dashboard Server Name:<span class="control-label redSpan">&nbsp;*</span></label>
67+
<div class="col-lg-6 col-md-6 col-xs-6 ">
68+
<label for="dashboardName">Server Name:<span class="control-label redSpan">&nbsp;*</span></label>
6969
<div class="input-groups">
70-
<input type="text" name="dashboardName" class="required gitName form-control" id="gitName">
70+
<input type="text" name="dashboardName" autofocus class="required gitName form-control" id="dashboardName">
7171
</div>
7272
</div>
73-
<div class="col-lg-6 col-md-6 col-xs-6">
73+
<div class="col-lg-6 col-md-6 col-xs-6 ">
7474
<label for="dashboardDesc">Description:</label>
7575
<div class="input-groups">
76-
<input type="text" name="dashboardDesc" class="gitDescription form-control" id="gitDescription">
76+
<input type="text" name="dashboardDesc" autofocus class="gitDescription form-control" id="dashboardDesc">
7777
</div>
7878
</div>
7979
<div class="col-lg-6 col-md-6 col-xs-6 margintop15">
@@ -82,31 +82,47 @@ <h4 class="modal-title">
8282
<select id="orgName" name="orgName" class="required form-control width-100" style="vertical-align:central"></select>
8383
</div>
8484
</div>
85-
85+
<div class="col-lg-6 col-md-6 col-xs-6 margintop15">
86+
<label for="dashboardServer">Hostname/IP:Port :<span class="control-label redSpan">&nbsp;*</span></label>
87+
<div class="input-groups">
88+
<input type="text" name="dashboardServer" class="required dashboardServer form-control" id="dashboardServer">
89+
</div>
90+
</div>
8691

87-
<div class="col-lg-6 col-md-6 col-xs-6 margintop15 hidden showForUserToken">
88-
<label for="protocolUser">User Name:</label>
89-
<input type="text" name="protocolUser" class="protocolUser form-control" id="protocolUser">
92+
<div class="col-lg-6 col-md-6 col-xs-6 margintop15">
93+
<label for="dashboardServerUserName">User Name:<span class="control-label redSpan">&nbsp;*</span></label>
94+
<div class="input-groups">
95+
<input type="text" name="dashboardServerUserName" class="required protocolUser form-control" id="dashboardServerUserName">
96+
</div>
9097
</div>
91-
<div class="col-lg-6 col-md-6 col-xs-6 margintop15 hidden showForUser">
92-
<label for="protocolPassword">Password:</label>
93-
<input type="password" name="protocolPassword" class="protocolPassword form-control" id="protocolPassword">
98+
<div class="col-lg-6 col-md-6 col-xs-6 margintop15">
99+
<label for="dashboardServerPassword">Password:<span class="control-label redSpan">&nbsp;*</span></label>
100+
<div class="input-groups">
101+
<input type="password" name="dashboardServerPassword" class="required dashboardServerPassword form-control" id="dashboardServerPassword" autocomplete="whatever" >
102+
</div>
103+
</div>
104+
105+
<div class="col-lg-6 col-md-6 margintop15">
106+
<label for="dashboardDbHostName">Dashboard DB Hostname:<span class="control-label redSpan">&nbsp;*</span></label>
107+
<div class="input-groups">
108+
<input type="text" name="dashboardDbHostName" class="required dashboardDbHostName form-control" id="dashboardDbHostName">
109+
</div>
94110
</div>
95111

96112

97-
<input type="hidden" id="gitEditHiddenInputId">
98-
<input type="hidden" id="gitEditHiddenInput">
113+
<input type="hidden" id="cicddashboardServerEditHiddenInputId">
114+
<input type="hidden" id="cicddashboardServerEditHiddenInput">
99115

100116
</fieldset>
101117
</div>
102118
<div class="modal-footer">
103119
<label id="saveItemSpinner" class="hidden"><img style="margin-left:5px;margin-right:25px;" src="img/select2-spinner.gif"></label>
104120
<a type="button" class="btn btn-default" data-dismiss="modal"><i class="ace-icon fa fa-times bigger-110"></i>&nbsp;Cancel</a>
105-
<button type="submit" id="saveBtnTrack" class="btn btn-primary" value="Save"><i class="ace-icon fa fa-check bigger-110"></i>&nbsp;Save</button>
121+
<button type="submit" id="saveBtncicddashboardServer" class="btn btn-primary" value="Save"><i class="ace-icon fa fa-check bigger-110"></i>&nbsp;Save</button>
106122
</div>
107123
</form>
108124
</div>
109125
</div>
110126
</div>
111127
<!--model ends here-->
112-
<script src="js/gitHubList.js"></script>
128+
<script src="js/cicddashboardserver.js"></script>

client/htmls/private/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,13 @@ <h4 class="modal-title">
11571157
"href": "#ajax/Settings/jiraConfigList.html",
11581158
"selectable": true,
11591159
"icon": "fa fa-lg fa-fw fa-ticket"
1160+
},{
1161+
"name": "organizations",
1162+
"text": "CICD Dashboard Server",
1163+
"borderColor": "#000",
1164+
"href": "#ajax/Settings/cicddashboardserverList.html",
1165+
"selectable": true,
1166+
"icon": "fa fa-lg fa-fw fa-server"
11601167
},{
11611168
"name": "organizations",
11621169
"text": "Sonarqube",
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
//initialising the datatable...
2+
if (!$.fn.dataTable.isDataTable('#cicdDashboardServerTable')) {
3+
var $cicdDashboardServerTable = $('#cicdDashboardServerTable').DataTable({
4+
"pagingType": "full_numbers",
5+
"bInfo": false,
6+
"bLengthChange": false,
7+
"paging": true,
8+
"bFilter": false,
9+
"aoColumns": [{
10+
"bSortable": false
11+
}, {
12+
"bSortable": false
13+
}, {
14+
"bSortable": false
15+
}, {
16+
"bSortable": false
17+
}, {
18+
"bSortable": false
19+
}]
20+
21+
});
22+
}
23+
24+
$(document).ready(function(e) {
25+
getGlobalcicdDashboardServers();
26+
});
27+
28+
function getGlobalcicdDashboardServers(){
29+
$('#cicdDashboardServerTable').DataTable( {
30+
"processing": true,
31+
"serverSide": true,
32+
"destroy":true,
33+
"createdRow": function( row, data ) {
34+
$( row ).attr({"dashboardName": data.dashboardName,"dashboardDesc":data.dashboardDesc,"orgId" : data.orgId ,"orgName" : data.orgName,"dashboardId" : data._id,"dashboardServer":data.dashboardServer,"dashboardServerUserName":data.dashboardServerUserName,"dashboardDbHostName":data.dashboardDbHostName
35+
});
36+
},
37+
"ajax": '/cicd-dashboardservice',
38+
"columns": [
39+
{"data": "dashboardName", "orderable" : true},
40+
{"data": "orgName","orderable" : false },
41+
{"data": "dashboardServer" ,"orderable" : true },
42+
{"data": "dashboardDbHostName" ,"orderable" : false},
43+
44+
{"data": "","orderable" : true,
45+
"render": function (data) {
46+
var $tdAction = '<div style="margin-left:14px;" class="btn-group"><button class="btn btn-info pull-left btn-sg tableactionbutton editcicdDashboardServer" data-placement="top" value="Update" title="Edit"><i class="ace-icon fa fa-pencil bigger-120"></i></button></div>';
47+
$tdAction = $tdAction + '<div style="margin-left:14px;" class="btn-group"><button class="btn btn-danger pull-left btn-sg tableactionbutton deletecicdDashboardServer" data-placement="top" value="Remove" title="Delete"><i class="ace-icon fa fa-trash-o bigger-120"></i></button></div>';
48+
return $tdAction;
49+
}
50+
}
51+
]
52+
} );
53+
54+
}
55+
56+
57+
//when the user clicks on the new button the setting the value to 'new' for the hidden field to know that user is creating the new item..
58+
$('.addcicddashboardServer').click(function(e) {
59+
$('#cicddashboardServerForm').trigger('reset');
60+
$('.modal-header').find('.modal-title').html('Create New CICD Dashboard Server');
61+
$('#cicddashboardServerEditHiddenInput').val('new');
62+
$('#dashboardDbHostName').val('localhost');
63+
64+
getOrganizationList();
65+
$('#orgName,#dashboardName').removeAttr('disabled');
66+
67+
$('#cicddashboardServerEditHiddenInputId').val('');
68+
var $editModal = $('#modalForcicddashboardServerEdit');
69+
$editModal.modal('show');
70+
71+
});
72+
73+
//to list down the organization for creating the gitHub repo item.
74+
function getOrganizationList() {
75+
$.get('/d4dMasters/readmasterjsonnew/1', function(data) {
76+
var str = ' <option value="">Select Organization</option>',
77+
len = data.length;
78+
for (var i = 0; i < data.length; i++) {
79+
str = str + '<option value="' + data[i].rowid + '">' + data[i].orgname + '</option>';
80+
}
81+
$('#orgName').html(str);
82+
});
83+
}
84+
85+
//save form for creating a new gitHub item and updation of the gitHub details.
86+
$('#cicddashboardServerForm').submit(function(e) {
87+
$('#saveBtncicddashboardServer').removeAttr('disabled');
88+
var isValidator = $('#cicddashboardServerForm').valid();
89+
if (!isValidator) {
90+
e.preventDefault();
91+
return false;
92+
} else {
93+
e.preventDefault();
94+
$('#saveItemSpinner').removeClass('hidden');
95+
var $form = $('#cicddashboardServerForm');
96+
$this = $(this);
97+
var dashboardName = $this.find('#dashboardName').val().trim();
98+
var orgValue = $this.find('#orgName').val();
99+
var dashboardDesc = $this.find('#dashboardDesc').val();
100+
var dashboardServer = $this.find('#dashboardServer').val();
101+
var dashboardServerUserName = $this.find('#dashboardServerUserName').val();
102+
var dashboardServerPassword = $this.find('#dashboardServerPassword').val();
103+
var dashboardDbHostName = $this.find('#dashboardDbHostName').val();
104+
var newFormData = new FormData();
105+
var dashboardEditNew = $this.find('#cicddashboardServerEditHiddenInput').val();
106+
var cicddashboardServerEditHiddenInputId = $form.find('input#cicddashboardServerEditHiddenInputId').val();
107+
if (dashboardEditNew === 'edit') {
108+
url = '../cicd-dashboardservice/' + cicddashboardServerEditHiddenInputId;
109+
methodName = 'PUT';
110+
} else {
111+
methodName = 'POST';
112+
url = '../cicd-dashboardservice';
113+
}
114+
reqBody = {
115+
"dashboardName": dashboardName,
116+
"orgId": orgValue,
117+
"dashboardDesc": dashboardDesc,
118+
"dashboardServer": dashboardServer,
119+
"dashboardServerUserName": dashboardServerUserName,
120+
"dashboardServerPassword": dashboardServerPassword,
121+
"dashboardDbHostName": dashboardDbHostName,
122+
123+
}
124+
125+
saveForm(methodName,url,reqBody);
126+
127+
}
128+
});
129+
130+
$('a.addcicddashboardServer[type="reset"]').on('click', function(e) {
131+
validator.resetForm();
132+
});
133+
134+
135+
function saveForm(methodName,url,reqBody) {
136+
$.ajax({
137+
method: methodName,
138+
url: url,
139+
async:false,
140+
data: reqBody,
141+
success: function(data, success) {
142+
$('#modalForcicddashboardServerEdit').modal('hide');
143+
$('#saveItemSpinner').addClass('hidden');
144+
$('#saveBtncicddashboardServer').removeAttr('disabled');
145+
getGlobalcicdDashboardServers();
146+
147+
},
148+
error: function(jxhr) {
149+
console.log(jxhr);
150+
var msg = "Server Behaved Unexpectedly";
151+
if (jxhr.responseJSON && jxhr.responseJSON.message) {
152+
msg = jxhr.responseJSON.message;
153+
} else if (jxhr.responseText) {
154+
msg = jxhr.responseText;
155+
}
156+
bootbox.alert(msg);
157+
158+
$('#saveItemSpinner').addClass('hidden');
159+
$('#saveBtncicddashboardServer').removeAttr('disabled');
160+
}
161+
});
162+
}
163+
164+
var validator = $('#cicddashboardServerForm').validate({
165+
ignore: [],
166+
rules: {
167+
168+
dashboardName: {
169+
maxlength: 15
170+
}
171+
},
172+
messages: {
173+
174+
gitName: {
175+
maxlength: "Limited to 30 chars"
176+
}
177+
},
178+
onkeyup: false,
179+
errorClass: "error",
180+
181+
//put error message behind each form element
182+
errorPlacement: function(error, element) {
183+
console.log(error, element);
184+
var elem = $(element);
185+
if (element.parent('.input-groups').length) {
186+
error.insertBefore(element.parent());
187+
} else {
188+
if (element.parent('div.inputGroups')) {
189+
error.insertBefore('div.inputGroups');
190+
}
191+
}
192+
}
193+
});
194+
195+
//Edit Population
196+
197+
$('#cicdDashboardServerTable tbody').on( 'click', 'button.editcicdDashboardServer', function(){
198+
validator.resetForm();
199+
var $this = $(this);
200+
var $editModal = $('#modalForcicddashboardServerEdit');
201+
$editModal.find('#cicddashboardServerEditHiddenInput').val('edit');
202+
$editModal.modal('show');
203+
204+
$editModal.find('h4.modal-title').html('Edit CICD Dashboard Server &nbsp;-&nbsp;&nbsp;' + $this.parents('tr').attr('dashboardName'));
205+
$editModal.find('#dashboardName').val($this.parents('tr').attr('dashboardName')).attr('disabled','true');
206+
$editModal.find('#dashboardDesc').val($this.parents('tr').attr('dashboardDesc'));
207+
$editModal.find('#orgName').empty().append('<option value="'+$this.parents('tr').attr("orgId")+'">'+$this.parents('tr').attr("orgName")+'</option>').attr('disabled','disabled');
208+
$editModal.find('#dashboardServer').val($this.parents('tr').attr('dashboardServer'));
209+
$editModal.find('#dashboardServerUserName').val($this.parents('tr').attr('dashboardServerUserName'));
210+
$editModal.find('#dashboardDbHostName').val($this.parents('tr').attr('dashboardDbHostName'));
211+
$editModal.find('#cicddashboardServerEditHiddenInputId').val($this.parents('tr').attr('dashboardId'));
212+
return false;
213+
});
214+
215+
$('#cicdDashboardServerTable tbody').on( 'click', 'button.deletecicdDashboardServer', function(){
216+
var $this = $(this);
217+
bootbox.confirm({
218+
message: 'Are you sure you want to Delete CI CD Dashboard Server -&nbsp;' + $this.parents('tr').attr('dashboardName'),
219+
title: "Warning",
220+
callback: function(result) {
221+
if (result) {
222+
$.ajax({
223+
url: '../cicd-dashboardservice/' + $this.parents('tr').attr('dashboardId'),
224+
method: 'DELETE',
225+
success: function() {
226+
getGlobalcicdDashboardServers();
227+
},
228+
error: function(jxhr) {
229+
var msg = "Unable to Delete CI CD Dashboard Server please try again later";
230+
if (jxhr.responseJSON && jxhr.responseJSON.message) {
231+
msg = jxhr.responseJSON.message;
232+
} else if (jxhr.responseText) {
233+
msg = jxhr.responseText;
234+
}
235+
bootbox.alert(msg);
236+
}
237+
});
238+
} else {
239+
return;
240+
}
241+
}
242+
});
243+
return false;
244+
});
245+
246+
//to show the focus on first input ....
247+
$(document).on('shown.bs.modal', function(e) {
248+
$('[autofocus]', e.target).focus();
249+
});

server/app/model/cicd-dashboards/cicdDashboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ CICDDashboardSchema.statics.updatecicdDashboad = function (cicdDashboadId, field
163163
};
164164

165165
CICDDashboardSchema.statics.deletecicdDashboad = function (cicdDashboadId, callback) {
166-
this.remove({'_id': gcicdDashboadId},
166+
this.remove({'_id': cicdDashboadId},
167167
function (err, data) {
168168
if (err) {
169169
logger.error(err);

0 commit comments

Comments
 (0)