SlideShare a Scribd company logo
Hands On SPA
Development
Lab
Requirements
VISUAL STUDIO 2013 U4
GOOGLE CHROME
Lab
Overview
Lab Starter
CODE
HTTP://GOO.GL/TMULBV
THIS PRESENTATION
HTTP://GOO.GL/CHUHGY
Disclaimer 1 – This application is for
demonstration purposes ONLY. It is
meant to teach the fundamentals of
Web API and SPA Design.
A real application would have better
security. Obviously you would
require better authentication
Disclaimer 2 – Please do not use this
application to write or draw
anything offensive 
Index.html is the main view. You can
start up the browser from this
location
App.js is the applications view
model.
Lab Objective
MODIFY THE APPLICATION TO
SHOW THE REGISTERED
PLAYERS
Inspect the URL
The TelephonePictionary API on Azure also supports viewing the players registered for a
game
Let’s take a look at what the response looks like in a browser
http://telephonepictionary.azurewebsites.net/api/games/1/players
Update GameClient with new call
In the Visual Studio project, open the GameClient.cs located in the /code folder
string apiUrl = string.Format("{0}api/games/{1}/players", clientUrl, gameId);
WebClient client = new WebClient();
byte[] data = client.DownloadData(apiUrl);
string json = UTF8Encoding.UTF8.GetString(data);
var list = JsonConvert.DeserializeObject<List<string>>(json);
return list;
Add an API Method Route
In the Visual Studio project, open the
GameController.cs
• Stub out the following method
Fill in the API method implementation
In the Visual Studio project, open the GameController.cs – Now let’s fill in the
implementation for GetPlayersForGame
Instead of a simple Ok() result – let’s have it return the data from the GameClient call:
Ok(GameClient.GetPlayersForGame(gameId));
Once complete; you should be able to test your new API call in a browser
http://localhost:25085/api/games/1/players (the port number will be different in your
project)
Add API Call in JavaScript
In /app/js/api-client.js add the following function. This is what will enable your application to
retrieve the same players from the server.
getGamePlayers = function (obj) {
$.ajax({
url: "../api/games/" + obj.GameId + "/players",
contentType: 'application/json',
method: 'GET',
success: function (data) {
obj.Callback(data);
}
})
}
Add a new view in the HTML
In index.html add the following markup before the closing container div (on line 175)
<div data-bind="visible: CurrentScreen() == 'PlayersList'">
<h2>All Players in game</h2>
<ul class="list-group" data-bind="foreach: AllPlayers">
<li class="list-group-item">
<span data-bind="text: $data"></span>
</li>
</ul>
</div>
Change the player count
In index.html, change line from:
<span data-bind="text: NumberOfPlayers"></span>
To:
<a href="#" data-bind="click: $root.PlayersClicked"><span data-bind="text:
NumberOfPlayers"></span></a>
Now we need to create the “PlayersClicked” function on the view model to hook everything
up
Update the view model
In app.js, add the following on line 19. This is what will hook everything together. When the
user clicks the “players” link, we will make a RESTful call back to the server to pull the players for
the selected game.
self.AllPlayers = ko.observableArray([]);
self.PlayersClicked = function (row) {
getGamePlayers({
GameId: row.Id,
Callback: function (data) {
self.AllPlayers(data);
}
});
}
Run the application
Browse to index.html (be sure to do a SHIFT-REFRESH to load your changes). What happens
when you login?
Using the Chrome Developer Tools (F12), you can see if you have any JavaScript errors on the
page. If you did everything correctly you should not have any
When you click the “number of players” link on each game, nothing happens though. Why?
View Model update to change views
Change the implementation of the PlayersClicked function in app.js – switching the view
after the data is loaded from the server will cause the application to display the players
view
self.PlayersClicked = function (row) {
getGamePlayers({
GameId: row.Id,
Callback: function (data) {
self.AllPlayers(data);
self.CurrentScreen("PlayersList");
}
});
}
Testing is my responsibility too
”
“
By iteratively developing
your tests, you will be
subtly influencing the
application design
”
“
We need to think of functional
tests as a construction deliverable
”
“
Mocking frameworks are a developer’s best friend

More Related Content

What's hot

AppiumSetupConfigurationonWindows
AppiumSetupConfigurationonWindowsAppiumSetupConfigurationonWindows
AppiumSetupConfigurationonWindows
Lalit Ghule
 
Langkah-langkah Instalasi software untuk develop aplikasi android
Langkah-langkah Instalasi software untuk develop aplikasi androidLangkah-langkah Instalasi software untuk develop aplikasi android
Langkah-langkah Instalasi software untuk develop aplikasi android
Agus Haryanto
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Joke Puts
 
Startup weekend bootcamp - Android up and running
Startup weekend bootcamp - Android up and runningStartup weekend bootcamp - Android up and running
Startup weekend bootcamp - Android up and running
Lance Nanek
 
Angular JS Introduction
Angular JS IntroductionAngular JS Introduction
Angular JS Introduction
Dhyego Fernando
 
Using chrome developer tools for QA'ing Optimizely
Using chrome developer tools for QA'ing Optimizely Using chrome developer tools for QA'ing Optimizely
Using chrome developer tools for QA'ing Optimizely
Optimizely
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
Katy Slemon
 
2013 10-10 selenium presentation to ocjug
2013 10-10 selenium presentation to ocjug2013 10-10 selenium presentation to ocjug
2013 10-10 selenium presentation to ocjug
Philip Schlesinger
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
Mindfire Solutions
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
Dipendra Shekhawat
 
HTC Bluetooth Low Energy Heart Rate Monitor Sample Code
HTC Bluetooth Low Energy Heart Rate Monitor Sample CodeHTC Bluetooth Low Energy Heart Rate Monitor Sample Code
HTC Bluetooth Low Energy Heart Rate Monitor Sample Code
Lance Nanek
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
Vivek Bhusal
 
Icreate
IcreateIcreate
Icreate
Zhou Wenhan
 
8fig
8fig8fig
Mobile phone future angular js
Mobile phone future angular jsMobile phone future angular js
Mobile phone future angular js
atanacy
 
07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)
Oum Saokosal
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
Oum Saokosal
 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business Workflow
Yakov Fain
 
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
Agile Testing Alliance
 
MVC3 Development with visual studio 2010
MVC3 Development with visual studio 2010MVC3 Development with visual studio 2010
MVC3 Development with visual studio 2010
AbhishekLuv Kumar
 

What's hot (20)

AppiumSetupConfigurationonWindows
AppiumSetupConfigurationonWindowsAppiumSetupConfigurationonWindows
AppiumSetupConfigurationonWindows
 
Langkah-langkah Instalasi software untuk develop aplikasi android
Langkah-langkah Instalasi software untuk develop aplikasi androidLangkah-langkah Instalasi software untuk develop aplikasi android
Langkah-langkah Instalasi software untuk develop aplikasi android
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
 
Startup weekend bootcamp - Android up and running
Startup weekend bootcamp - Android up and runningStartup weekend bootcamp - Android up and running
Startup weekend bootcamp - Android up and running
 
Angular JS Introduction
Angular JS IntroductionAngular JS Introduction
Angular JS Introduction
 
Using chrome developer tools for QA'ing Optimizely
Using chrome developer tools for QA'ing Optimizely Using chrome developer tools for QA'ing Optimizely
Using chrome developer tools for QA'ing Optimizely
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
 
2013 10-10 selenium presentation to ocjug
2013 10-10 selenium presentation to ocjug2013 10-10 selenium presentation to ocjug
2013 10-10 selenium presentation to ocjug
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
 
HTC Bluetooth Low Energy Heart Rate Monitor Sample Code
HTC Bluetooth Low Energy Heart Rate Monitor Sample CodeHTC Bluetooth Low Energy Heart Rate Monitor Sample Code
HTC Bluetooth Low Energy Heart Rate Monitor Sample Code
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Icreate
IcreateIcreate
Icreate
 
8fig
8fig8fig
8fig
 
Mobile phone future angular js
Mobile phone future angular jsMobile phone future angular js
Mobile phone future angular js
 
07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)07.4. Android Basic Simple Browser (WebView)
07.4. Android Basic Simple Browser (WebView)
 
07.1. Android Even Handling
07.1. Android Even Handling07.1. Android Even Handling
07.1. Android Even Handling
 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business Workflow
 
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
 
MVC3 Development with visual studio 2010
MVC3 Development with visual studio 2010MVC3 Development with visual studio 2010
MVC3 Development with visual studio 2010
 

Viewers also liked

Medilift For Spa Group
Medilift For Spa GroupMedilift For Spa Group
Medilift For Spa Group
Jonathan Sellers
 
Foot spa detox weight loss
Foot spa detox weight lossFoot spa detox weight loss
Foot spa detox weight loss
Heather Bruce
 
Singapore Foot Reflexology and Spa Centres
Singapore Foot Reflexology and Spa CentresSingapore Foot Reflexology and Spa Centres
Singapore Foot Reflexology and Spa Centres
tcmcity
 
Foot Reflexology In Temple TX
Foot Reflexology In Temple TXFoot Reflexology In Temple TX
Foot Reflexology In Temple TX
Belleviedayspa
 
Spa Pp
Spa PpSpa Pp
Ciencias naturales calentamiento global
Ciencias naturales calentamiento globalCiencias naturales calentamiento global
Ciencias naturales calentamiento global
Paulina Joya
 
พลังธรรมชาติ
พลังธรรมชาติพลังธรรมชาติ
พลังธรรมชาติSoar2dasky
 
Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014
Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014
Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014
Emilio Vergne
 
Convert 4k mxf for uploading to you tube, vimeo, facebook
Convert 4k mxf for uploading to you tube, vimeo, facebookConvert 4k mxf for uploading to you tube, vimeo, facebook
Convert 4k mxf for uploading to you tube, vimeo, facebookujinwang3
 
Cognos Security with NetVisn
Cognos Security with NetVisnCognos Security with NetVisn
Cognos Security with NetVisn
Envisn
 
Codigo
CodigoCodigo
Sistemas de Información.
Sistemas de Información.Sistemas de Información.
Sistemas de Información.
grupoiapd
 
Upload copy (2)
Upload   copy (2)Upload   copy (2)
Upload copy (2)
Sery Crusuiz
 
12 refrigeración…y congela
12 refrigeración…y congela12 refrigeración…y congela
12 refrigeración…y congela
Dalia Agüero
 
Nivelacion de sociales
Nivelacion de socialesNivelacion de sociales
Nivelacion de sociales
Gennifer Andrea Gomez
 
Pelicula lucy (2)
Pelicula lucy (2)Pelicula lucy (2)
Pelicula lucy (2)
juansebastianmacias
 
安いラルフローレンのシャツ
安いラルフローレンのシャツ安いラルフローレンのシャツ
安いラルフローレンのシャツ
boxian071
 
Formato 1-hugo
Formato 1-hugoFormato 1-hugo
Formato 1-hugo
Edwin Nasimba
 
Colombia online
Colombia onlineColombia online
Colombia online
yeyualno
 

Viewers also liked (20)

Medilift For Spa Group
Medilift For Spa GroupMedilift For Spa Group
Medilift For Spa Group
 
Foot spa detox weight loss
Foot spa detox weight lossFoot spa detox weight loss
Foot spa detox weight loss
 
Singapore Foot Reflexology and Spa Centres
Singapore Foot Reflexology and Spa CentresSingapore Foot Reflexology and Spa Centres
Singapore Foot Reflexology and Spa Centres
 
Foot Reflexology In Temple TX
Foot Reflexology In Temple TXFoot Reflexology In Temple TX
Foot Reflexology In Temple TX
 
Spa Pp
Spa PpSpa Pp
Spa Pp
 
Ciencias naturales calentamiento global
Ciencias naturales calentamiento globalCiencias naturales calentamiento global
Ciencias naturales calentamiento global
 
พลังธรรมชาติ
พลังธรรมชาติพลังธรรมชาติ
พลังธรรมชาติ
 
Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014
Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014
Documento promoción biblioteca y coop. juvenil 8 de agosto de 2014
 
Convert 4k mxf for uploading to you tube, vimeo, facebook
Convert 4k mxf for uploading to you tube, vimeo, facebookConvert 4k mxf for uploading to you tube, vimeo, facebook
Convert 4k mxf for uploading to you tube, vimeo, facebook
 
Cognos Security with NetVisn
Cognos Security with NetVisnCognos Security with NetVisn
Cognos Security with NetVisn
 
Codigo
CodigoCodigo
Codigo
 
Sistemas de Información.
Sistemas de Información.Sistemas de Información.
Sistemas de Información.
 
Upload copy (2)
Upload   copy (2)Upload   copy (2)
Upload copy (2)
 
r8
r8r8
r8
 
12 refrigeración…y congela
12 refrigeración…y congela12 refrigeración…y congela
12 refrigeración…y congela
 
Nivelacion de sociales
Nivelacion de socialesNivelacion de sociales
Nivelacion de sociales
 
Pelicula lucy (2)
Pelicula lucy (2)Pelicula lucy (2)
Pelicula lucy (2)
 
安いラルフローレンのシャツ
安いラルフローレンのシャツ安いラルフローレンのシャツ
安いラルフローレンのシャツ
 
Formato 1-hugo
Formato 1-hugoFormato 1-hugo
Formato 1-hugo
 
Colombia online
Colombia onlineColombia online
Colombia online
 

Similar to Hands on SPA development

Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Marco Vito Moscaritolo
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
European Innovation Academy
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
guest1af57e
 
Hi5 Hackathon Presentation
Hi5 Hackathon PresentationHi5 Hackathon Presentation
Hi5 Hackathon Presentation
Lou Moore
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
Timothy Fisher
 
Grails Advanced
Grails Advanced Grails Advanced
Grails Advanced
Saurabh Dixit
 
How to implement sso using o auth in golang application
How to implement sso using o auth in golang applicationHow to implement sso using o auth in golang application
How to implement sso using o auth in golang application
Katy Slemon
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
Brajesh Yadav
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
Gregor Woiwode
 
Pengenalan AngularJS
Pengenalan AngularJSPengenalan AngularJS
Pengenalan AngularJS
Edi Santoso
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
maamir farooq
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
maamir farooq
 
Angularjs
AngularjsAngularjs
Angularjs
Ynon Perek
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
tdc-globalcode
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Alberto Ruibal
 
Angular 2 introduction
Angular 2 introductionAngular 2 introduction
Angular 2 introduction
Christoffer Noring
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
Sencha
 
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
Nico Miceli
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
Rakesh Kushwaha
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
Pamela Fox
 

Similar to Hands on SPA development (20)

Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
Hi5 Hackathon Presentation
Hi5 Hackathon PresentationHi5 Hackathon Presentation
Hi5 Hackathon Presentation
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Grails Advanced
Grails Advanced Grails Advanced
Grails Advanced
 
How to implement sso using o auth in golang application
How to implement sso using o auth in golang applicationHow to implement sso using o auth in golang application
How to implement sso using o auth in golang application
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
Pengenalan AngularJS
Pengenalan AngularJSPengenalan AngularJS
Pengenalan AngularJS
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
Lecture exercise on activities
Lecture exercise on activitiesLecture exercise on activities
Lecture exercise on activities
 
Angularjs
AngularjsAngularjs
Angularjs
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
 
Angular 2 introduction
Angular 2 introductionAngular 2 introduction
Angular 2 introduction
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
 
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
All about engagement with Universal Analytics @ Google Developer Group NYC Ma...
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
 

Recently uploaded

8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 

Recently uploaded (20)

8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 

Hands on SPA development

  • 5. Disclaimer 1 – This application is for demonstration purposes ONLY. It is meant to teach the fundamentals of Web API and SPA Design. A real application would have better security. Obviously you would require better authentication
  • 6. Disclaimer 2 – Please do not use this application to write or draw anything offensive 
  • 7. Index.html is the main view. You can start up the browser from this location App.js is the applications view model.
  • 8. Lab Objective MODIFY THE APPLICATION TO SHOW THE REGISTERED PLAYERS
  • 9. Inspect the URL The TelephonePictionary API on Azure also supports viewing the players registered for a game Let’s take a look at what the response looks like in a browser http://telephonepictionary.azurewebsites.net/api/games/1/players
  • 10. Update GameClient with new call In the Visual Studio project, open the GameClient.cs located in the /code folder string apiUrl = string.Format("{0}api/games/{1}/players", clientUrl, gameId); WebClient client = new WebClient(); byte[] data = client.DownloadData(apiUrl); string json = UTF8Encoding.UTF8.GetString(data); var list = JsonConvert.DeserializeObject<List<string>>(json); return list;
  • 11. Add an API Method Route In the Visual Studio project, open the GameController.cs • Stub out the following method
  • 12. Fill in the API method implementation In the Visual Studio project, open the GameController.cs – Now let’s fill in the implementation for GetPlayersForGame Instead of a simple Ok() result – let’s have it return the data from the GameClient call: Ok(GameClient.GetPlayersForGame(gameId)); Once complete; you should be able to test your new API call in a browser http://localhost:25085/api/games/1/players (the port number will be different in your project)
  • 13. Add API Call in JavaScript In /app/js/api-client.js add the following function. This is what will enable your application to retrieve the same players from the server. getGamePlayers = function (obj) { $.ajax({ url: "../api/games/" + obj.GameId + "/players", contentType: 'application/json', method: 'GET', success: function (data) { obj.Callback(data); } }) }
  • 14. Add a new view in the HTML In index.html add the following markup before the closing container div (on line 175) <div data-bind="visible: CurrentScreen() == 'PlayersList'"> <h2>All Players in game</h2> <ul class="list-group" data-bind="foreach: AllPlayers"> <li class="list-group-item"> <span data-bind="text: $data"></span> </li> </ul> </div>
  • 15. Change the player count In index.html, change line from: <span data-bind="text: NumberOfPlayers"></span> To: <a href="#" data-bind="click: $root.PlayersClicked"><span data-bind="text: NumberOfPlayers"></span></a> Now we need to create the “PlayersClicked” function on the view model to hook everything up
  • 16. Update the view model In app.js, add the following on line 19. This is what will hook everything together. When the user clicks the “players” link, we will make a RESTful call back to the server to pull the players for the selected game. self.AllPlayers = ko.observableArray([]); self.PlayersClicked = function (row) { getGamePlayers({ GameId: row.Id, Callback: function (data) { self.AllPlayers(data); } }); }
  • 17. Run the application Browse to index.html (be sure to do a SHIFT-REFRESH to load your changes). What happens when you login? Using the Chrome Developer Tools (F12), you can see if you have any JavaScript errors on the page. If you did everything correctly you should not have any When you click the “number of players” link on each game, nothing happens though. Why?
  • 18. View Model update to change views Change the implementation of the PlayersClicked function in app.js – switching the view after the data is loaded from the server will cause the application to display the players view self.PlayersClicked = function (row) { getGamePlayers({ GameId: row.Id, Callback: function (data) { self.AllPlayers(data); self.CurrentScreen("PlayersList"); } }); }
  • 19. Testing is my responsibility too
  • 20. ” “ By iteratively developing your tests, you will be subtly influencing the application design
  • 21. ” “ We need to think of functional tests as a construction deliverable
  • 22. ” “ Mocking frameworks are a developer’s best friend