##// END OF EJS Templates
strip: improved html output....
marcink -
r1662:db3a7961 default
parent child Browse files
Show More
@@ -1,168 +1,193 b''
1 <div class="panel panel-default">
1 <div class="panel panel-default">
2 <div class="panel-heading">
2 <div class="panel-heading">
3 <h3 class="panel-title">${_('Strip commits from repository')}</h3>
3 <h3 class="panel-title">${_('Strip commits from repository')}</h3>
4 </div>
4 </div>
5 <div class="panel-body">
5 <div class="panel-body">
6 %if c.repo_info.repo_type != 'svn':
6 %if c.repo_info.repo_type != 'svn':
7 <h4>${_('Please provide up to %d commits commits to strip') % c.strip_limit}</h4>
7 <h4>${_('Please provide up to %d commits commits to strip') % c.strip_limit}</h4>
8 <p>
8 <p>
9 ${_('In the first step commits will be verified for existance in the repository')}. </br>
9 ${_('In the first step commits will be verified for existance in the repository')}. </br>
10 ${_('In the second step, correct commits will be available for stripping')}.
10 ${_('In the second step, correct commits will be available for stripping')}.
11 </p>
11 </p>
12 ${h.secure_form(h.route_path('strip_check', repo_name=c.repo_info.repo_name), method='post')}
12 ${h.secure_form(h.route_path('strip_check', repo_name=c.repo_info.repo_name), method='post')}
13 <div id="change_body" class="field">
13 <div id="change_body" class="field">
14 <div id="box-1" class="inputx locked_input">
14 <div id="box-1" class="inputx locked_input">
15 <input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
15 <input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
16 placeholder="${_('Enter full 40 character commit sha')}" type="text" value="">
16 placeholder="${_('Enter full 40 character commit sha')}" type="text" value="">
17 <div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
17 <div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
18 <i class="icon-plus">${_('Add another commit')}</i>
18 <i class="icon-plus">${_('Add another commit')}</i>
19 </div>
19 </div>
20 </div>
20 </div>
21 </div>
21 </div>
22
22
23 <div id="results" style="display:none; padding: 10px 0px;"></div>
23 <div id="results" style="display:none; padding: 10px 0px;"></div>
24
24
25 <div class="buttons">
25 <div class="buttons">
26 <button class="btn btn-small btn-primary" onclick="checkCommits();return false">
26 <button id="strip_action" class="btn btn-small btn-primary" onclick="checkCommits();return false">
27 ${_('Check commits')}
27 ${_('Check commits')}
28 </button>
28 </button>
29 </div>
29 </div>
30
30
31 ${h.end_form()}
31 ${h.end_form()}
32 %else:
32 %else:
33 <h4>${_('Sorry this functionality is not available for SVN repository')}</h4>
33 <h4>${_('Sorry this functionality is not available for SVN repository')}</h4>
34 %endif
34 %endif
35 </div>
35 </div>
36 </div>
36 </div>
37
37
38
38
39 <script>
39 <script>
40 var plus_leaf = 1;
40 var plus_leaf = 1;
41
41
42 addNew = function(number){
42 addNew = function(number){
43 if (number >= ${c.strip_limit}){
43 if (number >= ${c.strip_limit}){
44 return;
44 return;
45 }
45 }
46 var minus = '<i class="icon-minus">${_('Remove')}</i>';
46 var minus = '<i class="icon-minus">${_('Remove')}</i>';
47 $('#plus_icon-'+number).detach();
47 $('#plus_icon-'+number).detach();
48 number++;
48 number++;
49
49
50 var input = '<div id="box-'+number+'" class="inputx locked_input">'+
50 var input = '<div id="box-'+number+'" class="inputx locked_input">'+
51 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
51 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
52 'placeholder="${_('Enter full 40 character commit sha')}">'+
52 'placeholder="${_('Enter full 40 character commit sha')}">'+
53 '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
53 '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
54 '<i class="icon-plus">${_('Add another commit')}</i>'+
54 '<i class="icon-plus">${_('Add another commit')}</i>'+
55 '</div>'+
55 '</div>'+
56 '<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
56 '<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
57 minus +
57 minus +
58 '</div>' +
58 '</div>' +
59 '</div>';
59 '</div>';
60 $('#change_body').append(input);
60 $('#change_body').append(input);
61 plus_leaf++;
61 plus_leaf++;
62 };
62 };
63
63
64 reIndex = function(number){
64 reIndex = function(number){
65 for(var i=number;i<=plus_leaf;i++){
65 for(var i=number;i<=plus_leaf;i++){
66 var check = $('#box-'+i);
66 var check = $('#box-'+i);
67 if (check.length == 0){
67 if (check.length == 0){
68 var change = $('#box-'+(i+1));
68 var change = $('#box-'+(i+1));
69 change.attr('id','box-'+i);
69 change.attr('id','box-'+i);
70 var plus = $('#plus_icon-'+(i+1));
70 var plus = $('#plus_icon-'+(i+1));
71
71
72 if (plus.length != 0){
72 if (plus.length != 0){
73 plus.attr('id','plus_icon-'+i);
73 plus.attr('id','plus_icon-'+i);
74 plus.attr('onclick','addNew('+i+');return false');
74 plus.attr('onclick','addNew('+i+');return false');
75 plus_leaf--;
75 plus_leaf--;
76 }
76 }
77 var minus = $('#minus_icon-'+(i+1));
77 var minus = $('#minus_icon-'+(i+1));
78
78
79 minus.attr('id','minus_icon-'+i);
79 minus.attr('id','minus_icon-'+i);
80
80
81 minus.attr('onclick','delOld('+i+');re' +
81 minus.attr('onclick','delOld('+i+');re' +
82 'turn false');
82 'turn false');
83 var input = $('input#changeset_id-'+(i+1));
83 var input = $('input#changeset_id-'+(i+1));
84 input.attr('name','changeset_id-'+i);
84 input.attr('name','changeset_id-'+i);
85 input.attr('id','changeset_id-'+i);
85 input.attr('id','changeset_id-'+i);
86 }
86 }
87 }
87 }
88 };
88 };
89
89
90 delOld = function(number){
90 delOld = function(number){
91 $('#box-'+number).remove();
91 $('#box-'+number).remove();
92 number = number - 1;
92 number = number - 1;
93 var box = $('#box-'+number);
93 var box = $('#box-'+number);
94 var plus = '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number +');return false">'+
94 var plus = '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number +');return false">'+
95 '<i id="i_plus_icon-'+number+'" class="icon-plus">${_('Add another commit')}</i></div>';
95 '<i id="i_plus_icon-'+number+'" class="icon-plus">${_('Add another commit')}</i></div>';
96 var minus = $('#minus_icon-'+number);
96 var minus = $('#minus_icon-'+number);
97 if(number +1 == plus_leaf){
97 if(number +1 == plus_leaf){
98 minus.detach();
98 minus.detach();
99 box.append(plus);
99 box.append(plus);
100 box.append(minus);
100 box.append(minus);
101 plus_leaf --;
101 plus_leaf --;
102 }
102 }
103 reIndex(number+1);
103 reIndex(number+1);
104
104
105 };
105 };
106
106
107 var result_data;
107 var result_data;
108
108
109 checkCommits = function() {
109 checkCommits = function() {
110 var postData = $('form').serialize();
110 var postData = $('form').serialize();
111 $('#results').show();
111 $('#results').show();
112 $('#results').html('<h4>${_('Checking commits')}...</h4>');
112 $('#results').html('<h4>${_('Checking commits')}...</h4>');
113 var url = "${h.route_path('strip_check', repo_name=c.repo_info.repo_name)}";
113 var url = "${h.route_path('strip_check', repo_name=c.repo_info.repo_name)}";
114 var btn = $('button');
114 var btn = $('#strip_action');
115 btn.attr('disabled', 'disabled');
115 btn.attr('disabled', 'disabled');
116 btn.addClass('disabled');
116 btn.addClass('disabled');
117
117
118 var success = function (data) {
118 var success = function (data) {
119 result_data = {};
119 result_data = {};
120 var i = 0;
120 var i = 0;
121 result ='';
121 var result = '<ol>';
122 $.each(data, function(index, value){
122 $.each(data, function(index, value){
123 i= index;
123 i= index;
124 var box = $('#box-'+index);
124 var box = $('#box-'+index);
125 if (value.rev){
125 if (value.rev){
126 result_data[index] = JSON.stringify(value);
126 result_data[index] = JSON.stringify(value);
127 msg = '${_("author")}: ' + value.author + ' ${_("comment")}: ' + value.comment;
127
128 result += '<h4><code>' +value.rev+ '</code>${_(' commit verified positive')}</br> '+ msg + '</h4>';
128 var verifiedHtml = (
129 '<li style="line-height:1.2em">' +
130 '<code>{0}</code>' +
131 '{1}' +
132 '<div style="white-space:pre">' +
133 'author: {2}\n' +
134 'description: {3}' +
135 '</div>' +
136 '</li>').format(
137 value.rev,
138 "${_(' commit verified positive')}",
139 value.author, value.comment
140 );
141 result += verifiedHtml;
129 }
142 }
130 else{
143 else {
131 result += '<h4><code>' +value.commit+ '</code>${_(' commit verified negative')}' + '</h4>';
144 var verifiedHtml = (
145 '<li style="line-height:1.2em">' +
146 '<code><strike>{0}</strike></code>' +
147 '{1}' +
148 '</li>').format(
149 value.commit,
150 "${_(' commit verified negative')}"
151 );
152 result += verifiedHtml;
132 }
153 }
133 box.remove();
154 box.remove();
134 });
155 });
156 result += '</ol>';
135 var box = $('#box-'+(parseInt(i)+1));
157 var box = $('#box-'+(parseInt(i)+1));
136 box.remove();
158 box.remove();
137 $('#results').html(result);
159 $('#results').html(result);
138 };
160 };
139
161
140 btn.html('Strip');
162 btn.html('Strip');
141 btn.removeAttr('disabled');
163 btn.removeAttr('disabled');
142 btn.removeClass('disabled');
164 btn.removeClass('disabled');
143 btn.attr('onclick','strip();return false;');
165 btn.attr('onclick','strip();return false;');
144 ajaxPOST(url, postData, success, null);
166 ajaxPOST(url, postData, success, null);
145 };
167 };
146
168
147 strip = function(){
169 strip = function() {
148 var url = "${h.route_path('strip_execute', repo_name=c.repo_info.repo_name)}";
170 var url = "${h.route_path('strip_execute', repo_name=c.repo_info.repo_name)}";
149 var success = function(data){
171 var success = function(data) {
150 result = '';
172 var result = '<h4>Strip executed</h4><ol>';
151 $.each(data, function(index, value){
173 $.each(data, function(index, value){
152 if(data[index]){
174 if(data[index]) {
153 result += '<h4>' +index+ '${_(' commit striped successful')}' + '</h4>';
175 result += '<li><code>' +index+ '</code> ${_(' commit striped successfully')}' + '</li>';
154 }
176 }
155 else{
177 else {
156 result += '<h4>' +index+ '${_(' commit striped failed')}' + '</h4>';
178 result += '<li><code>' +index+ '</code> ${_(' commit strip failed')}' + '</li>';
157 }
179 }
158 });
180 });
181 if ($.isEmptyObject(data)) {
182 result += '<li>Nothing done...</li>'
183 }
184 result += '</ol>';
159 $('#results').html(result);
185 $('#results').html(result);
160
186
161 };
187 };
162 ajaxPOST(url, result_data, success, null);
188 ajaxPOST(url, result_data, success, null);
163 var btn = $('button');
189 var btn = $('#strip_action');
164 btn.attr('disabled', 'disabled');
190 btn.remove();
165 btn.addClass('disabled');
166
191
167 };
192 };
168 </script>
193 </script>
General Comments 0
You need to be logged in to leave comments. Login now