Initial commit
This commit is contained in:
228
public/assets/js/districtparams.js
Normal file
228
public/assets/js/districtparams.js
Normal file
@@ -0,0 +1,228 @@
|
||||
// Store Settings Page JavaScript
|
||||
|
||||
// Back button functionality
|
||||
function goBack() {
|
||||
if (window.history.length > 1) {
|
||||
window.history.back();
|
||||
} else {
|
||||
window.location.href = "index.html";
|
||||
}
|
||||
}
|
||||
|
||||
// Search functionality
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const searchInput = document.getElementById("searchInput");
|
||||
|
||||
if (searchInput) {
|
||||
searchInput.addEventListener("input", function (e) {
|
||||
const searchQuery = e.target.value.toLowerCase().trim();
|
||||
|
||||
// Get all settings cards
|
||||
const settingsCards = document.querySelectorAll(".settings-grid .col-12");
|
||||
// Get all integration cards
|
||||
const integrationCards = document.querySelectorAll(
|
||||
".integrations-grid .col-12"
|
||||
);
|
||||
|
||||
// Filter settings cards
|
||||
settingsCards.forEach((cardCol) => {
|
||||
const card = cardCol.querySelector(".settings-card");
|
||||
const title = card
|
||||
.querySelector(".card-title")
|
||||
.textContent.toLowerCase();
|
||||
const description = card
|
||||
.querySelector(".card-description")
|
||||
.textContent.toLowerCase();
|
||||
|
||||
if (
|
||||
title.includes(searchQuery) ||
|
||||
description.includes(searchQuery) ||
|
||||
searchQuery === ""
|
||||
) {
|
||||
cardCol.style.display = "";
|
||||
} else {
|
||||
cardCol.style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
// Filter integration cards
|
||||
integrationCards.forEach((cardCol) => {
|
||||
const card = cardCol.querySelector(".integration-card");
|
||||
const title = card
|
||||
.querySelector(".integration-name")
|
||||
.textContent.toLowerCase();
|
||||
const description = card
|
||||
.querySelector(".integration-description")
|
||||
.textContent.toLowerCase();
|
||||
|
||||
if (
|
||||
title.includes(searchQuery) ||
|
||||
description.includes(searchQuery) ||
|
||||
searchQuery === ""
|
||||
) {
|
||||
cardCol.style.display = "";
|
||||
} else {
|
||||
cardCol.style.display = "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Integration connect/disconnect functionality
|
||||
const integrationCards = document.querySelectorAll(".integration-card");
|
||||
|
||||
integrationCards.forEach((card) => {
|
||||
const connectBtn = card.querySelector(".connect-btn");
|
||||
const disconnectBtn = card.querySelector(".disconnect-btn");
|
||||
|
||||
// Handle Connect button click
|
||||
if (connectBtn) {
|
||||
connectBtn.addEventListener("click", function () {
|
||||
// Create connected status elements
|
||||
const connectedStatus = document.createElement("div");
|
||||
connectedStatus.className = "connected-status";
|
||||
|
||||
const badge = document.createElement("span");
|
||||
badge.className = "badge connected-badge mb-2";
|
||||
badge.innerHTML =
|
||||
'<i class="fas fa-circle me-1" style="font-size: 0.5rem"></i> Connected';
|
||||
|
||||
const newDisconnectBtn = document.createElement("button");
|
||||
newDisconnectBtn.className = "btn disconnect-btn";
|
||||
newDisconnectBtn.textContent = "Disconnect";
|
||||
|
||||
connectedStatus.appendChild(badge);
|
||||
connectedStatus.appendChild(newDisconnectBtn);
|
||||
|
||||
// Replace connect button with connected status
|
||||
connectBtn.replaceWith(connectedStatus);
|
||||
|
||||
// Add event listener to new disconnect button
|
||||
newDisconnectBtn.addEventListener("click", function () {
|
||||
// Show confirmation dialog
|
||||
const integrationName =
|
||||
card.querySelector(".integration-name").textContent;
|
||||
if (
|
||||
confirm(`Are you sure you want to disconnect ${integrationName}?`)
|
||||
) {
|
||||
// Create new connect button
|
||||
const newConnectBtn = document.createElement("button");
|
||||
newConnectBtn.className = "btn connect-btn";
|
||||
newConnectBtn.innerHTML =
|
||||
'Connect <i class="fas fa-arrow-right ms-2"></i>';
|
||||
|
||||
// Replace connected status with connect button
|
||||
connectedStatus.replaceWith(newConnectBtn);
|
||||
|
||||
// Add event listener to new connect button
|
||||
newConnectBtn.addEventListener("click", function () {
|
||||
// Recursively handle connect (reuse the same logic)
|
||||
newConnectBtn.click();
|
||||
});
|
||||
|
||||
// Re-attach the connect handler
|
||||
attachConnectHandler(newConnectBtn, card);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Disconnect button click
|
||||
if (disconnectBtn) {
|
||||
disconnectBtn.addEventListener("click", function () {
|
||||
const integrationName =
|
||||
card.querySelector(".integration-name").textContent;
|
||||
if (
|
||||
confirm(`Are you sure you want to disconnect ${integrationName}?`)
|
||||
) {
|
||||
const connectedStatus = card.querySelector(".connected-status");
|
||||
|
||||
// Create new connect button
|
||||
const newConnectBtn = document.createElement("button");
|
||||
newConnectBtn.className = "btn connect-btn";
|
||||
newConnectBtn.innerHTML =
|
||||
'Connect <i class="fas fa-arrow-right ms-2"></i>';
|
||||
|
||||
// Replace connected status with connect button
|
||||
connectedStatus.replaceWith(newConnectBtn);
|
||||
|
||||
// Add event listener to new connect button
|
||||
attachConnectHandler(newConnectBtn, card);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Helper function to attach connect handler
|
||||
function attachConnectHandler(button, card) {
|
||||
button.addEventListener("click", function () {
|
||||
// Create connected status elements
|
||||
const connectedStatus = document.createElement("div");
|
||||
connectedStatus.className = "connected-status";
|
||||
|
||||
const badge = document.createElement("span");
|
||||
badge.className = "badge connected-badge mb-2";
|
||||
badge.innerHTML =
|
||||
'<i class="fas fa-circle me-1" style="font-size: 0.5rem"></i> Connected';
|
||||
|
||||
const newDisconnectBtn = document.createElement("button");
|
||||
newDisconnectBtn.className = "btn disconnect-btn";
|
||||
newDisconnectBtn.textContent = "Disconnect";
|
||||
|
||||
connectedStatus.appendChild(badge);
|
||||
connectedStatus.appendChild(newDisconnectBtn);
|
||||
|
||||
// Replace connect button with connected status
|
||||
button.replaceWith(connectedStatus);
|
||||
|
||||
// Add event listener to new disconnect button
|
||||
newDisconnectBtn.addEventListener("click", function () {
|
||||
const integrationName =
|
||||
card.querySelector(".integration-name").textContent;
|
||||
if (
|
||||
confirm(`Are you sure you want to disconnect ${integrationName}?`)
|
||||
) {
|
||||
// Create new connect button
|
||||
const newConnectBtn = document.createElement("button");
|
||||
newConnectBtn.className = "btn connect-btn";
|
||||
newConnectBtn.innerHTML =
|
||||
'Connect <i class="fas fa-arrow-right ms-2"></i>';
|
||||
|
||||
// Replace connected status with connect button
|
||||
connectedStatus.replaceWith(newConnectBtn);
|
||||
|
||||
// Re-attach the connect handler
|
||||
attachConnectHandler(newConnectBtn, card);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Settings card click navigation
|
||||
const settingsCards = document.querySelectorAll(".settings-card");
|
||||
|
||||
settingsCards.forEach((card) => {
|
||||
card.style.cursor = "pointer";
|
||||
|
||||
card.addEventListener("click", function () {
|
||||
const title = card.querySelector(".card-title").textContent;
|
||||
|
||||
// Map settings to placeholder pages (can be updated later)
|
||||
const settingsMap = {
|
||||
General: "#general-settings",
|
||||
"Billing Plan": "#billing-settings",
|
||||
Team: "#team-settings",
|
||||
"SMS Settings": "#sms-settings",
|
||||
"Web Tracking Installation": "#tracking-settings",
|
||||
};
|
||||
|
||||
const targetPage = settingsMap[title];
|
||||
if (targetPage) {
|
||||
// For now, just show an alert (can be replaced with actual navigation)
|
||||
console.log(`Navigating to ${title} settings...`);
|
||||
// Uncomment the line below when actual pages are created
|
||||
// window.location.href = targetPage;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
42
public/assets/js/l4lfunctions.js
Normal file
42
public/assets/js/l4lfunctions.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// Where you want to render the map.
|
||||
var element = document.getElementById('map');
|
||||
|
||||
// Height has to be set. You can do this in CSS too.
|
||||
element.style = 'height:300px;';
|
||||
|
||||
// Create Openlayers map on map element.
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
})
|
||||
],
|
||||
target: element,
|
||||
controls: ol.control.defaults().extend([
|
||||
// new ol.control.LayerSwitcher(),
|
||||
new ol.control.MousePosition({
|
||||
projection: 'EPSG:4326',
|
||||
coordinateFormat: function(coordinate) {
|
||||
return ol.coordinate.format(coordinate, '{x}, {y}', 4);
|
||||
},
|
||||
//ol.coordinate.toStringXY,
|
||||
}),
|
||||
// new ol.control.OverviewMap({layers: [baseLayersGroup]}),
|
||||
new ol.control.ScaleLine(),
|
||||
//new ol.control.ScaleLineUnits0(),
|
||||
//new ol.control.ControlDrawFeatures(vector_draw, optionsControlDraw),
|
||||
//new ol.control.ControlDrawButtons(vector_layer, opt_options),
|
||||
// new ol.control.ZoomSlider(),
|
||||
//new ol.control.Attribution(),
|
||||
// new ol.control.MousePosition(),
|
||||
// new ol.control.ZoomToExtent(),
|
||||
// new ol.control.FullScreen()
|
||||
]),
|
||||
view: new ol.View({
|
||||
center: [-135846.63, 891762.35],
|
||||
// center: [-1.3605877812500313, 10.401734198145082],
|
||||
zoom: 6
|
||||
})
|
||||
});
|
||||
|
||||
// Target's GPS coordinates.
|
||||
22
public/assets/js/login.js
Normal file
22
public/assets/js/login.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Where you want to render the map.
|
||||
var element = document.getElementById('map');
|
||||
|
||||
// Height has to be set. You can do this in CSS too.
|
||||
element.style = 'height:300px;';
|
||||
|
||||
// Create Leaflet map on map element.
|
||||
var map = L.map(element);
|
||||
|
||||
// Add OSM tile layer to the Leaflet map.
|
||||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
// Target's GPS coordinates.
|
||||
var target = L.latLng('7.9527706', '-1.0307118');
|
||||
|
||||
// Set map's center to target with zoom 14.
|
||||
map.setView(target, 7);
|
||||
|
||||
// Place a marker on the same location.
|
||||
L.marker(target).addTo(map);
|
||||
57
public/assets/js/permit_tools.js
Normal file
57
public/assets/js/permit_tools.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// Where you want to render the map.
|
||||
var element = document.getElementById('applicationmap');
|
||||
|
||||
// Height has to be set. You can do this in CSS too.
|
||||
//element.style = 'height:450px;';
|
||||
|
||||
var defaultWKT = 'POLYGON((-1.22 7.14, -1.17 7.14, -1.17 7.26, -1.22 7.26, -1.22 7.14))';
|
||||
searchLayer = new ol.layer.Vector({
|
||||
title : 'Search Layer',
|
||||
source : undefined,
|
||||
style : new ol.style.Style({
|
||||
stroke : new ol.style.Stroke({
|
||||
color : 'red',
|
||||
width : 3
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
// Create Openlayers map on map element.
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
})
|
||||
],
|
||||
target: element,
|
||||
controls: ol.control.defaults().extend([
|
||||
new ol.control.MousePosition({
|
||||
projection: 'EPSG:4326',
|
||||
coordinateFormat: function(coordinate) {
|
||||
return ol.coordinate.format(coordinate, '{x}, {y}', 4);
|
||||
},
|
||||
}),
|
||||
new ol.control.ScaleLine(),
|
||||
]),
|
||||
view: new ol.View({
|
||||
center: [-135846.63, 891762.35],
|
||||
zoom: 6
|
||||
})
|
||||
});
|
||||
|
||||
map.addLayer(searchLayer);
|
||||
|
||||
searchLayer.setSource(new ol.source.Vector({features : (new ol.format.WKT()).readFeatures(defaultWKT)}));
|
||||
view.fit(searchLayer.getSource().getExtent());
|
||||
pvlmd_map.getView().fit(searchLayer.getSource().getExtent(),{size : map.getSize(),maxZoom : 16})
|
||||
|
||||
|
||||
function viewApplication(applicationId) {
|
||||
console.log(applicationId);
|
||||
window.location.href = "/permits/viewapplication?id=" + applicationId;
|
||||
}
|
||||
|
||||
function viewPending() {
|
||||
console.log('foo bar');
|
||||
window.location.href = "/permits/pending";
|
||||
}
|
||||
217
public/assets/js/usermgt.js
Normal file
217
public/assets/js/usermgt.js
Normal file
@@ -0,0 +1,217 @@
|
||||
$(document).ready(function(){
|
||||
// $('.editUserBtn').click(function(evnt){
|
||||
|
||||
// });
|
||||
//
|
||||
console.log('foo bar');
|
||||
$('#editAllowedApps').select2({
|
||||
// width: "resolve",
|
||||
dropdownParent: $('#editUserModal'),
|
||||
placeholder : "Select options, multiple allowed"
|
||||
|
||||
});
|
||||
|
||||
$('#allowedApps').select2({
|
||||
// width: "resolve",
|
||||
dropdownParent: $('#addUserModal'),
|
||||
placeholder : "Select options, multiple allowed"
|
||||
});
|
||||
|
||||
$('#inputPermissions').select2({
|
||||
// width: "resolve",
|
||||
dropdownParent: $('#editUserModal'),
|
||||
placeholder : "Select options, multiple allowed"
|
||||
});
|
||||
|
||||
$('.editUserBtn').click(function(evnt){
|
||||
evnt.preventDefault();
|
||||
var selectedUserId = $(this).siblings('.userIdinput').val();
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('user_id', selectedUserId);
|
||||
|
||||
$.ajax({
|
||||
url: base_url + '/users/edit/' + selectedUserId,
|
||||
type: 'GET',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
beforeSend: function() {
|
||||
$('#editSuccessArea').text("");
|
||||
$('#editErrorArea').text("Please wait ... loading user details!");
|
||||
},
|
||||
success: function(data) {
|
||||
var jason = data.data;
|
||||
if(data.success == true){
|
||||
var allowedAppsArray = [];
|
||||
if (jason['allowed_apps']) {
|
||||
allowedAppsArray = jason['allowed_apps'].split(",");
|
||||
}
|
||||
console.log(jason['full_name']);
|
||||
$('#editFullName').val(jason['full_name']);
|
||||
$('#editEmail').val(jason['email']);
|
||||
$('#editUsername').val(jason['username']);
|
||||
$('#editGender').val(jason['gender']);
|
||||
$('#editTitle').val(jason['title']);
|
||||
$('#editUaPostion').val(jason['ua_position']);
|
||||
$('#editPhone').val(jason['phone']);
|
||||
$('#editAllowedApps').val(allowedAppsArray).trigger('change');
|
||||
$('#editRegionID').val(jason['region_id']);
|
||||
$('#editDistrictId').val(jason['district_id']);
|
||||
$('#editUaPostion').val(jason['ua_position']);
|
||||
$('#editGender').val(jason['gender']);
|
||||
$("input[name='user_id']").val(jason.ua_id);
|
||||
|
||||
}
|
||||
//$('#editUserModal').modal('show');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
$('#errorArea').text(error);
|
||||
$('#errorArea').text(error);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('.viewUserBtn').click(function(evnt){
|
||||
evnt.preventDefault();
|
||||
var selectedUserId = $(this).siblings('.userIdinput').val();
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('user_id', selectedUserId);
|
||||
|
||||
$.ajax({
|
||||
url: base_url + '/users/' + selectedUserId,
|
||||
type: 'GET',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
beforeSend: function() {
|
||||
$('#viewSuccessArea').text("");
|
||||
$('#viewErrorArea').text("Please wait ... loading user details!");
|
||||
},
|
||||
success: function(data) {
|
||||
var jason = data.data;
|
||||
if(data.success == true){
|
||||
var allowedAppsArray = [];
|
||||
if (jason['allowed_apps']) {
|
||||
allowedAppsArray = jason['allowed_apps'].split(",");
|
||||
}
|
||||
console.log(jason['full_name']);
|
||||
$('#viewFullName').val(jason['full_name']);
|
||||
$('#viewEmail').val(jason['email']);
|
||||
$('#viewUsername').val(jason['username']);
|
||||
$('#viewGender').val(jason['gender']);
|
||||
$('#viewTitle').val(jason['title']);
|
||||
$('#viewUaPostion').val(jason['ua_position']);
|
||||
$('#viewPhone').val(jason['phone']);
|
||||
$('#viewAllowedApps').val(allowedAppsArray).trigger('change');
|
||||
$('#viewRegionID').val(jason['region_id']);
|
||||
$('#viewDistrictId').val(jason['district_id']);
|
||||
$('#viewUaPostion').val(jason['ua_position']);
|
||||
$('#viewGender').val(jason['gender']);
|
||||
$("input[name='user_id']").val(jason.ua_id);
|
||||
|
||||
}
|
||||
//$('#editUserModal').modal('show');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
$('#errorArea').text(error);
|
||||
$('#errorArea').text(error);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#newUserForm").submit(function(evt){
|
||||
evt.preventDefault();
|
||||
$('#successArea').addClass('d-none');
|
||||
$('#errorsArea').removeClass('d-none');
|
||||
var formData = new FormData($(this)[0]);
|
||||
|
||||
$.ajax({
|
||||
url: base_url + '/users',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
beforeSend: function() {
|
||||
$('#successArea').text("");
|
||||
$('#successArea').text("Please wait ... user creation in progress!");
|
||||
},
|
||||
success: function(data) {
|
||||
|
||||
if (data['success'] == true) {
|
||||
$('#successArea').removeClass('d-none');
|
||||
$('#errorsArea').addClass('d-none');
|
||||
|
||||
$('#successArea').text("");
|
||||
$('#successArea').text("User successfully created!");
|
||||
// location.reload();
|
||||
setTimeout(function() {
|
||||
location.reload(); // Reloads the current page
|
||||
}, 15000);
|
||||
}
|
||||
else{
|
||||
$('#successArea').addClass('d-none');
|
||||
$('#errorArea').removeClass('d-none');
|
||||
$('#errorArea').text("");
|
||||
$('#errorArea').text("User could not be created!");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
$('#successArea').text(error);
|
||||
$('#successArea').text(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#editUserForm").submit(function(evt){
|
||||
evt.preventDefault();
|
||||
$('#successArea').addClass('d-none');
|
||||
$('#errorsArea').removeClass('d-none');
|
||||
var formData = new FormData($(this)[0]);
|
||||
$.ajax({
|
||||
url: base_url + '/users/update/',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
beforeSend: function() {
|
||||
// $('#updateBtn').addClass('d-none');
|
||||
// $('#uodateProgressBtn').removeClass('d-none');
|
||||
// $('#updateResultsDiv').removeClass('d-none');
|
||||
// $('#updateResultsParagraph').text("Processing Please wait ...");
|
||||
},
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
$('#editSuccessArea').removeClass('d-none');
|
||||
$('#editErrorArea').addClass('d-none');
|
||||
$('#editSuccessArea').text("");
|
||||
$('#editSuccessArea').text("User successfully details updated!");
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
$('#editSuccessArea').text(error);
|
||||
$('#editErrorArea').text(error);
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#regionID').change(function(){
|
||||
var options = $('#districtID');
|
||||
var region_id = $('#regionID').val();
|
||||
$.get( base_url + '/admin/districts/' + region_id, function (data) {
|
||||
$('#districtID').empty();
|
||||
$.each(data['districts'], function(id, row) {
|
||||
$('#districtID').append($("<option />").val(row.districtid).text(row.district_name));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user