Skip to content

Commit

Permalink
Comment out legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkBrines committed Nov 16, 2024
1 parent 8644527 commit b9d490e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 92 deletions.
176 changes: 88 additions & 88 deletions app/Controllers/Http/AppsController.ts
Original file line number Diff line number Diff line change
@@ -1,89 +1,89 @@
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import App from '../../Models/App'
import { string } from '@ioc:Adonis/Core/Helpers'

// DEPRECATED - Use StoreController instead

export default class AppsController {
public async index({ view, params, request }: HttpContextContract) {
const query = request.qs()["query"]
const cat: number = params['category']
let apps: App[]

if (query) {
apps = await App.query()
.orderBy("downloads", "desc")
.orWhereLike("name", `%${query}%`)
.orWhereLike("desc", `%${query}%`)
.limit(15)
} else {
const q = App.query()
.orderBy("downloads", "desc")
.limit(15)

if (cat) {
q.where('category', cat)
}

apps = await q
}

return view.share({
category: cat,
apps,
query
}).render('apps/index')
}

public async show({ view, params }: HttpContextContract) {
const app = await App.query()
.where('id', params.id)
//.preload('author')
.firstOrFail()

return view.share({ app }).render('apps/product')
}

public async create({ view }: HttpContextContract) {
return view.render('apps/create')
}

public async createProcess({ auth, request, response }: HttpContextContract) {
const data = request.body()
const img = request.file('img')

if (!auth.user) return response.status(403)

if (img) {
const filename = img.fileName + string.generateRandom(8) + (img.extname ? "." + img.extname : "")
await img.moveToDisk('/appicons', {
name: filename
})
//imgUrl = process.env.ACCESS_ADDRESS + "/uploads/appicons/" + filename
}

await App.create({
userId: auth.user.id,
name: data.name,
desc: data.desc,
//image: imgUrl,
source_url: data.source_url,
//releases: data.releases,
category: data.categories
})
}

public async getAppJson({ params, response }: HttpContextContract) {
const app = await App.findOrFail(params["id"])
return response.send(app.toJSON())
}

public async appinstalldemo({ view }: HttpContextContract) {
return view.render('apps/appinstalldemo');
}

public async product({ view }: HttpContextContract) {
return view.render('apps/product');
}
}
// import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
// import App from '../../Models/App'
// import { string } from '@ioc:Adonis/Core/Helpers'

// // DEPRECATED - Use StoreController instead

// export default class AppsController {
// public async index({ view, params, request }: HttpContextContract) {
// const query = request.qs()["query"]
// const cat: number = params['category']
// let apps: App[]

// if (query) {
// apps = await App.query()
// .orderBy("downloads", "desc")
// .orWhereLike("name", `%${query}%`)
// .orWhereLike("desc", `%${query}%`)
// .limit(15)
// } else {
// const q = App.query()
// .orderBy("downloads", "desc")
// .limit(15)

// if (cat) {
// q.where('category', cat)
// }

// apps = await q
// }

// return view.share({
// category: cat,
// apps,
// query
// }).render('apps/index')
// }

// public async show({ view, params }: HttpContextContract) {
// const app = await App.query()
// .where('id', params.id)
// //.preload('author')
// .firstOrFail()

// return view.share({ app }).render('apps/product')
// }

// public async create({ view }: HttpContextContract) {
// return view.render('apps/create')
// }

// public async createProcess({ auth, request, response }: HttpContextContract) {
// const data = request.body()
// const img = request.file('img')

// if (!auth.user) return response.status(403)

// if (img) {
// const filename = img.fileName + string.generateRandom(8) + (img.extname ? "." + img.extname : "")
// await img.moveToDisk('/appicons', {
// name: filename
// })
// //imgUrl = process.env.ACCESS_ADDRESS + "/uploads/appicons/" + filename
// }

// await App.create({
// userId: auth.user.id,
// name: data.name,
// desc: data.desc,
// //image: imgUrl,
// source_url: data.source_url,
// //releases: data.releases,
// category: data.categories
// })
// }

// public async getAppJson({ params, response }: HttpContextContract) {
// const app = await App.findOrFail(params["id"])
// return response.send(app.toJSON())
// }

// public async appinstalldemo({ view }: HttpContextContract) {
// return view.render('apps/appinstalldemo');
// }

// public async product({ view }: HttpContextContract) {
// return view.render('apps/product');
// }
// }

4 changes: 0 additions & 4 deletions app/Controllers/Http/DashboardController.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import App from "App/Models/App"

export default class DashboardController {
public async index({ auth, view }: HttpContextContract) {
const user = auth.use('web').user

// show all apps for every user -> print
const apps = await App.query();

return view.render('core/dashboard', {
user: user,
})
Expand Down

0 comments on commit b9d490e

Please sign in to comment.