From d1e9738a1ec1bc937799f8365346f8597c96f9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedeljko=20Ru=C5=BEi=C4=87?= <33520721+NenoR96@users.noreply.github.com> Date: Mon, 17 Jul 2023 21:57:04 +0200 Subject: [PATCH 1/3] add ai seeder --- src/control/content/index.html | 93 +++++++++++++++++++++------------- src/widget/widget.js | 19 +------ 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/src/control/content/index.html b/src/control/content/index.html index 37cd540..e1c35ea 100644 --- a/src/control/content/index.html +++ b/src/control/content/index.html @@ -1,5 +1,6 @@ +
@@ -16,13 +17,14 @@ - + + -Some Text
`, + systemMessage: `For blog post images use dummyimages.com. For carousel images, generate small array of image urls based on topic, use source.unsplash.com for image URLs.`, + } + }).smartShowEmptyState({ selector: this.selector, }, (err, result) => { + if (!result) + buildfire.dialog.toast({ message: "Something went wrong" }); + $scope.$apply(function () { + $scope.showContent = true; + $scope.data.content = { + carouselImages: result.data.content.carouselImages.map(el => { return { iconUrl: el, action: "noAction", title: "image" } }), + text: result.data.content.text + } + editor.loadItems($scope.data.content.carouselImages); + console.log($scope) + seeder.requestResult.complete(); + }) + }); + $scope.showContent = true; + } + // create a new instance of the buildfire carousel editor var editor = new buildfire.components.carousel.editor("#carousel"); @@ -79,40 +122,16 @@ console.error("Error: ", err); return; } - - if (result && result.data && !angular.equals({}, result.data) && result.id) { - if(!result.data.design) result.data.design = $scope.data.design; + if (Object.keys(result.data).length && result.data.content.carouselImages.length > 0 && result.data.content.text && result.data.design) { + if (!result.data.design) result.data.design = $scope.data.design; $scope.data = result.data; $scope.id = result.id; - if($scope.data.content && $scope.data.content.carouselImages) + if ($scope.data.content && $scope.data.content.carouselImages) editor.loadItems($scope.data.content.carouselImages); if (tmrDelay) clearTimeout(tmrDelay); - } else{ - $scope.data = { content :{ - text : - 'The WYSIWYG (which stands for What You See Is What You Get) allows you to do some really cool stuff. You can add images like this
\ - \ -You can even create links like these:
Link to web content like this
Link to a phone number like this 8005551234
Link to an email like this noreply@google.com
Want to add some super cool videos about this item? You can do that too!
\ - \ -You can create bulleted and numbered lists like this:
\ -Want more info? Check out our tutorial by clicking the help button at the top of this page.
', - - carouselImages : - [{"action":"noAction","iconUrl":"http://imageserver.prod.s3.amazonaws.com/b55ee984-a8e8-11e5-88d3-124798dea82d/5db61d30-0854-11e6-8963-f5d737bc276b.jpg","title":"image 1"},{"action":"noAction","iconUrl":"http://imageserver.prod.s3.amazonaws.com/b55ee984-a8e8-11e5-88d3-124798dea82d/31c88a00-0854-11e6-8963-f5d737bc276b.jpeg","title":"image 2"}] - }, - design: { - backgroundImage: null, - backgroundBlur: 0, - selectedLayout: 1 - } - }; - editor.loadItems($scope.data.content.carouselImages); + $scope.showContent = true; + } else { + showAISeeder(); } /* @@ -143,9 +162,13 @@ return; } - if(!newObj.content || !newObj.design) + if (!newObj.content || !newObj.design) return; + if(!newObj.content.carouselImages.length && !newObj.content.text) { + showAISeeder(); + } + buildfire.datastore.save(newObj, function (err, result) { if (err || !result) { console.error('Error saving the widget details: ', err); @@ -177,4 +200,4 @@ }]); - +