Se creo el archivo de obras
This commit is contained in:
parent
bbe825313a
commit
8792c5b283
29
app/Http/Controllers/Dashboard/ObrasController.php
Normal file
29
app/Http/Controllers/Dashboard/ObrasController.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php namespace App\Http\Controllers\Dashboard;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class ObrasController extends BaseController
|
||||||
|
{
|
||||||
|
public function Obras(Request $request)
|
||||||
|
{
|
||||||
|
$query = $request->only(['start', 'end', 'type']);
|
||||||
|
$query = array_merge(['type' => 'api'], $query);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Http::timeout(5)->get('https://obras-information.comalcalco.gob.mx/api/controller.php?action=getCounters', $query);
|
||||||
|
|
||||||
|
if (! $response->successful()) {
|
||||||
|
return response()->json(['error' => 'External service error'], $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response->json(), $response->status())
|
||||||
|
->header('Content-Type', $response->header('Content-Type', 'application/json'));
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Proxy error: '.$e->getMessage());
|
||||||
|
return response()->json(['error' => 'Unable to contact external service'], 502);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/Http/Controllers/Dashboard/TramiteController.php
Normal file
29
app/Http/Controllers/Dashboard/TramiteController.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php namespace App\Http\Controllers\Dashboard;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class TramiteController extends BaseController
|
||||||
|
{
|
||||||
|
public function tramiteEspecial(Request $request)
|
||||||
|
{
|
||||||
|
$query = $request->only(['start', 'end', 'type']);
|
||||||
|
$query = array_merge(['type' => 'api'], $query);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Http::timeout(5)->get('https://tramites.comalcalco.gob.mx/reporte-especial', $query);
|
||||||
|
|
||||||
|
if (! $response->successful()) {
|
||||||
|
return response()->json(['error' => 'External service error'], $response->status());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($response->json(), $response->status())
|
||||||
|
->header('Content-Type', $response->header('Content-Type', 'application/json'));
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Proxy error: '.$e->getMessage());
|
||||||
|
return response()->json(['error' => 'Unable to contact external service'], 502);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -55,11 +55,6 @@ onMounted(()=> {
|
|||||||
name="help.title"
|
name="help.title"
|
||||||
to="dashboard.help"
|
to="dashboard.help"
|
||||||
/>
|
/>
|
||||||
<Link
|
|
||||||
icon="live_help"
|
|
||||||
name="Graficas"
|
|
||||||
to="dashboard.chart-test.index"
|
|
||||||
/>
|
|
||||||
</Section>
|
</Section>
|
||||||
<Section name="Configuraciones">
|
<Section name="Configuraciones">
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
29
resources/js/Pages/Dashboard/Obras.vue
Normal file
29
resources/js/Pages/Dashboard/Obras.vue
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
|
||||||
|
|
||||||
|
const fetchReport = async ({ start, end }) => {
|
||||||
|
// cancelar petición previa
|
||||||
|
if (cancelTokenSource) {
|
||||||
|
try { cancelTokenSource.cancel('cancel'); } catch (e) {}
|
||||||
|
}
|
||||||
|
cancelTokenSource = axios.CancelToken.source();
|
||||||
|
|
||||||
|
const params = {};
|
||||||
|
if (start) params.start = start;
|
||||||
|
if (end) params.end = end;
|
||||||
|
|
||||||
|
const res = await axios.get('/api/reporte-especial', {
|
||||||
|
params,
|
||||||
|
cancelToken: cancelTokenSource.token,
|
||||||
|
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// axios lanza en error si status >= 400, aquí devolvemos data directamente
|
||||||
|
return res.data;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
|
||||||
|
Hola
|
||||||
|
</template>
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, watch, onMounted } from "vue";
|
import { ref, computed, watch, onMounted } from "vue";
|
||||||
|
|
||||||
|
import axios from "axios";
|
||||||
import Bars from "@/Components/Dashboard/Charts/Bars.vue";
|
import Bars from "@/Components/Dashboard/Charts/Bars.vue";
|
||||||
import Pie from "@/Components/Dashboard/Charts/Pie.vue";
|
import Pie from "@/Components/Dashboard/Charts/Pie.vue";
|
||||||
import DateRange from "@/Components/Dashboard/Form/DateRange.vue";
|
import DateRange from "@/Components/Dashboard/Form/DateRange.vue";
|
||||||
@ -62,24 +63,28 @@ const mode = computed(() => {
|
|||||||
return "rango";
|
return "rango";
|
||||||
});
|
});
|
||||||
|
|
||||||
let abortController = null;
|
let cancelTokenSource = null;
|
||||||
let debounceId = null;
|
let debounceId = null;
|
||||||
|
|
||||||
const fetchReport = async ({ start, end }) => {
|
const fetchReport = async ({ start, end }) => {
|
||||||
if (abortController) abortController.abort();
|
// cancelar petición previa
|
||||||
abortController = new AbortController();
|
if (cancelTokenSource) {
|
||||||
const qs = new URLSearchParams();
|
try { cancelTokenSource.cancel('cancel'); } catch (e) {}
|
||||||
if (start) qs.set("start", start);
|
}
|
||||||
if (end) qs.set("end", end);
|
cancelTokenSource = axios.CancelToken.source();
|
||||||
|
|
||||||
const res = await fetch(
|
const params = {};
|
||||||
`/dashboard/api/proxy-reporte-especial?${qs.toString()}`,
|
if (start) params.start = start;
|
||||||
{
|
if (end) params.end = end;
|
||||||
signal: abortController.signal,
|
|
||||||
}
|
const res = await axios.get('/api/reporte-especial', {
|
||||||
);
|
params,
|
||||||
if (!res.ok) throw new Error("Error de red");
|
cancelToken: cancelTokenSource.token,
|
||||||
return res.json();
|
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||||
|
});
|
||||||
|
|
||||||
|
// axios lanza en error si status >= 400, aquí devolvemos data directamente
|
||||||
|
return res.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\Dashboard\ObrasController;
|
||||||
|
use App\Http\Controllers\Dashboard\TramiteController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
@ -17,3 +19,8 @@
|
|||||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||||
return $request->user();
|
return $request->user();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::middleware(['throttle:60,1'])->get('/reporte-especial', [TramiteController::class, 'tramiteEspecial']);
|
||||||
|
|
||||||
|
Route::middleware(['throttle:60,1'])->get('/reporte-obras', [ObrasController::class, 'Obras']);
|
||||||
|
|
||||||
|
|||||||
@ -30,11 +30,8 @@
|
|||||||
Route::inertia('/changelogs', 'Dashboard/Changelogs')->name('changelogs');
|
Route::inertia('/changelogs', 'Dashboard/Changelogs')->name('changelogs');
|
||||||
Route::inertia('/help', 'Dashboard/Help')->name('help');
|
Route::inertia('/help', 'Dashboard/Help')->name('help');
|
||||||
|
|
||||||
Route::inertia('/api-example', 'Dashboard/Tramites')->name('api-example');
|
Route::inertia('/api-tramite', 'Dashboard/Tramites')->name('api-tramite');
|
||||||
Route::get('/api/proxy-reporte-especial', function () {
|
Route::inertia('/api-obra', 'Dashboard/Obras')->name('api-obra');
|
||||||
$response = Http::get('https://tramites.comalcalco.gob.mx/reporte-especial?type=api');
|
|
||||||
return $response->json();
|
|
||||||
});
|
|
||||||
|
|
||||||
# Log de Acciones
|
# Log de Acciones
|
||||||
Route::resource('histories', HistoryLogController::class)->only([
|
Route::resource('histories', HistoryLogController::class)->only([
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user