1"use strict"; 2(self["webpackChunkprep"] = self["webpackChunkprep"] || []).push([["default-src_app_pages_file-upload_service_file-upload_service_ts"],{ 3 4/***/ 24130: 5/*!******************************************************************!*\ 6 !*** ./src/app/pages/file-upload/service/file-upload.service.ts ***! 7 \******************************************************************/ 8/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 9 10__webpack_require__.r(__webpack_exports__); 11/* harmony export */ __webpack_require__.d(__webpack_exports__, { 12/* harmony export */ "FileUploadService": () => (/* binding */ FileUploadService) 13/* harmony export */ }); 14/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ 34929); 15/* harmony import */ var _angular_common_http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @angular/common/http */ 28784); 16/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! rxjs/operators */ 86942); 17/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! rxjs/operators */ 47418); 18/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! rxjs */ 66587); 19/* harmony import */ var _environments_environment_prod__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../environments/environment.prod */ 89019); 20/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @angular/core */ 3184); 21/* harmony import */ var _angular_material_snack_bar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @angular/material/snack-bar */ 32528); 22 23 24 25 26 27 28 29 30class FileUploadService { 31 constructor(http, snackbar) { 32 this.http = http; 33 this.snackbar = snackbar; 34 this.showload = true; 35 this.httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ 36 'Content-Type': 'application/json; charset=utf-8', 37 }); 38 this.baseUrl = _environments_environment_prod__WEBPACK_IMPORTED_MODULE_0__.environment.backend; 39 this.fileIngestionBackend = _environments_environment_prod__WEBPACK_IMPORTED_MODULE_0__.environment.ingestion_backend; 40 } 41 // createJob(fd): Observable<any> { 42 // return this.http.post(this.baseUrl + 'pdf-content/create-job/', fd, this.getAuthHeaders()); 43 // } 44 createJob1(fd) { 45 const token = localStorage.getItem('token'); 46 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ Authorization: 'Token ' + token }); 47 return this.http.post(this.baseUrl + 'pdf-content/create-job/', fd, this.getAuthHeaders()); 48 } 49 passwordProtected(fd) { 50 const token = localStorage.getItem('token'); 51 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ Authorization: 'Token ' + token }); 52 return this.http.post(this.baseUrl + 'file-upload/retry_upload_with_pwd/', fd, this.getAuthHeaders()); 53 } 54 getCanvasLMSUrl(sync_courses = false) { 55 return this.http.get(this.baseUrl + 'clms/initiate-url/?sync_courses=' + sync_courses, this.getAuthHeaders()); 56 } 57 corsErrorS3Upload(fd) { 58 const token = localStorage.getItem('token'); 59 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ Authorization: 'Token ' + token }); 60 return this.http.post(this.baseUrl + 'file-upload/upload-v2/', fd, this.getAuthHeaders()); 61 } 62 createJob(fd) { 63 const token = localStorage.getItem('token'); 64 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ Authorization: 'Token ' + token }); 65 // return this.http.post(this.baseUrl + 'pdf-content/create-job/', fd, this.getAuthHeaders()); 66 return this.http 67 .post(this.baseUrl + 'pdf-content/create-job/', fd, { 68 reportProgress: true, 69 observe: 'events', 70 headers: httpHeaders, 71 }) 72 .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_2__.map)((event) => { 73 switch (event.type) { 74 case _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpEventType.UploadProgress: 75 const progress = Math.round((100 * event.loaded) / event.total); 76 if (progress === 100) { 77 this.showload = false; 78 this.snackbar.open('File Uploaded Successully. Please wait as we are extracting Pages', '', { 79 duration: 20000, 80 }); 81 return (this.uploadResponse = { 82 status: 'complete', 83 message: progress, 84 }); 85 } 86 else { 87 this.showload = true; 88 return (this.uploadResponse = { 89 status: 'progress', 90 message: progress, 91 }); 92 } 93 case _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpEventType.Response: { 94 this.snackbar.open('Pages extracted Successfully', '', { 95 duration: 10000, 96 }); 97 return event.body; 98 } 99 default: 100 return `Unhandled event: ${event.type}`; 101 } 102 })); 103 } 104 getConfigFileAIDetect() { 105 // return this.http.patch(this.baseUrl + 'v1/tags/job/' + id + '/', fd, this.getAuthHeaders()); 106 return this.http.get(this.baseUrl + 'accounts/configs/', this.getAuthHeaders()); 107 } 108 createJobMultiple(fd1) { 109 return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__awaiter)(this, void 0, void 0, function* () { 110 return yield this.http 111 .post(this.baseUrl + 'pdf-content/create-job/', fd1, this.getAuthHeaders()) 112 .toPromise(); 113 }); 114 } 115 importFileJSON(fd) { 116 return this.http.post(this.baseUrl + 'detects/import-file/', fd, this.getAuthHeaders()); 117 } 118 // postLevel1Data(fd): Observable<any> { 119 // return this.http 120 // .post( 121 // this.baseUrl + 'file-upload/get_signed_url/', 122 // fd, 123 // this.getAuthHeaders() 124 // ) 125 // .pipe(catchError((error) => this.handleError(error))); 126 // } 127 fileGetSignedUrl(fd) { 128 return this.http.post(this.baseUrl + 'file-upload/get_signed_url/', fd, this.getAuthHeaders()).pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.catchError)((error) => { 129 var _a; 130 if (error.status === 417 && ((_a = error.error) === null || _a === void 0 ? void 0 : _a.message)) { 131 this.snackbar.open(error.error.message, '', { 132 duration: 3000, 133 }); 134 } 135 return this.handleError(error); 136 })); 137 } 138 fileGetSignedUrlLTI(fd) { 139 return this.http.post('https://ingprfl.continualengine.com/api/upload/', fd, this.getAuthHeaders()).pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.catchError)((error) => { 140 var _a; 141 if (error.status === 417 && ((_a = error.error) === null || _a === void 0 ? void 0 : _a.message)) { 142 this.snackbar.open(error.error.message, '', { 143 duration: 3000, 144 }); 145 } 146 return this.handleError(error); 147 })); 148 } 149 postLevel1Data(fd) { 150 return this.http 151 .post(this.baseUrl + 'file-upload/get_signed_url/', fd, this.getAuthHeaders()) 152 .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.catchError)((error) => { 153 var _a; 154 if (error.status === 417 && ((_a = error.error) === null || _a === void 0 ? void 0 : _a.message)) { 155 this.snackbar.open(error.error.message, '', { 156 duration: 3000, 157 }); 158 } 159 return this.handleError(error); 160 })); 161 } 162 // Same endpoint as postLevel1Data, but rethrows the raw HttpErrorResponse instead 163 // of collapsing it via handleError(). Callers that build failure diagnostics off
164 // the original error shape (status/error body - e.g. buildErrorExtra in 165 // FileUploadComponent's ingestion-backend fallback) need this preserved so a 166 // failure here doesn't get logged as a generic, contextless error. 167 getSignedUrlPreserveError(fd) { 168 return this.http 169 .post(this.baseUrl + 'file-upload/get_signed_url/', fd, this.getAuthHeaders()) 170 .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.catchError)((error) => { 171 var _a; 172 if (error.status === 417 && ((_a = error.error) === null || _a === void 0 ? void 0 : _a.message)) { 173 this.snackbar.open(error.error.message, '', { 174 duration: 3000, 175 }); 176 } 177 // RxJS 6 (this project's version) has no throwError(factory) overload - 178 // throwError(() => error) would throw the arrow function itself, defeating 179 // the whole point of this method (preserving the raw error for buildErrorExtra). 180 return (0,rxjs__WEBPACK_IMPORTED_MODULE_5__.throwError)(error); 181 })); 182 } 183 postLevel1IngestionData(fd) { 184 return this.http 185 .post(this.fileIngestionBackend + 'api/upload/', fd, this.getAuthHeaders()); 186 } 187 // Retry API - requests a fresh signed S3 URL for a file/doc_file that already 188 // failed a direct S3 PUT, instead of re-trying the same (possibly expired) URL. 189 retryUploadIngestionData(payload) { 190 return this.http.post(this.fileIngestionBackend + 'api/upload/', payload, this.getAuthHeaders()); 191 } 192 postLevel2Data(fdurl, file) { 193 return this.http 194 .put(fdurl, file, this.getAuthHeaders1()) 195 .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.catchError)((error) => this.handleError(error))); 196 } 197 postLevel2DataWithFileType(fdurl, file) { 198 return this.http 199 .put(fdurl, file, this.getAuthHeadersForFile(file)) 200 .pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_4__.catchError)((error) => this.handleError(error))); 201 } 202 postLevel3Data(fd) { 203 return this.http 204 .post(this.baseUrl + 'file-upload/save_file_url/', fd, this.getAuthHeaders()); 205 } 206 postSaveRspOrder(fd) { 207 return this.http 208 .post(this.baseUrl + 'remediation/sales/user_file_upload_v1/', fd, this.getAuthHeaders()); 209 } 210 postSaveRemediatedFile(fd) { 211 return this.http 212 .post(this.baseUrl + 'remediation/sales/upload-remediated_v1/', fd, this.getAuthHeaders()); 213 } 214 chunkStart(fileName, docFileId, rspFilePath, orderId, url, isRSP) { 215 const body = { file_name: fileName }; 216 if (docFileId) { 217 if (isRSP) { 218 body.doc_file_id = docFileId; 219 } 220 else { 221 body.file_id = docFileId; 222 } 223 } 224 if (rspFilePath) 225 body.rsp_file_path = rspFilePath; 226 if (orderId) 227 body.order_id = orderId; 228 if (url) 229 body.url = url; 230 return this.http.post(this.baseUrl + 'file-upload/chunk/start/', body, this.getAuthHeaders()); 231 } 232 chunkUpload(fd) { 233 return this.http.post(this.baseUrl + 'file-upload/chunk/upload/', fd, this.getAuthHeaders()); 234 } 235 chunkComplete(body, docFileId, isRSP) { 236 const payload = Object.assign({}, body); 237 if (docFileId) { 238 if (isRSP) { 239 payload.doc_file_id = docFileId; 240 } 241 else { 242 payload.file_id = docFileId; 243 } 244 } 245 return this.http.post(this.baseUrl + 'file-upload/chunk/complete/', payload, this.getAuthHeaders()); 246 } 247 logUploadEvent(payload) { 248 const token = localStorage.getItem('token'); 249 const body = JSON.stringify(Object.assign(Object.assign({}, payload), { auth_token: token })); 250 fetch(this.baseUrl + 'file-upload/log_upload_event/', { 251 method: 'POST', 252 headers: { 253 'Content-Type': 'application/json', 254 'Authorization': 'Token ' + token, 255 }, 256 body, 257 keepalive: true, // survives page navigation/unload 258 }).catch(() => { }); // swallow errors, truly fire-and-forget 259 } 260 logUploadEventBeacon(payload) { 261 const token = localStorage.getItem('token'); 262 const body = JSON.stringify(Object.assign(Object.assign({}, payload), { auth_token: token })); 263 navigator.sendBeacon(this.baseUrl + 'file-upload/log_upload_event/', new Blob([body], { type: 'application/json' })); 264 } 265 // Generic error handler 266 handleError(error) { 267 console.error('API Error:', error); 268 // RxJS 6 (this project's version) has no throwError(factory) overload - 269 // throwError(() => ...) would throw that arrow function itself as the error, 270 // masking the real failure (e.g. an S3 PUT's net::ERR_FILE_NOT_FOUND) from every 271 // downstream catchError/buildErrorExtra call that expects a real Error/HttpErrorResponse. 272 return (0,rxjs__WEBPACK_IMPORTED_MODULE_5__.throwError)(new Error(error.message || 'Something went wrong!')); 273 } 274 getAuthHeaders() { 275 const token = localStorage.getItem('token'); 276 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ Authorization: 'Token ' + token }); 277 return { headers: httpHeaders }; 278 } 279 getAuthHeaders1() { 280 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ 281 'Content-Type': 'application/pdf; charset=utf-8', 282 }); 283 return { headers: httpHeaders }; 284 } 285 getAuthHeadersForFile(file) { 286 const httpHeaders = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpHeaders({ 287 'Content-Type': file.type || 'application/octet-stream', 288 }); 289 return { headers: httpHeaders }; 290 } 291} 292FileUploadService.ɵfac = function FileUploadService_Factory(t) { return new (t || FileUploadService)(_angular_core__WEBPACK_IMPORTED_MODULE_6__["ɵɵinject"](_angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpClient), _angular_core__WEBPACK_IMPORTED_MODULE_6__["ɵɵinject"](_angular_material_snack_bar__WEBPACK_IMPORTED_MODULE_7__.MatSnackBar)); }; 293FileUploadService.ɵprov = /*@__PURE__*/ _angular_core__WEBPACK_IMPORTED_MODULE_6__["ɵɵdefineInjectable"]({ token: FileUploadService, factory: FileUploadService.ɵfac, providedIn: 'root' }); 294 295 296/***/ }) 297 298}]); 299//# sourceMappingURL=default-src_app_pages_file-upload_service_file-upload_service_ts.92cc237a5df9ac79.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.