UNPKG

gumga-rest-ng

Version:

Gumga Rest

1 lines 5.22 kB
!function(t){function e(a){if(r[a])return r[a].exports;var u=r[a]={i:a,l:!1,exports:{}};return t[a].call(u.exports,u,u.exports,e),u.l=!0,u.exports}var r={};e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,a){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:a})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,r){"use strict";!function(){function t(t,e){function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;this.pageSize=e,this._url=t,this._query={params:{start:0,pageSize:this.pageSize}}}function a(e,r){var a=angular.copy(this._query);if(a.params.pageSize=r||a.params.pageSize,e&&(a.params.start=(e-1)*a.params.pageSize,e<1))throw"Invalid page";return a.params.searchCount=e<=1,t.get(this._url,a)}function u(){return t.get(this._url+"/new")}function s(e){return t.get(this._url+"/"+e)}function n(e){return t.post(this._url,e)}function i(e){return e.id?t.put(this._url+"/"+e.id,e):this.save(e)}function o(e){return t.delete(this._url+"/"+e.id)}function p(){this._query={params:{start:0,pageSize:this.pageSize}}}function l(){return this.resetDefaultState(),t.get(this._url,this._query)}function h(e,r,a,u){return this._query.params.sortField=e,this._query.params.sortDir=r,a&&(this._query.params.pageSize=a),u&&(this._query.params.start=(u-1)*this._query.params.pageSize),this._query.params.searchCount=u<=1,t.get(this._url,this._query)}function c(r){var a=this._url;return e.all(r.map(function(e){return t.delete(a+"/"+e.id)}))}function y(e,r){var a=new FormData;return a.append(e,r),t.post(this._url+"/"+e+"/",a,{transformRequest:angular.identity,headers:{"Content-Type":void 0}})}function g(e){var r=new FormData;return r.append(e,{}),t.delete(this._url+"/"+e,r,{transformRequest:angular.identity,headers:{"Content-Type":void 0}})}function f(t,e,r,a){return this.resetDefaultState(),e?angular.noop:e="",this._query.params.q=e,this._query.params.searchFields=t,r&&(this._query.params.pageSize=r),this._query.params.searchCount=a<=1,this.get(a)}function m(e,r,a){this.resetDefaultState(),r&&(this._query.params.pageSize=r);var u=angular.copy(this._query);return a&&(u.params.start=(a-1)*u.params.pageSize),"string"==typeof e?(this._query.params.aq=e,this._query.params.searchCount=a<=1,t.get(this._url,this._query)):(this._query.params.aq=e.hql,this._query.params.aqo=JSON.stringify(e.source),u.params.aqo=JSON.stringify(e.source),u.params.aq=e.hql,u.params.searchCount=a<=1,t.get(this._url,u))}function _(){return this._query}function d(){return t.get(this._url,this._query)}function q(e){var r={page:location.hash.replace("#","").replace(/\//gi,"_"),data:JSON.stringify(e.query),name:e.name};return t.post(this._url+"/saq",r)}function v(t){return!(null==t||void 0==t||!t[0])&&(!!(t[0]&&t[0].selects&&t[0].selects.length>0)||(t[0].subQuerys&&t[0].subQuerys.length>0?v(t[0].subQuerys):(t.shift(),t.length>0&&v(t))))}function S(e,r,a){return a&&(this._query.params.pageSize=a),r&&(this._query.params.start=(r-1)*this._query.params.pageSize),t.post(this._url+(v([angular.copy(e)])?"/v2":"")+"/gquery",{pageSize:this._query.params.pageSize,start:this._query.params.start,searchCount:r<=1,gQuery:e})}function z(e){return t.post(this._url+(v(e&&[angular.copy(e.gQuery)])?"/v2":"")+"/gquery",e)}function T(e){return t.get(this._url+"/gumgauserdata/aq;"+e.replace("#","").replace(/\//gi,"_"))}function b(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=[];return r.forEach(function(t){var r=angular.copy(t.definition);delete r.attributes,a.push({objectId:e,definition:r,values:t.definition.attributes.map(function(t){var e=angular.copy(t);return delete e.value,{definition:e,value:t.value}})})}),t.post(this._url+"/tags",{tags:a})}function C(){return t.get(this._url+"/tags/")}function O(e){return t.get(this._url+"/tags/"+e)}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"GET",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" ",a=arguments[2];return t[e.toLowerCase().trim()]||console.error("O método passado como primeiro parâmetro deve ser um método HTTP válido: GET, HEAD, POST, PUT, DELETE, JSONP, PATCH"),t[e.toLowerCase().trim()](""+this._url+r,a)}function Q(){var t=this._url.split("");"/"==t[t.length-1]&&t.pop();var e=t.join("").lastIndexOf("/");return t.join("").slice(0,e).concat("/proxy/softwarevalues")}return r.prototype.get=a,r.prototype.resetAndGet=l,r.prototype.getNew=u,r.prototype.getById=s,r.prototype.save=n,r.prototype.update=i,r.prototype.delete=o,r.prototype.sort=h,r.prototype.deleteCollection=c,r.prototype.saveImage=y,r.prototype.deleteImage=g,r.prototype.getSearch=f,r.prototype.getAdvancedSearch=m,r.prototype.resetDefaultState=p,r.prototype.getStateQuery=_,r.prototype.redoSearch=d,r.prototype.saveQuery=q,r.prototype.getQuery=T,r.prototype.postTags=b,r.prototype.getAvailableTags=C,r.prototype.getSelectedTags=O,r.prototype.extend=D,r.prototype.searchWithGQuery=S,r.prototype.sendQueryObject=z,r.prototype.getDocumentationURL=Q,r}t.$inject=["$http","$q"],angular.module("gumga.rest",[]).service("GumgaRest",t)}()}]);