Commit 87e39c3b authored by Manggar Mahardhika's avatar Manggar Mahardhika

push

parent 5a8d85e8
# from django.contrib import admin
# from django.urls import path, include
# from django.contrib.auth import views as auth_views
# from . import views
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as auth_views
from . import views
# app_name = 'apps'
# urlpatterns = [
# path('', views.Dashboard.as_view(), name='dashboard'),
# ]
\ No newline at end of file
app_name = 'api'
urlpatterns = [
path('search_auto', views.search_auto, name='search')
]
\ No newline at end of file
from django.shortcuts import render
from rest_framework import status
from rest_framework.decorators import api_view, renderer_classes
from rest_framework.response import Response
from django.db import connection as conn
# Create your views here.
from rest_framework.renderers import JSONRenderer, TemplateHTMLRenderer
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def search_auto(request):
nama_desa = request.GET.get('namadesa')
with conn.cursor() as desa:
desa.execute(f"SELECT id, desa, kecamatan FROM geo_data_kelurahan WHERE desa ILIKE '{nama_desa}%' order by desa ASC limit 5")
all = desa.fetchall()
data = {'nama_des':all}
return Response(data)
\ No newline at end of file
......@@ -10,6 +10,10 @@ class Dashboard(generic.TemplateView):
# @method_decorator(login_required(login_url='maps:login'))
def get(self, request):
with conn.cursor() as all_:
all_.execute("SELECT * from global_oku")
all = all_.fetchall()
with conn.cursor() as kel:
kel.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (kode_desa, desa, kecamatan, kab_kota, provinsi, jumlah_pen, jumlah_kk, luas_desa),'penduduk', (pria, wanita, belum_kawin, kawin, cerai_hidup, cerai_mati, wajib_ktp, islam, kristen, khatolik, hindu, budha, konghucu, kepercayaan_lain, u0, u5, u10, u15, u20, u25, u30, u35, u40, u45, u50, u55, u60, u65, u70, u75),'pekerjaan_pendidikan', (tidak_sekolah, belum_tamat, tamat_sd, sltp, slta, diploma_i, diploma_ii, diploma_iv, strata_ii, strata_iii, tidak_bekerja, aparatur_pemerintah, tenaga_pendidik, wiraswasta, pertanian, tenaga_kesehatan, pensiunan, pegawai, tentara, kepolisian, pedagang, petani, peternak, nelayan, karyawan, buruh, pembantu, tukang, pendeta, pastor, ustadz, dosen, guru, pilot, pengacara, notaris, arsitek, akuntan, konsultan, dokter, bidan, perawat, psikiater, sopir, lainnya),'geometry', ST_AsGeoJSON(geom :: geometry) :: json) from geo_data_kelurahan")
kel_res_ = kel.fetchall()
......@@ -26,10 +30,12 @@ class Dashboard(generic.TemplateView):
for i in kel_res_:
kel_res.append(i[0])
print(all)
context = {
'title':'NA - Dashboard',
'kelurahan':kel_res,
'kecamatan':kec_res,
'global':all[0]
}
return render (request, self.template_name, context)
......@@ -67,3 +73,4 @@ class SearchPolygon(generic.TemplateView):
def post(self, request):
return render (request, self.template_name, {"title":"NA - CheckByPolygon"})#,"polbang":polbang,"poltrees":poltrees,'jumlah_bangunan' : len(polbang)+len(poltrees), 'batas_co':zon, 'search_by': 'polygon', 'address':'None', 'lat':lat, 'lng':lng, 'zoom':zoom, 'line_jalan':line_jalan})
......@@ -21,7 +21,7 @@ from django.conf.urls.static import static
urlpatterns = [
path('', include('Application.urls')),
# path('api/', include('API.urls')),
path('api/', include('API.urls')),
path('admin/', admin.site.urls),
]
This diff is collapsed.
......@@ -28,7 +28,6 @@ maps = L.tileLayer('https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', {
OpenStreetMap.onclick = function() {
maps = L.tileLayer("https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", {
attribution: "Data by \u0026copy; \u003ca href=\"http://openstreetmap.org\"\u003eOpenStreetMap\u003c/a\u003e",
maxZoom: 22,
minZoom: 3,
}).addTo(map);
......@@ -37,7 +36,6 @@ OpenStreetMap.onclick = function() {
WorldImagery.onclick = function() {
maps = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "Data by \u0026copy; \u003ca href=\"http://openstreetmap.org\"\u003eESRI\u003c/a\u003e",
maxZoom: 22,
minZoom: 3,
}).addTo(map);
......
/* ------------------------------------------------------------------------------
*
* # Dynamic tree views
*
* Specific JS code additions for extra_trees.html page
*
* Version: 1.0
* Latest update: Aug 1, 2015
*
* ---------------------------------------------------------------------------- */
$(function() {
// Basic setup
// ------------------------------
// Basic example
$(".tree-default").fancytree({
init: function(event, data) {
$('.has-tooltip .fancytree-title').tooltip();
}
});
// Load JSON data
$(".tree-ajax").fancytree({
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
init: function(event, data) {
$('.has-tooltip .fancytree-title').tooltip();
}
});
// Embed JSON data
$(".tree-json").fancytree({
init: function(event, data) {
$('.has-tooltip .fancytree-title').tooltip();
}
});
// Child counter
$(".tree-child-count").fancytree({
extensions: ["childcounter"],
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
childcounter: {
deep: true,
hideZeros: true,
hideExpanded: true
},
init: function(event, data) {
$('.has-tooltip .fancytree-title').tooltip();
}
});
// Drag and drop support
$(".tree-drag").fancytree({
extensions: ["dnd"],
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
dnd: {
autoExpandMS: 400,
focusOnClick: true,
preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
dragStart: function(node, data) {
return true;
},
dragEnter: function(node, data) {
return true;
},
dragDrop: function(node, data) {
// This function MUST be defined to enable dropping of items on the tree.
data.otherNode.moveTo(node, data.hitMode);
}
},
init: function(event, data) {
$('.has-tooltip .fancytree-title').tooltip();
}
});
// Editable nodes
$(".tree-editable").fancytree({
extensions: ["edit"],
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
edit: {
adjustWidthOfs: 0,
inputCss: {minWidth: "0"},
triggerStart: ["f2", "dblclick", "shift+click", "mac+enter"],
save: function(event, data) {
alert("save " + data.input.val()); // Save data.input.val() or return false to keep editor open
}
}
});
// Selectable nodes
// ------------------------------
// Single selection
$(".tree-radio").fancytree({
checkbox: true,
selectMode: 1,
source: {
url: "assets/demo_data/fancytree/fancytree.json"
}
});
// Multiple selection
$(".tree-checkbox").fancytree({
checkbox: true,
selectMode: 2,
source: {
url: "assets/demo_data/fancytree/fancytree.json"
}
});
// Disable selections
$(".tree-checkbox-options").fancytree({
checkbox: true,
selectMode: 2
});
// Hierarchical select
$(".tree-checkbox-hierarchical").fancytree({
checkbox: true,
selectMode: 3
});
//
// Toggle checkbox state
//
// Initialize
$(".tree-checkbox-toggle").fancytree({
checkbox: true,
selectMode: 2,
source: {
url: "assets/demo_data/fancytree/fancytree.json"
}
});
// Initialize switchery toggle
var switcherySelect = document.querySelector('.switchery-select');
var initSelect = new Switchery(switcherySelect);
// Change checkbox states
switcherySelect.onchange = function() {
if(switcherySelect.checked) {
$(".tree-checkbox-toggle").fancytree("getTree").visit(function(node){
node.setSelected(true);
});
return false;
}
else {
$(".tree-checkbox-toggle").fancytree("getTree").visit(function(node){
node.setSelected(false);
});
return false;
}
};
// Advanced examples
// ------------------------------
//
// Toggle state
//
// Initialize switchery toggle
var switchery = document.querySelector('#tree-disabled');
var init = new Switchery(switchery);
// Do something on state change
switchery.onchange = function() {
if(switchery.checked) {
$(".tree-toggle").fancytree("disable");
}
else {
$(".tree-toggle").fancytree("enable");
}
};
// Initialize
$(".tree-toggle").fancytree({
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
init: function(event, data) {
$('.has-tooltip .fancytree-title').tooltip();
}
});
//
// Sorting
//
// Initialize
$(".tree-sorting").fancytree();
// Sort tree
$('.sort-tree').on('click', function() {
var node = $(".tree-sorting").fancytree("getRootNode");
node.sortChildren(null, true);
});
// Sort active nodes
$('.sort-branch').on('click', function() {
var node = $(".tree-sorting").fancytree("getActiveNode");
// Custom compare function (optional) that sorts case insensitive
var cmp = function(a, b) {
a = a.title.toLowerCase();
b = b.title.toLowerCase();
return a > b ? 1 : a < b ? -1 : 0;
};
node.sortChildren(cmp, false);
});
//
// Tree persistence
//
// Initialize
$(".tree-persistence").fancytree({
extensions: ["persist"],
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
checkbox: true,
persist: {
overrideSource: false, // true: cookie takes precedence over `source` data attributes.
store: "auto" // 'cookie', 'local': use localStore, 'session': sessionStore
},
postProcess: function(event, data) {
var prefix = data.node.getIndexHier() + ".";
$.each(data.response, function(idx, childEntry) {
if( childEntry.key == null ) {
childEntry.key = prefix + (idx + 1);
childEntry.title += " (" + childEntry.key + ")";
}
})
}
});
var tree5 = $(".tree-persistence").fancytree("getTree");
// Reset cookies on button click
$('.reset-cookies').on('click', function() {
tree5.clearCookies();
});
//
// Table tree
//
$(".tree-table").fancytree({
extensions: ["table"],
checkbox: true,
table: {
indentation: 20, // indent 20px per node level
nodeColumnIdx: 2, // render the node title into the 2nd column
checkboxColumnIdx: 0 // render the checkboxes into the 1st column
},
source: {
url: "assets/demo_data/fancytree/fancytree.json"
},
lazyLoad: function(event, data) {
data.result = {url: "ajax-sub2.json"}
},
renderColumns: function(event, data) {
var node = data.node,
$tdList = $(node.tr).find(">td");
// (index #0 is rendered by fancytree by adding the checkbox)
$tdList.eq(1).text(node.getIndexHier()).addClass("alignRight");
// (index #2 is rendered by fancytree)
$tdList.eq(3).text(node.key);
$tdList.eq(4).addClass('text-center').html("<input type='checkbox' class='styled' name='like' value='" + node.key + "'>");
// Style checkboxes
$(".styled").uniform({radioClass: 'choice'});
}
});
// Handle custom checkbox clicks
$(".tree-table").delegate("input[name=like]", "click", function (e){
var node = $.ui.fancytree.getNode(e),
$input = $(e.target);
e.stopPropagation(); // prevent fancytree activate for this row
if($input.is(":checked")){
alert("like " + $input.val());
}
else{
alert("dislike " + $input.val());
}
});
});
This diff is collapsed.
// Extending Fancytree
// ===================
//
// See also the [live demo](http://wwwendt.de/tech/fancytree/demo/sample-ext-childcounter.html) of this code.
//
// Every extension should have a comment header containing some information
// about the author, copyright and licensing. Also a pointer to the latest
// source code.
// Prefix with `/*!` so the comment is not removed by the minifier.
/*!
* jquery.fancytree.childcounter.js
*
* Add a child counter bubble to tree nodes.
* (Extension module for jquery.fancytree.js: https://github.com/mar10/fancytree/)
*
* Copyright (c) 2008-2017, Martin Wendt (http://wwWendt.de)
*
* Released under the MIT license
* https://github.com/mar10/fancytree/wiki/LicenseInfo
*
* @version 2.22.1
* @date 2017-04-21T05:55:46Z
*/
// To keep the global namespace clean, we wrap everything in a closure
;(function($, undefined) {
// Consider to use [strict mode](http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/)
"use strict";
// The [coding guidelines](http://contribute.jquery.org/style-guide/js/)
// require jshint compliance.
// But for this sample, we want to allow unused variables for demonstration purpose.
/*jshint unused:false */
// Adding methods
// --------------
// New member functions can be added to the `Fancytree` class.
// This function will be available for every tree instance:
//
// var tree = $("#tree").fancytree("getTree");
// tree.countSelected(false);
$.ui.fancytree._FancytreeClass.prototype.countSelected = function(topOnly){
var tree = this,
treeOptions = tree.options;
return tree.getSelectedNodes(topOnly).length;
};
// The `FancytreeNode` class can also be easily extended. This would be called
// like
// node.updateCounters();
//
// It is also good practice to add a docstring comment.
/**
* [ext-childcounter] Update counter badges for `node` and its parents.
* May be called in the `loadChildren` event, to update parents of lazy loaded
* nodes.
* @alias FancytreeNode#updateCounters
* @requires jquery.fancytree.childcounters.js
*/
$.ui.fancytree._FancytreeNodeClass.prototype.updateCounters = function(){
var node = this,
$badge = $("span.fancytree-childcounter", node.span),
extOpts = node.tree.options.childcounter,
count = node.countChildren(extOpts.deep);
node.data.childCounter = count;
if( (count || !extOpts.hideZeros) && (!node.isExpanded() || !extOpts.hideExpanded) ) {
if( !$badge.length ) {
$badge = $("<span class='fancytree-childcounter'/>").appendTo($("span.fancytree-icon", node.span));
}
$badge.text(count);
} else {
$badge.remove();
}
if( extOpts.deep && !node.isTopLevel() && !node.isRoot() ) {
node.parent.updateCounters();
}
};
// Finally, we can extend the widget API and create functions that are called
// like so:
//
// $("#tree").fancytree("widgetMethod1", "abc");
$.ui.fancytree.prototype.widgetMethod1 = function(arg1){
var tree = this.tree;
return arg1;
};
// Register a Fancytree extension
// ------------------------------
// A full blown extension, extension is available for all trees and can be
// enabled like so (see also the [live demo](http://wwwendt.de/tech/fancytree/demo/sample-ext-childcounter.html)):
//
// <script src="../src/jquery.fancytree.js"></script>
// <script src="../src/jquery.fancytree.childcounter.js"></script>
// ...
//
// $("#tree").fancytree({
// extensions: ["childcounter"],
// childcounter: {
// hideExpanded: true
// },
// ...
// });
//
/* 'childcounter' extension */
$.ui.fancytree.registerExtension({
// Every extension must be registered by a unique name.
name: "childcounter",
// Version information should be compliant with [semver](http://semver.org)
version: "2.22.1",
// Extension specific options and their defaults.
// This options will be available as `tree.options.childcounter.hideExpanded`
options: {
deep: true,
hideZeros: true,
hideExpanded: false
},
// Attributes other than `options` (or functions) can be defined here, and
// will be added to the tree.ext.EXTNAME namespace, in this case `tree.ext.childcounter.foo`.
// They can also be accessed as `this._local.foo` from within the extension
// methods.
foo: 42,
// Local functions are prefixed with an underscore '_'.
// Callable as `this._local._appendCounter()`.
_appendCounter: function(bar){
var tree = this;
},
// **Override virtual methods for this extension.**
//
// Fancytree implements a number of 'hook methods', prefixed by 'node...' or 'tree...'.
// with a `ctx` argument (see [EventData](http://www.wwwendt.de/tech/fancytree/doc/jsdoc/global.html#EventData)
// for details) and an extended calling context:<br>
// `this` : the Fancytree instance<br>
// `this._local`: the namespace that contains extension attributes and private methods (same as this.ext.EXTNAME)<br>
// `this._super`: the virtual function that was overridden (member of previous extension or Fancytree)
//
// See also the [complete list of available hook functions](http://www.wwwendt.de/tech/fancytree/doc/jsdoc/Fancytree_Hooks.html).
/* Init */
// `treeInit` is triggered when a tree is initalized. We can set up classes or
// bind event handlers here...
treeInit: function(ctx){
var tree = this, // same as ctx.tree,
opts = ctx.options,
extOpts = ctx.options.childcounter;
// Optionally check for dependencies with other extensions
/* this._requireExtension("glyph", false, false); */
// Call the base implementation
this._superApply(arguments);
// Add a class to the tree container
this.$container.addClass("fancytree-ext-childcounter");
},
// Destroy this tree instance (we only call the default implementation, so
// this method could as well be omitted).
treeDestroy: function(ctx){
this._superApply(arguments);
},
// Overload the `renderTitle` hook, to append a counter badge
nodeRenderTitle: function(ctx, title) {
var node = ctx.node,
extOpts = ctx.options.childcounter,
count = (node.data.childCounter == null) ? node.countChildren(extOpts.deep) : +node.data.childCounter;
// Let the base implementation render the title
// We use `_super()` instead of `_superApply()` here, since it is a little bit
// more performant when called often
this._super(ctx, title);
// Append a counter badge
if( (count || ! extOpts.hideZeros) && (!node.isExpanded() || !extOpts.hideExpanded) ){
$("span.fancytree-icon", node.span).append($("<span class='fancytree-childcounter'/>").text(count));
}
},
// Overload the `setExpanded` hook, so the counters are updated
nodeSetExpanded: function(ctx, flag, opts) {
var tree = ctx.tree,
node = ctx.node;
// Let the base implementation expand/collapse the node, then redraw the title
// after the animation has finished
return this._superApply(arguments).always(function(){
tree.nodeRenderTitle(ctx);
});
}
// End of extension definition
});
// End of namespace closure
}(jQuery));
// $(window).on("load", function() {
// loaderPage(true);
// });
$(document).ready(function() {
// loaderPage(true);
const $valueSpan = $('.valueSpan');
const $value_address = $('#slider-address');
const $value_point = $('#slider-point');
$valueSpan.html($value_address.val());
$value_address.on('input change', () => {
$valueSpan.html($value_address.val());
});
$valueSpan.html($value_point.val());
$value_point.on('input change', () => {
$valueSpan.html($value_point.val());
});
});
var lat, lng, latlng;
var container = $(".leaflet-control-layers")[0];
var markerClusters = new L.MarkerClusterGroup({
spiderfyOnMaxZoom: true,
showCoverageOnHover: false,
zoomToBoundsOnClick: true,
disableClusteringAtZoom: 16
});
var marker = {};
$(window).resize(function() {
sizeLayerControl();
});
if (!("ontouchstart" in window)) {
$(document).on("mouseover", ".feature-row", function(e) {
highlight.clearLayers().addLayer(L.circleMarker([$(this).attr("lat"), $(this).attr("lng")], highlightStyle));
});
}
$(document).on("mouseout", ".feature-row", clearHighlight);
$("#about-btn").click(function() {
$("#aboutModal").modal("show");
$(".navbar-collapse.in").collapse("hide");
return false;
});
$("#login-btn").click(function() {
$("#loginModal").modal("show");
$(".navbar-collapse.in").collapse("hide");
return false;
});
$("#sid").click(function() {
$("#sid").css('display', 'none');
$("#sidebar").css('display', 'block');
$("#offsid").css('display', 'block');
});
$("#offsid").click(function() {
$("#offsid").css('display', 'none');
$("#sidebar").css('display', 'none');
$("#sid").css('display', 'block');
});
$("#button_hide").click(function() {
$("#thisFooter").css('display', 'none');
$("#button_unhide").css('display', 'block');
})
$("#button_unhide").click(function() {
$("#thisFooter").css('display', 'block');
$("#button_unhide").css('display', 'none');
})
function sizeLayerControl() {
$(".leaflet-control-layers").css("max-height", $("#map").height() - 50);
}
function clearHighlight() {
highlight.clearLayers();
}
var highlight = L.geoJson(null);
var highlightStyle = {
stroke: false,
fillColor: "#00FFFF",
fillOpacity: 0.7,
radius: 10
};
map.on("click", function(e) {
highlight.clearLayers();
});
function updateAttribution(e) {
$.each(map._layers, function(index, layer) {
if (layer.getAttribution) {
$("#attribution").html((layer.getAttribution()));
}
});
}
map.on("layeradd", updateAttribution);
map.on("layerremove", updateAttribution);
var attributionControl = L.control({
position: "topleft"
});
attributionControl.onAdd = function(map) {
var div = L.DomUtil.create("div", "leaflet-control-attribution");
return div;
};
map.addControl(attributionControl);
var zoomControl = L.control.zoom({
position: "topleft"
}).addTo(map);
var locateControl = L.control.locate({
position: "topleft",
drawCircle: false,
follow: true,
setView: true,
keepCurrentZoomLevel: false,
markerStyle: {
weight: 1,
opacity: 0.8,
fillOpacity: 0.8
},
circleStyle: {
weight: 1,
clickable: false
},
icon: "fa fa-map-marker",
metric: false,
strings: {
title: "My location",
},
locateOptions: {}
}).addTo(map);
if (document.body.clientWidth <= 767) {
var isCollapsed = true;
} else {
var isCollapsed = false;
}
$("#featureModal").on("hidden.bs.modal", function(e) {
$(document).on("mouseout", ".feature-row", clearHighlight);
});
\ No newline at end of file
This diff is collapsed.
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