allex_cgiservice
Version:
1 lines • 3.81 kB
JavaScript
!function(a,b,c){}(ALLEX.lib,ALLEX,angular.module("allex.cgi",["ngFileUpload"])),function(a,b,c){var d=b.WEB_COMPONENT,e=d.http.parseHttpResponseError;c.factory("allex.cgi.UploadMixIn",["Upload",function(b){function c(a,b){this.uploadSettings=angular.extend({},d,b),this._uploadStateM=null,this.uploadURL=null,this.uploadFiles=null}var d={uploadslugname:"uploadURL",allowDir:!1,multiple:!1,doDrop:!0,accept:null,forget:!0,browse:!0};return c.prototype.__cleanUp=function(){this.uploadSettings=null,this._uploadStateM&&this._uploadStateM.destroy(),this._uploadStateM=null,this.uploadURL=null,this.uploadFiles=null},c.prototype.uploadSetUser=function(a){if(this._uploadStateM&&this._uploadStateM.destroy(),this._uploadStateM=null,a){var b={};b[this.uploadSettings.uploadslugname]=this.set.bind(this,"uploadURL"),this._uploadStateM=a.getStateAndAttach(b)}},c.prototype.uploadOnFileDropped=function(){},c.prototype.upload=function(c){var d=a.q.defer();return b.upload({url:this.uploadURL,file:this.get("uploadFiles"),method:"POST",fields:c}).progress(this._onUploadProgress.bind(this,d)).success(this._onUploadSuccess.bind(this,d)).error(this._onUploadError.bind(this,d)),d.promise},c.prototype._onUploadProgress=function(a,b){a.notify(parseInt(100*(b.loaded/b.total)))},c.prototype._onUploadSuccess=function(a,b,c,d,e){console.log("DAAAAAAAAAAAAAAAAAAAAAAAA LI SE OVO DOGODILO?"),this.uploadSettings.forget&&this.uploadFiles.splice(0,this.uploadFiles.length),a.resolve(this.uploadGetSuccessMessage())},c.prototype._onUploadError=function(a,b,c,d,f){return c?b.length?a.reject(b):void a.reject(e(c)):void a.reject("Connectivity issues detected ...")},c.prototype.uploadGetSuccessMessage=function(){return"Successfully done"},c.addMethods=function(b){a.inheritMethods(b,c,"_onUploadProgress","_onUploadSuccess","_onUploadError","uploadOnFileDropped","upload","uploadSetUser","uploadGetSuccessMessage")},c}])}(ALLEX.lib,ALLEX,angular.module("allex.cgi")),function(a,b,c){c.directive("allexCgiUpload",["$compile",function(a){function b(b,c,d){var e=!1,f=b._ctrl.uploadSettings;f.doDrop&&(c.attr("data-ngf-drop",""),e=!0),f.accept&&(c.attr("data-ngf-accept",f.accept),e=!0),f.browse&&c.attr("data-ngf-select","true"),d.cgilabel?c.html(d.cgilabel):c.html("Upload files"),e&&a(c)(b)}return{restrict:"E",replace:!0,scope:!1,template:'<button class="btn btn-primary" data-ng-model="_ctrl.uploadFiles" data-ngf-drag-over-class="dragover" ngf-multiple="{{_ctrl.uploadSettings.multiple}}" ngf-allow-dir="{{_ctrl.uploadSettings.allowDir}}" data-ngf-change="_ctrl.uploadOnFileDropped($files, $event, $rejected)"></button>',link:b}}])}(ALLEX.lib,ALLEX,angular.module("allex.cgi")),function(a,b,c){"use strict";function d(a){h.call(this,a)}var e=b.WEB_COMPONENT,f=e.jsonform,g=(f.widgets,f.DefaultWidgetDescriptor,f.DefaultWidgetsRegistry,f.WidgetsRegistry),h=f.BasicWidgetController,i=(f.widgets.GridController,f.helpers);a.inherit(d,h),d.prototype.__cleanUp=function(){h.prototype.__cleanUp.call(this)},d.prototype.get_default_config=function(){return d.DEFAULT_CONFIG},d.DEFAULT_CONFIG={allowDir:!1,multiple:!1,label:"Upload files",accept:null,allowDrop:!1,onChange:null},c.controller("allex.jf.widget.UploadFileController",["$scope",function(a){new d(a)}]),c.directive("allexJfWidgetUploadFile",["$compile",function(a){function b(b,c,d){var e=c.find("button"),f=b._ctrl,g=(f.config,{"data-ngf-select":!0});f.config.accept&&(g.accept=f.config.accept),f.config.allowDrop&&(g["data-ngf-drop"]=""),e.attr(g),i.bootwidget(a,b,c,e)}return{restrict:"E",replace:!0,controller:"allex.jf.widget.UploadFileController",scope:!0,templateUrl:"partials/allex_cgiservice/partials/widgets/upload.html",link:b}}]),g.replace("file_upload","<allex-jf-widget-upload-file></allex-jf-widget-upload-file>")}(ALLEX.lib,ALLEX,angular.module("allex.cgi"));