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" }}}
}
}