2
0
Fork 0

WIP open file for a while

This commit is contained in:
Willem 2017-06-10 16:53:29 +02:00
parent f937019e42
commit d280fb9af3
122 changed files with 5702 additions and 10 deletions

View file

@ -0,0 +1,25 @@
module.exports = (function () {
return function UIAngularServerRoutesPlugin() {
this.configPlugin = function (ctx) {
ctx.key = 'uiAngularServerPlugins';
ctx.description = 'Adds an angular server plugins page.';
ctx.dependencies.push('angular');
};
this.configServer = function(ctx) {
ctx.hostTemplateJS('js/server-plugins');
ctx.hostTemplateHTML('thtml/plugins',true);
ctx.registrateMenuItem({
name: 'Server Plugins',
link: ctx.troot.tmeta.tplugin.angular.tbase+'/server/plugins',
enable: true,
roles: [],
icon: 'fa fa-umbrella'
},'server');
};
};
})();

View file

@ -0,0 +1,26 @@
module.exports = (function () {
return function UIAngularServerRoutesPlugin() {
this.configPlugin = function (ctx) {
ctx.key = 'uiAngularServerRoutes';
ctx.description = 'Adds an angular server routes page.';
ctx.dependencies.push('angular');
ctx.dependencies.push('serverInfoPlugins');
};
this.configServer = function(ctx) {
ctx.hostTemplateJS('js/server-routes');
ctx.hostTemplateHTML('thtml/routes',true);
ctx.registrateMenuItem({
name: 'Server Routes',
link: ctx.troot.tmeta.tplugin.angular.tbase+'/server/routes',
enable: true,
roles: [],
icon: 'fa fa-road'
},'server');
};
};
})();

128
lib/plugin/ui/angular/ui-angular.js vendored Normal file
View file

@ -0,0 +1,128 @@
var debug = require('debug')('ff:tcrud:ui:angular:boot');
module.exports = (function () {
var renderCrudController = function (tview, thtmlPrefix, tapiPrefix, tapiPrefix2) {
if (tview.tmeta.tmodel.tkeys.length === 0) {
throw Error('no model keys in: '+tview.tid);
}
var keySlug = '';
for (var i = 0; i < tview.tmeta.tmodel.tkeys.length; i++) {
var key = tview.tmeta.tmodel.tkeys[i];
keySlug += '$routeParams.'+key;
if (i < (tview.tmeta.tmodel.tkeys.length - 1)) {
keySlug += '/';
}
}
var tviewCode = '';
var slugParts = tview.tslug.split('/');
for (var i = 0; i < slugParts.length; i++) {
var part = slugParts[i];
part = part.replace(/-/g,''); // TODO use tcode which is already cleaned ?
tviewCode += part.substring(0,1).toUpperCase()+part.substring(1);
}
//debug('tviewCode: $s',tviewCode);
return function (req, res, next) {
res.set('Content-Type', 'text/javascript');
res.render('node-ff-tcrud/angular/js/crud/controller',{
tview: tview,
tviewCode: tviewCode,
thtmlPrefix: thtmlPrefix,
tapiPrefix: tapiPrefix,
tapiPrefix2: tapiPrefix2,
ejsRouteParams: keySlug
});
};
}
var renderCrudTemplate = function (tview,paction) {
var ejsKeyRow = '';
var ejsKeyData = '';
for (var i = 0; i < tview.tmeta.tmodel.tkeys.length; i++) {
var key = tview.tmeta.tmodel.tkeys[i];
ejsKeyRow += '{{row.'+key+'}}';
ejsKeyData += '{{data.'+key+'}}';
if (i < (tview.tmeta.tmodel.tkeys.length - 1)) {
ejsKeyRow += '/';
ejsKeyData += '/';
}
}
return function (req, res, next) {
res.render('node-ff-tcrud/angular/'+paction+'/'+req.params.action,{
tview: tview,
ejsKeyRow: ejsKeyRow,
ejsKeyData: ejsKeyData
});
};
}
return function UIAngularCorePlugin() {
this.configPlugin = function (ctx) {
ctx.key = 'angular';
ctx.description = 'Exports angular ui data.';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'ui-angular.json';
ctx.dependencies.push('uiLibAngular');
ctx.dependencies.push('uiLibFFSpaLoader');
//ctx.dependencies.push('uiLibTopcoat');
ctx.dependencies.push('serverConfigTMenu');
ctx.dependencies.push('uiLibFontFaceOnLoad');
};
this.configServer = function(ctx) {
ctx.hostTemplateJS('js/application');
ctx.hostTemplateJS('js/application-font');
ctx.hostTemplateJS('js/application-controller')
ctx.hostTemplateJS('js/navigation-service');
ctx.hostTemplateHTML('thtml/application-view',true);;
ctx.hostTemplateHTML('thtml/application-top',true);
ctx.hostTemplateHTML('thtml/application-top-action',true);
ctx.hostTemplateHTML('thtml/application-top-tabs',true);
var uiPath = ctx.troot.tmeta.tplugin.angular.tbase;
debug('Exported uiPath: %s',uiPath);
ctx.server.get('/', ctx.renderRedirect(uiPath));
ctx.server.get(uiPath, ctx.renderTemplate('index','text/html'));
ctx.server.get(uiPath+'/*', ctx.renderTemplate('index','text/html')); // must be last; for HTML5 history
ctx.registrateMenu({
name: 'Server',
icon: 'fa fa-server'
},'server'); // move ?
};
this.configApi = function(ctx) {
var uriPrefix = ctx.createSlugApiTEntityBase();
var thtmlPrefix = uriPrefix + '/' + ctx.tview.tmeta.tplugin.angular.thtml;
var tapiPrefix = ctx.createSlugApiTEntityBasePlugin('formatJSON'); // TODO: move to tview ?
var tapiPrefix2 = ctx.createSlugApiTEntityBasePlugin('serverConfigTView'); // TODO: move to tview ?
ctx.server.get(uriPrefix + '/thtml/crud/:action', renderCrudTemplate(ctx.tview,'thtml/crud/'));
ctx.server.get(uriPrefix + '/crud/controller.js', renderCrudController(ctx.tview,thtmlPrefix,tapiPrefix,tapiPrefix2));
//ctx.server.get(uriPrefix + '/service.js', renderCrudService(tview))
ctx.registrateClientJSResource(uriPrefix + '/crud/controller.js');
if (ctx.tview.tmeta.tmenu.tenable && ctx.tview.tmeta.tmenu.tkey !== null && ctx.tview.tmeta.tmenu.titem) {
ctx.registrateMenuItem({
name: ctx.tview.tmeta.tmenu.tname,
link: ctx.tview.tmeta.tplugin.angular.tbase+'/'+ctx.tview.tslug+'/'+ctx.tview.tlist.tplugin.angular.tslug,
enable: ctx.tview.tlist.tenable,
roles: ctx.tview.tlist.troles,
icon: ctx.tview.tmeta.tmenu.ticon
},ctx.tview.tmeta.tmenu.tkey);
}
};
};
})();

View file

@ -0,0 +1,72 @@
{
"masterTEntityTemplate": {
"tlist": { "tplugin": { "angular": {
"tslug": "list",
"thtml": "crud/list",
"tcontroller": {
"prefix": "tcrudAuto",
"postfix": "ListCntr",
"argu": "$scope, $http, $location, $routeParams, navigationService"
},
"tlinks": {
"DataTODO":"/ui/XNodeData/list/XNode/{{row.net_id}}/{{row.net_id}}"
}
}}},
"tcreate": { "tplugin": { "angular": {
"tslug": "create",
"thtml": "crud/create",
"tcontroller": {
"prefix": "tcrudAuto",
"postfix": "CreateCntr",
"argu": "$scope, $http, $location, $routeParams, navigationService"
}
}}},
"tedit": { "tplugin": { "angular": {
"tslug": "edit",
"thtml": "crud/edit",
"tcontroller": {
"prefix": "tcrudAuto",
"postfix": "EditCntr",
"argu": "$scope, $http, $location, $routeParams, navigationService"
}
}}},
"tread": { "tplugin": { "angular": {
"tslug": "read",
"thtml": "crud/read",
"troute": {
},
"tcontroller": {
"prefix": "tcrudAuto",
"postfix": "ReadCntr",
"argu": "$scope, $http, $location, $routeParams, navigationService"
}
}}},
"tdelete": { "tplugin": { "angular": {
"tslug": "delete",
"thtml": "crud/delete",
"tcontroller": {
"prefix": "tcrudAuto",
"postfix": "DeleteCntr",
"argu": "$scope, $http, $location, $routeParams, navigationService"
}
}}},
"tcount": { "tplugin": { "angular": { "tslug": "list-count" }}},
"tverify": { "tplugin": { "angular": { "tslug": "verify" }}},
"tmeta": { "tplugin": { "angular": {
"tslug": "angular",
"tbase": "/ui",
"thtml": "thtml"
}}}
},
"masterTEntityTHelp": {
"tlist": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tcreate": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tedit": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tread": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tdelete": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tcount": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tverify": { "tplugin": { "angular": { "tslug": "slug of api url" }}},
"tmeta": { "tplugin": { "angular": { "tslug": "slug of api url" }}}
}
}

View file

@ -0,0 +1,46 @@
module.exports = (function () {
var incHostFileJSNodeModule = function(ctx,includeFile,namePart) {
if (includeFile) {
ctx.hostFileJSNodeModule({file: 'angular-'+namePart+'.min.js', path: 'angular-'+namePart});
}
};
return function UILibAngularPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibAngular';
ctx.description='Adds angular libs to resources.';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'ui-lib-angular.json';
ctx.dependencies.push('uiLibJQuery');
};
this.configServer = function(ctx) {
ctx.hostFileJSNodeModule({file: 'angular.min.js', path: 'angular'});
var inc = ctx.troot.tmeta.tplugin.uiLibAngular.include;
incHostFileJSNodeModule(ctx,inc.animate,'animate');
incHostFileJSNodeModule(ctx,inc.resource,'resource');
incHostFileJSNodeModule(ctx,inc.route,'route');
incHostFileJSNodeModule(ctx,inc.touch,'touch');
if (inc['ui-grid']) {
var filter = {
'(^.*url.*?;)': '', // removed all urls
'(@font-face[\\s\\S]*?})': '', // remove font-face
'(^\\s+)': '', // clean up white space
'(\\{[\\s\\/]+\\/.*)': '{', // rm comment on functions
'(^|\\s\\/\\/.*)': '', // rm comment lines
'(\\/\\*[\\s\\*\\!][\\s\\S]*?\\*\\/)': '', // rm comment blocks
};
ctx.hostFileJSNodeModule({file: 'ui-grid.min.js', path: 'angular-ui-grid'});
ctx.hostFileCSSNodeModule({file: 'ui-grid.css', path: 'angular-ui-grid', filterRegex: filter});
ctx.hostFileCSSFontNodeModule({file: 'ui-grid.ttf', path: 'angular-ui-grid/', fontFamily: 'ui-grid'});
}
};
};
})();

View file

@ -0,0 +1,19 @@
{
"masterTEntityTemplate": {
"tmeta": { "tplugin": { "uiLibAngular": {
"tslug": "uiLibAngular",
"include": {
"animate": true,
"resource": true,
"route": true,
"touch": true,
"ui-grid": true
}
}}}
},
"masterTEntityTHelp": {
"tmeta": { "tplugin": { "uiLibAngular": {
"tslug": "The angular lib slug."
}}}
}
}

View file

@ -0,0 +1,27 @@
module.exports = (function () {
return function UILibBootstrapPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibBootswatch';
ctx.description='Adds and hosts bootstrap.css as client resource.';
};
this.configServer = function(ctx) {
var filter = {
'(^.*url.*?;)': '', // removed all urls
'(@font-face[\\s\\S]*?})': '', // remove font-face
//'(body[\\s\\S]*?})': '', // remove body
'(^\\s+)': '', // clean up white space
'(\\{[\\s\\/]+\\/.*)': '{', // rm comment on functions
'(^|\\s\\/\\/.*)': '', // rm comment lines
'(\\/\\*[\\s\\*\\!][\\s\\S]*?\\*\\/)': '', // rm comment blocks
};
ctx.hostFileCSSNodeModule({file: 'bootstrap.css', path: 'bootswatch/paper', filterRegex: filter});
ctx.hostFileJSNodeModule({file: 'bootstrap.js', path: 'bootstrap/dist/js'});
ctx.hostFileCSSFontNodeModule({file: 'glyphicons-halflings-regular.ttf', path: 'bootswatch/fonts/', fontFamily: 'Glyphicons Halflings'});
};
};
})();

View file

@ -0,0 +1,20 @@
module.exports = (function () {
return function UILibSpaLoaderPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibFFSpaLoader';
ctx.description='Adds FFSpaLoader lib to resources.';
ctx.localDir = __dirname;
ctx.dependencies.push('serverConfigResourcesWeb');
ctx.dependencies.push('serverConfigResourcesMobile'); // TODO: is this opt ?
};
this.configServer = function(ctx) {
//ctx.hostFileJSNodeModule({file: 'es5-ff-spa-loader.js', path: 'es5-ff-spa-loader/dist', registrate: false});
ctx.hostFileJSNodeModule({file: 'es5-ff-spa-loader.js', path: '../../es5-ff-spa-loader', registrate: false});
ctx.hostFileCSSNodeModule({file: 'es5-ff-spa-loader.css', path: '../../es5-ff-spa-loader', registrate: false});
};
};
})();

View file

@ -0,0 +1,39 @@
module.exports = (function () {
var incHostFileJSNodeModule = function(ctx,includeFile,namePart) {
if (includeFile) {
ctx.hostFileJSNodeModule({file: 'jquery.flot.'+namePart+'.js',path: 'flot'});
}
};
return function UILibFlotPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibFlot';
ctx.description='Adds basic flot js libs to resources.';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'ui-lib-flot.json';
ctx.dependencies.push('uiLibJQuery');
};
this.configServer = function(ctx) {
ctx.hostFileJSNodeModule({file: 'jquery.flot.js', path: 'flot'});
var inc = ctx.troot.tmeta.tplugin.uiLibFlot.include;
incHostFileJSNodeModule(ctx,inc.categories, 'categories');
incHostFileJSNodeModule(ctx,inc.crosshair, 'crosshair');
incHostFileJSNodeModule(ctx,inc.errorbars, 'errorbars');
incHostFileJSNodeModule(ctx,inc.fillbetween, 'fillbetween');
incHostFileJSNodeModule(ctx,inc.image, 'image');
incHostFileJSNodeModule(ctx,inc.navigate, 'navigate');
incHostFileJSNodeModule(ctx,inc.pie, 'pie');
incHostFileJSNodeModule(ctx,inc.resize, 'resize');
incHostFileJSNodeModule(ctx,inc.selection, 'selection');
incHostFileJSNodeModule(ctx,inc.stack, 'stack');
incHostFileJSNodeModule(ctx,inc.symbol, 'symbol');
incHostFileJSNodeModule(ctx,inc.threshold, 'threshold');
incHostFileJSNodeModule(ctx,inc.time, 'time');
};
};
})();

View file

@ -0,0 +1,27 @@
{
"masterTEntityTemplate": {
"tmeta": { "tplugin": { "uiLibFlot": {
"tslug": "uiLibFlot",
"include": {
"categories": false,
"crosshair": false,
"errorbars": false,
"fillbetween": false,
"image": false,
"navigate": false,
"pie": true,
"resize": true,
"selection": false,
"stack": true,
"symbol": false,
"threshold": false,
"time": true
}
}}}
},
"masterTEntityTHelp": {
"tmeta": { "tplugin": { "uiLibFlot": {
"tslug": "The server debug slug."
}}}
}
}

View file

@ -0,0 +1,25 @@
module.exports = (function () {
return function UILibBootstrapPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibFontAwesome';
ctx.description='Adds fontawesome client resources.';
};
this.configServer = function(ctx) {
var filter = {
'(^.*url.*?;)': '', // removed all urls
'(@font-face[\\s\\S]*?})': '', // remove font-face
'(^\\s+)': '', // clean up white space
'(\\{[\\s\\/]+\\/.*)': '{', // rm comment on functions
'(^|\\s\\/\\/.*)': '', // rm comment lines
'(\\/\\*[\\s\\*\\!][\\s\\S]*?\\*\\/)': '', // rm comment blocks
};
ctx.hostFileCSSNodeModule({file: 'font-awesome.css', path: 'font-awesome/css', filterRegex: filter});
ctx.hostFileCSSFontNodeModule({file: 'fontawesome-webfont.ttf', path: 'font-awesome/fonts/', fontFamily: 'FontAwesome'});
};
};
})();

View file

@ -0,0 +1,15 @@
module.exports = (function () {
return function UILibFontFaceOnLoadPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibFontFaceOnLoad';
ctx.description='Adds fontfaceonload js lib to resources.';
};
this.configServer = function(ctx) {
ctx.hostFileJSNodeModule({file: 'fontfaceonload.js', path: 'fontfaceonload/dist'});
};
};
})();

View file

@ -0,0 +1,15 @@
module.exports = (function () {
return function UILibJQueryPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiLibJQuery';
ctx.description='Adds jquery js lib to resources.';
};
this.configServer = function(ctx) {
ctx.hostFileJSNodeModule({file: 'jquery.min.js', path: 'jquery/dist'});
};
};
})();

View file

@ -0,0 +1,18 @@
module.exports = (function () {
return function UISpaStylePlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiSpaStyle';
ctx.description='Adds basic styling resources.';
ctx.dependencies.push('uiSpaTopcoatFont');
};
this.configServer = function(ctx) {
ctx.hostTemplateCSS('css/flot');
ctx.hostTemplateCSS('css/panel');
ctx.hostTemplateCSS('css/style');
};
};
})();

View file

@ -0,0 +1,19 @@
module.exports = (function () {
var fontPath = 'topcoat-fonts/font/SourceSansPro/';
return function UISpaTopcoatFontPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiSpaTopcoatFont';
ctx.description='Adds Source Sans Pro fonts.';
};
this.configServer = function(ctx) {
ctx.hostFileCSSFontNodeModule({file: 'SourceSansPro-Light.otf', path: fontPath, fontFamily: 'Source Sans', fontWeight: 200});
ctx.hostFileCSSFontNodeModule({file: 'SourceSansPro-Regular.otf', path: fontPath, fontFamily: 'Source Sans', fontWeight: 400});
ctx.hostFileCSSFontNodeModule({file: 'SourceSansPro-Semibold.otf',path: fontPath, fontFamily: 'Source Sans', fontWeight: 600});
};
};
})();

View file

@ -0,0 +1,24 @@
module.exports = (function () {
return function UISpaTopcoatPlugin() {
this.configPlugin = function (ctx) {
ctx.key='uiSpaTopcoat';
ctx.description='Adds and hosts topcoat.css as client resource.';
};
this.configServer = function(ctx) {
var filter = {
'(^.*url.*?;)': '', // removed all urls
'(@font[\\s\\S]*?})': '', // remove font-face
'(body[\\s\\S]*?})': '', // remove body
'(^\\s+)': '', // clean up white space
'(\\{[\\s\\/]+\\/.*)': '{', // rm comment on functions
'(^|\\s\\/\\/.*)': '', // rm comment lines
'(\\/\\*[\\s\\*\\!][\\s\\S]*?\\*\\/)': '', // rm comment blocks
};
ctx.hostFileCSSNodeModule({file: 'topcoat-mobile-dark.css',path: 'topcoat/css', filterRegex: filter});
};
};
})();