disable ui_worldmap if Node-RED Dashboard not installed (#113)
This commit is contained in:
parent
f8a4f4207e
commit
76423e11cd
143
worldmap.html
143
worldmap.html
@ -359,75 +359,82 @@ then by default <code>⌘⇧m</code> - <code>ctrl-shift-m</code> will load the m
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
RED.nodes.registerType('ui_worldmap',{
|
$.get('/.ui-worldmap', function (data) {
|
||||||
category: 'dashboard',
|
if (data === "true") {
|
||||||
color: 'rgb( 63, 173, 181)',
|
RED.nodes.registerType('ui_worldmap',{
|
||||||
defaults: {
|
category: 'dashboard',
|
||||||
group: {type: 'ui_group', required:true},
|
color: 'rgb( 63, 173, 181)',
|
||||||
order: {value: 0},
|
defaults: {
|
||||||
width: {
|
group: {type: 'ui_group', required:true},
|
||||||
value: 0,
|
order: {value: 0},
|
||||||
validate: function(v) {
|
width: {
|
||||||
var valid = true
|
value: 0,
|
||||||
var width = v||0;
|
validate: function(v) {
|
||||||
var currentGroup = $('#node-input-group').val()|| this.group;
|
var valid = true
|
||||||
var groupNode = RED.nodes.node(currentGroup);
|
var width = v||0;
|
||||||
valid = !groupNode || +width <= +groupNode.width;
|
var currentGroup = $('#node-input-group').val()|| this.group;
|
||||||
$("#node-input-size").toggleClass("input-error",!valid);
|
var groupNode = RED.nodes.node(currentGroup);
|
||||||
return valid;
|
valid = !groupNode || +width <= +groupNode.width;
|
||||||
}},
|
$("#node-input-size").toggleClass("input-error",!valid);
|
||||||
height: {value: 0},
|
return valid;
|
||||||
name: {value:""},
|
}},
|
||||||
lat: {value:""},
|
height: {value: 0},
|
||||||
lon: {value:""},
|
name: {value:""},
|
||||||
zoom: {value:""},
|
lat: {value:""},
|
||||||
layer: {value:""},
|
lon: {value:""},
|
||||||
cluster: {value:""},
|
zoom: {value:""},
|
||||||
maxage: {value:""},
|
layer: {value:""},
|
||||||
usermenu: {value:"hide"},
|
cluster: {value:""},
|
||||||
layers: {value:"hide"},
|
maxage: {value:""},
|
||||||
panit: {value:"false"},
|
usermenu: {value:"hide"},
|
||||||
panlock: {value:"false"},
|
layers: {value:"hide"},
|
||||||
zoomlock: {value:"false"},
|
panit: {value:"false"},
|
||||||
hiderightclick: {value:"true"},
|
panlock: {value:"false"},
|
||||||
coords: {value:"false"},
|
zoomlock: {value:"false"},
|
||||||
showgrid: {value:"false"},
|
hiderightclick: {value:"true"},
|
||||||
path: {value:"/worldmap"}
|
coords: {value:"false"},
|
||||||
},
|
showgrid: {value:"false"},
|
||||||
inputs:1,
|
path: {value:"/worldmap"}
|
||||||
outputs:0,
|
},
|
||||||
icon: "white-globe.png",
|
inputs:1,
|
||||||
align: "right",
|
outputs:0,
|
||||||
paletteLabel: "worldmap",
|
icon: "white-globe.png",
|
||||||
label: function() {
|
align: "right",
|
||||||
return this.name||(this.path.charAt(0)==='/'?this.path.substr(1):this.path)||"world map";
|
paletteLabel: "worldmap",
|
||||||
},
|
label: function() {
|
||||||
labelStyle: function() {
|
return this.name||(this.path.charAt(0)==='/'?this.path.substr(1):this.path)||"world map";
|
||||||
return this.name?"node_label_italic":"";
|
},
|
||||||
},
|
labelStyle: function() {
|
||||||
info: function() {
|
return this.name?"node_label_italic":"";
|
||||||
return 'The map can also be found [here]('+RED.settings.httpNodeRoot.slice(0,-1)+this.path+').';
|
},
|
||||||
},
|
info: function() {
|
||||||
oneditprepare: function() {
|
return 'The map can also be found [here]('+RED.settings.httpNodeRoot.slice(0,-1)+this.path+').';
|
||||||
$("#node-input-size").elementSizer({
|
},
|
||||||
width: "#node-input-width",
|
oneditprepare: function() {
|
||||||
height: "#node-input-height",
|
$("#node-input-size").elementSizer({
|
||||||
group: "#node-input-group"
|
width: "#node-input-width",
|
||||||
|
height: "#node-input-height",
|
||||||
|
group: "#node-input-group"
|
||||||
|
});
|
||||||
|
if ($("#node-input-path").val() === undefined) {
|
||||||
|
$("#node-input-path").val("worldmap");
|
||||||
|
this.path = "worldmap";
|
||||||
|
}
|
||||||
|
if ($("#node-input-hiderightclick").val() === null) {
|
||||||
|
$("#node-input-hiderightclick").val("false");
|
||||||
|
this.hiderightclick = "false";
|
||||||
|
}
|
||||||
|
if ($("#node-input-coords").val() === null) {
|
||||||
|
$("#node-input-coords").val("none");
|
||||||
|
this.coords = "none";
|
||||||
|
}
|
||||||
|
$("#node-input-zoom").spinner({min:0, max:18});
|
||||||
|
$("#node-input-cluster").spinner({min:0, max:19});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if ($("#node-input-path").val() === undefined) {
|
}
|
||||||
$("#node-input-path").val("worldmap");
|
else {
|
||||||
this.path = "worldmap";
|
console.log("ui_worldmap: Node-RED not found.");
|
||||||
}
|
|
||||||
if ($("#node-input-hiderightclick").val() === null) {
|
|
||||||
$("#node-input-hiderightclick").val("false");
|
|
||||||
this.hiderightclick = "false";
|
|
||||||
}
|
|
||||||
if ($("#node-input-coords").val() === null) {
|
|
||||||
$("#node-input-coords").val("none");
|
|
||||||
this.coords = "none";
|
|
||||||
}
|
|
||||||
$("#node-input-zoom").spinner({min:0, max:18});
|
|
||||||
$("#node-input-cluster").spinner({min:0, max:19});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
90
worldmap.js
90
worldmap.js
@ -152,52 +152,58 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ui = undefined;
|
var ui = undefined;
|
||||||
|
try {
|
||||||
|
ui = RED.require("node-red-dashboard")(RED);
|
||||||
|
|
||||||
function UIWorldMap(config) {
|
if(ui) {
|
||||||
try {
|
function UIWorldMap(config) {
|
||||||
var node = this;
|
try {
|
||||||
if(ui === undefined) {
|
var node = this;
|
||||||
ui = RED.require("node-red-dashboard")(RED);
|
worldMap(node, config);
|
||||||
}
|
var done = null;
|
||||||
worldMap(node, config);
|
if (checkConfig(node, config)) {
|
||||||
var done = null;
|
var html = HTML(ui, config);
|
||||||
if (checkConfig(node, config)) {
|
done = ui.addWidget({
|
||||||
var html = HTML(ui, config);
|
node: node,
|
||||||
done = ui.addWidget({
|
order: config.order,
|
||||||
node: node,
|
group: config.group,
|
||||||
order: config.order,
|
width: config.width,
|
||||||
group: config.group,
|
height: config.height,
|
||||||
width: config.width,
|
format: html,
|
||||||
height: config.height,
|
templateScope: "local",
|
||||||
format: html,
|
emitOnlyNewValues: false,
|
||||||
templateScope: "local",
|
forwardInputMessages: false,
|
||||||
emitOnlyNewValues: false,
|
storeFrontEndInputAsState: false,
|
||||||
forwardInputMessages: false,
|
convertBack: function (value) {
|
||||||
storeFrontEndInputAsState: false,
|
return value;
|
||||||
convertBack: function (value) {
|
},
|
||||||
return value;
|
beforeEmit: function(msg, value) {
|
||||||
},
|
return { msg: { items: value } };
|
||||||
beforeEmit: function(msg, value) {
|
},
|
||||||
return { msg: { items: value } };
|
beforeSend: function (msg, orig) {
|
||||||
},
|
if (orig) { return orig.msg; }
|
||||||
beforeSend: function (msg, orig) {
|
},
|
||||||
if (orig) { return orig.msg; }
|
initController: function($scope, events) {
|
||||||
},
|
}
|
||||||
initController: function($scope, events) {
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
node.on("close", function() {
|
||||||
|
if (done) {
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
RED.nodes.registerType("ui_worldmap", UIWorldMap);
|
||||||
catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
}
|
||||||
node.on("close", function() {
|
|
||||||
if (done) {
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("ui_worldmap", UIWorldMap);
|
catch(e) {
|
||||||
|
RED.log.info("Node-RED Dashboard not found.");
|
||||||
|
RED.log.info("ui_worldmap not installed.");
|
||||||
|
}
|
||||||
|
|
||||||
var WorldMapIn = function(n) {
|
var WorldMapIn = function(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
@ -341,4 +347,8 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("worldmap-tracks",WorldMapTracks);
|
RED.nodes.registerType("worldmap-tracks",WorldMapTracks);
|
||||||
|
|
||||||
|
RED.httpNode.get("/.ui-worldmap", function(req, res) {
|
||||||
|
res.send(ui ? "true": "false");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user