[MediaWiki-commits] [Gerrit] Add widget instances to user default board - change (wikimedia...dash)
Ejegg has submitted this change and it was merged. Change subject: Add widget instances to user default board .. Add widget instances to user default board This could be better.. there should be a better flow for adding multiple instances, for example. Change-Id: I6739adc15eefe41b6c51c0ce367da3f4b1df4101 --- M src/components/app-content/app-content.html M src/components/app-content/app-content.js M src/components/widgets/fraud-gauge/fraud-gauge.js M src/css/style.css 4 files changed, 55 insertions(+), 3 deletions(-) Approvals: Ejegg: Looks good to me, approved diff --git a/src/components/app-content/app-content.html b/src/components/app-content/app-content.html index fd086ea..c3ac744 100644 --- a/src/components/app-content/app-content.html +++ b/src/components/app-content/app-content.html @@ -29,7 +29,9 @@ - + + Add to my default board + Added. diff --git a/src/components/app-content/app-content.js b/src/components/app-content/app-content.js index 49b3c65..a6e51c1 100644 --- a/src/components/app-content/app-content.js +++ b/src/components/app-content/app-content.js @@ -17,6 +17,8 @@ self.widgetTemplates = ko.observableArray(); self.widgetInstances = ko.observableArray(); + + //Get user info and configs like default board $.get('/user/info', function(userInfo) { if (userInfo) { @@ -38,6 +40,42 @@ } }); +self.addWidgetToBoard = function( event, data ){ +var widgetIDToAdd; +console.log('event: ', event); +console.log('data', data.target.id); + +//create an instance of the widget +$.ajax({ +method: 'POST', +url: '/widget-instance', +contentType: 'application/json; charset=UTF-8', +data: JSON.stringify({ +widgetId: event.id, +displayName: 'My ' + event.displayName, +configuration: {}, +isShared: false +}), +success: function( data ) { +widgetIDToAdd = data.id; +self.displayedBoard().widgets.push(data.id); + +$.ajax({ +method: 'PUT', +url: '/board/' + self.userdata().defaultBoard, +contentType: 'application/json; charset=UTF-8', +data: JSON.stringify(self.displayedBoard()), +success: function(stuff) { +//change the look of the add widget button +$('#add-widget-'+event.id).hide(); +$('#saved-widget-'+event.id).removeClass('hide'); +} +}); +} +}); + +}; + self.setDisplayPage = function(e, data){ var pages = ['Library', 'Profile', 'Home'], view = data.target.id; if( pages.indexOf(data.target.id) > -1 ){ diff --git a/src/components/widgets/fraud-gauge/fraud-gauge.js b/src/components/widgets/fraud-gauge/fraud-gauge.js index 8fca0bd..3baecae 100644 --- a/src/components/widgets/fraud-gauge/fraud-gauge.js +++ b/src/components/widgets/fraud-gauge/fraud-gauge.js @@ -33,7 +33,7 @@ var self = this; self.filters = ko.observableArray(); self.title = ko.observable(params.title); -console.log('fraud widget params: ', params); + self.columnSize = 'col-md-' + params.configuration.width + ' fraudGauge'; $.get( 'metadata/fraud-gauge', function(reqData){ diff --git a/src/css/style.css b/src/css/style.css index f0a0982..9561bb0 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -378,6 +378,14 @@ width: 100%; } +.addToBoardBtn { +bottom: 0; +} + +.widgetDesc { +height: 70px; +} + /* BOOTSTRAP OVERRIDES */ .btn { @@ -598,12 +606,16 @@ background-color: rgba(49,176,213,0.6); color: #f5f5f5; width: 250px; -height: 300px; +height: 320px; overflow: hidden; border-bottom: 7px solid rgb(49,176,213); border-radius: 4px 4px 0 0; } +.widgetLibrary li:hover { +background-color: rgb(49,176,213); +} + .widgetLibrary img { width: 210px; height: 100px; -- To view, visit https://gerrit.wikimedia.org/r/196403 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6739adc15eefe41b6c51c0ce367da3f4b1df4101 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/dash Gerrit-Branch: m
[MediaWiki-commits] [Gerrit] Add widget instances to user default board - change (wikimedia...dash)
Ssmith has uploaded a new change for review. https://gerrit.wikimedia.org/r/196403 Change subject: Add widget instances to user default board .. Add widget instances to user default board This could be better.. there should be a better flow for adding multiple instances, for example. Change-Id: I6739adc15eefe41b6c51c0ce367da3f4b1df4101 --- M src/components/app-content/app-content.html M src/components/app-content/app-content.js M src/components/widgets/fraud-gauge/fraud-gauge.js M src/css/style.css 4 files changed, 55 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/dash refs/changes/03/196403/1 diff --git a/src/components/app-content/app-content.html b/src/components/app-content/app-content.html index fd086ea..c3ac744 100644 --- a/src/components/app-content/app-content.html +++ b/src/components/app-content/app-content.html @@ -29,7 +29,9 @@ - + + Add to my default board + Added. diff --git a/src/components/app-content/app-content.js b/src/components/app-content/app-content.js index 49b3c65..a6e51c1 100644 --- a/src/components/app-content/app-content.js +++ b/src/components/app-content/app-content.js @@ -17,6 +17,8 @@ self.widgetTemplates = ko.observableArray(); self.widgetInstances = ko.observableArray(); + + //Get user info and configs like default board $.get('/user/info', function(userInfo) { if (userInfo) { @@ -38,6 +40,42 @@ } }); +self.addWidgetToBoard = function( event, data ){ +var widgetIDToAdd; +console.log('event: ', event); +console.log('data', data.target.id); + +//create an instance of the widget +$.ajax({ +method: 'POST', +url: '/widget-instance', +contentType: 'application/json; charset=UTF-8', +data: JSON.stringify({ +widgetId: event.id, +displayName: 'My ' + event.displayName, +configuration: {}, +isShared: false +}), +success: function( data ) { +widgetIDToAdd = data.id; +self.displayedBoard().widgets.push(data.id); + +$.ajax({ +method: 'PUT', +url: '/board/' + self.userdata().defaultBoard, +contentType: 'application/json; charset=UTF-8', +data: JSON.stringify(self.displayedBoard()), +success: function(stuff) { +//change the look of the add widget button +$('#add-widget-'+event.id).hide(); +$('#saved-widget-'+event.id).removeClass('hide'); +} +}); +} +}); + +}; + self.setDisplayPage = function(e, data){ var pages = ['Library', 'Profile', 'Home'], view = data.target.id; if( pages.indexOf(data.target.id) > -1 ){ diff --git a/src/components/widgets/fraud-gauge/fraud-gauge.js b/src/components/widgets/fraud-gauge/fraud-gauge.js index 8fca0bd..3baecae 100644 --- a/src/components/widgets/fraud-gauge/fraud-gauge.js +++ b/src/components/widgets/fraud-gauge/fraud-gauge.js @@ -33,7 +33,7 @@ var self = this; self.filters = ko.observableArray(); self.title = ko.observable(params.title); -console.log('fraud widget params: ', params); + self.columnSize = 'col-md-' + params.configuration.width + ' fraudGauge'; $.get( 'metadata/fraud-gauge', function(reqData){ diff --git a/src/css/style.css b/src/css/style.css index f0a0982..9561bb0 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -378,6 +378,14 @@ width: 100%; } +.addToBoardBtn { +bottom: 0; +} + +.widgetDesc { +height: 70px; +} + /* BOOTSTRAP OVERRIDES */ .btn { @@ -598,12 +606,16 @@ background-color: rgba(49,176,213,0.6); color: #f5f5f5; width: 250px; -height: 300px; +height: 320px; overflow: hidden; border-bottom: 7px solid rgb(49,176,213); border-radius: 4px 4px 0 0; } +.widgetLibrary li:hover { +background-color: rgb(49,176,213); +} + .widgetLibrary img { width: 210px; height: 100px; -- To view, visit https://gerrit.wikimedia.org/r/196403 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6739adc15eefe41b6c51c0ce367da3f4b