summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-09-26 13:59:31 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-30 16:52:22 +0100
commit0d70606022cad010f586ec29b558ee902be765ef (patch)
treedfcfb5b5ca63c6c1047807fd64ec482d73a2b1a5
parent7ca44f53bccf48d289c5f53c00ca7026aacef6dd (diff)
downloadpoky-0d70606022cad010f586ec29b558ee902be765ef.tar.gz
bitbake: toaster: project page Implement front end feature to delete project
Add confirm modal and api calls to delete a project from the project dashboard. [YOCTO #6238] (Bitbake rev: e1cca28826dfa66d905dd4daf9964564c355207e) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/toastergui/api.py15
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectpage.js30
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projecttopbar.js6
-rw-r--r--bitbake/lib/toaster/toastergui/templates/baseprojectpage.html6
-rw-r--r--bitbake/lib/toaster/toastergui/templates/project.html35
-rw-r--r--bitbake/lib/toaster/toastergui/templates/projecttopbar.html2
6 files changed, 71 insertions, 23 deletions
diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py
index 5589118027..856918b6a3 100644
--- a/bitbake/lib/toaster/toastergui/api.py
+++ b/bitbake/lib/toaster/toastergui/api.py
@@ -393,7 +393,7 @@ class XhrCustomRecipeId(View):
393 """ Get Custom Image recipe or return an error response""" 393 """ Get Custom Image recipe or return an error response"""
394 try: 394 try:
395 custom_recipe = \ 395 custom_recipe = \
396 CustomImageRecipe.objects.get(pk=recipe_id) 396 CustomImageRecipe.objects.get(pk=recipe_id)
397 return custom_recipe, None 397 return custom_recipe, None
398 398
399 except CustomImageRecipe.DoesNotExist: 399 except CustomImageRecipe.DoesNotExist:
@@ -418,8 +418,12 @@ class XhrCustomRecipeId(View):
418 if error: 418 if error:
419 return error 419 return error
420 420
421 project = custom_recipe.project
422
421 custom_recipe.delete() 423 custom_recipe.delete()
422 return JsonResponse({"error": "ok"}) 424 return JsonResponse({"error": "ok",
425 "gotoUrl": reverse("projectcustomimages",
426 args=(project.pk,))})
423 427
424 428
425class XhrCustomRecipePackages(View): 429class XhrCustomRecipePackages(View):
@@ -820,8 +824,11 @@ class XhrProject(View):
820 824
821 def delete(self, request, *args, **kwargs): 825 def delete(self, request, *args, **kwargs):
822 try: 826 try:
823 Project.objects.get(kwargs['project_id']).delete() 827 Project.objects.get(pk=kwargs['project_id']).delete()
824 except Project.DoesNotExist: 828 except Project.DoesNotExist:
825 return error_response("Project %s does not exist" % 829 return error_response("Project %s does not exist" %
826 kwargs['project_id']) 830 kwargs['project_id'])
827 return JsonResponse({"error": "ok"}) 831 return JsonResponse({
832 "error": "ok",
833 "gotoUrl": reverse("all-projects", args=[])
834 })
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
index 3bf3cbaf2b..7f19c0d7aa 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js
@@ -45,6 +45,9 @@ function projectPageInit(ctx) {
45 45
46 /* Now we're really ready show the page */ 46 /* Now we're really ready show the page */
47 $("#project-page").show(); 47 $("#project-page").show();
48
49 /* Set the project name in the delete modal */
50 $("#delete-project-modal .project-name").text(prjInfo.name);
48 }); 51 });
49 52
50 (function notificationRequest(){ 53 (function notificationRequest(){
@@ -328,7 +331,32 @@ function projectPageInit(ctx) {
328 331
329 $("#delete-project-confirmed").click(function(e){ 332 $("#delete-project-confirmed").click(function(e){
330 e.preventDefault(); 333 e.preventDefault();
331 334 libtoaster.disableAjaxLoadingTimer();
335 $(this).find('[data-role="submit-state"]').hide();
336 $(this).find('[data-role="loading-state"]').show();
337 $(this).attr("disabled", "disabled");
338 $('#delete-project-modal [data-dismiss="modal"]').hide();
339
340 $.ajax({
341 type: 'DELETE',
342 url: libtoaster.ctx.xhrProjectUrl,
343 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
344 success: function (data) {
345 if (data.error !== "ok") {
346 console.warn(data.error);
347 } else {
348 var msg = $('<span>You have deleted <strong>1</strong> project: <strong id="project-deleted"></strong></span>');
349
350 msg.find("#project-deleted").text(libtoaster.ctx.projectName);
351 libtoaster.setNotification("project-deleted", msg.html());
352
353 window.location.replace(data.gotoUrl);
354 }
355 },
356 error: function (data) {
357 console.warn(data);
358 }
359 });
332 }); 360 });
333 361
334} 362}
diff --git a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
index f0cd18bf48..92ab2d67fd 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
@@ -4,7 +4,7 @@ function projectTopBarInit(ctx) {
4 4
5 var projectNameForm = $("#project-name-change-form"); 5 var projectNameForm = $("#project-name-change-form");
6 var projectNameContainer = $("#project-name-container"); 6 var projectNameContainer = $("#project-name-container");
7 var projectName = $("#project-name"); 7 var projectName = $(".project-name");
8 var projectNameFormToggle = $("#project-change-form-toggle"); 8 var projectNameFormToggle = $("#project-change-form-toggle");
9 var projectNameChangeCancel = $("#project-name-change-cancel"); 9 var projectNameChangeCancel = $("#project-name-change-cancel");
10 10
@@ -25,14 +25,14 @@ function projectTopBarInit(ctx) {
25 e.preventDefault(); 25 e.preventDefault();
26 projectNameForm.hide(); 26 projectNameForm.hide();
27 projectNameContainer.fadeIn(); 27 projectNameContainer.fadeIn();
28 $("#project-name-change-input").val(projectName.text()); 28 $("#project-name-change-input").val(projectName.first().text());
29 }); 29 });
30 30
31 $("#project-name-change-btn").click(function(){ 31 $("#project-name-change-btn").click(function(){
32 var newProjectName = $("#project-name-change-input").val(); 32 var newProjectName = $("#project-name-change-input").val();
33 33
34 libtoaster.editCurrentProject({ projectName: newProjectName }, function (){ 34 libtoaster.editCurrentProject({ projectName: newProjectName }, function (){
35 projectName.html(newProjectName); 35 projectName.text(newProjectName);
36 libtoaster.ctx.projectName = newProjectName; 36 libtoaster.ctx.projectName = newProjectName;
37 projectNameChangeCancel.click(); 37 projectNameChangeCancel.click();
38 }); 38 });
diff --git a/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html b/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html
index b3b6f1caf8..8427d25210 100644
--- a/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html
+++ b/bitbake/lib/toaster/toastergui/templates/baseprojectpage.html
@@ -34,6 +34,12 @@ $(document).ready(function(){
34 <li><a href="{% url 'projectlayers' project.id %}">Layers</a></li> 34 <li><a href="{% url 'projectlayers' project.id %}">Layers</a></li>
35 <li class="nav-header">Extra configuration</li> 35 <li class="nav-header">Extra configuration</li>
36 <li><a href="{% url 'projectconf' project.id %}">BitBake variables</a></li> 36 <li><a href="{% url 'projectconf' project.id %}">BitBake variables</a></li>
37
38 <li class="nav-header">Actions</li>
39 <li>
40 <a href="#delete-project-modal" role="button" class="text-danger" data-toggle="modal" data-target="#delete-project-modal">
41 <i class="icon-trash text-danger"></i> Delete project</a>
42 </li>
37 </ul> 43 </ul>
38 </div> 44 </div>
39 <div class="col-md-10"> 45 <div class="col-md-10">
diff --git a/bitbake/lib/toaster/toastergui/templates/project.html b/bitbake/lib/toaster/toastergui/templates/project.html
index 30ee93a76f..7644dad2f3 100644
--- a/bitbake/lib/toaster/toastergui/templates/project.html
+++ b/bitbake/lib/toaster/toastergui/templates/project.html
@@ -24,30 +24,37 @@
24 }); 24 });
25</script> 25</script>
26 26
27{% comment %} 27<div id="delete-project-modal" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false">
28<!-- Comment out the ability to change the project release, until we decide what to do this functionality -->
29<div id="change-release-modal" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="change-release-modal" aria-hidden="false">
30 <div class="modal-dialog"> 28 <div class="modal-dialog">
31 <div class="modal-content"> 29 <div class="modal-content">
32
33 <div class="modal-header"> 30 <div class="modal-header">
34 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button> 31 <h4>Are you sure you want to delete this project?</h4>
35 <h3>Changing Yocto Project release to <span class="proposed-release-change-name"></span></h3>
36 </div> 32 </div>
37 <div class="modal-body"> 33 <div class="modal-body">
38 <p>The following added layers do not exist for <span class="proposed-release-change-name"></span>: </p> 34 <p>Deleting the <strong class="project-name"></strong> project will remove forever:</p>
39 <ul id="layers-to-remove-list"> 35 <ul>
40 </ul> 36 <li>Its configuration information</li>
41 <p>If you change the Yocto Project release to <span class="proposed-release-change-name"></span>, the above layers will be deleted from your added layers.</p> 37 <li>Its imported layers</li>
38 <li>Its custom images</li>
39 <li>All its build information</li>
40 </ul>
42 </div> 41 </div>
43 <div class="modal-footer"> 42 <div class="modal-footer">
44 <button id="change-release-and-rm-layers" data-dismiss="modal" type="submit" class="btn btn-primary">Change release and delete layers</button> 43 <button type="button" class="btn btn-primary" id="delete-project-confirmed">
45 <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> 44 <span data-role="submit-state">Delete project</span>
45 <span data-role="loading-state" style="display:none">
46 <span class="fa-pulse">
47 <i class="fa-pulse icon-spinner"></i>
48 </span>
49 &nbsp;Deleting project...
50 </span>
51 </button>
52 <button type="button" class="btn btn-link" data-dismiss="modal">Cancel</button>
46 </div> 53 </div>
47 </div><!-- /.modal-content --> 54 </div><!-- /.modal-content -->
48 </div><!-- /.modal-dialog --> 55 </div><!-- /.modal-dialog -->
49</div><!-- /.modal --> 56</div>
50{% endcomment %} 57
51 58
52<div class="row" id="project-page" style="display:none"> 59<div class="row" id="project-page" style="display:none">
53 <div class="col-md-6"> 60 <div class="col-md-6">
diff --git a/bitbake/lib/toaster/toastergui/templates/projecttopbar.html b/bitbake/lib/toaster/toastergui/templates/projecttopbar.html
index 2734af0c95..768ca94554 100644
--- a/bitbake/lib/toaster/toastergui/templates/projecttopbar.html
+++ b/bitbake/lib/toaster/toastergui/templates/projecttopbar.html
@@ -24,7 +24,7 @@
24 <!-- project name --> 24 <!-- project name -->
25 <div class="page-header"> 25 <div class="page-header">
26 <h1 id="project-name-container"> 26 <h1 id="project-name-container">
27 <span id="project-name">{{project.name}}</span> 27 <span class="project-name">{{project.name}}</span>
28 28
29 <span class="glyphicon glyphicon-edit" id="project-change-form-toggle"></i> 29 <span class="glyphicon glyphicon-edit" id="project-change-form-toggle"></i>
30 30