aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js
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 /bitbake/lib/toaster/toastergui/static/js
parent7ca44f53bccf48d289c5f53c00ca7026aacef6dd (diff)
downloadopenembedded-core-contrib-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>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectpage.js30
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projecttopbar.js6
2 files changed, 32 insertions, 4 deletions
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) {
/* 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);
+ }
+ });
});
}
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) {
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();
});