Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- appModule.service("jsonData", ["$http", function(a) {
- return {
- getApiRoot: function() {
- return "/api/rest/"
- },
- getData: function(b, d) {
- void 0 === b && (b = "/api/rest/");
- return a({
- method: "GET",
- url: b,
- headers: d,
- timeout: 3E4
- })
- },
- doPost: function(b, d, e) {
- return a({
- method: "POST",
- url: d,
- headers: e,
- data: angular.toJson(b),
- timeout: 3E4
- })
- },
- doPut: function(b, d, e) {
- return a({
- method: "PUT",
- url: d,
- headers: e,
- data: angular.toJson(b),
- timeout: 3E4
- })
- },
- doDelete: function(b, d) {
- return a({
- method: "DELETE",
- url: b,
- headers: d,
- timeout: 3E4
- })
- }
- }
- }]);
- damModule.service("messages", function() {
- var a = "";
- return {
- setMessage: function(b) {
- a = b
- },
- getMessage: function() {
- return a
- },
- clear: function() {
- a = ""
- }
- }
- });
- appModule.service("login", ["jsonData", "clientHeader", "appState", "chunkLoader", "$location", "$window", "configuration", function(a, b, d, e, c, h, f) {
- this.performAuth = function(c) {
- c.grant_type = "password";
- d.store.username = c.username;
- return a.doPost(c, a.getApiRoot() + "oauth/token", b)
- };
- this.performClientAuth = function(c) {
- c = c || {};
- c.grant_type = "client_credentials";
- return a.doPost(c, a.getApiRoot() + "oauth/token", b)
- };
- this.performAuthWithCode = function(c) {
- c.grant_type = "authorization_code";
- return a.doPost(c, a.getApiRoot() +
- "oauth/token", b)
- };
- this.performForgotPassword = function(c) {
- return a.doPost(c, a.getApiRoot() + "user/password/forgot")
- };
- this.verifyPasswordChange = function(c) {
- return a.doPost(c, a.getApiRoot() + "user/password/change/verify")
- };
- this.passwordChange = function(c) {
- return a.doPost(c, a.getApiRoot() + "user/password/change")
- };
- this.getAddress = function() {
- return a.getData(a.getApiRoot() + "user/address")
- };
- this.logout = function() {
- e.resetAllChunkers();
- a.doPost({}, a.getApiRoot() + "oauth/logout").success(function() {
- d.clearSessionStorage();
- d.resetUploader()
- }).error(function() {
- d.clearSessionStorage();
- d.resetUploader()
- });
- f.isApp() ? (delete d.store.token, c.path(f.frontPage)) : (delete d.store.token, h.location.href = "/logout")
- };
- this.prelogin = function() {
- return a.doPost({}, a.getApiRoot() + "oauth/prelogin", b)
- }
- }]);
- damModule.service("collectionData", ["jsonData", function(a) {
- var b = function(a) {
- this.type = a;
- this.collections = [];
- this.count = 0
- },
- d = function(c, d, f, e) {
- c = c || 0;
- d = d || 0;
- c = a.getApiRoot() + "collection/" + f + "?start\x3d" + c + "\x26max\x3d" + d;
- a.getData(c).success(function(a) {
- var c = new b(f);
- c.collections = a.collections;
- c.count = a.count;
- e(c)
- })
- },
- e = function(c, d, f, e, k) {
- c = c || 0;
- d = d || 0;
- var n = a.getApiRoot() + "collection/";
- e = isBlank(e) ? "" : "search/" + e;
- var m = isBlank(f) ? "" : "\x26type\x3d" + f;
- a.getData(n + e + ("?start\x3d" + c + "\x26max\x3d" +
- d) + m).success(function(a) {
- var c = new b(f);
- c.collections = a.collections;
- c.count = a.count;
- k(c)
- })
- };
- this.getGlobalCollections = function(a, b, f) {
- d(a, b, "global", f)
- };
- this.getLocalCollections = function(a, b, f) {
- d(a, b, "local", f)
- };
- this.getSharedCollections = function(a, b, f) {
- d(a, b, "shared", f)
- };
- this.getCollections = function(a, b, f, e) {
- d(b, f, a, e)
- };
- this.searchCollections = function(a, b, d, g, k) {
- e(b, d, a, g, k)
- };
- this.getBaseCollectionAssetsUri = function(c) {
- return a.getApiRoot() + "collection/uuid/" + c + "/assets"
- };
- this.createCollection =
- function(c, b, d) {
- c = {
- title: c,
- description: b,
- assets: {
- uuids: d
- }
- };
- b = a.getApiRoot() + "collection";
- return a.doPost(c, b)
- };
- this.shareCollection = function(c, b, d, e) {
- c = {
- uuid: c,
- recipients: {
- uuids: b
- },
- subject: d,
- notes: e
- };
- b = a.getApiRoot() + "collection/share";
- return a.doPost(c, b)
- };
- this.addOrRemoveAssets = function(c, b, d) {
- c = {
- collections: {
- uuids: c
- },
- add: {
- uuids: b
- },
- remove: {
- uuids: d
- }
- };
- b = a.getApiRoot() + "collection/assets";
- return a.doPost(c, b)
- }
- }]);
- damModule.service("assetData", ["jsonData", "appState", "$rootScope", function(a, b, d) {
- var e;
- this.setAssetDetailUrl = function(a) {
- e = a
- };
- this.getAssetDetail = function(b) {
- b = void 0 === e ? a.getApiRoot() + "asset/uuid/" + b : "/" + e;
- return a.getData(b)
- };
- this.getZoomData = function(b) {
- b = a.getApiRoot() + "asset/uuid/" + b + "/zoomdata?panzoom\x3dtrue";
- return a.getData(b)
- };
- this.getDocumentPreview = function(b) {
- b = a.getApiRoot() + "asset/uuid/" + b + "/documentpreview";
- return a.getData(b)
- };
- this.getUploadProfiles = function(c) {
- var e = a.getApiRoot() +
- "uploadprofile/mobile";
- a.getData(e).success(function(a) {
- b.sessionStore.uploadProfiles = a.uploadProfiles || [];
- d.$broadcast("uploadProfilesUpdated");
- c && c(a)
- })
- }
- }]);
- damModule.service("searchData", ["jsonData", "searchState", "damConstants", "cookie", "assetSelection", "configuration", function(a, b, d, e, c, h) {
- this.getBaseSearchURI = function() {
- return a.getApiRoot() + "asset/search"
- };
- this.performSearchPost = function(c, g, k, h, m) {
- var l = e.readCookie(d.sortCookieName),
- l = isBlank(l) ? "" : "\x26sort\x3d" + l;
- c = c + "?start\x3d" + g + "\x26max\x3d" + k + l + "\x26options\x3dpermissions";
- g = {};
- g.query = h;
- g.resultsOnly = m;
- g.fileTypeFilters = b.getSelectedFilterKeys();
- return a.doPost(g, c)
- };
- this.selectedAssetSearch =
- function() {
- if (0 === c.getSelection().length) return {
- success: function(a) {
- a && a({
- assets: [],
- numResults: 0
- })
- }
- };
- var f = e.readCookie(d.sortCookieName),
- f = isBlank(f) ? "" : "\x26sort\x3d" + f,
- g = isBlank(b.getSelectedFilterKeys()) ? "" : "\x26filters\x3d" + encodeURIComponent(b.getSelectedFilterKeys()),
- f = a.getApiRoot() + "asset/search?start\x3d0\x26max\x3d" + h.maxSelectedAssets + g + f + "\x26options\x3dpermissions",
- g = {
- query: "uuid:(" + c.getSelection().join(" or ") + ")"
- };
- return a.doPost(g, f)
- }
- }]);
- damModule.service("siteData", ["jsonData", "appState", "$window", "configuration", function(a, b, d, e) {
- this.getSiteData = function(c, d) {
- b.sessionStore.siteData && !d ? c && c(b.sessionStore.siteData) : !e.isApp() || b.store.server ? a.getData(a.getApiRoot() + "site/").success(function(a) {
- b.sessionStore.siteData = angular.fromJson(a);
- c && c(b.sessionStore.siteData)
- }) : c && c(e.defaultSiteData)
- };
- this.ping = function() {
- a.getData(a.getApiRoot() + "site/ping")
- };
- this.useFullSite = function() {
- b.useFullSite();
- a.getData(a.getApiRoot() + "site/fullsite", {
- AppType: "fullsite"
- }).success(function() {
- d.location.href = "/"
- }).error(function() {
- d.location.href = "/"
- })
- }
- }]);
- damModule.service("filteringData", ["jsonData", function(a) {
- this.getAvailableFilters = function() {
- var b = a.getApiRoot() + "filter/available";
- return a.getData(b)
- };
- this.toggleFilter = function(b) {
- return a.doPost({
- toggleKey: b
- }, a.getApiRoot() + "filter/")
- };
- this.resetFilters = function() {
- return a.doPost({}, a.getApiRoot() + "filter/")
- }
- }]);
- damModule.service("categoryData", ["jsonData", function(a) {
- this.getCategories = function(b) {
- b = a.getApiRoot() + "category/uuid/" + b + "/subcategories?includeEmpty\x3dfalse";
- return a.getData(b)
- };
- this.getBaseCategoryAssetsUri = function(b) {
- return a.getApiRoot() + "category/uuid/" + b + "/assets"
- }
- }]);
- damModule.service("help", ["damConstants", function(a) {
- var b = this;
- this.target = "_blank";
- this.launchHelp = function() {
- window.open(a.helpUrl, b.target)
- }
- }]);
- damModule.service("orderData", ["jsonData", function(a) {
- this.getConversionsForOrder = function(b, d) {
- var e = {};
- e.uuids = d;
- var c = a.getApiRoot() + "conversion/order/profile/uuid/" + b;
- return a.doPost(e, c)
- };
- this.getOrderItemRemovals = function(b) {
- var d = {};
- d.uuids = b;
- b = a.getApiRoot() + "order/items/removals";
- return a.doPost(d, b)
- };
- this.getOrderProfiles = function() {
- var b = a.getApiRoot() + "order/profile/internet";
- return a.getData(b)
- };
- this.getOrderEula = function() {
- var b = a.getApiRoot() + "eula/order";
- return a.getData(b)
- };
- this.createOrder =
- function(b) {
- var d = a.getApiRoot() + "order";
- return a.doPost(b, d)
- }
- }]);
- damModule.service("metadataData", ["jsonData", function(a) {
- var b = a.getApiRoot() + "metadata/type/uuid/";
- this.getMetadataType = function(d) {
- return a.getData(b + d)
- }
- }]);
- damModule.service("contactData", ["jsonData", function(a) {
- var b = a.getApiRoot() + "address/saved",
- d = a.getApiRoot() + "address/saved/uuid/",
- e = a.getApiRoot() + "address/countries";
- this.getSavedContacts = function() {
- return a.getData(b)
- };
- this.createContact = function(c) {
- return a.doPost(c, b)
- };
- this.updateContact = function(b) {
- return a.doPut(b, d + b.uuid)
- };
- this.deleteContact = function(b) {
- return a.doDelete(d + b.uuid)
- };
- this.getCountries = function() {
- return a.getData(e)
- }
- }]);
- damModule.service("userData", ["jsonData", function(a) {
- this.checkPermissions = function(b) {
- b = a.getApiRoot() + "user/permission/" + b;
- return a.getData(b)
- }
- }]);
- damModule.service("scopeData", ["jsonData", "appState", "$rootScope", function(a, b, d) {
- this.createOrder = "order_creation";
- this.checkScope = function(b) {
- return a.getData(a.getApiRoot() + "scopes/allowed/" + b)
- };
- this.getScopeData = function(e) {
- a.getData(a.getApiRoot() + "scopes").success(function(a) {
- b.sessionStore.scopes = a.scopes || [];
- d.$broadcast("securityScopesUpdated");
- e && e(b.sessionStore.scopes)
- })
- }
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement