(function () {
var publicEventParticipantsController = function ($scope, $http, $window, ServerValues, ModalConfirmService, CallRestApiService, uiGridConstants) {
$scope.participantsListIsPublic = false;
$scope.personHasEventAccess = false;
$scope.loadingData = false;
$scope.dataGridOptions = {
enableFiltering: true,
enableColumnMenus: false,
showGridFooter: true,
data: [],
columnDefs: [
{
name: "Etternavn",
field: "personLastName",
visible: true,
enableFiltering: true
},
{
name: "Fornavn",
field: "personFirstName",
visible: true,
enableFiltering: true
},
{
name: "Fødselsår",
field: "personBirthYear",
visible: true,
cellClass: 'memberGrid-rightalign',
enableFiltering: true,
cellTemplate: '
{{row.entity.personBirthYear}}
'
},
{
name: "Produkt",
field: "trackName",
visible: true,
enableFiltering: true
},
],
};
$scope.dataGridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
};
$scope.getEventParticipantsPublic = function () {
$scope.loadingData = true;
$http.get("/rest/organizations/" + ServerValues.organizationID + "/eventRegistrations/" + ServerValues.eventID)
.success(function (response) {
$scope.dataGridOptions.data = response.result;
$scope.loadingData = false;
$scope.noData = $scope.dataGridOptions.data.length == 0;
})
.error(function (response) {
var errorMsg = response.error != "" ? response.error : "En feil har oppstått.";
ModalConfirmService.confirm("Feil", errorMsg, "OK");
$scope.loadingData = false;
});
}
$scope.getEventParticipantsPublic();
};
// Set up dependecy injections for dependencies used by controller function
publicEventParticipantsController.$inject = ['$scope', '$http', '$window', 'ServerValues', 'ModalConfirmService', 'CallRestApiService', 'uiGridConstants'];
// Register the controller
angular.module('rubicApp').controller('publicEventParticipantsController', publicEventParticipantsController);
}());;
(function () {
angular.module('rubicApp').factory('ModalAwaiterService', ['$modal', function ($modal) {
return {
awaitApiCall: function (title, body, type, apiFunc, calcElements, PredictedCalcTimeInSecPrElement, PredictedTotalTimeInSec) {
var modalInst = $modal.open({
templateUrl: '/app/templates/ModalAwaiter.html',
controller: 'modalAwaiterController',
backdrop: 'static',
keyboard: false,
resolve: {
title: function () {
return title;
},
body: function () {
return body;
},
apiFunc: function () {
return apiFunc;
},
type: function () {
return type;
},
calcElements: function () {
return calcElements;
},
calcSecElement: function () {
return PredictedCalcTimeInSecPrElement;
},
totalSec: function () {
return PredictedTotalTimeInSec;
}
}
});
return modalInst.result;
},
typeEnum: {
progressBar: 1,
loadingSpinner: 2
}
}
}]);
angular.module('rubicApp').controller('modalAwaiterController',
['$scope', '$http', '$modalInstance', '$q', '$timeout', 'CallApiService', 'title', 'body', 'apiFunc', 'type', 'calcElements', 'calcSecElement', 'totalSec', function ($scope, $http, $modalInstance, $q, $timeout, callApi, title, body, apiFunc, type, calcElements, calcSecElement, totalSec) {
$scope.title = title;
$scope.body = body;
$scope.internalTypes = { progressBarDynamic: 1, progressBarStatic: 2, loadingSpinner: 3 };
callApi(apiFunc)
.then(function (response) {
if (angular.isDefined($scope.timeoutPromise)) {
$timeout.cancel($scope.timeoutPromise);
$scope.elapsedTimeMS = $scope.totalTimeMS;
}
$modalInstance.close(response);
},
function (error) {
if (angular.isDefined($scope.timeoutPromise)) {
$timeout.cancel($scope.timeoutPromise);
}
$modalInstance.dismiss(error);
});
if (type === 2) {
$scope.internalType = $scope.internalTypes.loadingSpinner;
}
else if (type === 1 && ((angular.isDefined(calcElements) && angular.isDefined(calcSecElement)) || angular.isDefined(totalSec))) {
$scope.internalType = $scope.internalTypes.progressBarDynamic;
showProgress();
}
else {
$scope.internalType = $scope.internalTypes.progressBarStatic;
$scope.dynamicProgressBar = false;
}
function showProgress() {
var updateIntervallMS = 100;
if (angular.isDefined(totalSec)) {
$scope.totalTimeMS = totalSec * 1000;
}
else {
var calcTimeElementMS = calcSecElement * 1000;
$scope.totalTimeMS = calcElements * calcTimeElementMS;
}
$scope.elapsedTimeMS = 1;
$scope.timeoutPromise = $timeout(updateProgressBar, updateIntervallMS);
function updateProgressBar() {
$scope.elapsedTimeMS += updateIntervallMS;
$scope.timeoutPromise = $timeout(updateProgressBar, updateIntervallMS);
}
}
}]);
}());;
(function () {
var modalConfirmWithHtmlService = function ($modal) {
this.confirm = function (title, body, confirmLabel, cancelLabel) {
var modalInst = $modal.open({
templateUrl: '/app/templates/ModalConfirmWithHtml.html',
controller: 'modalConfirmController',
resolve: {
title: function () {
return title;
},
body: function () {
return body;
},
confirmLabel: function () {
return confirmLabel;
},
cancelLabel: function () {
return cancelLabel;
}
}
});
if (typeof (confirmLabel) == 'undefined' && typeof (cancelLabel) == 'undefined') {
setTimeout(function () { modalInst.dismiss(); }, 1500);
}
return modalInst.result;
};
};
modalConfirmWithHtmlService.$inject = ['$modal'];
angular.module('rubicApp').service('ModalConfirmWithHtmlService', modalConfirmWithHtmlService);
}());;