Top Banner
Single Page Apps with Breeze and Ruby
31

Single Page Apps with Breeze and Ruby

Feb 23, 2016

Download

Documents

phuc

Single Page Apps with Breeze and Ruby. John Papa’s Code Camper Jumpstart. http://pluralsight.com/training/Courses/TableOfContents/single-page-apps-jumpstart. https://github.com/johnpapa/PluralsightSpaJumpStartFinal. Features. Multi-entity model - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Single Page Apps  with Breeze and Ruby

Single Page Apps with

Breeze and Ruby

Page 2: Single Page Apps  with Breeze and Ruby

http://pluralsight.com/training/Courses/TableOfContents/single-page-apps-jumpstart https://github.com/johnpapa/PluralsightSpaJumpStartFinal

John Papa’s Code Camper Jumpstart

Page 3: Single Page Apps  with Breeze and Ruby

Features• Multi-entity model• Navigation properties / cached lookup lists• Projections / partial entities• Change notification• Dirty checking• Validation• Save• Local storage

Page 4: Single Page Apps  with Breeze and Ruby

Keys• Client app is server agnostic (almost)• Ruby on Rails (RoR) server• Straight rails; no breeze.ruby components• “REST” API• Python web server• No MS

Page 5: Single Page Apps  with Breeze and Ruby

Not anti-Microsoft

Page 6: Single Page Apps  with Breeze and Ruby

If it works in Rubyit can work for you

Page 7: Single Page Apps  with Breeze and Ruby

Run it1. Download from GitHub2. Setup install gems and create sample MySQL database

3. Start rails server bundle exec rails s

4. Start client application server python –m http.server

5. Launch in browser http://localhost:8000

~\ccjs_ruby\rails>bundle exec rails s

Page 8: Single Page Apps  with Breeze and Ruby

Demo

Page 9: Single Page Apps  with Breeze and Ruby

Web Server

HTML, JavaScript, CSS, images

Page 10: Single Page Apps  with Breeze and Ruby

Code Tour

Page 11: Single Page Apps  with Breeze and Ruby

RoR Server

Page 12: Single Page Apps  with Breeze and Ruby

RoR Server – Configuration

Locate the My SQL database

Page 13: Single Page Apps  with Breeze and Ruby

RoR Server – ConfigurationBreeze Metadata

Page 14: Single Page Apps  with Breeze and Ruby

RoR Server – Model View Controller

Page 15: Single Page Apps  with Breeze and Ruby

RoR Server – ControllersCross Origin Resource Sharing

Page 16: Single Page Apps  with Breeze and Ruby

RoR Server – Models

Page 17: Single Page Apps  with Breeze and Ruby

RoR Server - ControllersSessions Controller

GET by id

GET all

PUT

POST

DELETE

Page 18: Single Page Apps  with Breeze and Ruby

Sessions Controller – Index (get all)

Partial entity if $select in query

Default sort order is time_slot_idbut client typically wants by ‘timeslot, track, speaker name’

Make speaker available in case sorting on speaker name

Projection (selected fields)

Page 19: Single Page Apps  with Breeze and Ruby

RoR Server – Session Views

Page 20: Single Page Apps  with Breeze and Ruby

RoR Server – Controllers

Page 21: Single Page Apps  with Breeze and Ruby

RoR Server - Views

Page 22: Single Page Apps  with Breeze and Ruby

API Differences

Page 23: Single Page Apps  with Breeze and Ruby

Rails serialization vs JSON.NET serialization

Rails Session

JSON.NET Session

• Rails-style entity property_names

• No $id node property

• $type node property is readable (v. anonymous type)

Page 24: Single Page Apps  with Breeze and Ruby

Rails REST update vs Breeze “save changes”

PUT to resource w/ id=1

Send only the changed values

POST to SaveChanges

Send entire entity

Page 25: Single Page Apps  with Breeze and Ruby

Adjust breeze clientfor Rails API

Page 26: Single Page Apps  with Breeze and Ruby

Configure adapters

Inject with RequireJS

Breeze extension points

Page 27: Single Page Apps  with Breeze and Ruby

AjaxRestInterceptorTweak the breeze ajax adapter to convert OData id-query into a REST URL

e.g., /breeze/Sessions/?$filter=id eq 1 /breeze/Sessions/1

Page 28: Single Page Apps  with Breeze and Ruby

DataServiceAdapterReplace POST to “SaveChanges” with RESTPUT/POST/DELETE to entity type controllers

Page 29: Single Page Apps  with Breeze and Ruby

JsonResultsAdapterIdentify “partial entity” JSON data nodes

Page 30: Single Page Apps  with Breeze and Ruby

NamingConvention Convert property namese.g., timeSlotId time_slot_id

Page 31: Single Page Apps  with Breeze and Ruby

Thank you, RubyTribe