badge
38 |
39 | Examples:
40 | | previous_attempts | badge_name |
41 | | 9 | BRONZE_MULTIPLICATOR |
42 | | 49 | SILVER_MULTIPLICATOR |
43 | | 99 | GOLD_MULTIPLICATOR |
44 |
--------------------------------------------------------------------------------
/ui/start.d/deploy.ini:
--------------------------------------------------------------------------------
1 | # ---------------------------------------
2 | # Module: deploy
3 | # Enables webapplication deployment from the webapps directory.
4 | # ---------------------------------------
5 | --module=deploy
6 |
7 | # Monitored directory name (relative to $jetty.base)
8 | # jetty.deploy.monitoredDir=webapps
9 | # - OR -
10 | # Monitored directory path (fully qualified)
11 | # jetty.deploy.monitoredPath=/var/www/webapps
12 |
13 | # Defaults Descriptor for all deployed webapps
14 | # jetty.deploy.defaultsDescriptorPath=${jetty.base}/etc/webdefault.xml
15 |
16 | # Monitored directory scan period (seconds)
17 | # jetty.deploy.scanInterval=1
18 |
19 | # Whether to extract *.war files
20 | # jetty.deploy.extractWars=true
21 |
22 |
--------------------------------------------------------------------------------
/ui/start.d/http.ini:
--------------------------------------------------------------------------------
1 | # ---------------------------------------
2 | # Module: http
3 | # Enables a HTTP connector on the server.
4 | # By default HTTP/1 is support, but HTTP2C can
5 | # be added to the connector with the http2c module.
6 | # ---------------------------------------
7 | --module=http
8 |
9 | ### HTTP Connector Configuration
10 |
11 | ## Connector host/address to bind to
12 | # jetty.http.host=0.0.0.0
13 |
14 | ## Connector port to listen on
15 | jetty.http.port=9090
16 |
17 | ## Connector idle timeout in milliseconds
18 | # jetty.http.idleTimeout=30000
19 |
20 | ## Connector socket linger time in seconds (-1 to disable)
21 | # jetty.http.soLingerTime=-1
22 |
23 | ## Number of acceptors (-1 picks default based on number of cores)
24 | # jetty.http.acceptors=-1
25 |
26 | ## Number of selectors (-1 picks default based on number of cores)
27 | # jetty.http.selectors=-1
28 |
29 | ## ServerSocketChannel backlog (0 picks platform default)
30 | # jetty.http.acceptorQueueSize=0
31 |
32 | ## Thread priority delta to give to acceptor threads
33 | # jetty.http.acceptorPriorityDelta=0
34 |
35 | ## HTTP Compliance: RFC7230, RFC2616, LEGACY
36 | # jetty.http.compliance=RFC7230
37 |
38 |
--------------------------------------------------------------------------------
/ui/webapps/ui/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microservices-practical/microservices-v10/2397a423fa0cbb2dcd111a05963aa5b625cbf71f/ui/webapps/ui/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/ui/webapps/ui/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microservices-practical/microservices-v10/2397a423fa0cbb2dcd111a05963aa5b625cbf71f/ui/webapps/ui/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/ui/webapps/ui/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microservices-practical/microservices-v10/2397a423fa0cbb2dcd111a05963aa5b625cbf71f/ui/webapps/ui/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/ui/webapps/ui/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microservices-practical/microservices-v10/2397a423fa0cbb2dcd111a05963aa5b625cbf71f/ui/webapps/ui/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/ui/webapps/ui/gamification-client.js:
--------------------------------------------------------------------------------
1 | var SERVER_URL = "http://localhost:8000/api";
2 |
3 | function updateLeaderBoard() {
4 | $.ajax({
5 | url: SERVER_URL + "/leaders"
6 | }).then(function(data) {
7 | $('#leaderboard-body').empty();
8 | data.forEach(function(row) {
9 | $('#leaderboard-body').append('' + row.userId + ' | ' +
10 | '' + row.totalScore + ' | ');
11 | });
12 | });
13 | }
14 |
15 | function updateStats(userId) {
16 | $.ajax({
17 | url: SERVER_URL + "/stats?userId=" + userId,
18 | success: function(data) {
19 | $('#stats-div').show();
20 | $('#stats-user-id').empty().append(userId);
21 | $('#stats-score').empty().append(data.score);
22 | $('#stats-badges').empty().append(data.badges.join());
23 | },
24 | error: function(data) {
25 | $('#stats-div').show();
26 | $('#stats-user-id').empty().append(userId);
27 | $('#stats-score').empty().append(0);
28 | $('#stats-badges').empty();
29 | }
30 | });
31 | }
32 |
33 | $(document).ready(function() {
34 |
35 | updateLeaderBoard();
36 |
37 | $("#refresh-leaderboard").click(function( event ) {
38 | updateLeaderBoard();
39 | });
40 |
41 | });
42 |
--------------------------------------------------------------------------------
/ui/webapps/ui/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Multiplication v1
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
Welcome to Social Multiplication
17 |
18 |
19 |
20 |
21 |
Your new challenge is
22 |
23 | x
24 |
25 |
26 |
37 |
38 |
39 |
40 |
41 |
Your statistics
42 |
43 |
44 |
45 | User ID: |
46 | |
47 |
48 |
49 | Score: |
50 | |
51 |
52 |
53 | Badges: |
54 | |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
Leaderboard
63 |
64 |
65 | User ID |
66 | Score |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
Your latest attempts
76 |
77 |
78 | Attempt ID |
79 | Multiplication |
80 | You entered |
81 | Correct? |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/ui/webapps/ui/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/ui/webapps/ui/multiplication-client.js:
--------------------------------------------------------------------------------
1 | var SERVER_URL = "http://localhost:8000/api";
2 |
3 | function updateMultiplication() {
4 | $.ajax({
5 | url: SERVER_URL + "/multiplications/random"
6 | }).then(function(data) {
7 | // Cleans the form
8 | $("#attempt-form").find( "input[name='result-attempt']" ).val("");
9 | $("#attempt-form").find( "input[name='user-alias']" ).val("");
10 | // Gets a random challenge from API and loads the data in the HTML
11 | $('.multiplication-a').empty().append(data.factorA);
12 | $('.multiplication-b').empty().append(data.factorB);
13 | });
14 | }
15 |
16 | function updateResults(alias) {
17 | var userId = -1;
18 | $.ajax({
19 | url: SERVER_URL + "/results?alias=" + alias,
20 | async: false,
21 | success: function(data) {
22 | $('#results-div').show();
23 | $('#results-body').empty();
24 | data.forEach(function(row) {
25 | $('#results-body').append('
' + row.id + ' | ' +
26 | '' + row.multiplication.factorA + ' x ' + row.multiplication.factorB + ' | ' +
27 | '' + row.resultAttempt + ' | ' +
28 | '' + (row.correct === true ? 'YES' : 'NO') + ' |
');
29 | });
30 | userId = data[0].user.id;
31 | }
32 | });
33 | return userId;
34 | }
35 |
36 | $(document).ready(function() {
37 |
38 | updateMultiplication();
39 |
40 | $("#attempt-form").submit(function( event ) {
41 |
42 | // Don't submit the form normally
43 | event.preventDefault();
44 |
45 | // Get some values from elements on the page
46 | var a = $('.multiplication-a').text();
47 | var b = $('.multiplication-b').text();
48 | var $form = $( this ),
49 | attempt = $form.find( "input[name='result-attempt']" ).val(),
50 | userAlias = $form.find( "input[name='user-alias']" ).val();
51 |
52 | // Compose the data in the format that the API is expecting
53 | var data = { user: { alias: userAlias}, multiplication: {factorA: a, factorB: b}, resultAttempt: attempt};
54 |
55 | // Send the data using post
56 | $.ajax({
57 | url: SERVER_URL + '/results',
58 | type: 'POST',
59 | data: JSON.stringify(data),
60 | contentType: "application/json; charset=utf-8",
61 | dataType: "json",
62 | async: false,
63 | success: function(result){
64 | if(result.correct) {
65 | $('.result-message').empty()
66 | .append("The result is correct! Congratulations!
");
67 | } else {
68 | $('.result-message').empty()
69 | .append("Ooops that's not correct! But keep trying!
");
70 | }
71 | }
72 | });
73 |
74 | updateMultiplication();
75 |
76 | setTimeout(function(){
77 | var userId = updateResults(userAlias);
78 | updateStats(userId);
79 | updateLeaderBoard();
80 | }, 300);
81 | });
82 | });
83 |
--------------------------------------------------------------------------------
/ui/webapps/ui/styles.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | height: 100%;
3 | }
4 |
5 | html {
6 | display: table;
7 | margin: auto;
8 | }
9 |
10 | body {
11 | display: table-cell;
12 | vertical-align: middle;
13 | }
--------------------------------------------------------------------------------