Coder Social home page Coder Social logo

danwahlin / customermanager Goto Github PK

View Code? Open in Web Editor NEW
711.0 93.0 398.0 16.12 MB

CustomerManager AngularJS/BreezeJS Application with a custom route provider.

License: MIT License

C# 12.94% CSS 4.10% JavaScript 70.71% HTML 12.09% Shell 0.06% Batchfile 0.04% ASP.NET 0.04% Pug 0.01%

customermanager's Introduction

Customer Manager with AngularJS (with custom routing and dynamic controller script loading)

If you’re new to AngularJS check out my AngularJS in 60-ish Minutes video tutorial or download the free eBook. Also check out The AngularJS Magazine for up-to-date information on using AngularJS to build Single Page Applications (SPAs).

Also check out my AngularJS JumpStart video course:

Customer Management App

This version of the application has support for custom routing and dynamic controller script loading. See this this post for more details. The standard version of the application with no custom routing can be found here.

This application demonstrates:

  • A complete application with read-only and editable data
  • Using AngularJS with $http in a factory to access a backend RESTful service
  • Using BreezeJS in a factory to access a backend RESTful Service
  • Techniques for showing multiple views of data (card view and list view)
  • Custom filters for filtering customer and product data
  • A custom directive to ensure unique values in a form for email
  • A custom directive that intercepts $http and jQuery XHR requests (in case either are used) and displays a loading dialog
  • A custom directive that handles highlighting menu items automatically based upon the path navigated to by the user
  • Form validation using AngularJS
  • Provides login and authentication functionality (currently client-side only - plan to add server-side part too which is absolutely required in a "real" app)
  • A custom routing mechanism that allows a controller & template to be downloaded dynamically "on the fly" and provides a standard convention for controller and view names (see this post for more details)

The factories can be switched by changing the app/customersApp/services/config useBreeze setting to true.

The AngularJS portion of the app is structured using the following folders:

Customer Management App Structure

Requirements:

If you're using Visual Studio and .NET:

The following is required to support the backend services:

  • Visual Studio 2015 Community (free version) - https://www.visualstudio.com/?WT.mc_id=m365-0000-dwahlin

  • ASP.NET MVC and Web API are used for the back-end services along with Entity Framework for database access (included if you have VS 2015 community installed with the LocalDB option selected)

To get started, double-click the CustomerManager.sln file located at the root of the CustomerManager repository. Once the solution loads press F5 to run the project.

Note: If you want to use Visual Studio 2013 that should work although you may have to change the connection string in web.config from "MSSqlLocalDB" to "v11.0" depending upon which version of LocalDB you have installed.

If you're using Node.js/Express/MongoDB

If you don't already have Node.js on your machine install it from http://nodejs.org. You'll also need to install MongoDB from http://www.mongodb.org if you don't have it already and get it configured and running using the instructions on their site.

In the CustomerManager directory execute 'npm install' to install Express, MongoDB and Mongoose (package.json).

Load MongoDB Sample Data Option 1:

Load data into MongoDB by performing the following steps:

  • Execute 'mongod' to start the MongoDB daemon
  • Navigate to the CustomerManager/server directory (the one that has initMongoData.js in it)
  • Execute 'mongo' to start the MongoDB shell
  • Enter the following in the mongo shell to load the data seed file:
  • use customermanager
  • load("initMongoData.js")

Load Sample Data Option 2:

Alternatively you can navigate to CustomerManager/server and double-click the initMongoData.bat (Windows) or initMongoData.sh (Mac/Linux) file to initialize MongoDB with the data.

The Windows script assumes that MongoDB is installed at c:\mongodb while the Linux/Mac script relies on the fact that you have the monogo executable in the path.

Start the Node/Express server:

  • Open a command prompt
  • Navigate to the CustomerManager directory
  • Run 'npm install' at the command prompt
  • Navigate to the CustomerManager/server directory
  • Run 'node server.js'

View the application at http://localhost:3000

Thanks to Tony Quinn for contributing the initial Node.js/MongoDB code!

customermanager's People

Contributors

azureadvocatebit avatar bryant1410 avatar danwahlin avatar dependabot[bot] avatar dvirh avatar lacmyers avatar robertaramar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

customermanager's Issues

pagination cannot be changed to page size other than 10

Hi Dan

Your demo application is impressive. I am currently study it to understand how to use Angular.js with MVC.

I have a question regarding the data-pagination used in the demo. I tried to change the page size in data-ng-repeat used in the customers.html, and found that data-pagination still shows the same number of pages, assuming the page size is 10. Is that any way to change the page size (thus increase or decrease the total number of pages)?

Thank you
Nelson

app.js is deprecated due to express

I had to make the following changes to the app.js file in order for it to work with express.
I also had to:

npm install mongoose
npm install cookie-parser
npm install express-session
npm install body-parser
npm install method-override
npm install errorhandler
/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')
  , api = require('./routes/api')
  , DB = require('./accessDB').AccessDB
  , protectJSON = require('./lib/protectJSON');

var cookieParser = require('cookie-parser');
var session = require('express-session');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var errorhandler = require('errorhandler')
var app = module.exports = express();

var DB = require('./accessDB');

// Configuration

// app.configure(function(){
  app.use(protectJSON);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  // app.use(express.cookieParser()); //*
  app.use(cookieParser());
  // app.use(express.session({ secret: 'gopalapuram' })); //*
  app.use(session({secret: 'gopalapuram'}));
  // app.use(express.bodyParser());
  app.use(bodyParser());
  // app.use(express.methodOverride());
  app.use(methodOverride());
  app.use(express.static(__dirname + '/../'));
  // app.use(app.router);
// });

var conn = 'mongodb://localhost/custmgr';
var db;
db = new DB.startup(conn);

// development only
if ('development' == app.get('env')) {
  // app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
  app.use(errorhandler({ dumpExceptions: true, showStack: true }));
}

// production only
if ('production' == app.get('env')) {
  // app.use(express.errorHandler());
  app.use(errorhandler());
}

function csrf(req, res, next) {
  res.locals.token = req.session._csrf;
  next();
}

// Routes

app.get('/', routes.index);

// JSON API

app.get('/api/dataservice/Customers', api.customers);
app.get('/api/dataservice/Customer/:id', api.customer);
app.post('/api/dataservice/PostCustomer', api.addCustomer);
app.put('/api/dataservice/PutCustomer/:id', api.editCustomer);
app.delete('/api/dataservice/DeleteCustomer/:id', api.deleteCustomer);

app.get('/api/dataservice/States', api.states);

app.get('/api/dataservice/CustomersSummary', api.customersSummary);
app.get('/api/dataservice/CustomerById/:id', api.customer);
app.get('/api/dataservice/CheckUnique/:email', api.checkemail);


// redirect all others to the index (HTML5 history)
app.get('*', routes.index);

// Start server

app.listen(3000, function(){
  console.log("CustMgr Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});

RequireJS caching objects

I love the idea you have here and just finished refactoring my code to get a similar pattern working. One big (HUGE) gotcha that took me quite a while to work out, though, was that RequireJS seems to cache any returned object. The result of this is that the creation of the extra property (register) in the app at config time is not persisted to the cached app object. This caused my code to blow up at the registration of the controllers (because register was undefined).

By not returning the app as an object and instead just calling angular.module('myapp').register, I was able to work around it. Just throwing this out there in case anyone else runs across this weirdness (and in case you have some sage advice on the matter).

Cannot load app

Hey, thanks for your git contributions!

I can't seem to get the app to load properly, and I was wondering if you had any suggestions.
So far I get this:

screen shot 2014-10-26 at 5 39 26 pm

To get the app loaded that far I had to edit a case sensitive typo in index.html
<script src="Scripts/tweenMax.min.js"></script>
to
<script src="Scripts/TweenMax.min.js"></script>

I also changed:
<script src="Scripts/require.js" data-main="scripts/main"></script>
to
<script src="Scripts/require.js" data-main="Scripts/main"></script>
And after those changes the page loaded as pictured above.
From what I can see it seems like main.js needs some work potentially. Are the javascript files being required properly? They do not need the .js file ending?

Appreciate any feedback and suggestions! Thanks again!

NodeJS+MongoDB backend

I would like to see it with a node+mongo backend as you said!
I think will help a lot newcomers like me. thank you for sharing knowledge

Can not load the seed files.

I have mongo running, but can't load the seed files.

Using mac OSX, my terminal output is:


curtiss-mbp:CustomerManager curtiss$ mongo
MongoDB shell version: 2.7.4
connecting to: test
Server has startup warnings:
2014-08-16T18:28:54.115-0400 [initandlisten]
2014-08-16T18:28:54.115-0400 [initandlisten] ** NOTE: This is a development version (2.7.4) of MongoDB.
2014-08-16T18:28:54.115-0400 [initandlisten] ** Not recommended for production.
2014-08-16T18:28:54.115-0400 [initandlisten]
2014-08-16T18:28:54.115-0400 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2014-08-16T18:28:54.115-0400 [initandlisten]

use custmgr
switched to db custmgr
load("initMongoCustData.js")
2014-08-16T18:40:33.956-0400 Error: remove needs a query
at Error ()
at DBCollection.remove (src/mongo/shell/collection.js:299:31)
at initMongoCustData.js:65:14
at (shell):1:1 at src/mongo/shell/collection.js:299
2014-08-16T18:40:33.956-0400 Error: error loading js file: initMongoCustData.js
at (shell):1:1

Wondering if I'm missing something here?

routeresolver - n number of controllers

The way the routeresolver is written right now, all the controllers have to be in one folder. If we want to differentiate between sections or areas, we would need to modify the resolver. We are considering adding a path parameter to handle folders. What is your opinion on this?

No solution in download

There is no solution file in the download. Errors are generated when you run the application using the .csproj project. Please fix.

How to execute code?

Honestly this definition is not clear at all . It was good if somebody who know how we can execute this code take a video of all this instructions in order to be clear. I spent near 2 hours, after having lots of error i change my opinion to continue with it.
What is happen if somebody is not familiar with mongodb. so how we can continue all this steps and so on.

disable motion continuous creation of bbdd for developing

Hi there:

I created a new DB on a server, with new tables and each time the application is run from Visual Studio is completely deleted.

It is possible to disable the ongoing creation of the DB ...

I tried to cancel the process from reposiroty or from mongo and continues to create the DB

Thank you

App does not work on Ubuntu 13.10

Node - 0.10.15
Mongodb - 2.4.8

Steps to reproduce:

  1. Clone repo
  2. use mongo shell to setup db.
  3. run npm install ( in folder containing package.json )
  4. run node app.'s ( in server folder )
  5. navigate to http://localhost:3000/

Observed Result:
Blank Page with Title - Customer Manager

Noticed the following errors on Chrome console
Uncaught SyntaxError: Unexpected token < tweenMax.min.js:1
Uncaught SyntaxError: Unexpected token < :3000/scripts/main.js:1

Adil

Bind Data To Modal

Hi
I use your Modal Service to show my template in modal but when i create model on controller and set to $scope and bind to some directive in modal template two-way binding is not worked, how can i change data on controller in modal template?

my

gfdfgdfg

angular hotkeys

Hello,
I'm impressed with your solution. Thanks

I have a little app using angular hotkeys, but have no idea how to inject into controller.

Would you mind, teach me how

Thanks in advance

new project throws exception

here is the exception

{ [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect EC
REFUSED' } 'Error: connect ECONNREFUSED\n at exports._errnoException (util
:746:11)\n at TCPConnectWrap.afterConnect as oncomplete

my workaround was npm install

Unable to load customer list

Hi Dan,

I stared node server.js and verified the api/dataservice is OK http://localhost:3000/api/dataservice

I tried to run debug mode in visual studio for the front end however it could not load the customers list due to it was trying to locate the server location on http://localhost:51511/api/dataservice

I tried to open the customersService.js and modified the var serviceBase = '/api/dataservice/' to var serviceBase = 'http://localhost:3000/api/dataservice/'. It throws the exception on XMLHttpRequest cannot load ... Origin is not allowed by Access-Control-Allow-Origin.

Google and I found plenty of solution however I can only manage to fix the GET API e.g able to load customer data by adding Access-Control-Allow-Origin", "*" to server.js.

I could not fix the POST API for the authService.js

Please advise the solution for this.

Thanks
Thomas.

httpInterceptors doesn't work ;)

Hi Dan!

I just tried to use the interceptor but I noticed that nothing happens when I got 401 unauthorized, So I checked the code in refer to the documentation and I found that you return a promise instead of an object of 'request','response' as explained in here.

For example:

$httpProvider.interceptors.push(function($q, dependency1, dependency2) {
  return {
   'request': function(config) {
       // same as above
    },
    'response': function(response) {
       // same as above
    }
  };
});

Yeoman generator

Hi Dan,
Good job.
It will be very interesting if some one can write a Yeoman Generator for this good project.
Regards.

passing a url fetched from a service to a factory; factory use it to fetch additional data and pass it to a route

Hi Dan,

Thank you for your great tutorial and video on 60-ish minutes on Angular - that was my bootstrap help in starting to learn this one-page app framework.

I worked on your customermanagerapp example (not this last release, just the simpler initial one) and I'd like to kindly ask for a briefing to you...

What I want to do is the following:

  1. a general ng-app="site" which collect a list of objects from a server (e.g. customers, the list of customers is pulled via $http )
  2. each object contains a link (like the orders of the customers, but in this case is a $http json request associated to that customer)
    3.A. By clicking on a obj link the app routes to the object-page (the customer page)
    3.B By clicking on the obj link a factory/service component of the object-page load additional data for that object, and render the graph associated with it. (the customer page displays also additional data fetched from point 2.)

At the moment, I've been (almost) able to code 3.B, thank also to the work
I say almost cause I want to call data from wikipedia, and I am able to fetch data in a factory but I failed for some reason to pass it to the directive to render the graph (return an undefined).

I have doubt in how to code 3.A.
For example, I have a service fetching data of the objets.
I have a factory fetching additional data for a selected object.
I don't know how to pass the "link" 2. both to 3.A and load the corresponding data in 3.B ...
I have a lot of confusion still...

I am posting you a sample in github:
It is based on your sample project: if you have a little time to give it a look and brief me, REAL MUCH appreciated!!

https://github.com/xdiscovery/angular-viva-route

Thank you very much!

IE 10 issue

Hi Wahlin,

This is really awesome to improve knowledge on Angular JS and ebook also simply good but I have issues with IE. I encountered an error like "angular is undefined" in IE. I am using IE10. Could you plz help me in this. Thanks in advance.

Thanks,
Srini

Unit Testing

Do you have Unit Test for this project?

My jasmine unit tests are failing to find the controller.
Since the value of app.register.controller is null, because $providers did not get registered in the config while at testing time. It seems app.config is called only when $route is resolved which happens in the normal user navigation scenario.

Any ideas?

errors in require.js

Hi Dan,

I tried to install also this last version of the customermanager sample.
I got
/api/dataservice
is missing.

also, how to change the url in require.js to look for the /app/ folder?
(It look for localhost/app/services....., while I want it in localhost/mysite/app .)

Thank you!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.