Skip to content

Commit

Permalink
* Fix Issues in Checkbox Inputs, Range Slider and Gallery Widgets
Browse files Browse the repository at this point in the history
* Fix Range Input Bugs with Values
* Add Context Menu in the Elements Navigator
* Add Query Sync Feature to Page Datasource, Text Input, Range Slider Checkbox and Radio Button Widgets
  • Loading branch information
talp-525 committed Jan 18, 2023
1 parent 72cd9f0 commit 99528ca
Show file tree
Hide file tree
Showing 69 changed files with 1,751 additions and 2,051 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ dhparam.pem
/test.js
/test.css
/test.scss
/test.html
/test.log
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## Changelog

### 1.4.7 build 26
### 1.4.7 build 40

* Fix Checkbox Inputs Issues
* Fix Issues in Checkbox Inputs, Range Slider and Gallery Widgets
* Fix Range Input Bugs with Values
* Add Context Menu in the Elements Navigator
* Add Query Sync Feature to Page Datasource, Text Input, Range Slider Checkbox and Radio Button Widgets

### 1.4.6
* Added CRON Results Logs
Expand Down
27 changes: 19 additions & 8 deletions altrpnjs/app/Controllers/Http/IndicesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {schema, rules} from '@ioc:Adonis/Core/Validator'
import Edge from "../../../helpers/edge";
import Env from "@ioc:Adonis/Core/Env";
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
import Drive from '@ioc:Adonis/Core/Drive'
import Application from '@ioc:Adonis/Core/Application'
import path from "path";
import isProd from "../../../helpers/isProd";
Expand Down Expand Up @@ -81,7 +80,9 @@ export default class IndicesController {

response.header("Content-Type", "text/javascript")

const file = await Drive.get(pathToPublic)
const file = fs.readFileSync(pathToPublic, {
encoding: 'utf8'
})

return file
}
Expand Down Expand Up @@ -156,10 +157,16 @@ export default class IndicesController {
public async changelog({ response }) {
const pathToPublic = base_path( "CHANGELOG.md");
let file:any = ''

try {
file = await Drive.get(pathToPublic)
file = fs.readFileSync(pathToPublic, {
encoding: 'utf8'
})
} catch (e) {

file = fs.readFileSync(base_path( "../CHANGELOG.md"), {
encoding: 'utf8'
})
console.error(e);
}

response.header('Content-type', 'text/plain');
Expand Down Expand Up @@ -189,10 +196,14 @@ export default class IndicesController {
const faviconPath = Application.tmpPath("favicon") + `/${params.path}`;
const defaultFaviconPath = Application.resourcesPath("favicon") + `/altrp_${params.path}`

if(await Drive.exists(faviconPath)) {
value = await Drive.get(faviconPath)
} else if(await Drive.exists(defaultFaviconPath)) {
value = await Drive.get(defaultFaviconPath)
if(fs.existsSync(faviconPath)) {
value = fs.readFileSync(faviconPath, {
encoding: 'utf8'
})
} else if(fs.existsSync(defaultFaviconPath)) {
value = fs.readFileSync(defaultFaviconPath, {
encoding: 'utf8'
})
}

if(value) {
Expand Down
2 changes: 1 addition & 1 deletion altrpnjs/app/Controllers/Http/TemplatesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default class TemplatesController {
}
}
if(body.type !== "review"){
console.log(await exec(`node ${base_path('ace')} generator:template --id=${template.id}`))
console.log(`result of generator:template --id=${template.id}`,await exec(`node ${base_path('ace')} generator:template --id=${template.id}`))
}
applyPluginsFiltersAsync('template_updated', template)
return {
Expand Down
17 changes: 8 additions & 9 deletions altrpnjs/app/Controllers/Http/admin/AdminController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
import Application from '@ioc:Adonis/Core/Application';
import jimp from "jimp";
import FAVICONS_SIZES from "../../../../helpers/const/FAVICONS_SIZES";
import Drive from '@ioc:Adonis/Core/Drive'
import ListenerGenerator from "App/Generators/ListenerGenerator";
import isProd from "../../../../helpers/isProd";
import UpdateService from "App/Services/UpdateService";
Expand Down Expand Up @@ -109,7 +108,7 @@ export default class AdminController {

const id = request.input('id')

console.log(await exec(`node ${base_path('ace')} generator:template ${id ? `--id=${id}` : ''}`))
console.log(`result of generator:template ${id ? `--id=${id}` : ''}`,await exec(`node ${base_path('ace')} generator:template ${id ? `--id=${id}` : ''}`))

console.info('Templates Upgraded')
}
Expand All @@ -132,7 +131,7 @@ export default class AdminController {
})
}

await Drive.delete(Application.tmpPath("favicon") + `/basic.${favicon.extname}`)
fs.unlinkSync(Application.tmpPath("favicon") + `/basic.${favicon.extname}`)

return {
success: true
Expand Down Expand Up @@ -199,7 +198,7 @@ export default class AdminController {
console.info('Upgrading Pages')
const id = request.input('id')

console.log(await exec(`node ${base_path('ace')} generator:page ${id ? `--id=${id}` : ''}`))
console.log(`result of generator:page ${id ? `--id=${id}` : ''}`, await exec(`node ${base_path('ace')} generator:page ${id ? `--id=${id}` : ''}`))

console.info('Pages Upgraded')
}
Expand All @@ -213,8 +212,8 @@ export default class AdminController {
await Model.createDefaultCustomizers(model.toJSON(), model)
}
console.info('Upgraded Default Models Robotizers')
console.log(await exec(`node ${base_path('ace')} generator:model`))
console.log(await exec(`node ${base_path('ace')} generator:router`))
console.log(`result of generator:model`,await exec(`node ${base_path('ace')} generator:model`))
console.log(`result of generator:router`,await exec(`node ${base_path('ace')} generator:router`))

console.info('Models Upgraded')
}
Expand All @@ -230,23 +229,23 @@ export default class AdminController {
await listenerGenerator.hookPages()
await listenerGenerator.hookListeners()

console.log(await exec(`node ${base_path('ace')} generator:listener`))
console.log(`resul of generator:listener`, await exec(`node ${base_path('ace')} generator:listener`))

console.info('Listeners Upgraded')
}

private static async upgradeCRUDs() {
console.info('Upgrading CRUDs')

console.log(await exec(`node ${base_path('ace')} generator:crud`))
console.log(`resul of generator:crud`, await exec(`node ${base_path('ace')} generator:crud`))

console.info('CRUDs Upgraded')
}

private static async upgradeSchedules() {
console.info('Upgrading Schedules')

console.log(await exec(`node ${base_path('ace')} generator:schedule`))
console.log(`result of generator:schedule`, await exec(`node ${base_path('ace')} generator:schedule`))

console.info('Schedules Upgraded')
}
Expand Down
20 changes: 10 additions & 10 deletions altrpnjs/app/Controllers/Http/admin/MediaController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,17 @@ export default class MediaController {
media.title = filename
let urlBase =
"/media/" + date.getFullYear() + "/" + (date.getMonth() + 1) + "/";
let dirname = public_path("/storage" + urlBase);
let dirname = ("/storage" + urlBase);


if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true });
if (!fs.existsSync(public_path(dirname))) {
fs.mkdirSync(public_path(dirname), { recursive: true });
}
media.filename = urlBase + filename;

// @ts-ignore
await file.moveToDisk(dirname, { name: filename }, "local");
let content = fs.readFileSync(dirname + filename);
let content = fs.readFileSync(public_path(dirname + filename));

if (ext == "heic") {
media.title = file.clientName.split(".")[0] + ".jpg";
Expand All @@ -259,7 +259,7 @@ export default class MediaController {
format: "JPEG",
quality: 1,
});
fs.writeFileSync(dirname + filename, content);
fs.writeFileSync(public_path(dirname + filename), content);
}

if (ext === "svg") {
Expand Down Expand Up @@ -330,14 +330,14 @@ export default class MediaController {
let filename = title + "." + ext;
let urlBase =
"/media/" + date.getFullYear() + "/" + (date.getMonth() + 1) + "/";
let dirname = public_path("/storage" + urlBase);
if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true });
let dirname = ("/storage" + urlBase);
if (!fs.existsSync(public_path("/storage" + urlBase))) {
fs.mkdirSync(public_path("/storage" + urlBase), { recursive: true });
}
media.filename = urlBase + filename;
// @ts-ignore
await file.moveToDisk(dirname, { name: filename }, "local");
let content = fs.readFileSync(dirname + filename);
let content = fs.readFileSync(public_path(dirname + filename));

if (ext == "heic") {
media.title = file.clientName.split(".")[0] + ".jpg";
Expand All @@ -348,7 +348,7 @@ export default class MediaController {
format: "JPEG",
quality: 1,
});
fs.writeFileSync(dirname + filename, content);
fs.writeFileSync(public_path(dirname + filename), content);
}

if (ext === "svg") {
Expand Down
7 changes: 0 additions & 7 deletions altrpnjs/app/Controllers/Http/admin/ModelsController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {HttpContextContract} from '@ioc:Adonis/Core/HttpContext'
import Model from 'App/Models/Model'
import Source from 'App/Models/Source'
import Accessors from 'App/Models/Accessor'
import exec from '../../../../helpers/exec'
import empty from '../../../../helpers/empty'
import CategoryObject from 'App/Models/CategoryObject'
Expand Down Expand Up @@ -486,12 +485,6 @@ export default class ModelsController {
}
}))
}

async getAccessors({params, response}: HttpContextContract) {
let accessors = await Accessors.query().where('model_id', params.id).select()
return response.json(accessors)
}

async storeModel({request, response, auth}: HttpContextContract) {
let modelData = request.all()
let model = new Model()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class PageDatasourcesController {
const data = {
alias: body.alias,
autoload: body.autoload,
query_sync: body.query_sync,
parameters: body.parameters || null,
priority: body.priority,
source_id: body.source_id,
Expand All @@ -48,6 +49,7 @@ export default class PageDatasourcesController {
}

pageDatasource.alias = body.alias;
pageDatasource.query_sync = body.query_sync || false;
pageDatasource.autoload = body.autoload || false;
pageDatasource.parameters = body.parameters || null;
pageDatasource.priority = body.priority;
Expand All @@ -73,6 +75,7 @@ export default class PageDatasourcesController {
public async getByPage({params}) {
const pageQuery = Page.query().preload("pageDatasources", (pageDatasources) => {
pageDatasources.preload("source")
pageDatasources.orderBy('id')
})

if(isNaN(params.id)) {
Expand Down
14 changes: 8 additions & 6 deletions altrpnjs/app/Middleware/ConvertEmptyString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export default class ConvertEmptyString {
}
}
await next()
console.log(`END: ${((performance.now() - start) + '').substring(0, 8)} ${
(request.method() + ' ').substring(0, 7)
} ${
request.url(true)
}, ${
request.header('X-Real-IP') || ''}`);
if(! request.url().includes('/wsaltrp/')){
console.log(`END: ${((performance.now() - start) + '').substring(0, 8)} ${
(request.method() + ' ').substring(0, 7)
} ${
request.url(true)
}, ${
request.header('X-Real-IP') || ''}`);
}
}
}
13 changes: 12 additions & 1 deletion altrpnjs/app/Models/PageDatasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default class PageDatasource extends BaseModel {
@column()
public alias: string;

@column()
public query_sync: string;

@column()
public parameters: string;

Expand Down Expand Up @@ -103,7 +106,15 @@ export default class PageDatasource extends BaseModel {
}
}
}
httpContext.request.updateQs(this.getParsedParameters(altrpContext))

let newQs = this.getParsedParameters(altrpContext)
if(this.query_sync){
newQs = {
...newQs,
...httpContext.request.qs(),
}
}
httpContext.request.updateQs(newQs)

const res = await controller[this.source.getMethodName()](httpContext)
return httpContext.response.getBody() || res;
Expand Down
13 changes: 1 addition & 12 deletions altrpnjs/app/Models/Source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,18 +502,7 @@ export default class Source extends BaseModel {
.select('*')

for(const pageDatasource of pageDatasources){
const newHttpContext = {
params: httpContext.params,
auth:{
user: httpContext.auth.user
},
request: httpContext.request,
response: httpContext.response,
logger: httpContext.logger,
profiler: httpContext.profiler,
route: httpContext.route,
routeKey: httpContext.routeKey,
}
const newHttpContext = _.cloneDeep(httpContext)
const data = await pageDatasource.fetchControllerMethod(newHttpContext, altrpContext)
if(data?.data){
datasources[pageDatasource.alias] = data.data
Expand Down
6 changes: 0 additions & 6 deletions altrpnjs/app/Models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from '@ioc:Adonis/Lucid/Orm'
import { v4 as uuid } from "uuid";
import Template from "App/Models/Template";
import Accessors from "App/Models/Accessor";
import Model from "App/Models/Model";
import Table from "App/Models/Table";
import Column from "App/Models/Column";
Expand Down Expand Up @@ -179,11 +178,6 @@ export default class User extends BaseModel {
page.user_id = newAdmin ? newAdmin.id : null;
await page.save()
}
const accessors = await Accessors.query().where("user_id", user.id)
for(const accessor of accessors){
accessor.user_id = newAdmin ? newAdmin.id : null;
await accessor.save()
}
const models = await Model.query().where("user_id", user.id)
for(const model of models){
model.user_id = newAdmin ? newAdmin.id : null;
Expand Down
45 changes: 45 additions & 0 deletions altrpnjs/app/altrp-templates/styles/elements/gallery.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

.altrp-gallery-overlay {
left: 0;
top: 0;
align-items: flex-start;
justify-content: flex-start;
}

.altrp-gallery-overlay-bg {
mix-blend-mode: none;
}

.altrp-gallery-grid {
display: grid;
position: relative;
grid-template-columns: repeat(3, 1fr);
}

.altrp-gallery-img {
background-size: cover;
background-position: center center;
width: 100%;
transform-origin: center top;
padding-bottom:100%;
}

.altrp-gallery-img-container {
position: relative;
overflow: hidden;
}

.altrp-gallery-icon {
height: 35px;
width: 35px;
opacity: 0.5;
}

.altrp-gallery-empty-container {
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
background-color: #C4C4C4;
}

Loading

0 comments on commit 99528ca

Please sign in to comment.