Transcript
Page 1: Angular revolution in Gerrit

1 Copyright ©2014 CollabNet, Inc. All Rights Reserved.ENTERPRISE CLOUD DEVELOPMENTENTERPRISE CLOUD DEVELOPMENT

The Angular revolution in Gerrit

Dariusz Luksza CollabNet Engineering, Potsdam, Germany

Page 2: Angular revolution in Gerrit

2 Copyright ©2014 CollabNet, Inc. All Rights Reserved.ENTERPRISE CLOUD DEVELOPMENTENTERPRISE CLOUD DEVELOPMENT

● Why and what for?

● Meet Angular-Gerrit

● How would OpenChanges screen look like?

● Twitter Bootstrap? Why not!

● Q&A

Page 3: Angular revolution in Gerrit

3 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

Why and what for?● Day to day development

– Debugging– Compilation time (no compilation!)– Dependency injection– Testability– Lower entry barrier to Gerrit WEB UI plugin development

● Branding– Not only colors but also document structure

Page 4: Angular revolution in Gerrit

4 Copyright ©2014 CollabNet, Inc. All Rights Reserved.ENTERPRISE CLOUD DEVELOPMENTENTERPRISE CLOUD DEVELOPMENT

Meet Angular­Gerrit

Dariusz Luksza CollabNet Engineering, Potsdam, Germany

Page 5: Angular revolution in Gerrit

5 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

Meet angular­gerrit.js● Preconditions

– Modified Gerrit with change #53341 (and its dependencies) is required you can just put JS code in $gerrit_site/plugins/$plugin_name/static/init.js

● Development flow

– $gerrit_site/plugins/$plugin_name/static/*● Build

– Zip the 'static' directory, then change archive extension to jar● Angular­Gerrit

– init.js – loads all JavaScript dependencies like jquery, angular, angular­route, angular­gerrit.js and plugin code

– angular­gerrit.js – wraps Gerrit JS API into AngularJS friendly services

* JAR files are actually ZIP with different extension

Page 6: Angular revolution in Gerrit

6 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

Meet angular­gerrit.js● Angular­Gerrit services:

– GerritRoute – wraps angular­route and prefixes page URLs with '/x/$plugin_name/' and template URL with '/plugins/$plugin_name/static/'

– GerritSrv – wraps Gerrit JS APIs– GerritPluginSrv – wraps Gerrit 'plugin aware' JS APIs– GerritScreenSrv – wraps Gerrit Screen service

Page 7: Angular revolution in Gerrit

7 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

Meet angular­gerrit.js● How to actually use it?

– Your plugin code goes to 'static/plugin.js':

– Template code goes to `static/templates/hello.html`:

AngularGerrit.install([/* additional modules goes here */], function(app) { app.config(function(GerritRouteProvider) { GerritRouteProvider .when('/', {controller: 'HelloCtrl', templateUrl: 'templates/hello.html'}); }); app.controller('HelloCtrl', function($scope) { $scope.greeting = 'Hello Diffy!'; });});

<h1>{{greeting}}</h1>

Page 8: Angular revolution in Gerrit

8 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

Meet Angular­Gerrit

Page 9: Angular revolution in Gerrit

9 Copyright ©2014 CollabNet, Inc. All Rights Reserved.ENTERPRISE CLOUD DEVELOPMENTENTERPRISE CLOUD DEVELOPMENT

How would OpenChanges screen look like?

Dariusz Luksza CollabNet Engineering, Potsdam, Germany

Page 10: Angular revolution in Gerrit

10 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

How would OpenChanges screen look like?

Page 11: Angular revolution in Gerrit

11 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

How would OpenChanges screen look like?Yes, this was created with Angular!

Page 12: Angular revolution in Gerrit

12 Copyright ©2014 CollabNet, Inc. All Rights Reserved.ENTERPRISE CLOUD DEVELOPMENTENTERPRISE CLOUD DEVELOPMENT

Twitter Bootstrap? Why not!

Dariusz Luksza CollabNet Engineering, Potsdam, Germany

Page 13: Angular revolution in Gerrit

13 Copyright ©2014 CollabNet, Inc. All Rights Reserved.

Twitter Bootstrap? Why not!This page uses different template file, JavaScipt code was reused from original screen.

Page 14: Angular revolution in Gerrit

14 Copyright ©2014 CollabNet, Inc. All Rights Reserved.ENTERPRISE CLOUD DEVELOPMENTENTERPRISE CLOUD DEVELOPMENT

Q&ADariusz Luksza CollabNet Engineering, Potsdam, Germany

Angular­Gerrit can be cloned from:https://github.com/dluksza/angular­gerrit


Top Related