Force refresh
This commit is contained in:
parent
40d234fc2e
commit
ad2a9d5593
|
@ -4,12 +4,24 @@ import { hasRolesMiddleware } from '../middlewares/hasRolesMiddleware.js'
|
||||||
import { prisma } from '../prisma.js'
|
import { prisma } from '../prisma.js'
|
||||||
|
|
||||||
import { distributedCopy } from '../utils/distributedCopy.js'
|
import { distributedCopy } from '../utils/distributedCopy.js'
|
||||||
|
import { PrinterStatusService } from '../services/PrinterStatusService.js'
|
||||||
|
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
class PrinterController {
|
class PrinterController {
|
||||||
static async index(req: Request, res: Response) {
|
static async index(req: Request, res: Response) {
|
||||||
const { campus } = req.query
|
const { campus, force } = req.query
|
||||||
|
|
||||||
|
if (force) {
|
||||||
|
const printers = await prisma.printer.findMany()
|
||||||
|
console.log(`Updating printers status ${new Date().toLocaleString()}`)
|
||||||
|
|
||||||
|
Promise.allSettled(
|
||||||
|
printers.map(async printer => {
|
||||||
|
new PrinterStatusService(printer)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (campus == 'RT') {
|
if (campus == 'RT') {
|
||||||
const printers = await prisma.printer.findMany({
|
const printers = await prisma.printer.findMany({
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
class="mr-1"
|
class="mr-1"
|
||||||
color="primary"
|
color="primary"
|
||||||
title="Atualizar"
|
title="Atualizar"
|
||||||
@click="appStore.fetchPrinters"
|
@click="appStore.fetchPrinters(true)"
|
||||||
:disabled="appStore.loadingPrinters"
|
:disabled="appStore.loadingPrinters"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,13 @@ export const useAppStore = defineStore('app', {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
async fetchPrinters() {
|
async fetchPrinters(force = false) {
|
||||||
this.loadingPrinters = true
|
this.loadingPrinters = true
|
||||||
try {
|
try {
|
||||||
this.printers = await api<any[]>(
|
this.printers = await api<any[]>(
|
||||||
`printer?${new URLSearchParams({
|
`printer?${new URLSearchParams({
|
||||||
campus: this.selectedCampus
|
campus: this.selectedCampus,
|
||||||
|
force: force ? 'true' : ''
|
||||||
})}`,
|
})}`,
|
||||||
{ method: 'GET' }
|
{ method: 'GET' }
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user