sails-adminpanel
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -14,3 +14,8 @@ 'use strict'; | ||
module.exports = function(req, res) { | ||
return res.viewAdmin('dashboard'); | ||
if (!req.session.UserAP && sails.config.adminpanel.auth) { | ||
return res.redirect('/admin/userap/login'); | ||
} | ||
return res.viewAdmin('dashboard',{ instance: "instance"}); | ||
}; |
@@ -65,4 +65,2 @@ 'use strict'; | ||
console.log(1,reqData,instance); | ||
// callback before save instance | ||
@@ -73,3 +71,2 @@ if(typeof instance.config.edit.instanceModifier === "function"){ | ||
console.log(2,reqData); | ||
@@ -76,0 +73,0 @@ instance.model.update(params, reqData).exec(function(err, newRecord) { |
@@ -8,3 +8,2 @@ 'use strict'; | ||
var fieldsHelper = require('../helper/fieldsHelper'); | ||
var sortingHelper = require('../helper/sortingHelper'); | ||
@@ -37,3 +36,2 @@ var async = require('async'); | ||
//Processing sorting | ||
sortingHelper.processRequest(req); | ||
@@ -78,7 +76,6 @@ async.parallel([ | ||
} | ||
console.log(fields); | ||
res.viewAdmin({ | ||
requestProcessor: requestProcessor, | ||
sortingHelper: sortingHelper, | ||
instance: instance, | ||
total: total, | ||
list: records, | ||
@@ -85,0 +82,0 @@ fields: fields, |
@@ -12,2 +12,3 @@ 'use strict'; | ||
module.exports = function (req, res) { | ||
console.log('admin > upload'); | ||
@@ -19,2 +20,5 @@ var instance = util.findInstanceObject(req); | ||
if (!sails.adminpanel.havePermission(req, instance.config, __filename)) | ||
return res.redirect('/admin/userap/login'); | ||
if (req.method.toUpperCase() === 'POST') { | ||
@@ -189,5 +193,4 @@ // if this file must not be loaded | ||
const ext = filename.substr(filename.lastIndexOf('.') + 1, filename.length); | ||
// const url = '/admin/icons/' + ext + '/' + ext + '-128_32.png'; | ||
const urlIcon = '/admin/icons/' + ext + '/' + ext + '-128_32.png'; | ||
const url = fullDir + filename; | ||
const urlIcon = '/admin/assets/fileuploader/icons/' + ext + '.svg'; | ||
const url = dirDownload + filename; | ||
res.status(201); | ||
@@ -194,0 +197,0 @@ res.send({ |
@@ -47,8 +47,6 @@ class File_ { | ||
this.size.width = JSON.parse(this.size.width); | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
try { | ||
this.size.height = JSON.parse(this.size.height); | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
} | ||
@@ -60,8 +58,6 @@ if (this.type === 'image') { | ||
this.size.width = JSON.parse(this.size.width); | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
try { | ||
this.size.height = JSON.parse(this.size.height); | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
} | ||
@@ -72,3 +68,3 @@ | ||
else | ||
this.acceptedFiles = this.acceptedFiles.map(function (x) { | ||
this.acceptedFiles = this.acceptedFiles.map(function(x) { | ||
return "." + x; | ||
@@ -135,3 +131,3 @@ }); | ||
const dzId = this.elName + '-dropzone'; | ||
const dzDiv = "<form method='post' id=" + dzId + " class='dropzone'></form>"; | ||
const dzDiv = "<form method='post' id=" + dzId + " class='dropzone dropzone-fileuploader'></form>"; | ||
this.el.append(this.progressDiv, containerDiv, dzDiv, modalDOM[0]); | ||
@@ -174,3 +170,3 @@ $('#file-info-modal-' + this.elName).hide(); | ||
queuecomplete: () => { | ||
$('.dz-message').css({'display': 'block'}); | ||
$('.dz-message').css({ 'display': 'block' }); | ||
}, | ||
@@ -182,5 +178,5 @@ maxfilesexceeded: (file) => { | ||
}, | ||
thumbnail: function (file) { | ||
thumbnail: function(file) { | ||
const t = this; | ||
file.previewElement.addEventListener("click", function () { | ||
file.previewElement.addEventListener("click", function() { | ||
t.removeFile(file); | ||
@@ -206,16 +202,29 @@ }); | ||
const check = this.dataPreview ? | ||
" <i class='fa fa-check' title='Pick as primary'></i>" : ""; | ||
" <i class='las la-check' title='Pick as primary'></i>" : ""; | ||
const control = | ||
" <div class='item-control'>" + | ||
check + | ||
" <i class='fa fa-times' title='Delete file'></i>" + | ||
" <i class='las la-times' title='Delete file'></i>" + | ||
" </div>"; | ||
const item = | ||
"<div class='" + this.fileContainer + " file-container'>" + | ||
control + | ||
" <div class='item-image'>" + | ||
" <img src=" + file.urlS + " id='" + file.id + "'>" + | ||
" </div>" + | ||
"</div>"; | ||
let item = ""; | ||
console.log(this.type) | ||
if (this.type === 'file' || this.type === 'files') { | ||
item = | ||
"<div class='" + this.fileContainer + " file-container'>" + | ||
" <div class='item-file'>" + | ||
" <img src=" + file.urlS + " id='" + file.id + "'>" + | ||
" <div class='fileuploader_name'>" + file.name + "</div>" + | ||
" </div>" + control + | ||
"</div>"; | ||
} else if (this.type === 'image' || this.type === 'images') { | ||
item = | ||
"<div class='" + this.fileContainer + " file-container'>" + | ||
" <div class='item-image'>" + | ||
" <img src=" + file.urlS + " id='" + file.id + "'>" + | ||
" </div>" + control + | ||
"</div>"; | ||
} | ||
/* | ||
@@ -226,4 +235,4 @@ How it looks | ||
<div class='item-control'> | ||
<i class='fa fa-check' title='Pick as primary'></i> | ||
<i class='fa fa-times' title='Delete file'></i> | ||
<i class='las la-check' title='Pick as primary'></i> | ||
<i class='las la-times' title='Delete file'></i> | ||
</div> | ||
@@ -295,3 +304,3 @@ <div class='item-image'> | ||
const fu = this; | ||
$('.' + this.fileContainer + ' > .item-image').click(function () { | ||
$('.' + this.fileContainer + ' > .item-image').click(function() { | ||
const fileEl = $(this).find('img'); | ||
@@ -304,4 +313,13 @@ const id = fileEl.attr('id'); | ||
$('.' + this.fileContainer + ' > .item-file').click(function() { | ||
const fileEl = $(this).find('img'); | ||
const id = fileEl.attr('id'); | ||
const file = fu.files[id]; | ||
fu.setModalFile(file); | ||
$('#file-info-modal-' + fu.elName).show(); | ||
}); | ||
// make picture preview | ||
$('.' + this.fileContainer + ' > .item-control > .fa-check').click(function () { | ||
$('.' + this.fileContainer + ' > .item-control > .la-check').click(function() { | ||
const fc = $('.' + fu.fileContainer); | ||
@@ -316,3 +334,3 @@ fc.removeClass('preview'); | ||
// delete item | ||
$('.' + this.fileContainer + ' > .item-control > .fa-times').click(function () { | ||
$('.' + this.fileContainer + ' > .item-control > .la-times').click(function() { | ||
$(this).parents('.' + fu.fileContainer).remove(); | ||
@@ -354,4 +372,3 @@ fu.saveData(); | ||
} | ||
} catch (e) { | ||
} | ||
} catch (e) {} | ||
@@ -371,3 +388,2 @@ const preview = $('#' + this.dataPreview).val(); | ||
} | ||
} | ||
} |
@@ -14,2 +14,9 @@ # Custom actions | ||
model: 'User', | ||
actions: [ | ||
{ | ||
link: "/", | ||
title: "First action", | ||
icon: "" | ||
}, | ||
], | ||
@@ -16,0 +23,0 @@ list: { |
# Admin panel assets | ||
## Used staff | ||
First of all this hook is build on a list of OpenSourse libraries and tools. | ||
+ [Twitter Bootstrap 3](getbootstrap.com) | ||
+ [LESS](http://lesscss.org/) | ||
+ [CkEditor](http://ckeditor.com/) | ||
+ [jQuery](https://jquery.com) | ||
## Configuration | ||
All styles and js files will be linked to your project automatically. | ||
There are 2 ways of how it will be linked. | ||
+ `copy` - Assets will be copied into your projects `assets` folder | ||
+ `link` - Assets will be linked to your projects `assets` folder using `symlink` | ||
**By default `copy` method is using.** | ||
You can change this behaviour using `assets` configuration field into main frame of config object. | ||
Example: | ||
``` | ||
module.exports.adminpanel = { | ||
assets: 'copy', /* or 'link' */ | ||
instances: { /* ... */ } | ||
}; | ||
``` | ||
Assets stored as midleware static content in `/admin/assets` from `./assets` folder |
# Edit callback | ||
instanceModifier - function in adminpanel config edit sections for modification instance data | ||
displayModifier | ||
``` | ||
module.exports.adminpanel = { | ||
instances: { | ||
users: { | ||
title: 'Users', | ||
model: 'User', | ||
add: { | ||
fields: { | ||
}, | ||
// saved object to be modificated before save in database | ||
instanceModifier: function (instance) { | ||
instance.human_edited = true; | ||
return instance; | ||
}, | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
# List callback | ||
displayModifier - modificate data do show in datatables (only list) | ||
``` | ||
module.exports.adminpanel = { | ||
instances: { | ||
users: { | ||
title: 'Users', | ||
model: 'User', | ||
list: { | ||
avatar: { | ||
// Data to be modificated before send to frontend | ||
displayModifier: function (data) { | ||
return `<img src="${data[0].url}" width="50px">`; | ||
}, | ||
} | ||
} | ||
} | ||
} | ||
} |
@@ -13,3 +13,3 @@ # Admin Panel configuration | ||
| `instances` | Configuration for instances. Read below... | ||
| `showORMtime` | Set `true` for enable showing fields createdAt and updatedAt in edit and add sections | ||
## Instances | ||
@@ -114,2 +114,3 @@ | ||
required: true, // you can mark field required or not | ||
tooltip: 'tooltip for field', // You can define tooltip for field | ||
editor: true, // you can add WYSTYG editor for the field in admin panel | ||
@@ -116,0 +117,0 @@ } |
# Styles | ||
Now admin panel has new style from Clatiry CSS framework. | ||
You can change style in config | ||
> Styles not supported | ||
~~~js | ||
@@ -5,0 +8,0 @@ module.exports.adminpanel = { |
'use strict'; | ||
var util = require('../lib/adminUtil'); | ||
var async = require('async'); | ||
var _ = require('lodash'); | ||
module.exports = { | ||
/** | ||
@@ -89,3 +86,3 @@ * Will normalize a field configuration that willl be loaded fro config file. | ||
*/ | ||
_normalizeFieldConfig: function(config, key, modelField) { | ||
_normalizeFieldConfig: function (config, key, modelField) { | ||
if (_.isUndefined(config) || _.isUndefined(key)) { | ||
@@ -100,7 +97,8 @@ throw new Error('No `config` or `key` passed !'); | ||
return false; | ||
} else { | ||
} | ||
else { | ||
return { | ||
key: key, | ||
title: key | ||
} | ||
}; | ||
} | ||
@@ -124,3 +122,2 @@ } | ||
} | ||
//validate associations | ||
@@ -131,26 +128,29 @@ // console.log(modelField); | ||
var displayField; | ||
if (config.type === 'association'){ | ||
if (config.type === 'association') { | ||
try { | ||
associatedModelAtrubutes = util.getModel(modelField.model.toLowerCase()).attributes; | ||
} catch (e) { | ||
} | ||
catch (e) { | ||
sails.log.error(e); | ||
} | ||
} else if (config.type === 'association-many'){ | ||
} | ||
else if (config.type === 'association-many') { | ||
try { | ||
// console.log('admin > helper > collection > ', util.getModel(modelField.collection.toLowerCase()).attributes); | ||
associatedModelAtrubutes = util.getModel(modelField.collection.toLowerCase()).attributes; | ||
} catch (e) { | ||
} | ||
catch (e) { | ||
sails.log.error(e); | ||
} | ||
} | ||
// console.log('admin > helper > model > ', associatedModelAtrubutes); | ||
if (associatedModelAtrubutes.hasOwnProperty('name')){ | ||
displayField = 'name' | ||
} else if (associatedModelAtrubutes.hasOwnProperty('label')){ | ||
displayField = 'label' | ||
} else { | ||
displayField = 'id' | ||
if (associatedModelAtrubutes.hasOwnProperty('name')) { | ||
displayField = 'name'; | ||
} | ||
else if (associatedModelAtrubutes.hasOwnProperty('label')) { | ||
displayField = 'label'; | ||
} | ||
else { | ||
displayField = 'id'; | ||
} | ||
_.defaults(config, { | ||
@@ -165,3 +165,2 @@ identifierField: 'id', | ||
}, | ||
/** | ||
@@ -173,5 +172,4 @@ * Load list of records for all associations into `fields` | ||
*/ | ||
loadAssociations: function(fields, cb) { | ||
cb = cb || function() {}; | ||
loadAssociations: function (fields, cb) { | ||
cb = cb || function () { }; | ||
/** | ||
@@ -183,3 +181,3 @@ * Load all associated records for given field key | ||
*/ | ||
var loadAssoc = function(key, cb) { | ||
var loadAssoc = function (key, cb) { | ||
if (fields[key].config.type !== 'association' && fields[key].config.type !== 'association-many') { | ||
@@ -198,3 +196,3 @@ return cb(); | ||
} | ||
Model.find().exec(function(err, list) { | ||
Model.find().exec(function (err, list) { | ||
if (err) { | ||
@@ -207,4 +205,3 @@ return cb(); | ||
}; | ||
async.each(_.keys(fields), loadAssoc, function(err) { | ||
async.each(_.keys(fields), loadAssoc, function (err) { | ||
if (err) { | ||
@@ -216,3 +213,2 @@ return cb(err); | ||
}, | ||
/** | ||
@@ -224,5 +220,5 @@ * Create list of populated models | ||
*/ | ||
getFieldsToPopulate: function(fields) { | ||
getFieldsToPopulate: function (fields) { | ||
var result = []; | ||
_.forEach(fields, function(field, key) { | ||
_.forEach(fields, function (field, key) { | ||
if (field.config.type === 'association' || field.config.type === 'association-many') { | ||
@@ -234,3 +230,2 @@ result.push(key); | ||
}, | ||
/** | ||
@@ -262,3 +257,3 @@ * Basicaly it will fetch all attributes without functions | ||
*/ | ||
getFields: function(req, instance, type) { | ||
getFields: function (req, instance, type) { | ||
if (!instance.model || !instance.model.attributes) { | ||
@@ -272,12 +267,10 @@ return {}; | ||
var fieldsConfig = instance.config.fields || {}; | ||
//Get keys from config | ||
//var actionConfigFields = _.keys(actionConfig.fields); | ||
//Getting list of fields from model | ||
var modelAttributes = _.pick(instance.model.attributes, function(val, key) { | ||
return (_.isPlainObject(val) || _.isString(val)); | ||
}); | ||
let modelAttributes = instance.model.attributes | ||
console.log("<<<<",modelAttributes) | ||
var that = this; | ||
/** | ||
@@ -290,3 +283,3 @@ * Iteration function for every field | ||
*/ | ||
var _prepareField = function(modelField, key) { | ||
var _prepareField = function (modelField, key) { | ||
/** | ||
@@ -318,4 +311,5 @@ * Checks for short type in waterline: | ||
ignoreField = true; | ||
} else { | ||
var tmpCfg = that._normalizeFieldConfig(fieldsConfig[key], key,modelField); | ||
} | ||
else { | ||
var tmpCfg = that._normalizeFieldConfig(fieldsConfig[key], key, modelField); | ||
_.merge(fldConfig, tmpCfg); | ||
@@ -329,4 +323,5 @@ } | ||
ignoreField = true; | ||
} else { | ||
var tmpCfg = that._normalizeFieldConfig(actionConfig.fields[key], key,modelField); | ||
} | ||
else { | ||
var tmpCfg = that._normalizeFieldConfig(actionConfig.fields[key], key, modelField); | ||
ignoreField = false; | ||
@@ -349,3 +344,3 @@ _.merge(fldConfig, tmpCfg); | ||
//nomalizing configs | ||
fldConfig = that._normalizeFieldConfig(fldConfig, key,modelField) | ||
fldConfig = that._normalizeFieldConfig(fldConfig, key, modelField); | ||
//Adding new field to resultset | ||
@@ -357,3 +352,2 @@ result[key] = { | ||
}; | ||
// creating result | ||
@@ -360,0 +354,0 @@ var result = {}; |
@@ -42,3 +42,3 @@ 'use strict'; | ||
if (!config.menu || !config.menu.brand) { | ||
return 'Dashboard'; | ||
return 'Sails-adminpanel'; | ||
} | ||
@@ -51,3 +51,3 @@ if (_.isString(config.menu.brand)) { | ||
} | ||
return 'Dashboard'; | ||
return 'Sails-adminpanel'; | ||
}, | ||
@@ -196,2 +196,9 @@ | ||
} | ||
if (val.actions && val.actions.length > 0 && val.actions[0].title !== "Overview") { | ||
val.actions.unshift({ | ||
link: config.routePrefix + '/' + key, | ||
title: "Overview", | ||
icon: "" | ||
}) | ||
} | ||
menues.push({ | ||
@@ -201,2 +208,4 @@ link: config.routePrefix + '/' + key, | ||
icon: val.icon || null, | ||
actions: val.actions || null, | ||
id: val.id || val.title.replace(" ","_"), | ||
instanceName: key | ||
@@ -213,2 +222,3 @@ }); | ||
title: menu.title, | ||
id: menu.id || menu.title.replace(" ","_"), | ||
icon: menu.icon || null | ||
@@ -215,0 +225,0 @@ }); |
@@ -31,3 +31,3 @@ 'use strict'; | ||
getViewPath: function getViewPath(view) { | ||
return path.join(sails.config.adminpanel.pathToViews, view); | ||
return path.resolve(sails.config.adminpanel.pathToViews, view); | ||
}, | ||
@@ -34,0 +34,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var flash = require('connect-flash'); | ||
const bindAuthorization = require("./bindAuthorization"); | ||
module.exports = function ToAfterHooksLoaded(sails) { | ||
@@ -9,12 +10,9 @@ sails.hooks.http.app.use(flash()); | ||
require('./bindResView')(sails); | ||
// bind config for views | ||
require('./bindConfig')(sails); | ||
//binding all routes. | ||
require('./bindRoutes')(sails); | ||
//binding authorization | ||
require('./bindAuthorization')(sails); | ||
bindAuthorization(sails); | ||
}; | ||
}; |
@@ -7,6 +7,6 @@ "use strict"; | ||
sails.hooks.http.app.use('/admin/assets', serveStatic(path.join(__dirname, '../assets'))); | ||
let layer = sails.hooks.http.app._router.stack.slice(-1)[0]; | ||
sails.hooks.http.app._router.stack.splice(1, 0, layer); | ||
//let layer = sails.hooks.http.app._router.stack.slice(-1)[0] | ||
//sails.hooks.http.app._router.stack.splice(1, 0, layer) | ||
} | ||
exports.default = default_1; | ||
; |
@@ -5,4 +5,4 @@ import * as serveStatic from 'serve-static' | ||
sails.hooks.http.app.use('/admin/assets', serveStatic(path.join(__dirname, '../assets'))); | ||
let layer = sails.hooks.http.app._router.stack.slice(-1)[0] | ||
sails.hooks.http.app._router.stack.splice(1, 0, layer) | ||
//let layer = sails.hooks.http.app._router.stack.slice(-1)[0] | ||
//sails.hooks.http.app._router.stack.splice(1, 0, layer) | ||
}; |
'use strict'; | ||
var path = require('path'); | ||
var _login = require('../actions/login'); | ||
var superAdmin = 'isAdminpanelSuperAdmin'; | ||
module.exports = function bindAuthorization(sails) { | ||
@@ -18,3 +14,2 @@ /** | ||
sails.router.bind(baseRoute + '/logout', _bindPolicies(policies, _login)); | ||
var apConfName = ['list', 'add', 'edit', 'remove', 'view']; | ||
@@ -45,3 +40,3 @@ var apConf = { | ||
password: false | ||
} | ||
}; | ||
} | ||
@@ -55,3 +50,2 @@ if (apConfName[i] === 'add') { | ||
}; | ||
/** | ||
@@ -81,3 +75,4 @@ * Add method to check permission from controller | ||
return true; | ||
} else if (obj[action]) { | ||
} | ||
else if (obj[action]) { | ||
if (typeof obj[action] === 'boolean') | ||
@@ -96,6 +91,8 @@ return true; | ||
} | ||
} else { | ||
} | ||
else { | ||
return true; | ||
} | ||
} else if (action === '') { | ||
} | ||
else if (action === '') { | ||
if (obj.permission) { | ||
@@ -117,5 +114,4 @@ if (!Array.isArray(obj.permission)) { | ||
return false; | ||
} | ||
sails.on('lifted', () => { | ||
}; | ||
sails.on('lifted', async function () { | ||
/** | ||
@@ -125,23 +121,29 @@ * Model | ||
var conf; | ||
// Only in dev mode after drop | ||
if (sails.config.models.migrate !== 'drop') | ||
return; | ||
if (sails.config.adminpanel.admin) { | ||
conf = sails.config.adminpanel.admin; | ||
} else { | ||
} | ||
else { | ||
var conf = { | ||
username: 'engineer', | ||
password: 'engineer' | ||
} | ||
}; | ||
} | ||
UserAP.findOne({username: conf.username}).exec((err, user) => { | ||
if (err) sails.log.error(err); | ||
try { | ||
let user = await UserAP.findOne({ username: conf.username }); | ||
if (!user) { | ||
UserAP.create({ | ||
user = await UserAP.create({ | ||
username: conf.username, | ||
password: conf.password, | ||
permission: [superAdmin] | ||
}).exec((err, user) => { | ||
if (err) sails.log.error(err); | ||
if (!user) sails.log.error("Can't create user!"); | ||
}); | ||
}).fetch(); | ||
if (!user) | ||
sails.log.error("Can't create user!"); | ||
} | ||
}); | ||
} | ||
catch (e) { | ||
sails.log.error(e); | ||
} | ||
}); |
@@ -78,2 +78,3 @@ 'use strict'; | ||
sails.router.bind(sails.config.adminpanel.routePrefix + '\/*', bindResFunctions); | ||
sails.emit("adminpanel:viewadmin:loaded") | ||
}; |
@@ -6,2 +6,4 @@ 'use strict'; | ||
var _dashboard = require('../actions/dashboard'); | ||
var _welcome = require('../actions/welcome'); | ||
var _list = require('../actions/list'); | ||
@@ -13,3 +15,2 @@ var _list_json = require('../actions/list_json'); | ||
var _remove = require('../actions/remove'); | ||
var _records = require('../actions/records'); | ||
var _upload = require('../actions/upload'); | ||
@@ -59,9 +60,9 @@ | ||
*/ | ||
sails.router.bind(sails.config.adminpanel.routePrefix, _bindPolicies(policies, _dashboard)); | ||
/** | ||
* Bind records searcher | ||
*/ | ||
sails.router.bind(sails.config.adminpanel.routePrefix + '/_records/:model', _bindPolicies(policies, _records)); | ||
if (Boolean(sails.config.adminpanel.dashboard)) { | ||
sails.router.bind(sails.config.adminpanel.routePrefix, _bindPolicies(policies, _dashboard)); | ||
} else { | ||
sails.router.bind(sails.config.adminpanel.routePrefix, _bindPolicies(policies, _welcome)); | ||
} | ||
}; |
@@ -56,4 +56,9 @@ 'use strict'; | ||
*/ | ||
actions: [] | ||
actions: [], | ||
/** | ||
* List of sections in head | ||
*/ | ||
sections: [] | ||
} | ||
}; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var viewsHelper = require('../helper/viewsHelper'); | ||
const path = require("path"); | ||
const bindAssets_1 = require("./bindAssets"); | ||
@@ -56,4 +57,6 @@ function ToInitialize(sails) { | ||
sails.on("lifted", require('../lib/afterHooksLoaded')(sails)); | ||
sails.config.adminpanel.templateRootPath = viewsHelper.BASE_VIEWS_PATH; | ||
sails.config.adminpanel.rootPath = path.resolve(__dirname + "/.."); | ||
// Bind assets | ||
await bindAssets_1.default(sails); | ||
await (0, bindAssets_1.default)(sails); | ||
cb(); | ||
@@ -60,0 +63,0 @@ }; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var viewsHelper = require('../helper/viewsHelper'); | ||
import * as path from "path"; | ||
import bindAssets from "./bindAssets" | ||
@@ -62,6 +63,9 @@ | ||
var initAuth = require('./initializeAuthorization')(sails, cb); | ||
// sails.after(eventsToWaitFor, require('../lib/afterHooksLoaded')(sails)); | ||
sails.on("lifted", require('../lib/afterHooksLoaded')(sails)); | ||
sails.config.adminpanel.templateRootPath = viewsHelper.BASE_VIEWS_PATH; | ||
sails.config.adminpanel.rootPath = path.resolve(__dirname+"/..") | ||
// Bind assets | ||
@@ -71,2 +75,2 @@ await bindAssets(sails); | ||
} | ||
}; | ||
}; |
@@ -102,6 +102,10 @@ 'use strict'; | ||
}); | ||
console.log("booleanFields",booleanFields); | ||
var data = req.allParams(); | ||
var postParams = _.pick(data, function(value, key) { | ||
return Boolean(fields[key]); | ||
}); | ||
console.log("postParams",postParams); | ||
@@ -116,8 +120,17 @@ _.forIn(postParams, function(val, key) { | ||
} | ||
if (field.model.type == 'integer') { | ||
postParams[key] = parseInt(val) || null; | ||
} | ||
if (field.model.type == 'float' || field.model.type == 'number') { | ||
//if (field.model.type == 'integer') { | ||
// postParams[key] = parseInt(val) || null; | ||
//} | ||
if (field.model.type == 'number') { | ||
postParams[key] = parseFloat(val); | ||
} | ||
if (field.model.type == 'json') { | ||
try { | ||
postParams[key] = JSON.parse(val); | ||
} catch (error) { | ||
sails.log.error("Adminpanel > processRequest: json parse error", error) | ||
} | ||
} | ||
//remove empty field from list | ||
@@ -133,7 +146,7 @@ if (field.model.type == 'association' && !postParams[key]) { | ||
//} | ||
if (field.model.type === 'date') { | ||
if (!postParams[key]) { | ||
delete postParams[key]; | ||
} | ||
} | ||
// if (field.model.type === 'date') { | ||
// if (!postParams[key]) { | ||
// delete postParams[key]; | ||
// } | ||
// } | ||
}); | ||
@@ -140,0 +153,0 @@ // Hook for seting boolean vars to false. |
@@ -10,3 +10,3 @@ { | ||
"jimp": "^0.2.28", | ||
"lodash": "^3.9.0", | ||
"lodash": "^3.0.0", | ||
"ncp": "^2.0.0", | ||
@@ -17,3 +17,3 @@ "password-hash": "^1.2.2", | ||
"deprecated": false, | ||
"description": "Implements the basic admin panel for Sails", | ||
"description": "Basic adminpanel for Sails 1x", | ||
"devDependencies": { | ||
@@ -23,3 +23,4 @@ "chai": "^1.10.0", | ||
"mocha": "^2.0.1", | ||
"sails": "^0.11.0" | ||
"node-sass": "^7.0.1", | ||
"sails": "^1.4.0" | ||
}, | ||
@@ -33,3 +34,4 @@ "homepage": "https://github.com/sails-adminpanel/sails-adminpanel#readme", | ||
"admin", | ||
"admin-panel" | ||
"admin-panel", | ||
"adminpanel" | ||
], | ||
@@ -39,3 +41,2 @@ "license": "MIT", | ||
"name": "sails-adminpanel", | ||
"optionalDependencies": {}, | ||
"repository": { | ||
@@ -50,5 +51,6 @@ "type": "git", | ||
"scripts": { | ||
"test": "node ./node_modules/mocha/bin/mocha -b --timeout 5000" | ||
"test": "node ./node_modules/mocha/bin/mocha -b --timeout 5000", | ||
"build:css": "sass assets/styles:clarity/src" | ||
}, | ||
"version": "1.1.2" | ||
"version": "1.2.0" | ||
} |
@@ -12,3 +12,3 @@ sails-adminpanel readme for sails v1.x | ||
**config/views.js** | ||
**config/views.js** | ||
@@ -121,2 +121,3 @@ extension: 'jade', | ||
for build styles - sass --watch clarity/src:assets/styles/ | ||
@@ -126,1 +127,2 @@ ## License | ||
MIT | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9228340
419
94218
126
5
1
Updatedlodash@^3.0.0