mirror of
https://git.yoctoproject.org/poky
synced 2026-09-20 12:49:33 +02:00
bitbake: toaster: Clean up and convert to rest api project edit and get calls
Convert the project xhr calls into proper rest api and port the client side calls to use the new API. Fix all the pyflakes identified issues and clean up unused fields. Also remove the api and client side code for changing release on the fly as this is no longer supported. [YOCTO #9519] (Bitbake rev: 8b01767d6e787cdb09789116ebf57dfb70f521bc) 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:
committed by
Richard Purdie
parent
0b17e6d32c
commit
4d0bc8d521
@@ -167,7 +167,6 @@ var libtoaster = (function () {
|
||||
function _getProjectInfo(url, onsuccess, onfail){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data : { format: "json" },
|
||||
url: url,
|
||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||
success: function (_data) {
|
||||
@@ -194,7 +193,7 @@ var libtoaster = (function () {
|
||||
function _editCurrentProject(data, onSuccess, onFail){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: libtoaster.ctx.projectPageUrl + "?format=json",
|
||||
url: libtoaster.ctx.xhrProjectUrl,
|
||||
data: data,
|
||||
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||
success: function (data) {
|
||||
|
||||
@@ -27,11 +27,10 @@ function projectPageInit(ctx) {
|
||||
|
||||
var urlParams = libtoaster.parseUrlParams();
|
||||
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, function(prjInfo){
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.xhrProjectUrl, function(prjInfo){
|
||||
updateProjectLayers(prjInfo.layers);
|
||||
updateFreqBuildRecipes(prjInfo.freqtargets);
|
||||
updateProjectRelease(prjInfo.release);
|
||||
updateProjectReleases(prjInfo.releases, prjInfo.release);
|
||||
|
||||
/* If we're receiving a machine set from the url and it's different from
|
||||
* our current machine then activate set machine sequence.
|
||||
@@ -287,7 +286,9 @@ function projectPageInit(ctx) {
|
||||
machineNameTitle.text(machineName);
|
||||
}
|
||||
|
||||
libtoaster.makeTypeahead(machineChangeInput, libtoaster.ctx.machinesTypeAheadUrl, { }, function(item){
|
||||
libtoaster.makeTypeahead(machineChangeInput,
|
||||
libtoaster.ctx.machinesTypeAheadUrl,
|
||||
{ }, function(item){
|
||||
currentMachineAddSelection = item.name;
|
||||
machineChangeBtn.removeAttr("disabled");
|
||||
});
|
||||
@@ -324,146 +325,10 @@ function projectPageInit(ctx) {
|
||||
releaseTitle.text(release.description);
|
||||
}
|
||||
|
||||
function updateProjectReleases(releases, current){
|
||||
for (var i in releases){
|
||||
var releaseOption = $("<option></option>");
|
||||
|
||||
releaseOption.val(releases[i].id);
|
||||
releaseOption.text(releases[i].description);
|
||||
releaseOption.data('release', releases[i]);
|
||||
|
||||
if (releases[i].id == current.id)
|
||||
releaseOption.attr("selected", "selected");
|
||||
|
||||
releaseForm.children("select").append(releaseOption);
|
||||
}
|
||||
}
|
||||
|
||||
releaseChangeFormToggle.click(function(){
|
||||
releaseForm.slideDown();
|
||||
releaseTitle.hide();
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
cancelReleaseChange.click(function(e){
|
||||
$("#delete-project-confirmed").click(function(e){
|
||||
e.preventDefault();
|
||||
releaseForm.slideUp(function(){
|
||||
releaseTitle.show();
|
||||
releaseChangeFormToggle.show();
|
||||
});
|
||||
});
|
||||
|
||||
function changeProjectRelease(release, layersToRm){
|
||||
libtoaster.editCurrentProject({ projectVersion : release.id },
|
||||
function(){
|
||||
/* Success */
|
||||
/* Update layers list with new layers */
|
||||
layersInPrjList.addClass('muted');
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
|
||||
function(prjInfo){
|
||||
layersInPrjList.children().remove();
|
||||
updateProjectLayers(prjInfo.layers);
|
||||
layersInPrjList.removeClass('muted');
|
||||
releaseChangedNotification(release, prjInfo.layers, layersToRm);
|
||||
});
|
||||
updateProjectRelease(release);
|
||||
cancelReleaseChange.click();
|
||||
});
|
||||
}
|
||||
|
||||
/* Create a notification to show the changes to the layer configuration
|
||||
* caused by changing a release.
|
||||
*/
|
||||
|
||||
function releaseChangedNotification(release, layers, layersToRm){
|
||||
|
||||
var message;
|
||||
|
||||
if (layers.length === 0 && layersToRm.length === 0){
|
||||
message = $('<span><span class="lead">You have changed the project release to: <strong><span id="notify-release-name"></span></strong>.');
|
||||
message.find("#notify-release-name").text(release.description);
|
||||
libtoaster.showChangeNotification(message);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create the whitespace separated list of layers removed */
|
||||
var layersDelList = "";
|
||||
|
||||
layersToRm.map(function(layer, i){
|
||||
layersDelList += layer.name;
|
||||
if (layersToRm[i+1] !== undefined)
|
||||
layersDelList += ', ';
|
||||
});
|
||||
|
||||
message = $('<span><span class="lead">You have changed the project release to: <strong><span id="notify-release-name"></span></strong>. This has caused the following changes in your project layers:</span><ul id="notify-layers-changed-list"></ul></span>');
|
||||
|
||||
var changedList = message.find("#notify-layers-changed-list");
|
||||
|
||||
message.find("#notify-release-name").text(release.description);
|
||||
|
||||
/* Manually construct the list item for changed layers */
|
||||
var li = '<li><strong>'+layers.length+'</strong> layers changed to the <strong>'+release.name+'</strong> release: ';
|
||||
for (var i in layers){
|
||||
li += '<a href='+layers[i].layerdetailurl+'>'+layers[i].name+'</a>';
|
||||
if (i !== 0)
|
||||
li += ', ';
|
||||
}
|
||||
|
||||
changedList.append($(li));
|
||||
|
||||
/* Layers removed */
|
||||
if (layersToRm && layersToRm.length > 0){
|
||||
if (layersToRm.length == 1)
|
||||
li = '<li><strong>1</strong> layer removed: '+layersToRm[0].name+'</li>';
|
||||
else
|
||||
li = '<li><strong>'+layersToRm.length+'</strong> layers deleted: '+layersDelList+'</li>';
|
||||
|
||||
changedList.append($(li));
|
||||
}
|
||||
|
||||
libtoaster.showChangeNotification(message);
|
||||
}
|
||||
|
||||
/* Show the modal dialog which gives the option to remove layers which
|
||||
* aren't compatible with the proposed release
|
||||
*/
|
||||
function showReleaseLayerChangeModal(release, layers){
|
||||
var layersToRmList = releaseModal.find("#layers-to-remove-list");
|
||||
layersToRmList.text("");
|
||||
|
||||
releaseModal.find(".proposed-release-change-name").text(release.description);
|
||||
releaseModal.data("layers", layers);
|
||||
releaseModal.data("release", release);
|
||||
|
||||
for (var i in layers){
|
||||
layersToRmList.append($("<li></li>").text(layers[i].name));
|
||||
}
|
||||
releaseModal.modal('show');
|
||||
}
|
||||
|
||||
$("#change-release-btn").click(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
var newRelease = releaseForm.find("option:selected").data('release');
|
||||
|
||||
$.getJSON(ctx.testReleaseChangeUrl,
|
||||
{ new_release_id: newRelease.id },
|
||||
function(layers) {
|
||||
if (layers.rows.length === 0){
|
||||
/* No layers to change for this release */
|
||||
changeProjectRelease(newRelease, []);
|
||||
} else {
|
||||
showReleaseLayerChangeModal(newRelease, layers.rows);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* Release change modal accept */
|
||||
$("#change-release-and-rm-layers").click(function(){
|
||||
var layers = releaseModal.data("layers");
|
||||
var release = releaseModal.data("release");
|
||||
|
||||
changeProjectRelease(release, layers);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -42,9 +42,8 @@ QUnit.test("Layer alert notification", function(assert) {
|
||||
|
||||
QUnit.test("Project info", function(assert){
|
||||
var done = assert.async();
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, function(prjInfo){
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.xhrProjectUrl, function(prjInfo){
|
||||
assert.ok(prjInfo.machine.name);
|
||||
assert.ok(prjInfo.releases.length > 0);
|
||||
assert.ok(prjInfo.layers.length > 0);
|
||||
assert.ok(prjInfo.freqtargets);
|
||||
assert.ok(prjInfo.release);
|
||||
@@ -82,11 +81,11 @@ QUnit.test("Add layer", function(assert){
|
||||
}, 200);
|
||||
|
||||
/* Compare the number of layers before and after the add in the project */
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, function(prjInfo){
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.xhrProjectUrl, function(prjInfo){
|
||||
var origNumLayers = prjInfo.layers.length;
|
||||
|
||||
libtoaster.addRmLayer(layer, true, function(deps){
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl,
|
||||
libtoaster.getProjectInfo(libtoaster.ctx.xhrProjectUrl,
|
||||
function(prjInfo){
|
||||
assert.ok(prjInfo.layers.length > origNumLayers,
|
||||
"Layer not added to project");
|
||||
|
||||
Reference in New Issue
Block a user