@gregoriusrippenstein/node-red-contrib-introspection 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -234,7 +234,7 @@
234
234
  generates an SVG and posts that to the POST endpoint (that is assumed)
235
235
  to be running. If not, there will be a console error.
236
236
  */
237
- RED.comms.subscribe('introspect:screenshot-timer-tripped', (event,data) => {
237
+ RED.comms.subscribe('introspect:screenshot-trigger-tripped', (event,data) => {
238
238
  if ( data.msg == "timer-tripped" ) {
239
239
 
240
240
  if ( data.notification != "off" ) {
@@ -243,24 +243,49 @@
243
243
 
244
244
  var notification = data.notification;
245
245
  nr_intro_generate_svg( (svgdata) => {
246
- // TODO the post will hit a 'Request too large' limit with the
247
- // TODO SVG gets larger than XX-MB (got this when an svg of 5.5MB
248
- // TODO but an svg with 4.1MB went through). No immediate fix, would
249
- // TODO good to create parts that can be manually joined using the
250
- // TODO 'join' node.
251
246
  $.ajax({
252
247
  type: "POST",
253
248
  url: "/screenshot",
249
+ dataType: "image/svg+xml;charset=utf-8",
254
250
  data: {
255
251
  ...data,
256
252
  d: svgdata
257
253
  },
258
- complete: (_ignore) => {
259
- if ( notification != "off" ) {
260
- RED.notify("Screenshot posted", { type: "success" });
261
- }
254
+ complete: (obj) => {
255
+ switch( obj.status ) {
256
+ case 413:
257
+ // apiMaxLength in the settings.js is set to 5mb by default,
258
+ // if svg larger than that, need to increase the limit.
259
+ // Provide a hint to that setting in the error message.
260
+ RED.notify(
261
+ "Screenshot too large, increase apiMaxLength in settings.js.", {
262
+ type: "error"
263
+ }
264
+ );
265
+ break;
266
+ case 404:
267
+ // Http-in POST node is missing
268
+ RED.notify(
269
+ "Missing http-in node: method: POST, path: /screenshot.", {
270
+ type: "error"
271
+ }
272
+ );
273
+ break;
274
+ case 200:
275
+ if ( notification != "off" ) {
276
+ RED.notify("Screenshot successfully posted", {
277
+ type: "success"
278
+ });
279
+ }
280
+ break;
281
+ default:
282
+ RED.notify(
283
+ "Screenshot failed: " + obj.statusText + " " + obj.status, {
284
+ type: "error"
285
+ }
286
+ );
287
+ };
262
288
  },
263
- dataType: "image/svg+xml;charset=utf-8"
264
289
  });
265
290
  });
266
291
  }
@@ -10,7 +10,7 @@ module.exports = function(RED) {
10
10
  });
11
11
 
12
12
  node.on("input", function(msg, send, done) {
13
- RED.comms.publish("introspect:screenshot-timer-tripped",
13
+ RED.comms.publish("introspect:screenshot-trigger-tripped",
14
14
  RED.util.encodeObject({
15
15
  ...msg,
16
16
  msg: "timer-tripped",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/node-red-contrib-introspection",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "keywords": [
5
5
  "node-red"
6
6
  ],