diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-06-08 18:33:44 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-12 00:01:49 +0100 |
commit | 58cd4a14ea81b72dcd9679608e5e2231ec3d3631 (patch) | |
tree | 15cea3afb06ad5ae448fbf2fb65bfb4cb7535308 /bitbake/lib/toaster/toastergui/static/js | |
parent | 27f5137cd6143b523e9aea8eeba406337aa935c4 (diff) | |
download | poky-58cd4a14ea81b72dcd9679608e5e2231ec3d3631.tar.gz |
bitbake: toaster: fixes after refactoring
This patch fixes issues brought in by refactoring:
* the New Build button is working with pre-set projects
* the xhr_datatypeahead is exposed for calls that are not
mapable to the REST objects
* a new table returing recipes provided by layers currently
selected in the project is used to provide recipe suggestions
* the field names in json are switched from "list" to "rows" as
to maintain consistency with the ToasterTables
* the "value" field in xhr_ calls is now named "search" to maintain
consistency
(Bitbake rev: a5bc29083d4f85a5695f3f62d5badb783c6f7224)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@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/base.js | 104 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 2 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/projectapp.js | 24 |
3 files changed, 78 insertions, 52 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js index 747442cc9e..06d0676cbf 100644 --- a/bitbake/lib/toaster/toastergui/static/js/base.js +++ b/bitbake/lib/toaster/toastergui/static/js/base.js | |||
@@ -1,100 +1,118 @@ | |||
1 | 'use strict'; | ||
1 | 2 | ||
2 | 3 | function basePageInit(ctx) { | |
3 | function basePageInit (ctx) { | ||
4 | 4 | ||
5 | var newBuildButton = $("#new-build-button"); | 5 | var newBuildButton = $("#new-build-button"); |
6 | /* Hide the button if we're on the project,newproject or importlyaer page | 6 | /* Hide the button if we're on the project,newproject or importlyaer page |
7 | * or if there are no projects yet defined | 7 | * or if there are no projects yet defined |
8 | */ | 8 | */ |
9 | if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d$|importlayer$') > 0){ | 9 | if (ctx.numProjects === 0 || ctx.currentUrl.search('newproject|project/\\d$|importlayer$') > 0) { |
10 | newBuildButton.hide(); | 10 | newBuildButton.hide(); |
11 | return; | 11 | return; |
12 | } | 12 | } |
13 | 13 | ||
14 | var currentProjectId = libtoaster.ctx.projectId; | 14 | var currentProjectId = libtoaster.ctx.projectId; |
15 | 15 | ||
16 | /* Hide the change project icon when there is only one project */ | 16 | /* Hide the change project icon when there is only one project */ |
17 | if (ctx.numProjects == 1){ | 17 | if (ctx.numProjects === 1) { |
18 | $('#project .icon-pencil').hide(); | 18 | $('#project .icon-pencil').hide(); |
19 | } | 19 | } |
20 | 20 | ||
21 | newBuildButton.show().removeAttr("disabled"); | 21 | newBuildButton.show().removeAttr("disabled"); |
22 | 22 | ||
23 | 23 | ||
24 | _checkProjectBuildable() | 24 | var newBuildProjectInput = $("#new-build-button #project-name-input"); |
25 | var newBuildTargetBuildBtn = $("#new-build-button #build-button"); | ||
26 | var newBuildTargetInput = $("#new-build-button #build-target-input"); | ||
27 | var newBuildProjectSaveBtn = $("#new-build-button #save-project-button"); | ||
28 | |||
29 | |||
30 | var selectedTarget; | ||
31 | |||
32 | _checkProjectBuildable(); | ||
25 | _setupNewBuildButton(); | 33 | _setupNewBuildButton(); |
26 | 34 | ||
27 | 35 | ||
28 | function _checkProjectBuildable(){ | 36 | function _checkProjectBuildable() { |
29 | if (libtoaster.ctx.projectId == undefined) | 37 | if (libtoaster.ctx.projectId === undefined) { |
30 | return; | 38 | return; |
39 | } | ||
31 | 40 | ||
32 | libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, | 41 | libtoaster.getProjectInfo(libtoaster.ctx.projectPageUrl, |
33 | function(data){ | 42 | function (data) { |
34 | if (data.machine.name == undefined || data.layers.length == 0) { | 43 | if (data.machine.name === undefined || data.layers.length === 0) { |
35 | /* we can't build anything with out a machine and some layers */ | 44 | /* we can't build anything with out a machine and some layers */ |
36 | $("#new-build-button #targets-form").hide(); | 45 | $("#new-build-button #targets-form").hide(); |
37 | $("#new-build-button .alert").show(); | 46 | $("#new-build-button .alert").show(); |
38 | } else { | 47 | } else { |
39 | $("#new-build-button #targets-form").show(); | 48 | $("#new-build-button #targets-form").show(); |
40 | $("#new-build-button .alert").hide(); | 49 | $("#new-build-button .alert").hide(); |
50 | |||
51 | /* we can build this project; enable input fields */ | ||
52 | newBuildTargetInput.prop("disabled", false); | ||
53 | newBuildTargetBuildBtn.prop("disabled", false); | ||
54 | |||
55 | libtoaster.makeTypeahead(newBuildTargetInput, libtoaster.ctx.projectTargetsUrl, { format: "json" }, function (item) { | ||
56 | /* successfully selected a target */ | ||
57 | selectedTarget = item; | ||
58 | }); | ||
59 | |||
41 | } | 60 | } |
42 | }, null); | 61 | }, null); |
43 | } | 62 | } |
44 | 63 | ||
45 | function _setupNewBuildButton() { | 64 | function _setupNewBuildButton() { |
46 | /* Setup New build button */ | 65 | /* Setup New build button */ |
47 | var newBuildProjectInput = $("#new-build-button #project-name-input"); | ||
48 | var newBuildTargetBuildBtn = $("#new-build-button #build-button"); | ||
49 | var newBuildTargetInput = $("#new-build-button #build-target-input"); | ||
50 | var newBuildProjectSaveBtn = $("#new-build-button #save-project-button"); | ||
51 | var selectedTarget; | ||
52 | var selectedProject; | 66 | var selectedProject; |
53 | 67 | ||
54 | /* If we don't have a current project then present the set project | 68 | /* If we don't have a current project then present the set project |
55 | * form. | 69 | * form. |
56 | */ | 70 | */ |
57 | if (libtoaster.ctx.projectId == undefined) { | 71 | if (libtoaster.ctx.projectId === undefined) { |
58 | $('#change-project-form').show(); | 72 | $('#change-project-form').show(); |
59 | $('#project .icon-pencil').hide(); | 73 | $('#project .icon-pencil').hide(); |
60 | } | 74 | } |
61 | 75 | ||
62 | 76 | ||
63 | libtoaster.makeTypeahead(newBuildProjectInput, libtoaster.ctx.projectsUrl, { format : "json" }, function(item){ | 77 | libtoaster.makeTypeahead(newBuildProjectInput, libtoaster.ctx.projectsUrl, { format : "json" }, function (item) { |
64 | /* successfully selected a project */ | 78 | /* successfully selected a project */ |
65 | newBuildProjectSaveBtn.removeAttr("disabled"); | 79 | newBuildProjectSaveBtn.removeAttr("disabled"); |
66 | selectedProject = item; | 80 | selectedProject = item; |
67 | }); | 81 | }); |
68 | 82 | ||
69 | /* Any typing in the input apart from enter key is going to invalidate | 83 | /* Any typing in the input apart from enter key is going to invalidate |
70 | * the value that has been set by selecting a suggestion from the typeahead | 84 | * the value that has been set by selecting a suggestion from the typeahead |
71 | */ | 85 | */ |
72 | newBuildProjectInput.on('input', function(event) { | 86 | newBuildProjectInput.on('input', function (event) { |
73 | if (event.keyCode == 13) | 87 | if (event.keyCode === 13) { |
74 | return; | 88 | return; |
75 | newBuildProjectSaveBtn.attr("disabled", "disabled"); | 89 | } |
90 | newBuildProjectSaveBtn.attr("disabled", "disabled"); | ||
76 | }); | 91 | }); |
77 | 92 | ||
78 | newBuildTargetInput.on('input', function() { | 93 | newBuildTargetInput.on('input', function () { |
79 | if ($(this).val().length == 0) | 94 | if ($(this).val().length === 0) { |
80 | newBuildTargetBuildBtn.attr("disabled", "disabled"); | 95 | newBuildTargetBuildBtn.attr("disabled", "disabled"); |
81 | else | 96 | } else { |
82 | newBuildTargetBuildBtn.removeAttr("disabled"); | 97 | newBuildTargetBuildBtn.removeAttr("disabled"); |
98 | } | ||
83 | }); | 99 | }); |
84 | 100 | ||
85 | newBuildTargetBuildBtn.click(function() { | 101 | newBuildTargetBuildBtn.click(function () { |
86 | if (!newBuildTargetInput.val()) | 102 | if (!newBuildTargetInput.val()) { |
87 | return; | 103 | return; |
104 | } | ||
88 | 105 | ||
89 | if (!selectedTarget) | 106 | if (!selectedTarget) { |
90 | selectedTarget = { name: newBuildTargetInput.val() }; | 107 | selectedTarget = { name: newBuildTargetInput.val() }; |
108 | } | ||
91 | /* fire and forget */ | 109 | /* fire and forget */ |
92 | libtoaster.startABuild(ctx.projectBuildsUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null); | 110 | libtoaster.startABuild(libtoaster.ctx.projectBuildsUrl, libtoaster.ctx.projectId, selectedTarget.name, null, null); |
93 | window.location.replace(libtoaster.ctx.projectPageUrl); | 111 | window.location.replace(libtoaster.ctx.projectPageUrl); |
94 | }); | 112 | }); |
95 | 113 | ||
96 | newBuildProjectSaveBtn.click(function() { | 114 | newBuildProjectSaveBtn.click(function () { |
97 | libtoaster.ctx.projectId = selectedProject.pk | 115 | libtoaster.ctx.projectId = selectedProject.pk; |
98 | /* Update the typeahead project_id paramater */ | 116 | /* Update the typeahead project_id paramater */ |
99 | _checkProjectBuildable(); | 117 | _checkProjectBuildable(); |
100 | 118 | ||
@@ -111,10 +129,10 @@ function basePageInit (ctx) { | |||
111 | newBuildTargetInput.prop("disabled", false); | 129 | newBuildTargetInput.prop("disabled", false); |
112 | newBuildTargetBuildBtn.prop("disabled", false); | 130 | newBuildTargetBuildBtn.prop("disabled", false); |
113 | 131 | ||
114 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function(item){ | 132 | libtoaster.makeTypeahead(newBuildTargetInput, selectedProject.projectTargetsUrl, { format: "json" }, function (item) { |
115 | /* successfully selected a target */ | 133 | /* successfully selected a target */ |
116 | selectedTarget = item; | 134 | selectedTarget = item; |
117 | }); | 135 | }); |
118 | 136 | ||
119 | newBuildTargetInput.val(""); | 137 | newBuildTargetInput.val(""); |
120 | 138 | ||
@@ -123,12 +141,12 @@ function basePageInit (ctx) { | |||
123 | $("#new-build-button .alert a").attr('href', libtoaster.ctx.projectPageUrl); | 141 | $("#new-build-button .alert a").attr('href', libtoaster.ctx.projectPageUrl); |
124 | $("#project .icon-pencil").show(); | 142 | $("#project .icon-pencil").show(); |
125 | 143 | ||
126 | $("#change-project-form").slideUp({ 'complete' : function() { | 144 | $("#change-project-form").slideUp({ 'complete' : function () { |
127 | $("#new-build-button #project").show(); | 145 | $("#new-build-button #project").show(); |
128 | }}); | 146 | }}); |
129 | }); | 147 | }); |
130 | 148 | ||
131 | $('#new-build-button #project .icon-pencil').click(function() { | 149 | $('#new-build-button #project .icon-pencil').click(function () { |
132 | newBuildProjectSaveBtn.attr("disabled", "disabled"); | 150 | newBuildProjectSaveBtn.attr("disabled", "disabled"); |
133 | newBuildProjectInput.val($("#new-build-button #project a").text()); | 151 | newBuildProjectInput.val($("#new-build-button #project a").text()); |
134 | $("#cancel-change-project").show(); | 152 | $("#cancel-change-project").show(); |
@@ -136,8 +154,8 @@ function basePageInit (ctx) { | |||
136 | $("#change-project-form").slideDown(); | 154 | $("#change-project-form").slideDown(); |
137 | }); | 155 | }); |
138 | 156 | ||
139 | $("#new-build-button #cancel-change-project").click(function() { | 157 | $("#new-build-button #cancel-change-project").click(function () { |
140 | $("#change-project-form").hide(function(){ | 158 | $("#change-project-form").hide(function () { |
141 | $('#new-build-button #project').show(); | 159 | $('#new-build-button #project').show(); |
142 | }); | 160 | }); |
143 | 161 | ||
@@ -146,7 +164,7 @@ function basePageInit (ctx) { | |||
146 | }); | 164 | }); |
147 | 165 | ||
148 | /* Keep the dropdown open even unless we click outside the dropdown area */ | 166 | /* Keep the dropdown open even unless we click outside the dropdown area */ |
149 | $(".new-build").click (function(event) { | 167 | $(".new-build").click (function (event) { |
150 | event.stopPropagation(); | 168 | event.stopPropagation(); |
151 | }); | 169 | }); |
152 | }; | 170 | }; |
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index b1038cf618..23755a75f2 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
@@ -25,7 +25,7 @@ var libtoaster = (function (){ | |||
25 | return; | 25 | return; |
26 | } | 26 | } |
27 | 27 | ||
28 | return process (data.list); | 28 | return process (data.rows); |
29 | }); | 29 | }); |
30 | }, | 30 | }, |
31 | updater: function(item) { | 31 | updater: function(item) { |
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js index a915278444..44e244d302 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js | |||
@@ -217,13 +217,13 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
217 | $scope.getAutocompleteSuggestions = function(type, currentValue) { | 217 | $scope.getAutocompleteSuggestions = function(type, currentValue) { |
218 | var deffered = $q.defer(); | 218 | var deffered = $q.defer(); |
219 | 219 | ||
220 | $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, value: currentValue}}) | 220 | $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: type, search: currentValue}}) |
221 | .success(function (_data) { | 221 | .success(function (_data) { |
222 | if (_data.error != "ok") { | 222 | if (_data.error != "ok") { |
223 | console.warn(_data.error); | 223 | console.warn(_data.error); |
224 | deffered.reject(_data.error); | 224 | deffered.reject(_data.error); |
225 | } | 225 | } |
226 | deffered.resolve(_data.list); | 226 | deffered.resolve(_data.rows); |
227 | }); | 227 | }); |
228 | 228 | ||
229 | return deffered.promise; | 229 | return deffered.promise; |
@@ -534,8 +534,17 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
534 | if (_data.error != "ok") { | 534 | if (_data.error != "ok") { |
535 | console.warn(_data.error); | 535 | console.warn(_data.error); |
536 | } else { | 536 | } else { |
537 | console.log("got layer deps", _data.layerdeps.list); | 537 | /* filter out layers that are already in the project */ |
538 | if (_data.layerdeps.list.length > 0) { | 538 | var filtered_list = []; |
539 | var projectlayers_ids = $scope.layers.map(function (e) { return e.id }); | ||
540 | for (var i = 0; i < _data.layerdeps.list.length; i++) { | ||
541 | if (projectlayers_ids.indexOf(_data.layerdeps.list[i].id) == -1) { | ||
542 | filtered_list.push( _data.layerdeps.list[i]); | ||
543 | } | ||
544 | } | ||
545 | |||
546 | _data.layerdeps.list = filtered_list; | ||
547 | if (_data.layerdeps.list.length > 0) { | ||
539 | // activate modal | 548 | // activate modal |
540 | console.log("listing modals"); | 549 | console.log("listing modals"); |
541 | var modalInstance = $modal.open({ | 550 | var modalInstance = $modal.open({ |
@@ -575,7 +584,6 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
575 | console.log("built modal instance", modalInstance); | 584 | console.log("built modal instance", modalInstance); |
576 | 585 | ||
577 | modalInstance.result.then(function (selectedArray) { | 586 | modalInstance.result.then(function (selectedArray) { |
578 | console.log("layer to add", $scope.layerToAdd) | ||
579 | selectedArray.push($scope.layerToAdd.id); | 587 | selectedArray.push($scope.layerToAdd.id); |
580 | console.warn("TRC6: selected", selectedArray); | 588 | console.warn("TRC6: selected", selectedArray); |
581 | 589 | ||
@@ -634,13 +642,13 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
634 | $scope.testProjectSettingsChange = function(elementid) { | 642 | $scope.testProjectSettingsChange = function(elementid) { |
635 | if (elementid != '#change-project-version') throw "Not implemented"; | 643 | if (elementid != '#change-project-version') throw "Not implemented"; |
636 | 644 | ||
637 | $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "versionlayers", value: $scope.projectVersion }}). | 645 | $http({method:"GET", url: $scope.urls.xhr_datatypeahead, params : { type: "versionlayers", search: $scope.projectVersion }}). |
638 | success(function (_data) { | 646 | success(function (_data) { |
639 | if (_data.error != "ok") { | 647 | if (_data.error != "ok") { |
640 | alert (_data.error); | 648 | alert (_data.error); |
641 | } | 649 | } |
642 | else { | 650 | else { |
643 | if (_data.list.length > 0) { | 651 | if (_data.rows.length > 0) { |
644 | // activate modal | 652 | // activate modal |
645 | var modalInstance = $modal.open({ | 653 | var modalInstance = $modal.open({ |
646 | templateUrl: 'change_version_modal', | 654 | templateUrl: 'change_version_modal', |
@@ -660,7 +668,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc | |||
660 | }, | 668 | }, |
661 | resolve: { | 669 | resolve: { |
662 | items: function () { | 670 | items: function () { |
663 | return _data.list; | 671 | return _data.rows; |
664 | }, | 672 | }, |
665 | releaseName: function () { | 673 | releaseName: function () { |
666 | return $scope.releases.filter(function (e) { if (e.id == $scope.projectVersion) return e;})[0].name; | 674 | return $scope.releases.filter(function (e) { if (e.id == $scope.projectVersion) return e;})[0].name; |