-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sgotre
committed
Nov 17, 2017
1 parent
0f271f4
commit beb9bcb
Showing
22 changed files
with
1,077 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|
||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.