-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular.html
More file actions
executable file
·362 lines (305 loc) · 10.3 KB
/
angular.html
File metadata and controls
executable file
·362 lines (305 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html><!--[if IEMobile 7]><html class="no-js ie iem7" lang="en" dir="ltr"><![endif]--><!--[if lte IE 6]><html class="no-js ie lt-ie9 lt-ie8 lt-ie7" lang="en" dir="ltr"><![endif]--><!--[if (IE 7)&(!IEMobile)]><html class="no-js ie lt-ie9 lt-ie8" lang="en" dir="ltr"><![endif]--><!--[if IE 8]><html class="no-js ie lt-ie9" lang="en" dir="ltr"><![endif]--><!--[if (gte IE 9)|(gt IEMobile 7)]><html class="no-js ie" lang="en" dir="ltr"><![endif]--><!--[if !IE]><!--><html class="js" dir="ltr" lang="en"><!--<![endif]-->
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--[if lt IE 9]>
<script src="lib/html5shim.js"></script>
<![endif]-->
<!-- These are some core styles the slideshow app requires -->
<link rel="stylesheet" href="lib/styles.css" />
<!-- These are the styles you'll add to make the slides look great -->
<link rel="stylesheet" href="css/styles.css" />
<title>Angular Drupal Rest | UCLA Library</title>
</head>
<body class="html not-front not-logged-in page-search section-search">
<div id="wrapper">
<div id="header">
<!-- START OF HEADER -->
<style><!--
/* Effective stylesheet produced by snapshot save */
@import url("ucla.css");
--></style>
<div class="l-page has-no-sidebars">
<div class="l-header-wrapper">
<div class="l-header" role="banner">
<div class="l-region l-region--branding">
<div class="panel-pane pane-page-logo">
<div class="pane-content">
<a href="http://www.library.ucla.edu/" rel="home" id="logo" title="Home"><img src="logo.png" alt="Home"></a>
</div>
</div>
</div>
</div>
</div>
<div class="l-navigation-wrapper">
<div id="menu" class="l-navigation">
<div class="l-region l-region--navigation">
<div class="panel-pane pane-page-primary-links">
<div class="pane-content" style="white-space: nowrap">
Angular, Drupal and RESTful Services
</div>
</div>
</div>
</div>
</div>
<div class="l-main-wrapper">
<div class="l-main">
<div class="l-content" role="main">
<a name="main-content"></a>
<div class="panel-pane pane-page-content">
<div class="pane-content">
<div class="sidebar-left panel-sidebar-left with-sidebar-left">
<br>
<!-- END OF HEADER -->
</div>
<div id="content">
<header>
<h1><a href="">Start</a></h1>
<nav>
<ul>
<li><button id="prev-btn" title="Previous slide">Previous Slide</button></li>
<li><span id="slide-number"></span>/<span id="slide-total"></span></li>
<li><button id="next-btn" title="Next Slide">Next Slide</button></li>
</ul>
</nav>
</header>
<div id="deck">
<!-- Begin slides -->
<!-- Begin slides -->
<!-- Begin slides -->
<section>
<hgroup>
<br>
<br>
<br>
<h1>UCLA Library - Angular, Drupal and RESTful Services</h1>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<h2>Darrow Cole</h2>
</hgroup>
</section>
<section>
<hgroup>
<h1>Angular, Drupal and RESTful Services</h1>
<h2>Basic Idea</h2>
</hgroup>
<img src="images/angular1.svg" alt="Embedded AngularJS talks to Drupal Server" />
</section>
<section>
<hgroup>
<h1>Background and Requirements</h1>
<h2>Reservations app that enforces rules based on user category</h2>
</hgroup>
<ul>
<li class="action">Limits on number, frequency and advance of reservations</li>
<li class="action">Must work with our CMS ===> Drupal Module</li>
<li class="action">Federated authentication</li>
<li class="action">Compatibility with existing reservations system</li>
<li class="action">Secure connection</li>
</ul>
</section>
<section>
<hgroup>
<h1>Angular, Drupal and REST</h1>
<h2>What we ended up with</h2>
</hgroup>
<img src="images/angular2.svg" alt="Embedded AngularJS talks to Drupal Server, and other services" />
</section>
<section>
<hgroup>
<h1>Shibboleth</h1>
<h2>Federated Single Sign-On Authentication Service</h2>
</hgroup>
<img src="images/angular3.svg" alt="Shibboleth provides authentication and a secure connection" />
</section>
<section>
<hgroup>
<h1>Drupal Module</h1>
<h2>Start with a Drupal Module - which injects the Angular</h2>
</hgroup>
<img src="images/angular4.svg" alt="Shibboleth provides authentication and a secure connection" />
</section>
<section>
<hgroup>
<h1>Access Web Services Server</h1>
<h2>Angular access the WS through a second Drupal Module</h2>
</hgroup>
<img src="images/angular5.svg" alt="Shibboleth provides authentication and a secure connection" />
</section>
<section>
<hgroup>
<h1>Access 3rd-party services</h1>
<h2>Web Services accesses other services as needed</h2>
</hgroup>
<img src="images/angular6.svg" alt="Shibboleth provides authentication and a secure connection" />
</section>
<section>
<hgroup>
<h1>JSON in the Web Page</h1>
<h2>The JSON is processed by Angular</h2>
</hgroup>
<img src="images/angular5.svg" alt="Shibboleth provides authentication and a secure connection" />
</section>
<section>
<hgroup>
<h1>JSON in the Web Page</h1>
<h2>JSON data displayed by Ag in standard UCLA Library page</h2>
</hgroup>
<img src="images/json_in_browser.png" alt="Web page with JSON data" />
</section>
<section>
<hgroup>
<h1>Main Files</h1>
<h2>Drupal modules and Angular</h2>
</hgroup>
<br>
<br>
<br>
<h2>Module #1</h2>
<h2>Module #2</h2>
<h2>Angular Library</h2>
<h2>Angular Application</h2>
</section>
<section>
<hgroup>
<h1>Some Code</h1>
<h2>Module #1</h2>
</hgroup>
<pre>
function all_ag_res_page() {
// Get the UID from Drupal
$ucuid = "502673598";
// Set the path and load Angular
$path = drupal_get_path('module', 'ag_res');
drupal_add_library('angularjs', 'angularjs');
// Load the app and return theme
drupal_add_js($path . '/js/ag_res.gen.js');
return theme('all_ag_res');
}
</pre>
</section>
<section>
<hgroup>
<h1>Some Code</h1>
<h2>The Angular App</h2>
</hgroup>
<pre>
var ag_res = angular.module('ag_res', []);
jQuery(document).ready(function() {
// Iitialize the angular app by hand for multiple apps
angular.bootstrap(document.getElementById('ag_res-app'),['ag_res']); });
ag_res.controller('ag_resController', function ($scope, $http) {
$http.get('http://uclalib.local/UCLALIB/www/ajaxx').success(function (result) {
$scope.ag_res = (function() {
return result;
})();
}); });
</pre>
</section>
<section>
<hgroup>
<h1>Some Code</h1>
<h2>Module #2</h2>
</hgroup>
<pre>
// get any existing patron reservations
$dev_host_resource_base = 'https://webservices.library.ucla.edu';
$url =
"$dev_host_resource_base"."/rcres/currentreservations/for/"."$working_uid";
$options = array(
"headers" => array(
"Pragma" => "no-cache",
"Cache-Control" => "no-cache", ), );
$response_voy = drupal_http_request($url, $options);
$patron_reservations = $response_voy->data;
$patron_reservations = drupal_json_decode($patron_reservations);
return drupal_json_output($patron_reservations);
</pre>
</section>
<section>
<hgroup>
<h1>Overview</h1>
<h2>Transaction diagram</h2>
</hgroup>
<img src="images/angular99.svg" alt="Diagram of transactions" />
</section>
<section>
<hgroup>
<h1>Code and Links</h1>
</hgroup>
<br>
<br>
<br>
<br>
<h2>--- <a href="https://github.com/BluesparkLabs/UCLALIB/tree/master/www/sites/all/modules/custom/ag-res">Angular Reservations code on github</a> (login required)</h2>
<h2>--- <a href="http://darrowco.github.io/code4lib/angular.html">Link to these slides</a></h2>
<h2>--- How these slides were made and hosted on github</h2>
<h2>--- darrowco@library.ucla.edu</h2>
</section>
<!-- /End slides -->
<!-- /End slides -->
<!-- /End slides -->
</div>
<!-- /deck -->
<script src="lib/jquery-1.5.2.min.js"></script>
<script src="lib/jquery.jswipe-0.1.2.js"></script>
<script src="lib/htmlSlides.js"></script>
<script>
//Do our business when the DOM is ready for us
$(function() {
//You can trigger Javascript based on the slide number like this:
$('html').bind('newSlide', function(e, id) {
switch(id) {
case 2:
console.log('This is the second slide.');;
break;
case 3:
console.log('Hello, third slide.');
break;
}
});
//One little option: hideToolbar (boolean; default = false)
htmlSlides.init({ hideToolbar: true });
});
</script>
</div>
<!-- START OF FOOTER -->
</div>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="l-footer-wrapper">
<div class="l-footer" role="contentinfo">
<div class="l-region l-region--footer">
<div class="panel-pane pane-block pane-menu-menu-footer">
<div class="pane-content">
<ul class="menu">
<li class="first last leaf"><span title="" class="footer-copyright nolink"></span></li>
<!--<li class="first last leaf"><span title="" class="footer-copyright nolink">2014 © UC Regents</span></li>-->
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END OF FOOTER -->
</div>
</div>
</body></html>