1
|
|
|
(function webpackUniversalModuleDefinition(root, factory) { |
2
|
|
|
if(typeof exports === 'object' && typeof module === 'object') |
3
|
|
|
module.exports = factory(require("underscore"), require("handlebars/runtime"), require("jQuery")); |
|
|
|
|
4
|
|
|
else if(typeof define === 'function' && define.amd) |
|
|
|
|
5
|
|
|
define(["underscore", "handlebars/runtime", "jQuery"], factory); |
|
|
|
|
6
|
|
|
else if(typeof exports === 'object') |
7
|
|
|
exports["Ocr"] = factory(require("underscore"), require("handlebars/runtime"), require("jQuery")); |
|
|
|
|
8
|
|
|
else |
9
|
|
|
root["OCA"] = root["OCA"] || {}, root["OCA"]["Ocr"] = factory(root["_"], root["Handlebars"], root["$"]); |
|
|
|
|
10
|
|
|
})(this, function(__WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_10__, __WEBPACK_EXTERNAL_MODULE_11__) { |
11
|
|
|
return /******/ (function(modules) { // webpackBootstrap |
12
|
|
|
/******/ // The module cache |
13
|
|
|
/******/ var installedModules = {}; |
14
|
|
|
|
15
|
|
|
/******/ // The require function |
16
|
|
|
/******/ function __webpack_require__(moduleId) { |
17
|
|
|
|
18
|
|
|
/******/ // Check if module is in cache |
19
|
|
|
/******/ if(installedModules[moduleId]) |
20
|
|
|
/******/ return installedModules[moduleId].exports; |
|
|
|
|
21
|
|
|
|
22
|
|
|
/******/ // Create a new module (and put it into the cache) |
23
|
|
|
/******/ var module = installedModules[moduleId] = { |
24
|
|
|
/******/ exports: {}, |
25
|
|
|
/******/ id: moduleId, |
26
|
|
|
/******/ loaded: false |
27
|
|
|
/******/ }; |
28
|
|
|
|
29
|
|
|
/******/ // Execute the module function |
30
|
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
31
|
|
|
|
32
|
|
|
/******/ // Flag the module as loaded |
33
|
|
|
/******/ module.loaded = true; |
34
|
|
|
|
35
|
|
|
/******/ // Return the exports of the module |
36
|
|
|
/******/ return module.exports; |
37
|
|
|
/******/ } |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/******/ // expose the modules object (__webpack_modules__) |
41
|
|
|
/******/ __webpack_require__.m = modules; |
42
|
|
|
|
43
|
|
|
/******/ // expose the module cache |
44
|
|
|
/******/ __webpack_require__.c = installedModules; |
45
|
|
|
|
46
|
|
|
/******/ // __webpack_public_path__ |
47
|
|
|
/******/ __webpack_require__.p = ""; |
48
|
|
|
|
49
|
|
|
/******/ // Load entry module and return exports |
50
|
|
|
/******/ return __webpack_require__(0); |
51
|
|
|
/******/ }) |
52
|
|
|
/************************************************************************/ |
53
|
|
|
/******/ ([ |
|
|
|
|
54
|
|
|
/* 0 */ |
55
|
|
|
/***/ (function(module, exports, __webpack_require__) { |
|
|
|
|
56
|
|
|
|
57
|
|
|
"use strict"; |
58
|
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
59
|
|
|
var view_1 = __webpack_require__(12); |
60
|
|
|
var controller_1 = __webpack_require__(13); |
61
|
|
|
var configuration_1 = __webpack_require__(14); |
62
|
|
|
var http_service_1 = __webpack_require__(15); |
63
|
|
|
var handlebarsTableTemplate = __webpack_require__(16); |
64
|
|
|
var underscore_1 = __webpack_require__(5); |
|
|
|
|
65
|
|
|
var jquery_1 = __webpack_require__(11); |
|
|
|
|
66
|
|
|
var Personal = (function () { |
67
|
|
|
function Personal() { |
68
|
|
|
var _this = this; |
69
|
|
|
_.delay(function () { |
|
|
|
|
70
|
|
|
_this.config = new configuration_1.Configuration(); |
71
|
|
|
_this.view = new view_1.View(OC.Notification, handlebarsTableTemplate, t, $, document); |
|
|
|
|
72
|
|
|
_this.httpService = new http_service_1.HttpService(_this.config, $); |
73
|
|
|
_this.controller = new controller_1.Controller(_this.view, _this.httpService, document, $, t); |
74
|
|
|
try { |
75
|
|
|
_this.controller.init(); |
76
|
|
|
} |
77
|
|
|
catch (e) { |
78
|
|
|
console.error(e); |
79
|
|
|
_this.view.displayMessage(e.message, true); |
80
|
|
|
} |
81
|
|
|
}, 1000); |
82
|
|
|
} |
83
|
|
|
return Personal; |
84
|
|
|
}()); |
85
|
|
|
exports.Personal = Personal; |
86
|
|
|
exports.$personal = new Personal(); |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/***/ }), |
90
|
|
|
/* 1 */, |
|
|
|
|
91
|
|
|
/* 2 */, |
92
|
|
|
/* 3 */, |
93
|
|
|
/* 4 */, |
94
|
|
|
/* 5 */ |
95
|
|
|
/***/ (function(module, exports) { |
96
|
|
|
|
97
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE_5__; |
98
|
|
|
|
99
|
|
|
/***/ }), |
100
|
|
|
/* 6 */, |
|
|
|
|
101
|
|
|
/* 7 */, |
102
|
|
|
/* 8 */, |
103
|
|
|
/* 9 */, |
104
|
|
|
/* 10 */ |
105
|
|
|
/***/ (function(module, exports) { |
106
|
|
|
|
107
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE_10__; |
108
|
|
|
|
109
|
|
|
/***/ }), |
110
|
|
|
/* 11 */ |
111
|
|
|
/***/ (function(module, exports) { |
112
|
|
|
|
113
|
|
|
module.exports = __WEBPACK_EXTERNAL_MODULE_11__; |
114
|
|
|
|
115
|
|
|
/***/ }), |
116
|
|
|
/* 12 */ |
117
|
|
|
/***/ (function(module, exports) { |
118
|
|
|
|
119
|
|
|
"use strict"; |
120
|
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
121
|
|
|
var View = (function () { |
122
|
|
|
function View(notification, handlebarsTableTemplateFunction, t, jquery, document) { |
123
|
|
|
this.notification = notification; |
124
|
|
|
this.handlebarsTableTemplateFunction = handlebarsTableTemplateFunction; |
125
|
|
|
this.t = t; |
126
|
|
|
this.jquery = jquery; |
127
|
|
|
this.document = document; |
128
|
|
|
this.el = this.document.getElementById('ocr-settings'); |
129
|
|
|
} |
130
|
|
|
View.prototype.displayMessage = function (message, error) { |
131
|
|
|
if (error) { |
132
|
|
|
this.notification.showHtml("<div>" + message + "</div>", { timeout: 10, type: 'error' }); |
133
|
|
|
} |
134
|
|
|
else { |
135
|
|
|
this.notification.showHtml("<div>" + message + "</div>", { timeout: 10 }); |
136
|
|
|
} |
137
|
|
|
}; |
138
|
|
|
View.prototype.render = function (status) { |
139
|
|
|
var html = this.renderTable(status); |
140
|
|
|
this.appendHtmlToElement(html, this.el); |
141
|
|
|
}; |
142
|
|
|
View.prototype.destroy = function () { |
143
|
|
|
this.el.innerHTML = ''; |
144
|
|
|
}; |
145
|
|
|
View.prototype.renderTable = function (status) { |
146
|
|
|
var template = this.handlebarsTableTemplateFunction; |
147
|
|
|
var enabled = status && status.length > 0 ? true : false; |
148
|
|
|
return template({ |
149
|
|
|
deleteText: t('ocr', 'Delete'), |
150
|
|
|
enabled: enabled, |
151
|
|
|
noPendingOrFailedText: t('ocr', 'No pending or failed OCR items found.'), |
152
|
|
|
refreshButtonText: t('ocr', 'Refresh'), |
153
|
|
|
status: status, |
154
|
|
|
tableHeadDeleteFromQueueText: t('ocr', 'Delete from queue'), |
155
|
|
|
tableHeadNameText: t('ocr', 'Name'), |
156
|
|
|
tableHeadStatusText: t('ocr', 'Status'), |
157
|
|
|
}); |
158
|
|
|
}; |
159
|
|
|
View.prototype.appendHtmlToElement = function (html, el) { |
160
|
|
|
this.jquery(html).appendTo(el); |
161
|
|
|
}; |
162
|
|
|
Object.defineProperty(View.prototype, "el", { |
163
|
|
|
get: function () { |
164
|
|
|
return this._el; |
165
|
|
|
}, |
166
|
|
|
set: function (value) { |
167
|
|
|
this._el = value; |
168
|
|
|
}, |
169
|
|
|
enumerable: true, |
170
|
|
|
configurable: true |
171
|
|
|
}); |
172
|
|
|
return View; |
173
|
|
|
}()); |
174
|
|
|
exports.View = View; |
175
|
|
|
|
176
|
|
|
|
177
|
|
|
/***/ }), |
178
|
|
|
/* 13 */ |
179
|
|
|
/***/ (function(module, exports) { |
180
|
|
|
|
181
|
|
|
"use strict"; |
182
|
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
183
|
|
|
var Controller = (function () { |
184
|
|
|
function Controller(view, httpService, document, jquery, t) { |
185
|
|
|
this.view = view; |
186
|
|
|
this.httpService = httpService; |
187
|
|
|
this.document = document; |
188
|
|
|
this.jquery = jquery; |
189
|
|
|
this.t = t; |
190
|
|
|
this._status = []; |
191
|
|
|
} |
192
|
|
|
Controller.prototype.init = function () { |
193
|
|
|
this.loadAndRender(); |
194
|
|
|
this.registerEvents(); |
195
|
|
|
}; |
196
|
|
|
Controller.prototype.destroy = function () { |
197
|
|
|
this.view.destroy(); |
198
|
|
|
}; |
199
|
|
|
Controller.prototype.loadAndRender = function () { |
200
|
|
|
var _this = this; |
201
|
|
|
this.httpService.getAllStatus().always(function () { |
202
|
|
|
_this.view.destroy(); |
203
|
|
|
}).done(function (status) { |
204
|
|
|
_this.status = status; |
205
|
|
|
_this.view.render(_this.status); |
206
|
|
|
}).fail(function (jqXHR) { |
207
|
|
|
_this.view.displayMessage(t('ocr', 'OCR status could not be retrieved:') + " " + jqXHR.responseText, true); |
208
|
|
|
_this.status = []; |
209
|
|
|
_this.view.render(_this.status); |
210
|
|
|
}); |
211
|
|
|
}; |
212
|
|
|
Controller.prototype.delete = function (id) { |
213
|
|
|
var _this = this; |
214
|
|
|
this.httpService.deleteStatus(id).done(function () { |
215
|
|
|
_this.view.destroy(); |
216
|
|
|
var status = _this.status.filter(function (s) { return s.id === id; }); |
217
|
|
|
_this.status = _this.status.filter(function (s) { |
218
|
|
|
return s.id !== id; |
219
|
|
|
}); |
220
|
|
|
_this.view.displayMessage(t('ocr', 'Following status object has been successfully deleted:') + " " + status[0].target, false); |
221
|
|
|
_this.view.render(_this.status); |
222
|
|
|
}).fail(function (jqXHR) { |
223
|
|
|
_this.view.displayMessage(t('ocr', 'Error during deletion:') + " " + jqXHR.responseText, true); |
224
|
|
|
_this.loadAndRender(); |
225
|
|
|
}); |
226
|
|
|
}; |
227
|
|
|
Controller.prototype.registerEvents = function () { |
228
|
|
|
var _this = this; |
229
|
|
|
this.document.addEventListener('click', function (event) { |
230
|
|
|
if (event.target.id === 'ocr-search') { |
231
|
|
|
_this.loadAndRender(); |
232
|
|
|
} |
233
|
|
|
}); |
234
|
|
|
this.document.addEventListener('click', function (event) { |
235
|
|
|
if (event.target.id === 'ocr-delete' || event.target.parentNode.id === 'ocr-delete') { |
236
|
|
|
_this.delete(event.target.closest('tr').dataset.id - 0); |
237
|
|
|
} |
238
|
|
|
}); |
239
|
|
|
}; |
240
|
|
|
Object.defineProperty(Controller.prototype, "status", { |
241
|
|
|
get: function () { |
242
|
|
|
return this._status; |
243
|
|
|
}, |
244
|
|
|
set: function (value) { |
245
|
|
|
this._status = value; |
246
|
|
|
}, |
247
|
|
|
enumerable: true, |
248
|
|
|
configurable: true |
249
|
|
|
}); |
250
|
|
|
return Controller; |
251
|
|
|
}()); |
252
|
|
|
exports.Controller = Controller; |
253
|
|
|
|
254
|
|
|
|
255
|
|
|
/***/ }), |
256
|
|
|
/* 14 */ |
257
|
|
|
/***/ (function(module, exports) { |
258
|
|
|
|
259
|
|
|
"use strict"; |
260
|
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
261
|
|
|
var Configuration = (function () { |
262
|
|
|
function Configuration() { |
263
|
|
|
this._personalSettingsEndpoint = OC.generateUrl('/apps/ocr/settings/personal'); |
|
|
|
|
264
|
|
|
} |
265
|
|
|
Object.defineProperty(Configuration.prototype, "personalSettingsEndpoint", { |
266
|
|
|
get: function () { |
267
|
|
|
return this._personalSettingsEndpoint; |
268
|
|
|
}, |
269
|
|
|
enumerable: true, |
270
|
|
|
configurable: true |
271
|
|
|
}); |
272
|
|
|
return Configuration; |
273
|
|
|
}()); |
274
|
|
|
exports.Configuration = Configuration; |
275
|
|
|
|
276
|
|
|
|
277
|
|
|
/***/ }), |
278
|
|
|
/* 15 */ |
279
|
|
|
/***/ (function(module, exports) { |
280
|
|
|
|
281
|
|
|
"use strict"; |
282
|
|
|
Object.defineProperty(exports, "__esModule", { value: true }); |
283
|
|
|
var HttpService = (function () { |
284
|
|
|
function HttpService(config, jquery) { |
285
|
|
|
this.config = config; |
286
|
|
|
this.jquery = jquery; |
287
|
|
|
} |
288
|
|
|
HttpService.prototype.makeRequest = function (opts) { |
289
|
|
|
return this.jquery.ajax(opts); |
290
|
|
|
}; |
291
|
|
|
HttpService.prototype.getAllStatus = function () { |
292
|
|
|
var options = { |
293
|
|
|
method: 'GET', |
294
|
|
|
url: this.config.personalSettingsEndpoint, |
295
|
|
|
}; |
296
|
|
|
return this.makeRequest(options); |
297
|
|
|
}; |
298
|
|
|
HttpService.prototype.deleteStatus = function (id) { |
299
|
|
|
var options = { |
300
|
|
|
data: { |
301
|
|
|
id: id, |
302
|
|
|
}, |
303
|
|
|
method: 'DELETE', |
304
|
|
|
url: this.config.personalSettingsEndpoint, |
305
|
|
|
}; |
306
|
|
|
return this.makeRequest(options); |
307
|
|
|
}; |
308
|
|
|
return HttpService; |
309
|
|
|
}()); |
310
|
|
|
exports.HttpService = HttpService; |
311
|
|
|
|
312
|
|
|
|
313
|
|
|
/***/ }), |
314
|
|
|
/* 16 */ |
315
|
|
|
/***/ (function(module, exports, __webpack_require__) { |
316
|
|
|
|
317
|
|
|
var Handlebars = __webpack_require__(10); |
318
|
|
|
function __default(obj) { return obj && (obj.__esModule ? obj["default"] : obj); } |
|
|
|
|
319
|
|
|
module.exports = (Handlebars["default"] || Handlebars).template({"1":function(container,depth0,helpers,partials,data,blockParams,depths) { |
|
|
|
|
320
|
|
|
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; |
|
|
|
|
321
|
|
|
|
322
|
|
|
return "<table class=\"grid ocrsettings\">\n <thead>\n <tr>\n <th>" |
323
|
|
|
+ alias4(((helper = (helper = helpers.tableHeadNameText || (depth0 != null ? depth0.tableHeadNameText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tableHeadNameText","hash":{},"data":data}) : helper))) |
|
|
|
|
324
|
|
|
+ "</th>\n <th>" |
|
|
|
|
325
|
|
|
+ alias4(((helper = (helper = helpers.tableHeadStatusText || (depth0 != null ? depth0.tableHeadStatusText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tableHeadStatusText","hash":{},"data":data}) : helper))) |
|
|
|
|
326
|
|
|
+ "</th>\n <th>" |
|
|
|
|
327
|
|
|
+ alias4(((helper = (helper = helpers.tableHeadDeleteFromQueueText || (depth0 != null ? depth0.tableHeadDeleteFromQueueText : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tableHeadDeleteFromQueueText","hash":{},"data":data}) : helper))) |
|
|
|
|
328
|
|
|
+ "</th>\n </tr>\n </thead>\n <tbody>\n" |
|
|
|
|
329
|
|
|
+ ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.status : depth0),{"name":"each","hash":{},"fn":container.program(2, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") |
|
|
|
|
330
|
|
|
+ " </tbody>\n</table>\n"; |
|
|
|
|
331
|
|
|
},"2":function(container,depth0,helpers,partials,data,blockParams,depths) { |
|
|
|
|
332
|
|
|
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; |
|
|
|
|
333
|
|
|
|
334
|
|
|
return " <tr data-id=\"" |
335
|
|
|
+ alias4(((helper = (helper = helpers.id || (depth0 != null ? depth0.id : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"id","hash":{},"data":data}) : helper))) |
|
|
|
|
336
|
|
|
+ "\">\n <td>" |
|
|
|
|
337
|
|
|
+ alias4(((helper = (helper = helpers.target || (depth0 != null ? depth0.target : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"target","hash":{},"data":data}) : helper))) |
|
|
|
|
338
|
|
|
+ "</td>\n <td>" |
|
|
|
|
339
|
|
|
+ alias4(((helper = (helper = helpers.status || (depth0 != null ? depth0.status : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"status","hash":{},"data":data}) : helper))) |
|
|
|
|
340
|
|
|
+ "</td>\n <td class=\"ocr-action-delete\">\n <div id=\"ocr-delete\"><span>" |
|
|
|
|
341
|
|
|
+ alias4(container.lambda((depths[1] != null ? depths[1].deleteText : depths[1]), depth0)) |
|
|
|
|
342
|
|
|
+ "</span><span class=\"icon icon-delete\"></span></div>\n </td>\n </tr>\n"; |
|
|
|
|
343
|
|
|
},"4":function(container,depth0,helpers,partials,data) { |
344
|
|
|
var helper; |
345
|
|
|
|
346
|
|
|
return "<p>" |
347
|
|
|
+ container.escapeExpression(((helper = (helper = helpers.noPendingOrFailedText || (depth0 != null ? depth0.noPendingOrFailedText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{"name":"noPendingOrFailedText","hash":{},"data":data}) : helper))) |
|
|
|
|
348
|
|
|
+ "</p>\n"; |
|
|
|
|
349
|
|
|
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { |
350
|
|
|
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}); |
|
|
|
|
351
|
|
|
|
352
|
|
|
return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.enabled : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.program(4, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") |
353
|
|
|
+ "<button id=\"ocr-search\">" |
354
|
|
|
+ container.escapeExpression(((helper = (helper = helpers.refreshButtonText || (depth0 != null ? depth0.refreshButtonText : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"refreshButtonText","hash":{},"data":data}) : helper))) |
|
|
|
|
355
|
|
|
+ "</button>"; |
356
|
|
|
},"useData":true,"useDepths":true}); |
357
|
|
|
|
358
|
|
|
/***/ }) |
359
|
|
|
/******/ ]) |
360
|
|
|
}); |
361
|
|
|
; |
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.
Consider:
If you or someone else later decides to put another statement in, only the first statement will be executed.
In this case the statement
b = 42
will always be executed, while the logging statement will be executed conditionally.ensures that the proper code will be executed conditionally no matter how many statements are added or removed.