Neurotic and Probably Misinformed

    larvitadmingui

    0.15.0 • Public • Published

    larvitadmingui

    node.js admin GUI

    Installation

    npm i larvitadmingui;

    Usage

    Application startup

    In your app, start the admin interface like this:

    'use strict';
    
    const	Intercom	= require('larvitamintercom'),
    	UserLib	= require('larvituser'),
    	winston	= require('winston'),
    	log	= winston.createLogger({'transports': [new winston.transports.Console()]}),
    	App	= require('larvitadmingui'),
    	db	= require('larvitdb');
    
    let	userLib,
    	app;
    
    db.setup(...); // See https://github.com/larvit/larvitdb on how to configure the database
    
    userLib = new UserLib({
    	'db':	db,
    	'log':	log,
    	'mode':	'master',
    	'intercom':	new Intercom({'conStr': 'loopback interface', 'log': log})
    });
    
    app = new App({
    	'port':	8001, // Listening port
    	'userLib':	userLib,
    	'log':	log,
    	'db':	db
    });

    Start it up and check your browser at http://127.0.0.1:8001 - be sure to setup your MySQL or MariaDB correctly with your database settings in this file.

    Set messages or errors in the GUI from a controller

    'use strict';
    
    exports.run = function(req, res, cb) {
    	const	data	= {'global': res.globalData};
    
    	data.global.messages	= ['Happy message'];
    	data.global.errors	= ['Sad message'];
    
    	cb(null, req, res, data);
    };

    To set messages to the next page load, do this:

    if ( ! req.session.data.nextCallData)
    	req.session.data.nextCallData = {};
    
    req.session.data.nextCallData	= {'global': {'messages': ['Happy message']}};
    // or
    req.session.data.nextCallData	= {'global': {'errors': ['Sad message']}};

    These will be loaded on the next page load, and then erased again.

    Install

    npm i larvitadmingui

    DownloadsWeekly Downloads

    14

    Version

    0.15.0

    License

    ISC

    Unpacked Size

    1.96 MB

    Total Files

    218

    Last publish

    Collaborators

    • vktr
    • lilleman
    • gagge
    • klabbekluck
    • jaggu-snorr
    • jaggu-darull