-
-
Save balbany/a2ebee6195bd20b9a0636015eb3c1098 to your computer and use it in GitHub Desktop.
Angular Warmup Snippet
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
// In our Angular Service module | |
this.setItemPermissions = function(request, listName, id, warmup) { | |
if(warmup){ | |
var payload = 'WARMUP'; | |
} else { | |
var payload = { | |
"list": listName, | |
"itemId": id, | |
"readAccess": request.ReadAccess, | |
"writeAccess": request.WriteAccess | |
} | |
} | |
var url = 'https://adshel-spo-auto.azurewebsites.net/api/SecureItem?code=SASCodeForFunctionGoesHere' | |
return $http({ | |
method: 'POST', | |
url: url, | |
headers: { "Content-Type": "application/json" }, | |
data: JSON.stringify(payload), | |
transformResponse: function(data, headersGetter) { | |
data = angular.fromJson(data); | |
if (angular.isUndefined(data["odata.error"])) { | |
return data.data; | |
} else { | |
throw "Error setting permissions: " + data["odata.error"].message.value; | |
} | |
} | |
}); | |
} | |
// At the top of our form Controller | |
// To warm things up... | |
FormsData.setItemPermissions('', '', '', true).then(function(result){ | |
// Do nothing | |
}); | |
// Later on... | |
//Immediately after save... for realsies. | |
FormsData.setItemPermissions(vm.request, vm.formType, itemId, false).then(function(result){ | |
// Do stuff | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment