Skip to content

Commit

Permalink
Product Widget Webservice
Browse files Browse the repository at this point in the history
  • Loading branch information
sgotre committed Nov 17, 2017
1 parent 0f271f4 commit beb9bcb
Show file tree
Hide file tree
Showing 22 changed files with 1,077 additions and 258 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
Alternately, if you want to try out the extension, here are the download links. After you download it, unzip the file and load it in your browser using the steps mentioned below.
- [**Download Chrome Extension**](https://github.com/affilinet/browser-webextension-publisher/raw/master/dist/chrome.zip)
- [**Download Firefox Extension**](https://github.com/affilinet/browser-webextension-publisher/raw/master/dist/firefox.zip)
- [**Download Opera Extension**](https://github.com/affilinet/browser-webextension-publisher/raw/master/dist/opera.zip)


##### Load the extension in Chrome
##### Load the extension in Chrome & Opera
1. Open Chrome/Opera browser and navigate to chrome://extensions
2. Select "Developer Mode" and then click "Load unpacked extension..."
3. From the file browser, choose to `browser-webextension-publisher/build/chrome` or (`browser-webextension-publisher/build/opera`)
Expand All @@ -25,6 +26,7 @@ The following tasks can be used when you want to start developing the extension

- `npm run chrome-watch`
- `npm run firefox-watch`
- `npm run opera-watch`


## Packaging
Expand Down
Binary file modified dist/chrome.zip
Binary file not shown.
Binary file modified dist/firefox.zip
Binary file not shown.
Binary file modified dist/opera.zip
Binary file not shown.
20 changes: 18 additions & 2 deletions src/_locales/de/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,23 @@ app.config(function ($translateProvider) {
"WIDGET_BtnDeleteWidget": "Widget löschen",
"WIDGET_WarningChangesNotSaved": "Sie haben ungesicherte Änderungen. Wollen Sie wirklich ein neues Widget anlegen",
"SEARCHDISCOVER_FindProducts": "Produkte finden",
"SEARCHDISCOVER_SelectAllProducts": "All selektieren",
"SETTINGS_updateProgramDataBtn": "Programmliste aktualisieren"
"SEARCHDISCOVER_Filter": "Filter",
"SEARCHDISCOVER_SelectAllProducts": "Alle selektieren",
"SEARCHDISCOVER_LabelBrand" : "Marke",
"SEARCHDISCOVER_LabelManufacturer" : "Hersteller",
"SEARCHDISCOVER_LabelAffilinetCategoryPath" : "Kategorie",
"SEARCHDISCOVER_LabelDistributor" : "Distributor",
"SETTINGS_updateProgramDataBtn": "Programmliste aktualisieren",
"WIDGET_CouldNotSave": "Konnte das Widget nicht speichern. Internet Verbindung prüfen",


"ALLWIDGETS_PageName": "Alle Widgets",
"ALLWIDGETS_WidgetName": "Name",
"ALLWIDGETS_ProductCount": "Produkte",
"ALLWIDGETS_Edit": "Bearbeiten",
"ALLWIDGETS_OldProducts": "Aktualisieren",
"ALLWIDGETS_ButtonEdit": "Bearbeiten",
"ALLWIDGETS_ClearOldProducts": "Entferne {{number}} veraltete Produkte",
"ALLWIDGETS_OldProductsRemoved": "Veraltete Produkte entfernt",
});
});
13 changes: 12 additions & 1 deletion src/_locales/en/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ app.config(function ($translateProvider) {
"WIDGET_WidgetSaved": "Widget saved",
"SEARCHDISCOVER_FindProducts": "Find Products",
"SEARCHDISCOVER_SelectAllProducts": "Select all",
"SETTINGS_updateProgramDataBtn": "Update program list data"
"SETTINGS_updateProgramDataBtn": "Update program list data",
"WIDGET_CouldNotSave": "Could not save Widget. Check Internet Connection",


"ALLWIDGETS_PageName": "All Widgets",
"ALLWIDGETS_WidgetName": "Name",
"ALLWIDGETS_ProductCount": "Number of products",
"ALLWIDGETS_Edit": "Edit",
"ALLWIDGETS_OldProducts": "Update Products",
"ALLWIDGETS_ButtonEdit": "Edit",
"ALLWIDGETS_ClearOldProducts": "Clear unavailable products",
"ALLWIDGETS_OldProductsRemoved": "Widget updated",
});
});
10 changes: 10 additions & 0 deletions src/_locales/es/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,15 @@ app.config(function ($translateProvider) {
"SEARCHDISCOVER_FindProducts": "Encontrar productos",
"SEARCHDISCOVER_SelectAllProducts": "Seleccionar todo",
"SETTINGS_updateProgramDataBtn": "Actualizar los datos de la lista de programas"


"ALLWIDGETS_PageName": "All Widgets",
"ALLWIDGETS_WidgetName": "Name",
"ALLWIDGETS_ProductCount": "Number of products",
"ALLWIDGETS_Edit": "Edit",
"ALLWIDGETS_OldProducts": "Update Products",
"ALLWIDGETS_ButtonEdit": "Edit",
"ALLWIDGETS_ClearOldProducts": "Clear unavailable products",
"ALLWIDGETS_OldProductsRemoved": "Widget updated",
});
});
12 changes: 11 additions & 1 deletion src/_locales/fr/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ app.config(function ($translateProvider) {
"WIDGET_WarningChangesNotSaved": "Vous avez effectué des modifications sans les enregistrer, voulez-vous vraiment créer un nouveau widget ?",
"SEARCHDISCOVER_FindProducts": "Trouvez des produits",
"SEARCHDISCOVER_SelectAllProducts": "Tout sélectionner",
"SETTINGS_updateProgramDataBtn": "Update program list data"
"SETTINGS_updateProgramDataBtn": "Update program list data",
"WIDGET_CouldNotSave": "Could not save Widget. Check Internet Connection",

"ALLWIDGETS_PageName": "All Widgets",
"ALLWIDGETS_WidgetName": "Name",
"ALLWIDGETS_ProductCount": "Number of products",
"ALLWIDGETS_Edit": "Edit",
"ALLWIDGETS_OldProducts": "Update Products",
"ALLWIDGETS_ButtonEdit": "Edit",
"ALLWIDGETS_ClearOldProducts": "Clear unavailable products",
"ALLWIDGETS_OldProductsRemoved": "Widget updated",
});
});
12 changes: 11 additions & 1 deletion src/_locales/nl/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@
"WIDGET_WarningChangesNotSaved": "Er zijn niet-opgeslagen wijzigingen. Weet je zeker dat je een nieuwe widget aan wilt maken?",
"SEARCHDISCOVER_FindProducts": "Find Products",
"SEARCHDISCOVER_SelectAllProducts": "Select all",
"SETTINGS_updateProgramDataBtn": "Update program list data"
"SETTINGS_updateProgramDataBtn": "Update program list data",
"WIDGET_CouldNotSave": "Could not save Widget. Check Internet Connection",

"ALLWIDGETS_PageName": "All Widgets",
"ALLWIDGETS_WidgetName": "Name",
"ALLWIDGETS_ProductCount": "Number of products",
"ALLWIDGETS_Edit": "Edit",
"ALLWIDGETS_OldProducts": "Update Products",
"ALLWIDGETS_ButtonEdit": "Edit",
"ALLWIDGETS_ClearOldProducts": "Clear unavailable products",
"ALLWIDGETS_OldProductsRemoved": "Widget updated",
});
});
2 changes: 1 addition & 1 deletion src/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let globalHasPartnership = false;
let globalHasProgram = false;
let globalHasProgramPartnerShipAndDeeplink = false;

const linkShortener = 'https://widget-server.dev/api/v1.0/shortlink';
const linkShortener = 'https://productwidget.com/api/v1.0/shortlink';


ext.runtime.onMessage.addListener(
Expand Down
16 changes: 16 additions & 0 deletions src/settings-page/css/searchdiscover.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
.searchDiscover {
/**
facets
*/
/**
products
*/
}
.searchDiscover #filters-widget-body {
padding: 20px 0;
}
.searchDiscover .facet .facet-item {
display: block;
width: 100%;
font-size: 12px;
}
.searchDiscover .line {
border-bottom: 1px solid #7f7f7f;
}
Expand Down
6 changes: 6 additions & 0 deletions src/settings-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,16 @@
<a ui-sref="likeList"><span translate="LIKELIST_PageName"></span><span class="menu-icon fa fa-thumbs-up"></span></a>
</li>



<li class="sidebar-list" ng-if="validCredentials">
<a ui-sref="widget"><span translate="WIDGET_PageName"></span><span class="menu-icon fa fa-file-code-o"></span></a>
</li>

<li class="sidebar-list" ng-if="validCredentials">
<a ui-sref="allwidgets"><span translate="ALLWIDGETS_PageName"></span><span class="menu-icon fa fa-list"></span></a>
</li>



</ul>
Expand Down
129 changes: 129 additions & 0 deletions src/settings-page/js/controllers/allWidgets-ctrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
angular.module('AffilinetToolbar')
.controller('AllWidgetsController', ['$scope', '$sce', '$translate', 'LogonService', AllWidgetsController]);

function AllWidgetsController($scope, $sce, $translate, LogonService) {



$scope.loadingFinished = false;

$translate('ALLWIDGETS_PageName').then(function (text) {
$scope.$parent.pageName = text;
});

$scope.messages = [];

$translate('ALLWIDGETS_OldProducts').then(function (text) {
$scope.messages.ALL_WIDGETS_CLEAR_OLD_PRODUCS = text;
});

$scope.allWidgets = [];


$scope.copySuccess = false;


$scope.trustAsUrl = function(url) {
"use strict";
return $sce.trustAsUrl(url);
}


$scope.deletedProductCount = function(widget) {
"use strict";
let count = 0;
widget.products.forEach(
function(prod) {
if (prod.deleted === true) {
count++;
}
}
);
return count;
}

$scope.clearOldProduct = function(widget) {
"use strict";
let newProds = [];
widget.products.forEach(
function(prod) {
if (prod.deleted === false) {
newProds.push(prod);
}
}
);
widget.products = newProds;
updateWidget(widget)

return count;
}


let updateWidget = function(widget) {
LogonService.WidgetUpdate(widget.id, widget).then(function (result) {
"use strict";
let changedWidget = result.data;
let index = $scioe.allWidgets.findIndex(function(widg) { return widg.id === changedWidget.id});
$scope.allWidgets[index] = changedWidget;
$scope.$parent.sendAlert($scope.messages.ALLWIDGETS_OldProductsRemoved, 'success')


}, function (error) {
"use strict";
console.error(error);
$scope.$parent.sendAlert( 'Could not update widget', 'danger')
});


};



$scope.deleteWidget = function() {

/**
* delete it serverside, then remove from allWidgets
*/

if (!confirm($scope.messages.ALL_WIDGETS_SureYouWantToDeleteWidget)) {
return;
}

LogonService.WidgetDelete($scope.widget.id).then(
function(result) {
const index = $scope.allWidgets.findIndex((widget) => {return widget.id === $scope.widget.id});
$scope.selectedWidget = null;
$scope.widget = angular.copy($scope.defaultWidget);
$scope.addWatchToWidget();
$scope.allWidgets.splice(index, 1);
},
function(error) {
$scope.$parent.sendAlert('Could not delete widget. Please check internet connection', 'danger')
}
)
};




/**
* Load the widgets
*/

let init = () => {
LogonService.WidgetIndex().then(function(response){
$scope.allWidgets = response.data;
$scope.loadingFinished = true;

}, function (error) {
$scope.$parent.sendAlert('Could not load widgets, please check internet connection', 'danger')
$scope.loadingFinished = true;
})
};

init()




};
2 changes: 1 addition & 1 deletion src/settings-page/js/controllers/master-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function MasterCtrl($scope, $rootScope, BrowserExtensionService) {
var checkIfCredentialObjectIsSet = function () {
BrowserExtensionService.storage.local.get(['publisherId', 'webservicePassword', 'countryPlatform', 'disableImageContextMenu', 'productWebservicePassword'], function(result) {
"use strict";
if (result.webservicePassword && result.publisherId && result.countryPlatform) {
if (result.webservicePassword && result.publisherId && result.countryPlatform && result.productWebservicePassword) {
$rootScope.credentials = result;
clearInterval(refreshIntervalId);
$rootScope.$broadcast('updateCredentials');
Expand Down
Loading

0 comments on commit beb9bcb

Please sign in to comment.