summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static/js')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerBtn.js12
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js105
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/mrbsection.js4
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projecttopbar.js22
4 files changed, 142 insertions, 1 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
index 9f9eda1e1e..a5a6563d1a 100644
--- a/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
+++ b/bitbake/lib/toaster/toastergui/static/js/layerBtn.js
@@ -67,6 +67,18 @@ function layerBtnsInit() {
67 }); 67 });
68 }); 68 });
69 69
70 $("td .set-default-recipe-btn").unbind('click');
71 $("td .set-default-recipe-btn").click(function(e){
72 e.preventDefault();
73 var recipe = $(this).data('recipe-name');
74
75 libtoaster.setDefaultImage(null, recipe,
76 function(){
77 /* Success */
78 window.location.replace(libtoaster.ctx.projectSpecificPageUrl);
79 });
80 });
81
70 82
71 $(".customise-btn").unbind('click'); 83 $(".customise-btn").unbind('click');
72 $(".customise-btn").click(function(e){ 84 $(".customise-btn").click(function(e){
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index 6f9b5d0f00..2e8863af26 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -465,6 +465,108 @@ var libtoaster = (function () {
465 $.cookie('toaster-notification', JSON.stringify(data), { path: '/'}); 465 $.cookie('toaster-notification', JSON.stringify(data), { path: '/'});
466 } 466 }
467 467
468 /* _updateProject:
469 * url: xhrProjectUpdateUrl or null for current project
470 * onsuccess: callback for successful execution
471 * onfail: callback for failed execution
472 */
473 function _updateProject (url, targets, default_image, onsuccess, onfail) {
474
475 if (!url)
476 url = libtoaster.ctx.xhrProjectUpdateUrl;
477
478 /* Flatten the array of targets into a space spearated list */
479 if (targets instanceof Array){
480 targets = targets.reduce(function(prevV, nextV){
481 return prev + ' ' + next;
482 });
483 }
484
485 $.ajax( {
486 type: "POST",
487 url: url,
488 data: { 'do_update' : 'True' , 'targets' : targets , 'default_image' : default_image , },
489 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
490 success: function (_data) {
491 if (_data.error !== "ok") {
492 console.warn(_data.error);
493 } else {
494 if (onsuccess !== undefined) onsuccess(_data);
495 }
496 },
497 error: function (_data) {
498 console.warn("Call failed");
499 console.warn(_data);
500 if (onfail) onfail(data);
501 } });
502 }
503
504 /* _cancelProject:
505 * url: xhrProjectUpdateUrl or null for current project
506 * onsuccess: callback for successful execution
507 * onfail: callback for failed execution
508 */
509 function _cancelProject (url, onsuccess, onfail) {
510
511 if (!url)
512 url = libtoaster.ctx.xhrProjectCancelUrl;
513
514 $.ajax( {
515 type: "POST",
516 url: url,
517 data: { 'do_cancel' : 'True' },
518 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
519 success: function (_data) {
520 if (_data.error !== "ok") {
521 console.warn(_data.error);
522 } else {
523 if (onsuccess !== undefined) onsuccess(_data);
524 }
525 },
526 error: function (_data) {
527 console.warn("Call failed");
528 console.warn(_data);
529 if (onfail) onfail(data);
530 } });
531 }
532
533 /* _setDefaultImage:
534 * url: xhrSetDefaultImageUrl or null for current project
535 * targets: an array or space separated list of targets to set as default
536 * onsuccess: callback for successful execution
537 * onfail: callback for failed execution
538 */
539 function _setDefaultImage (url, targets, onsuccess, onfail) {
540
541 if (!url)
542 url = libtoaster.ctx.xhrSetDefaultImageUrl;
543
544 /* Flatten the array of targets into a space spearated list */
545 if (targets instanceof Array){
546 targets = targets.reduce(function(prevV, nextV){
547 return prev + ' ' + next;
548 });
549 }
550
551 $.ajax( {
552 type: "POST",
553 url: url,
554 data: { 'targets' : targets },
555 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
556 success: function (_data) {
557 if (_data.error !== "ok") {
558 console.warn(_data.error);
559 } else {
560 if (onsuccess !== undefined) onsuccess(_data);
561 }
562 },
563 error: function (_data) {
564 console.warn("Call failed");
565 console.warn(_data);
566 if (onfail) onfail(data);
567 } });
568 }
569
468 return { 570 return {
469 enableAjaxLoadingTimer: _enableAjaxLoadingTimer, 571 enableAjaxLoadingTimer: _enableAjaxLoadingTimer,
470 disableAjaxLoadingTimer: _disableAjaxLoadingTimer, 572 disableAjaxLoadingTimer: _disableAjaxLoadingTimer,
@@ -485,6 +587,9 @@ var libtoaster = (function () {
485 createCustomRecipe: _createCustomRecipe, 587 createCustomRecipe: _createCustomRecipe,
486 makeProjectNameValidation: _makeProjectNameValidation, 588 makeProjectNameValidation: _makeProjectNameValidation,
487 setNotification: _setNotification, 589 setNotification: _setNotification,
590 updateProject : _updateProject,
591 cancelProject : _cancelProject,
592 setDefaultImage : _setDefaultImage,
488 }; 593 };
489})(); 594})();
490 595
diff --git a/bitbake/lib/toaster/toastergui/static/js/mrbsection.js b/bitbake/lib/toaster/toastergui/static/js/mrbsection.js
index c0c5fa9589..f07ccf8181 100644
--- a/bitbake/lib/toaster/toastergui/static/js/mrbsection.js
+++ b/bitbake/lib/toaster/toastergui/static/js/mrbsection.js
@@ -86,7 +86,7 @@ function mrbSectionInit(ctx){
86 if (buildFinished(build)) { 86 if (buildFinished(build)) {
87 // a build finished: reload the whole page so that the build 87 // a build finished: reload the whole page so that the build
88 // shows up in the builds table 88 // shows up in the builds table
89 window.location.reload(); 89 window.location.reload(true);
90 } 90 }
91 else if (stateChanged(build)) { 91 else if (stateChanged(build)) {
92 // update the whole template 92 // update the whole template
@@ -110,6 +110,8 @@ function mrbSectionInit(ctx){
110 // update the clone progress text 110 // update the clone progress text
111 selector = '#repos-cloned-percentage-' + build.id; 111 selector = '#repos-cloned-percentage-' + build.id;
112 $(selector).html(build.repos_cloned_percentage); 112 $(selector).html(build.repos_cloned_percentage);
113 selector = '#repos-cloned-progressitem-' + build.id;
114 $(selector).html('('+build.progress_item+')');
113 115
114 // update the recipe progress bar 116 // update the recipe progress bar
115 selector = '#repos-cloned-percentage-bar-' + build.id; 117 selector = '#repos-cloned-percentage-bar-' + build.id;
diff --git a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
index 69220aaf57..3f9e186708 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js
@@ -14,6 +14,9 @@ function projectTopBarInit(ctx) {
14 var newBuildTargetBuildBtn = $("#build-button"); 14 var newBuildTargetBuildBtn = $("#build-button");
15 var selectedTarget; 15 var selectedTarget;
16 16
17 var updateProjectBtn = $("#update-project-button");
18 var cancelProjectBtn = $("#cancel-project-button");
19
17 /* Project name change functionality */ 20 /* Project name change functionality */
18 projectNameFormToggle.click(function(e){ 21 projectNameFormToggle.click(function(e){
19 e.preventDefault(); 22 e.preventDefault();
@@ -89,6 +92,25 @@ function projectTopBarInit(ctx) {
89 }, null); 92 }, null);
90 }); 93 });
91 94
95 updateProjectBtn.click(function (e) {
96 e.preventDefault();
97
98 selectedTarget = { name: "_PROJECT_PREPARE_" };
99
100 /* Save current default build image, fire off the build */
101 libtoaster.updateProject(null, selectedTarget.name, newBuildTargetInput.val().trim(),
102 function(){
103 window.location.replace(libtoaster.ctx.projectSpecificPageUrl);
104 }, null);
105 });
106
107 cancelProjectBtn.click(function (e) {
108 e.preventDefault();
109
110 /* redirect to 'done/canceled' landing page */
111 window.location.replace(libtoaster.ctx.landingSpecificCancelURL);
112 });
113
92 /* Call makeProjectNameValidation function */ 114 /* Call makeProjectNameValidation function */
93 libtoaster.makeProjectNameValidation($("#project-name-change-input"), 115 libtoaster.makeProjectNameValidation($("#project-name-change-input"),
94 $("#hint-error-project-name"), $("#validate-project-name"), 116 $("#hint-error-project-name"), $("#validate-project-name"),