Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. appModule.service("jsonData", ["$http", function(a) {
  2.     return {
  3.         getApiRoot: function() {
  4.             return "/api/rest/"
  5.         },
  6.         getData: function(b, d) {
  7.             void 0 === b && (b = "/api/rest/");
  8.             return a({
  9.                 method: "GET",
  10.                 url: b,
  11.                 headers: d,
  12.                 timeout: 3E4
  13.             })
  14.         },
  15.         doPost: function(b, d, e) {
  16.             return a({
  17.                 method: "POST",
  18.                 url: d,
  19.                 headers: e,
  20.                 data: angular.toJson(b),
  21.                 timeout: 3E4
  22.             })
  23.         },
  24.         doPut: function(b, d, e) {
  25.             return a({
  26.                 method: "PUT",
  27.                 url: d,
  28.                 headers: e,
  29.                 data: angular.toJson(b),
  30.                 timeout: 3E4
  31.             })
  32.         },
  33.         doDelete: function(b, d) {
  34.             return a({
  35.                 method: "DELETE",
  36.                 url: b,
  37.                 headers: d,
  38.                 timeout: 3E4
  39.             })
  40.         }
  41.     }
  42. }]);
  43. damModule.service("messages", function() {
  44.     var a = "";
  45.     return {
  46.         setMessage: function(b) {
  47.             a = b
  48.         },
  49.         getMessage: function() {
  50.             return a
  51.         },
  52.         clear: function() {
  53.             a = ""
  54.         }
  55.     }
  56. });
  57. appModule.service("login", ["jsonData", "clientHeader", "appState", "chunkLoader", "$location", "$window", "configuration", function(a, b, d, e, c, h, f) {
  58.     this.performAuth = function(c) {
  59.         c.grant_type = "password";
  60.         d.store.username = c.username;
  61.         return a.doPost(c, a.getApiRoot() + "oauth/token", b)
  62.     };
  63.     this.performClientAuth = function(c) {
  64.         c = c || {};
  65.         c.grant_type = "client_credentials";
  66.         return a.doPost(c, a.getApiRoot() + "oauth/token", b)
  67.     };
  68.     this.performAuthWithCode = function(c) {
  69.         c.grant_type = "authorization_code";
  70.         return a.doPost(c, a.getApiRoot() +
  71.             "oauth/token", b)
  72.     };
  73.     this.performForgotPassword = function(c) {
  74.         return a.doPost(c, a.getApiRoot() + "user/password/forgot")
  75.     };
  76.     this.verifyPasswordChange = function(c) {
  77.         return a.doPost(c, a.getApiRoot() + "user/password/change/verify")
  78.     };
  79.     this.passwordChange = function(c) {
  80.         return a.doPost(c, a.getApiRoot() + "user/password/change")
  81.     };
  82.     this.getAddress = function() {
  83.         return a.getData(a.getApiRoot() + "user/address")
  84.     };
  85.     this.logout = function() {
  86.         e.resetAllChunkers();
  87.         a.doPost({}, a.getApiRoot() + "oauth/logout").success(function() {
  88.             d.clearSessionStorage();
  89.             d.resetUploader()
  90.         }).error(function() {
  91.             d.clearSessionStorage();
  92.             d.resetUploader()
  93.         });
  94.         f.isApp() ? (delete d.store.token, c.path(f.frontPage)) : (delete d.store.token, h.location.href = "/logout")
  95.     };
  96.     this.prelogin = function() {
  97.         return a.doPost({}, a.getApiRoot() + "oauth/prelogin", b)
  98.     }
  99. }]);
  100. damModule.service("collectionData", ["jsonData", function(a) {
  101.     var b = function(a) {
  102.             this.type = a;
  103.             this.collections = [];
  104.             this.count = 0
  105.         },
  106.         d = function(c, d, f, e) {
  107.             c = c || 0;
  108.             d = d || 0;
  109.             c = a.getApiRoot() + "collection/" + f + "?start\x3d" + c + "\x26max\x3d" + d;
  110.             a.getData(c).success(function(a) {
  111.                 var c = new b(f);
  112.                 c.collections = a.collections;
  113.                 c.count = a.count;
  114.                 e(c)
  115.             })
  116.         },
  117.         e = function(c, d, f, e, k) {
  118.             c = c || 0;
  119.             d = d || 0;
  120.             var n = a.getApiRoot() + "collection/";
  121.             e = isBlank(e) ? "" : "search/" + e;
  122.             var m = isBlank(f) ? "" : "\x26type\x3d" + f;
  123.             a.getData(n + e + ("?start\x3d" + c + "\x26max\x3d" +
  124.                 d) + m).success(function(a) {
  125.                 var c = new b(f);
  126.                 c.collections = a.collections;
  127.                 c.count = a.count;
  128.                 k(c)
  129.             })
  130.         };
  131.     this.getGlobalCollections = function(a, b, f) {
  132.         d(a, b, "global", f)
  133.     };
  134.     this.getLocalCollections = function(a, b, f) {
  135.         d(a, b, "local", f)
  136.     };
  137.     this.getSharedCollections = function(a, b, f) {
  138.         d(a, b, "shared", f)
  139.     };
  140.     this.getCollections = function(a, b, f, e) {
  141.         d(b, f, a, e)
  142.     };
  143.     this.searchCollections = function(a, b, d, g, k) {
  144.         e(b, d, a, g, k)
  145.     };
  146.     this.getBaseCollectionAssetsUri = function(c) {
  147.         return a.getApiRoot() + "collection/uuid/" + c + "/assets"
  148.     };
  149.     this.createCollection =
  150.         function(c, b, d) {
  151.             c = {
  152.                 title: c,
  153.                 description: b,
  154.                 assets: {
  155.                     uuids: d
  156.                 }
  157.             };
  158.             b = a.getApiRoot() + "collection";
  159.             return a.doPost(c, b)
  160.         };
  161.     this.shareCollection = function(c, b, d, e) {
  162.         c = {
  163.             uuid: c,
  164.             recipients: {
  165.                 uuids: b
  166.             },
  167.             subject: d,
  168.             notes: e
  169.         };
  170.         b = a.getApiRoot() + "collection/share";
  171.         return a.doPost(c, b)
  172.     };
  173.     this.addOrRemoveAssets = function(c, b, d) {
  174.         c = {
  175.             collections: {
  176.                 uuids: c
  177.             },
  178.             add: {
  179.                 uuids: b
  180.             },
  181.             remove: {
  182.                 uuids: d
  183.             }
  184.         };
  185.         b = a.getApiRoot() + "collection/assets";
  186.         return a.doPost(c, b)
  187.     }
  188. }]);
  189. damModule.service("assetData", ["jsonData", "appState", "$rootScope", function(a, b, d) {
  190.     var e;
  191.     this.setAssetDetailUrl = function(a) {
  192.         e = a
  193.     };
  194.     this.getAssetDetail = function(b) {
  195.         b = void 0 === e ? a.getApiRoot() + "asset/uuid/" + b : "/" + e;
  196.         return a.getData(b)
  197.     };
  198.     this.getZoomData = function(b) {
  199.         b = a.getApiRoot() + "asset/uuid/" + b + "/zoomdata?panzoom\x3dtrue";
  200.         return a.getData(b)
  201.     };
  202.     this.getDocumentPreview = function(b) {
  203.         b = a.getApiRoot() + "asset/uuid/" + b + "/documentpreview";
  204.         return a.getData(b)
  205.     };
  206.     this.getUploadProfiles = function(c) {
  207.         var e = a.getApiRoot() +
  208.             "uploadprofile/mobile";
  209.         a.getData(e).success(function(a) {
  210.             b.sessionStore.uploadProfiles = a.uploadProfiles || [];
  211.             d.$broadcast("uploadProfilesUpdated");
  212.             c && c(a)
  213.         })
  214.     }
  215. }]);
  216. damModule.service("searchData", ["jsonData", "searchState", "damConstants", "cookie", "assetSelection", "configuration", function(a, b, d, e, c, h) {
  217.     this.getBaseSearchURI = function() {
  218.         return a.getApiRoot() + "asset/search"
  219.     };
  220.     this.performSearchPost = function(c, g, k, h, m) {
  221.         var l = e.readCookie(d.sortCookieName),
  222.             l = isBlank(l) ? "" : "\x26sort\x3d" + l;
  223.         c = c + "?start\x3d" + g + "\x26max\x3d" + k + l + "\x26options\x3dpermissions";
  224.         g = {};
  225.         g.query = h;
  226.         g.resultsOnly = m;
  227.         g.fileTypeFilters = b.getSelectedFilterKeys();
  228.         return a.doPost(g, c)
  229.     };
  230.     this.selectedAssetSearch =
  231.         function() {
  232.             if (0 === c.getSelection().length) return {
  233.                 success: function(a) {
  234.                     a && a({
  235.                         assets: [],
  236.                         numResults: 0
  237.                     })
  238.                 }
  239.             };
  240.             var f = e.readCookie(d.sortCookieName),
  241.                 f = isBlank(f) ? "" : "\x26sort\x3d" + f,
  242.                 g = isBlank(b.getSelectedFilterKeys()) ? "" : "\x26filters\x3d" + encodeURIComponent(b.getSelectedFilterKeys()),
  243.                 f = a.getApiRoot() + "asset/search?start\x3d0\x26max\x3d" + h.maxSelectedAssets + g + f + "\x26options\x3dpermissions",
  244.                 g = {
  245.                     query: "uuid:(" + c.getSelection().join(" or ") + ")"
  246.                 };
  247.             return a.doPost(g, f)
  248.         }
  249. }]);
  250. damModule.service("siteData", ["jsonData", "appState", "$window", "configuration", function(a, b, d, e) {
  251.     this.getSiteData = function(c, d) {
  252.         b.sessionStore.siteData && !d ? c && c(b.sessionStore.siteData) : !e.isApp() || b.store.server ? a.getData(a.getApiRoot() + "site/").success(function(a) {
  253.             b.sessionStore.siteData = angular.fromJson(a);
  254.             c && c(b.sessionStore.siteData)
  255.         }) : c && c(e.defaultSiteData)
  256.     };
  257.     this.ping = function() {
  258.         a.getData(a.getApiRoot() + "site/ping")
  259.     };
  260.     this.useFullSite = function() {
  261.         b.useFullSite();
  262.         a.getData(a.getApiRoot() + "site/fullsite", {
  263.             AppType: "fullsite"
  264.         }).success(function() {
  265.             d.location.href = "/"
  266.         }).error(function() {
  267.             d.location.href = "/"
  268.         })
  269.     }
  270. }]);
  271. damModule.service("filteringData", ["jsonData", function(a) {
  272.     this.getAvailableFilters = function() {
  273.         var b = a.getApiRoot() + "filter/available";
  274.         return a.getData(b)
  275.     };
  276.     this.toggleFilter = function(b) {
  277.         return a.doPost({
  278.             toggleKey: b
  279.         }, a.getApiRoot() + "filter/")
  280.     };
  281.     this.resetFilters = function() {
  282.         return a.doPost({}, a.getApiRoot() + "filter/")
  283.     }
  284. }]);
  285. damModule.service("categoryData", ["jsonData", function(a) {
  286.     this.getCategories = function(b) {
  287.         b = a.getApiRoot() + "category/uuid/" + b + "/subcategories?includeEmpty\x3dfalse";
  288.         return a.getData(b)
  289.     };
  290.     this.getBaseCategoryAssetsUri = function(b) {
  291.         return a.getApiRoot() + "category/uuid/" + b + "/assets"
  292.     }
  293. }]);
  294. damModule.service("help", ["damConstants", function(a) {
  295.     var b = this;
  296.     this.target = "_blank";
  297.     this.launchHelp = function() {
  298.         window.open(a.helpUrl, b.target)
  299.     }
  300. }]);
  301. damModule.service("orderData", ["jsonData", function(a) {
  302.     this.getConversionsForOrder = function(b, d) {
  303.         var e = {};
  304.         e.uuids = d;
  305.         var c = a.getApiRoot() + "conversion/order/profile/uuid/" + b;
  306.         return a.doPost(e, c)
  307.     };
  308.     this.getOrderItemRemovals = function(b) {
  309.         var d = {};
  310.         d.uuids = b;
  311.         b = a.getApiRoot() + "order/items/removals";
  312.         return a.doPost(d, b)
  313.     };
  314.     this.getOrderProfiles = function() {
  315.         var b = a.getApiRoot() + "order/profile/internet";
  316.         return a.getData(b)
  317.     };
  318.     this.getOrderEula = function() {
  319.         var b = a.getApiRoot() + "eula/order";
  320.         return a.getData(b)
  321.     };
  322.     this.createOrder =
  323.         function(b) {
  324.             var d = a.getApiRoot() + "order";
  325.             return a.doPost(b, d)
  326.         }
  327. }]);
  328. damModule.service("metadataData", ["jsonData", function(a) {
  329.     var b = a.getApiRoot() + "metadata/type/uuid/";
  330.     this.getMetadataType = function(d) {
  331.         return a.getData(b + d)
  332.     }
  333. }]);
  334. damModule.service("contactData", ["jsonData", function(a) {
  335.     var b = a.getApiRoot() + "address/saved",
  336.         d = a.getApiRoot() + "address/saved/uuid/",
  337.         e = a.getApiRoot() + "address/countries";
  338.     this.getSavedContacts = function() {
  339.         return a.getData(b)
  340.     };
  341.     this.createContact = function(c) {
  342.         return a.doPost(c, b)
  343.     };
  344.     this.updateContact = function(b) {
  345.         return a.doPut(b, d + b.uuid)
  346.     };
  347.     this.deleteContact = function(b) {
  348.         return a.doDelete(d + b.uuid)
  349.     };
  350.     this.getCountries = function() {
  351.         return a.getData(e)
  352.     }
  353. }]);
  354. damModule.service("userData", ["jsonData", function(a) {
  355.     this.checkPermissions = function(b) {
  356.         b = a.getApiRoot() + "user/permission/" + b;
  357.         return a.getData(b)
  358.     }
  359. }]);
  360. damModule.service("scopeData", ["jsonData", "appState", "$rootScope", function(a, b, d) {
  361.     this.createOrder = "order_creation";
  362.     this.checkScope = function(b) {
  363.         return a.getData(a.getApiRoot() + "scopes/allowed/" + b)
  364.     };
  365.     this.getScopeData = function(e) {
  366.         a.getData(a.getApiRoot() + "scopes").success(function(a) {
  367.             b.sessionStore.scopes = a.scopes || [];
  368.             d.$broadcast("securityScopesUpdated");
  369.             e && e(b.sessionStore.scopes)
  370.         })
  371.     }
  372. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement