Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.

Commit 28cd063

Browse files
committed
Added license, added cabinet querying and included url in info window
1 parent 5e6dc0d commit 28cd063

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 FTTx.GR
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

src/components/Map.vue

+37-5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export default {
240240
markedMarker: null,
241241
hamburger: false,
242242
finishedLoading: false,
243+
cabinetQuery: null,
243244
};
244245
},
245246
components: {
@@ -267,11 +268,13 @@ export default {
267268
async mounted() {
268269
this.isLoading = true;
269270
let ref = this;
271+
270272
// add the map to a data object
271273
this.$refs.mapRef.$mapPromise.then((map) => (this.map = map));
272274
this.$root.$on("hamburgerState", (state) => {
273275
this.hamburger = state;
274276
});
277+
275278
// DSLAM LOADING
276279
let dslam = await axios
277280
.get("https://api.fttx.gr/api/v1/centers?limit=0&approved=true")
@@ -311,6 +314,33 @@ export default {
311314
this.paths.push(e[0]);
312315
});
313316
this.isLoading = false;
317+
// cabinet query start
318+
const cabQuery = "cabinet?id=";
319+
if (window.location.href.includes(cabQuery)) {
320+
const cabId = window.location.href.split(cabQuery)[1];
321+
console.log(cabId);
322+
let c = await axios
323+
.get(`https://api.fttx.gr/api/v1/cabinets/${cabId}`)
324+
.then((r) => r);
325+
c = c.data.data;
326+
const marker = new google.maps.Marker({
327+
position: c.position,
328+
map: this.map,
329+
icon: this.markerIcons[c.isp],
330+
});
331+
marker.db = c;
332+
ref.infoWindow(marker);
333+
marker.addListener("click", function () {
334+
ref.infoWindow(marker);
335+
});
336+
this.myCoordinates = {
337+
lat: c.position.lat,
338+
lng: c.position.lng,
339+
};
340+
this.zoom = 17;
341+
this.cabinetQuery = cabId;
342+
}
343+
// cabinet query end
314344
// POLYGON LOADING END -- LOAD EVERYTHING ELSE BUT INVISIBLE (NOTE: This part here is what causing the initial lag spike because there's just too much data. Working on it.)
315345
const initialize = async (page) => {
316346
const results = await axios
@@ -321,6 +351,8 @@ export default {
321351
const cabinets = results.data.data.filter((d) => d.type !== "DSLAM");
322352
this.numberOfCabinets += cabinets.length;
323353
cabinets.forEach((d) => {
354+
// check if a cabinet is queried and if it's stored in cabinetQuery, exclude it from loading because it's already loaded.
355+
if (this.cabinetQuery && d._id === this.cabinetQuery) return;
324356
const marker = new google.maps.Marker({
325357
position: d.position,
326358
map: this.map,
@@ -432,7 +464,9 @@ export default {
432464
marker.db._id
433465
}<br><a style="font-weight: bold; color: purple;" target="_blank" href="${
434466
marker.db.img_url
435-
}">Click Here for image</a>`;
467+
}">Click Here for image</a><br><a style="font-weight: bold; color: purple;" target="_blank" href="https://fttx.gr/cabinet?id=${
468+
marker.db._id
469+
}">URL to this Cabinet</a>`;
436470
const infowindow = new google.maps.InfoWindow({
437471
content: text,
438472
});
@@ -590,10 +624,8 @@ export default {
590624
},
591625
},
592626
async created() {
593-
const cabQuery = "cabinet?id=";
594-
if (window.location.pathname.includes(cabQuery)) {
595-
const cabId = window.location.pathname.split(cabQuery)[1];
596-
}
627+
const ref = this;
628+
//
597629
},
598630
};
599631
</script>

0 commit comments

Comments
 (0)