diff options
Diffstat (limited to 'import-layers/yocto-poky/bitbake/lib/toaster/toastergui/static/js/projectpage.js')
-rw-r--r-- | import-layers/yocto-poky/bitbake/lib/toaster/toastergui/static/js/projectpage.js | 232 |
1 files changed, 43 insertions, 189 deletions
diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/static/js/projectpage.js index 3013416dd..453670364 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/static/js/projectpage.js +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/static/js/projectpage.js @@ -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. @@ -46,54 +45,13 @@ function projectPageInit(ctx) { /* Now we're really ready show the page */ $("#project-page").show(); - }); - - (function notificationRequest(){ - - if (urlParams.hasOwnProperty('notify')){ - switch (urlParams.notify){ - case 'new-project': - $("#project-created-notification").show(); - break; - case 'layer-imported': - layerImportedNotification(); - break; - default: - break; - } - } - })(); - - /* Layer imported notification */ - function layerImportedNotification(){ - var imported = $.cookie("layer-imported-alert"); - var message = "Layer imported"; - - if (!imported) - return; - else - imported = JSON.parse(imported); - - if (imported.deps_added.length === 0) { - message = "You have imported <strong><a href=\""+imported.imported_layer.layerdetailurl+"\">"+imported.imported_layer.name+"</a></strong> and added it to your project."; - } else { - var links = "<a href=\""+imported.imported_layer.layerdetailurl+"\">"+imported.imported_layer.name+"</a>, "; - - imported.deps_added.map (function(item, index){ - links +='<a href="'+item.layerdetailurl+'">'+item.name+'</a>'; - /*If we're at the last element we don't want the trailing comma */ - if (imported.deps_added[index+1] !== undefined) - links += ', '; - }); - - /* Length + 1 here to do deps + the imported layer */ - message = 'You have imported <strong><a href="'+imported.imported_layer.layerdetailurl+'">'+imported.imported_layer.name+'</a></strong> and added <strong>'+(imported.deps_added.length+1)+'</strong> layers to your project: <strong>'+links+'</strong>'; - } - - libtoaster.showChangeNotification(message); + /* Set the project name in the delete modal */ + $("#delete-project-modal .project-name").text(prjInfo.name); + }); - $.removeCookie("layer-imported-alert", { path: "/"}); + if (urlParams.hasOwnProperty('notify') && urlParams.notify === 'new-project'){ + $("#project-created-notification").show(); } /* Add/Rm layer functionality */ @@ -145,7 +103,7 @@ function projectPageInit(ctx) { for (var i in layers){ var layerObj = layers[i]; - var projectLayer = $("<li><a></a><span class=\"icon-trash\" data-toggle=\"tooltip\" title=\"Remove\"></span></li>"); + var projectLayer = $("<li><a></a><span class=\"glyphicon glyphicon-trash\" data-toggle=\"tooltip\" title=\"Remove\"></span></li>"); projectLayer.data('layer', layerObj); projectLayer.children("span").tooltip(); @@ -154,7 +112,12 @@ function projectPageInit(ctx) { link.attr("href", layerObj.layerdetailurl); link.text(layerObj.name); - link.tooltip({title: layerObj.vcs_url + " | "+ layerObj.vcs_reference, placement: "right"}); + + if (layerObj.local_source_dir) { + link.tooltip({title: layerObj.local_source_dir, placement: "right"}); + } else { + link.tooltip({title: layerObj.vcs_url + " | "+ layerObj.vcs_reference, placement: "right"}); + } var trashItem = projectLayer.children("span"); trashItem.click(function (e) { @@ -208,7 +171,7 @@ function projectPageInit(ctx) { } for (var i in recipes){ - var freqTargetCheck = $('<li><label class="checkbox"><input type="checkbox" /><span class="freq-target-name"></span></label></li>'); + var freqTargetCheck = $('<li><div class="checkbox"><label><input type="checkbox" /><span class="freq-target-name"></span></label></li>'); freqTargetCheck.find(".freq-target-name").text(recipes[i]); freqTargetCheck.find("input").val(recipes[i]); freqTargetCheck.click(function(){ @@ -264,7 +227,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"); }); @@ -285,7 +250,7 @@ function projectPageInit(ctx) { machineChangeCancel.click(); /* Show the alert message */ - var message = $('<span class="lead">You have changed the machine to: <strong><span id="notify-machine-name"></span></strong></span>'); + var message = $('<span>You have changed the machine to: <strong><span id="notify-machine-name"></span></strong></span>'); message.find("#notify-machine-name").text(currentMachineAddSelection); libtoaster.showChangeNotification(message); }, @@ -301,146 +266,35 @@ 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); + 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); } }); }); - /* Release change modal accept */ - $("#change-release-and-rm-layers").click(function(){ - var layers = releaseModal.data("layers"); - var release = releaseModal.data("release"); - - changeProjectRelease(release, layers); - }); - } |