diff --git a/_vault/design_aspects/ecms.js b/_vault/design_aspects/ecms.js index 52e8eb9..b65f8c9 100644 --- a/_vault/design_aspects/ecms.js +++ b/_vault/design_aspects/ecms.js @@ -31,7 +31,7 @@ var Schema1 = new Schema({ } }); -mongoose.model('User', Schema1); +mongoose.model('ECMS', Schema1); /* An equipment has a model. diff --git a/config/config.server.js b/config/config.server.js index d5857e4..a9e31fd 100644 --- a/config/config.server.js +++ b/config/config.server.js @@ -56,6 +56,7 @@ module.exports = function(app){ // override with the X-HTTP-Method-Override header in the request. simulate DELETE/PUT app.use(methodOverride('X-HTTP-Method-Override')); + app.use(methodOverride('_method')); if (app.get('env') === 'development') require('./env/development')(app); @@ -66,7 +67,8 @@ module.exports = function(app){ // set the static files location /public/img will be /img for users app.use(express.static(path.resolve('public'))); // app.use(express.static('uploads')); http://expressjs.com/en/starter/static-files.html // app.use(express.static(path.resolve('modules/client/core'))); - + app.use(express.static(path.resolve('modules/core/client/views'))); + app.use(express.static(path.resolve('modules/angular1/client/views'))); // render views require('./config.view')(app); diff --git a/modules/angular1/client/views/angular1-ui.html b/modules/angular1/client/views/angular1-ui.html new file mode 100644 index 0000000..f27bca4 --- /dev/null +++ b/modules/angular1/client/views/angular1-ui.html @@ -0,0 +1,57 @@ + + + + + UI-Router + + + + +
+ + +

Best viewed in pop-out mode to see location changes. Click blue button on the right.

+ + + +
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/modules/angular1/client/views/includes/state1.html b/modules/angular1/client/views/includes/state1.html new file mode 100644 index 0000000..924563b --- /dev/null +++ b/modules/angular1/client/views/includes/state1.html @@ -0,0 +1,3 @@ +

State 1

+
+
\ No newline at end of file diff --git a/modules/angular1/client/views/includes/state1.list.pug b/modules/angular1/client/views/includes/state1.list.pug new file mode 100644 index 0000000..5d9f017 --- /dev/null +++ b/modules/angular1/client/views/includes/state1.list.pug @@ -0,0 +1,3 @@ +h3 List of State 1 Items +ul + li(ng-repeat='item in items') {{item}} \ No newline at end of file diff --git a/modules/angular1/client/views/includes/state1.pug b/modules/angular1/client/views/includes/state1.pug new file mode 100644 index 0000000..16840e8 --- /dev/null +++ b/modules/angular1/client/views/includes/state1.pug @@ -0,0 +1,4 @@ +h1 State 1 +hr + a(ui-sref='state1.list') Show List + div(ui-view) \ No newline at end of file diff --git a/modules/angular1/client/views/includes/state2.html b/modules/angular1/client/views/includes/state2.html new file mode 100644 index 0000000..73d5877 --- /dev/null +++ b/modules/angular1/client/views/includes/state2.html @@ -0,0 +1,3 @@ +

State 2

+
+
\ No newline at end of file diff --git a/modules/angular1/client/views/includes/state2.list.pug b/modules/angular1/client/views/includes/state2.list.pug new file mode 100644 index 0000000..388aa99 --- /dev/null +++ b/modules/angular1/client/views/includes/state2.list.pug @@ -0,0 +1,3 @@ +h3 List of State 2 Items +ul + li(ng-repeat='item in items') {{item}} \ No newline at end of file diff --git a/modules/angular1/client/views/includes/state2.pug b/modules/angular1/client/views/includes/state2.pug new file mode 100644 index 0000000..b8e5b29 --- /dev/null +++ b/modules/angular1/client/views/includes/state2.pug @@ -0,0 +1,4 @@ +h1 State 2 +hr + a(ui-sref='state2.list') Show List + div(ui-view) \ No newline at end of file diff --git a/modules/calibrates/client/views/calibrate.pug b/modules/calibrates/client/views/calibrate.pug index a63aab0..2c66a8d 100644 --- a/modules/calibrates/client/views/calibrate.pug +++ b/modules/calibrates/client/views/calibrate.pug @@ -10,6 +10,7 @@ block content table.table.table-striped thead.thead-inverse tr + th Actions th Asset Number th Model th Location @@ -19,6 +20,13 @@ block content tbody each calibrate in calibrates tr + td + form(action='/calibrates/asset_number/' + calibrate.asset_number+'?_method=',method='post',enctype='application/x-www-form-urlencoded') + // temporarily obstrusive method + button(type='submit', onclick='this.form.action=this.form.action+"DELETE";'). + Delete + button(type='submit', onclick='this.form.action=this.form.action+"GET";'). + View td= calibrate.asset_number td= calibrate.model td= calibrate.ECMS_Location.desc @@ -27,4 +35,4 @@ block content - if (calibrate.ECMS_Attributes[0].file) { td= calibrate.ECMS_Attributes[0].file - } - - } \ No newline at end of file + - } \ No newline at end of file diff --git a/modules/calibrates/client/views/list.pug b/modules/calibrates/client/views/list.pug new file mode 100644 index 0000000..0a71d5e --- /dev/null +++ b/modules/calibrates/client/views/list.pug @@ -0,0 +1,22 @@ +div + h3='Listing from ECMS main table' + - if (mains.length) { + table.table + tr + th id + th asset_number + th file + th last_cal + th next_cal + th schedule + each main in mains + tr + td= main.id + td= main.asset_number + td= main.file + td #{main.last_cal.toDateString()} + - if (main.next_cal) { + td #{main.next_cal.toDateString()} + - } + td= main.schedule + - } \ No newline at end of file diff --git a/modules/calibrates/client/views/main.pug b/modules/calibrates/client/views/main.pug index 4e66179..882e03e 100644 --- a/modules/calibrates/client/views/main.pug +++ b/modules/calibrates/client/views/main.pug @@ -4,24 +4,4 @@ block page - var menu = 'calibrates' block content div - h3='Listing from ECMS main table' - - if (mains.length) { - table.table - tr - th id - th asset_number - th file - th last_cal - th next_cal - th schedule - each main in mains - tr - td= main.id - td= main.asset_number - td= main.file - td #{main.last_cal.toDateString()} - - if (main.next_cal) { - td #{main.next_cal.toDateString()} - - } - td= main.schedule - - } \ No newline at end of file + #content \ No newline at end of file diff --git a/modules/core/client/views/includes/ui-menu.html b/modules/core/client/views/includes/ui-menu.html new file mode 100644 index 0000000..39b385e --- /dev/null +++ b/modules/core/client/views/includes/ui-menu.html @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/modules/core/client/views/index.pug b/modules/core/client/views/index.pug index 565737f..8676093 100644 --- a/modules/core/client/views/index.pug +++ b/modules/core/client/views/index.pug @@ -3,4 +3,12 @@ extends layout block page - var menu = 'index' block content - p #{greet}! \ No newline at end of file + p #{greet}! + div(ng-app='manukeApp') + div(ng-controller='coreCtrl') + div(ng-include="'includes/ui-menu.html'") + #content(ui-view) + a(ui-sref="state1") State 1 + a(ui-sref="state2") State 2 + - x = {"name": "john", "age": "5" } + input(type="text", name=x.name, value=x.age) \ No newline at end of file diff --git a/modules/core/client/views/layout.pug b/modules/core/client/views/layout.pug index 73b7cc0..e3d7d68 100644 --- a/modules/core/client/views/layout.pug +++ b/modules/core/client/views/layout.pug @@ -6,42 +6,47 @@ html(lang='en') link(rel='stylesheet', type='text/css', href='/css/core.css') link(rel='stylesheet', href='/lib/bootstrap/dist/css/bootstrap.min.css') body - #wrap - .container - h1 Manuke application - h2 #{title} application - span Environment: #{env} - block header - div.container-fluid - block page - block nav - div - include includes/menu - .content - br - block content - br - br - span.alert-success Tervetuloa, Välkommen, Velkommen, Bienvenue, Welcome, Willkommen ! - block footer - footer - .container.floatright.right.italic-small.nopad.gray.inline-block - p - | Made from Helsinki with love Copyright © ZeTekLA 2016 | Issues? Submit to   - a(href="https://github.com/zenithtekla/NodeMySQL") GitHub - | . + .container#wrap + h1 Manuke application + h2 #{title} application + span Environment: #{env} + block header + block page + block nav + div + include includes/menu + .content + br + block content + br + br + span.alert-success Tervetuloa, Välkommen, Velkommen, Bienvenue, Welcome, Willkommen ! + block footer + footer + .container.floatright.right.italic-small.nopad.gray.inline-block + p + | Made from Helsinki with love Copyright © ZeTekLA 2016 | Issues? Submit to   + a(href="https://github.com/zenithtekla/NodeMySQL") GitHub + | . + // build:js(.) scripts/vendor.js // bower:js - script(src='/lib/jquery/dist/jquery.min.js') - script(src='/lib/angular/angular.min.js') - script(src='/lib/moment/min/moment.min.js') - script(src='/lib/tether/dist/js/tether.min.js') - script(src='/lib/bootstrap/dist/js/bootstrap.min.js') - script(src='/lib/angular-animate/angular-animate.min.js') - script(src='/lib/angular-cookies/angular-cookies.min.js') - script(src='/lib/angular-resource/angular-resource.min.js') - script(src='/lib/angular-ui-router/release/angular-ui-router.min.js') - script(src='/lib/angular-route/angular-route.min.js') - script(src='/lib/angular-sanitize/angular-sanitize.min.js') - script(src='/lib/angular-touch/angular-touch.min.js') - script(src='/lib/lodash/dist/lodash.min.js') - script(src='/lib/angular-bootstrap/ui-bootstrap-tpls.js') \ No newline at end of file + .script + script(src='/lib/jquery/dist/jquery.min.js') + script(src='/lib/angular/angular.min.js') + script(src='/lib/moment/min/moment.min.js') + script(src='/lib/tether/dist/js/tether.min.js') + script(src='/lib/bootstrap/dist/js/bootstrap.min.js') + script(src='/lib/angular-animate/angular-animate.min.js') + script(src='/lib/angular-cookies/angular-cookies.min.js') + script(src='/lib/angular-resource/angular-resource.min.js') + script(src='/lib/angular-ui-router/release/angular-ui-router.min.js') + script(src='/lib/angular-route/angular-route.min.js') + script(src='/lib/angular-sanitize/angular-sanitize.min.js') + script(src='/lib/angular-touch/angular-touch.min.js') + script(src='/lib/lodash/dist/lodash.min.js') + script(src='/lib/angular-bootstrap/ui-bootstrap-tpls.js') + // endbower + // endbuild + // build:js({.tmp,app}) js/app.js + script(src='/app/core.client.config.js') + script(src='/app/core.client.controllers.js') diff --git a/modules/core/server/controllers/core.server.controllers.js b/modules/core/server/controllers/core.server.controllers.js index fadee27..ab70ed1 100644 --- a/modules/core/server/controllers/core.server.controllers.js +++ b/modules/core/server/controllers/core.server.controllers.js @@ -2,11 +2,11 @@ var models = require( process.cwd() + '/modules/core/server/models'), env = process.env.NODE_ENV || "development"; -exports.home = function (req,res) { +exports.layout = function (req,res) { res.render('layout', {title: "CoreHomeApp", env: env}); }; -exports.greet = function (req,res) { - res.render('index', {greet: "This is a greet text", title: "CoreIndexApp", env: env}); +exports.home = function (req,res) { + res.render('index', {greet: "This is a greet text @ index page", title: "CoreIndexApp", env: env}); }; exports.article = function (req,res) { diff --git a/modules/core/server/routes/core.server.routes.js b/modules/core/server/routes/core.server.routes.js index d35e894..f89659b 100644 --- a/modules/core/server/routes/core.server.routes.js +++ b/modules/core/server/routes/core.server.routes.js @@ -2,9 +2,9 @@ var controller = require('../controllers/core.server.controllers'); module.exports = function(app){ - app.get('/home', controller.home) + app.get('/layout', controller.layout) .get('/', controller.home) - .get('/greet', controller.greet) + .get('/home', controller.home) .get('/chat', controller.chat) .get('/article', controller.article); diff --git a/public/app/angular1.ui_router.js b/public/app/angular1.ui_router.js new file mode 100644 index 0000000..4f1a547 --- /dev/null +++ b/public/app/angular1.ui_router.js @@ -0,0 +1,31 @@ +var myapp = angular.module('manukeApp', ["ui.router"]) +myapp.config(function($stateProvider, $urlRouterProvider){ + + // For any unmatched url, send to /state1 + $urlRouterProvider.otherwise("/state1") + + $stateProvider + .state('state1', { + url: "/state1", + templateUrl: "includes/state1.html" + }) + .state('state1.list', { + url: "/list", + templateUrl: "includes/state1.list.html", + controller: function($scope){ + $scope.items = ["A", "List", "Of", "Items"]; + } + }) + + .state('state2', { + url: "/state2", + templateUrl: "includes/state2.html" + }) + .state('state2.list', { + url: "/list", + templateUrl: "includes/state2.list.html", + controller: function($scope){ + $scope.things = ["A", "Set", "Of", "Things"]; + } + }) +}) \ No newline at end of file diff --git a/public/app/core.client.config.js b/public/app/core.client.config.js new file mode 100644 index 0000000..f4e2a10 --- /dev/null +++ b/public/app/core.client.config.js @@ -0,0 +1,81 @@ +(function () { + 'use strict'; + var app = angular + .module('manukeApp', [ + 'ui.router', + 'ngAnimate', + 'ui.bootstrap', + 'ngCookies', + 'ngResource', + 'ngRoute', + 'ngSanitize', + 'ngTouch' + ]); + + app.config(routeConfig); + + routeConfig.$inject = ['$stateProvider', '$urlRouterProvider']; + + function routeConfig($stateProvider, $urlRouterProvider) { + $urlRouterProvider.when('', '/state1'); + $urlRouterProvider.otherwise('/404'); + + $stateProvider + .state('home', { + url: '/', + templateUrl: 'modules/core/client/views/index', + controller: 'coreCtrl' + }) + .state('state1', { + url: "/state1", + templateUrl: "includes/state1.html" + }) + .state('state1.list', { + url: "/list", + templateUrl: "includes/state1.list.html", + controller: function($scope) { + $scope.items = ["A", "List", "Of", "Items"]; + } + }) + .state('state2', { + url: "/state2", + templateUrl: "includes/state2.html" + }) + .state('state2.list', { + url: "/list", + templateUrl: "includes/state2.list.html", + controller: function($scope) { + $scope.things = ["A", "Set", "Of", "Things"]; + } + }) + .state('main', { + url: '/table_main', + templateUrl: 'modules/calibrates/client/views/main', + controller: 'coreCtrl' + }) + .state('not-found', { + url: '/not-found', + templateUrl: 'modules/core/client/views/error', + data: { + ignoreState: true, + pageTitle: 'Not-Found' + } + }) + .state('bad-request', { + url: '/bad-request', + templateUrl: 'modules/core/client/views/error', + data: { + ignoreState: true, + pageTitle: 'Bad-Request' + } + }) + .state('forbidden', { + url: '/forbidden', + templateUrl: 'modules/core/client/views/error', + data: { + ignoreState: true, + pageTitle: 'Forbidden' + } + }); + } +}()); \ No newline at end of file diff --git a/public/app/core.client.controllers.js b/public/app/core.client.controllers.js new file mode 100644 index 0000000..2ca5967 --- /dev/null +++ b/public/app/core.client.controllers.js @@ -0,0 +1,14 @@ +(function () { + 'use strict'; + + var app = angular + .module('manukeApp', []) + .controller('coreCtrl', coreCtrlFn); + + coreCtrlFn.$inject = ['$scope', '$http', '$location']; + + function coreCtrlFn($scope, $http, $location) { + console.log('coreCtrl success'); + } + +}()); \ No newline at end of file