Commit 85e25477 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Update gadget_erp5_page_map

   Clean up unrequired code
   Use domsugar rather them createElement for simplification
parent a0553cf5
.sensor-status {
min-width: 210px;
}
/* --------------------- CUSTOM MAP ----------------------- */
.custom-map-wrap {
position: relative;
......
......@@ -71,7 +71,9 @@
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
......@@ -246,7 +248,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.17264.3291.60876</string> </value>
<value> <string>1006.58340.40727.23620</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1513789742.97</float>
<float>1693252894.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,8 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- custom script -->
<script src="leaflet.js" type="text/javascript"></script>
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.22055.19881.8430</string> </value>
<value> <string>1009.49086.48551.49459</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1502452463.01</float>
<float>1693252925.17</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint nomen: true, maxlen:200, indent:2*/
/*global window, document, rJS, console, RSVP, L, $, Image */
(function (window, document, rJS, RSVP) {
/*global window, rJS, console, RSVP, L, Image, domsugar */
(function (window, rJS, RSVP, L, domsugar) {
"use strict";
rJS(window)
.ready(function (g) {
g.props = {};
})
.ready(function (g) {
g.props.deferred = new RSVP.defer();
})
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -57,31 +49,12 @@
return gadget.props.deferred.resolve();
});
})
.declareMethod('getContent', function (options) {
var gadget = this,
result = [],
tmp,
i;
for (i = 0; i < gadget.props.new_marker_list.length; i += 1) {
tmp = gadget.props.new_marker_list[i].getLatLng();
result.push({latitude: tmp.lat, longitude: tmp.lng});
}
return result;
})
.declareService(function () {
var gadget = this,
map_element,
latitude,
longitude,
zoom,
marker_list,
new_marker_list = [],
marker_link,
marker_label,
marker_space,
marker_monitor_link,
group,
redIcon,
map,
osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osm,
......@@ -91,7 +64,6 @@
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
marker,
marker_options = {},
queue,
m,
i,
bounds,
......@@ -109,24 +81,21 @@
return gadget.props.deferred.promise;
})
.push(function () {
var l = [],
marker_list = gadget.options.marker_list || [];
var l = [];
marker_list = gadget.options.marker_list || [];
for (i = 0; i < marker_list.length; i += 1) {
l.push(gadget.getUrlFor({command: "change",
options: {jio_key: marker_list[i].jio_key,
page: "slap_controller"}}));
}
l.push(gadget.getSetting("hateoas_url"));
return RSVP.all(l);
})
.push(function (url_list) {
var hateoas_url = url_list.pop();
map_element = gadget.props.element.querySelector(".map"),
latitude = gadget.options.doc.latitude || 0,
longitude = gadget.options.doc.longitude || 0,
zoom = gadget.options.zoom || 0,
marker_list = gadget.options.marker_list || [];
redIcon = L.icon({iconUrl: "hateoas/marker-icon-mod-100-70-10.png",
var map_element = gadget.element.querySelector(".map"),
latitude = gadget.options.doc.latitude || 0,
longitude = gadget.options.doc.longitude || 0,
zoom = gadget.options.zoom || 0,
redIcon = L.icon({iconUrl: "hateoas/marker-icon-mod-100-70-10.png",
shadowUrl: "hateoas/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
......@@ -152,18 +121,9 @@
for (i = 0; i < marker_list.length; i += 1) {
m = marker_list[i];
marker_link = document.createElement("a");
marker_link.href = url_list[i];
marker_link.text = m.doc.title;
marker_link.className = "ui-btn-map";
marker_label = document.createElement("div");
marker_label.appendChild(marker_link);
marker_space = document.createElement("span");
marker_space.innerHTML = " &nbsp; &nbsp; | &nbsp; ";
marker_space.className = "ui-btn-map";
marker_label.appendChild(marker_space);
marker_label = domsugar("div", {}, [
domsugar("a", {href: url_list[i], text: m.doc.title, 'class': "ui-btn-map"})
]);
marker = new L.marker(
[m.doc.latitude || 0, m.doc.longitude || 0],
marker_options
......@@ -200,16 +160,13 @@
container = e.popup._container.querySelector('.leaflet-popup-content-wrapper');
tmp = container.querySelector('.sensor-status');
if (!tmp) {
tmp = document.createElement('div');
tmp.className = 'sensor-status';
tmp.style['min-width'] = '210px';
tmp = domsugar('div', {'class': 'sensor-status'});
container.appendChild(tmp);
e.target._queue.push(function () {
return gadget.declareGadget('gadget_slapos_status.html', {
element: tmp
});
})
.push(function (compute_node) {
}).push(function (compute_node) {
//xxxx repopup to resize popup
new_marker_list[index].openPopup();
return compute_node.render({
......@@ -225,4 +182,4 @@
return RSVP.all(list);
});
});
}(window, document, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, L, domsugar));
\ No newline at end of file
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.49809.16983.53265</string> </value>
<value> <string>1010.50117.59231.38434</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1693251958.55</float>
<float>1693270216.86</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment