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>
This commit is contained in:
parent
7ca44f53bc
commit
0d70606022
|
@ -393,7 +393,7 @@ class XhrCustomRecipeId(View):
|
|||
""" Get Custom Image recipe or return an error response"""
|
||||
try:
|
||||
custom_recipe = \
|
||||
CustomImageRecipe.objects.get(pk=recipe_id)
|
||||
CustomImageRecipe.objects.get(pk=recipe_id)
|
||||
return custom_recipe, None
|
||||
|
||||
except CustomImageRecipe.DoesNotExist:
|
||||
|
@ -418,8 +418,12 @@ class XhrCustomRecipeId(View):
|
|||
if error:
|
||||
return error
|
||||
|
||||
project = custom_recipe.project
|
||||
|
||||
custom_recipe.delete()
|
||||
return JsonResponse({"error": "ok"})
|
||||
return JsonResponse({"error": "ok",
|
||||
"gotoUrl": reverse("projectcustomimages",
|
||||
args=(project.pk,))})
|
||||
|
||||
|
||||
class XhrCustomRecipePackages(View):
|
||||
|
@ -820,8 +824,11 @@ class XhrProject(View):
|
|||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
try:
|
||||
Project.objects.get(kwargs['project_id']).delete()
|
||||
Project.objects.get(pk=kwargs['project_id']).delete()
|
||||
except Project.DoesNotExist:
|
||||
return error_response("Project %s does not exist" %
|
||||
kwargs['project_id'])
|
||||
return JsonResponse({"error": "ok"})
|
||||
return JsonResponse({
|
||||
"error": "ok",
|
||||
"gotoUrl": reverse("all-projects", args=[])
|
||||
})
|
||||
|
|
|
@ -45,6 +45,9 @@ function projectPageInit(ctx) {
|
|||
|
||||
/* Now we're really ready show the page */
|
||||
$("#project-page").show();
|
||||
|
||||
/* Set the project name in the delete modal */
|
||||
$("#delete-project-modal .project-name").text(prjInfo.name);
|
||||
});
|
||||
|
||||
(function notificationRequest(){
|
||||
|
@ -328,7 +331,32 @@ function projectPageInit(ctx) {
|
|||
|
||||
$("#delete-project-confirmed").click(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
libtoaster.disableAjaxLoadingTimer();
|
||||
$(this).find('[data-role="submit-state"]').hide();
|
||||
$(this).find('[data-role="loading-state"]').show();
|
||||
$(this).attr("disabled", "disabled");
|
||||
$('#delete-project-modal [data-dismiss="modal"]').hide();
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: libtoaster.ctx.xhrProjectUrl,
|
||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||
success: function (data) {
|
||||
if (data.error !== "ok") {
|
||||
console.warn(data.error);
|
||||
} else {
|
||||
var msg = $('<span>You have deleted <strong>1</strong> project: <strong id="project-deleted"></strong></span>');
|
||||
|
||||
msg.find("#project-deleted").text(libtoaster.ctx.projectName);
|
||||
libtoaster.setNotification("project-deleted", msg.html());
|
||||
|
||||
window.location.replace(data.gotoUrl);
|
||||
}
|
||||
},
|
||||
error: function (data) {
|
||||
console.warn(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ function projectTopBarInit(ctx) {
|
|||
|
||||
var projectNameForm = $("#project-name-change-form");
|
||||
var projectNameContainer = $("#project-name-container");
|
||||
var projectName = $("#project-name");
|
||||
var projectName = $(".project-name");
|
||||
var projectNameFormToggle = $("#project-change-form-toggle");
|
||||
var projectNameChangeCancel = $("#project-name-change-cancel");
|
||||
|
||||
|
@ -25,14 +25,14 @@ function projectTopBarInit(ctx) {
|
|||
e.preventDefault();
|
||||
projectNameForm.hide();
|
||||
projectNameContainer.fadeIn();
|
||||
$("#project-name-change-input").val(projectName.text());
|
||||
$("#project-name-change-input").val(projectName.first().text());
|
||||
});
|
||||
|
||||
$("#project-name-change-btn").click(function(){
|
||||
var newProjectName = $("#project-name-change-input").val();
|
||||
|
||||
libtoaster.editCurrentProject({ projectName: newProjectName }, function (){
|
||||
projectName.html(newProjectName);
|
||||
projectName.text(newProjectName);
|
||||
libtoaster.ctx.projectName = newProjectName;
|
||||
projectNameChangeCancel.click();
|
||||
});
|
||||
|
|
|
@ -34,6 +34,12 @@ $(document).ready(function(){
|
|||
<li><a href="{% url 'projectlayers' project.id %}">Layers</a></li>
|
||||
<li class="nav-header">Extra configuration</li>
|
||||
<li><a href="{% url 'projectconf' project.id %}">BitBake variables</a></li>
|
||||
|
||||
<li class="nav-header">Actions</li>
|
||||
<li>
|
||||
<a href="#delete-project-modal" role="button" class="text-danger" data-toggle="modal" data-target="#delete-project-modal">
|
||||
<i class="icon-trash text-danger"></i> Delete project</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
|
|
|
@ -24,30 +24,37 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
{% comment %}
|
||||
<!-- Comment out the ability to change the project release, until we decide what to do this functionality -->
|
||||
<div id="change-release-modal" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="change-release-modal" aria-hidden="false">
|
||||
<div id="delete-project-modal" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
|
||||
<h3>Changing Yocto Project release to <span class="proposed-release-change-name"></span></h3>
|
||||
<h4>Are you sure you want to delete this project?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>The following added layers do not exist for <span class="proposed-release-change-name"></span>: </p>
|
||||
<ul id="layers-to-remove-list">
|
||||
</ul>
|
||||
<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>
|
||||
<p>Deleting the <strong class="project-name"></strong> project will remove forever:</p>
|
||||
<ul>
|
||||
<li>Its configuration information</li>
|
||||
<li>Its imported layers</li>
|
||||
<li>Its custom images</li>
|
||||
<li>All its build information</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="change-release-and-rm-layers" data-dismiss="modal" type="submit" class="btn btn-primary">Change release and delete layers</button>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="delete-project-confirmed">
|
||||
<span data-role="submit-state">Delete project</span>
|
||||
<span data-role="loading-state" style="display:none">
|
||||
<span class="fa-pulse">
|
||||
<i class="fa-pulse icon-spinner"></i>
|
||||
</span>
|
||||
Deleting project...
|
||||
</span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-link" data-dismiss="modal">Cancel</button>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
{% endcomment %}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" id="project-page" style="display:none">
|
||||
<div class="col-md-6">
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<!-- project name -->
|
||||
<div class="page-header">
|
||||
<h1 id="project-name-container">
|
||||
<span id="project-name">{{project.name}}</span>
|
||||
<span class="project-name">{{project.name}}</span>
|
||||
|
||||
<span class="glyphicon glyphicon-edit" id="project-change-form-toggle"></i>
|
||||
|
||||
|
|
Loading…
Reference in New Issue