wabur 0.4.0d1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -66
  3. data/bin/wabur +48 -11
  4. data/export/assets/css/wab.css +2 -0
  5. data/export/assets/css/wab.css.map +7 -0
  6. data/export/assets/fonts/wabfont/README +18 -0
  7. data/export/assets/fonts/wabfont/fonts/WAB.eot +0 -0
  8. data/export/assets/fonts/wabfont/fonts/WAB.svg +25 -0
  9. data/export/assets/fonts/wabfont/fonts/WAB.ttf +0 -0
  10. data/export/assets/fonts/wabfont/fonts/WAB.woff +0 -0
  11. data/export/assets/fonts/wabfont/selection.json +460 -0
  12. data/export/assets/fonts/wabfont/style.css +74 -0
  13. data/export/assets/js/transpile.js +8 -0
  14. data/export/assets/js/ui.js +377 -0
  15. data/export/assets/js/vendor/plugin-babel/babel-helpers.js +558 -0
  16. data/export/assets/js/vendor/plugin-babel/babel-helpers/asyncGenerator.js +112 -0
  17. data/export/assets/js/vendor/plugin-babel/babel-helpers/asyncGeneratorDelegate.js +51 -0
  18. data/export/assets/js/vendor/plugin-babel/babel-helpers/asyncIterator.js +14 -0
  19. data/export/assets/js/vendor/plugin-babel/babel-helpers/asyncToGenerator.js +28 -0
  20. data/export/assets/js/vendor/plugin-babel/babel-helpers/classCallCheck.js +5 -0
  21. data/export/assets/js/vendor/plugin-babel/babel-helpers/createClass.js +17 -0
  22. data/export/assets/js/vendor/plugin-babel/babel-helpers/defaults.js +14 -0
  23. data/export/assets/js/vendor/plugin-babel/babel-helpers/defineEnumerableProperties.js +10 -0
  24. data/export/assets/js/vendor/plugin-babel/babel-helpers/defineProperty.js +14 -0
  25. data/export/assets/js/vendor/plugin-babel/babel-helpers/extends.js +13 -0
  26. data/export/assets/js/vendor/plugin-babel/babel-helpers/get.js +24 -0
  27. data/export/assets/js/vendor/plugin-babel/babel-helpers/inherits.js +15 -0
  28. data/export/assets/js/vendor/plugin-babel/babel-helpers/instanceof.js +7 -0
  29. data/export/assets/js/vendor/plugin-babel/babel-helpers/interopRequireDefault.js +5 -0
  30. data/export/assets/js/vendor/plugin-babel/babel-helpers/interopRequireWildcard.js +16 -0
  31. data/export/assets/js/vendor/plugin-babel/babel-helpers/jsx.js +42 -0
  32. data/export/assets/js/vendor/plugin-babel/babel-helpers/newArrowCheck.js +5 -0
  33. data/export/assets/js/vendor/plugin-babel/babel-helpers/objectDestructuringEmpty.js +3 -0
  34. data/export/assets/js/vendor/plugin-babel/babel-helpers/objectWithoutProperties.js +11 -0
  35. data/export/assets/js/vendor/plugin-babel/babel-helpers/possibleConstructorReturn.js +7 -0
  36. data/export/assets/js/vendor/plugin-babel/babel-helpers/selfGlobal.js +1 -0
  37. data/export/assets/js/vendor/plugin-babel/babel-helpers/set.js +21 -0
  38. data/export/assets/js/vendor/plugin-babel/babel-helpers/slicedToArray.js +37 -0
  39. data/export/assets/js/vendor/plugin-babel/babel-helpers/slicedToArrayLoose.js +17 -0
  40. data/export/assets/js/vendor/plugin-babel/babel-helpers/taggedTemplateLiteral.js +7 -0
  41. data/export/assets/js/vendor/plugin-babel/babel-helpers/taggedTemplateLiteralLoose.js +4 -0
  42. data/export/assets/js/vendor/plugin-babel/babel-helpers/temporalRef.js +7 -0
  43. data/export/assets/js/vendor/plugin-babel/babel-helpers/temporalUndefined.js +1 -0
  44. data/export/assets/js/vendor/plugin-babel/babel-helpers/toArray.js +3 -0
  45. data/export/assets/js/vendor/plugin-babel/babel-helpers/toConsumableArray.js +9 -0
  46. data/export/assets/js/vendor/plugin-babel/babel-helpers/typeof.js +5 -0
  47. data/export/assets/js/vendor/plugin-babel/plugin-babel.js +222 -0
  48. data/export/assets/js/vendor/plugin-babel/regenerator-runtime.js +685 -0
  49. data/export/assets/js/vendor/plugin-babel/systemjs-babel-browser.js +1 -0
  50. data/export/assets/js/vendor/plugin-babel/systemjs-babel-node.js +55086 -0
  51. data/export/assets/js/vendor/systemjs/system-production.js +4 -0
  52. data/export/assets/js/vendor/systemjs/system-production.js.map +1 -0
  53. data/export/assets/js/vendor/systemjs/system-production.src.js +1711 -0
  54. data/export/assets/js/vendor/systemjs/system-production.src.js.map +1 -0
  55. data/export/assets/js/vendor/systemjs/system.js +4 -0
  56. data/export/assets/js/vendor/systemjs/system.js.map +1 -0
  57. data/export/assets/js/vendor/systemjs/system.src.js +4000 -0
  58. data/export/assets/js/vendor/systemjs/system.src.js.map +1 -0
  59. data/export/assets/js/wab.js +109 -0
  60. data/export/index.html +41 -0
  61. data/lib/wab.rb +13 -0
  62. data/lib/wab/controller.rb +2 -2
  63. data/lib/wab/errors.rb +12 -0
  64. data/lib/wab/impl.rb +2 -0
  65. data/lib/wab/impl/configuration.rb +24 -6
  66. data/lib/wab/impl/export_proxy.rb +39 -0
  67. data/lib/wab/impl/exprs/regex.rb +1 -1
  68. data/lib/wab/impl/handler.rb +14 -14
  69. data/lib/wab/impl/init.rb +108 -0
  70. data/lib/wab/impl/model.rb +4 -3
  71. data/lib/wab/impl/shell.rb +14 -4
  72. data/lib/wab/impl/templates/opo-rub.conf.template +253 -0
  73. data/lib/wab/impl/templates/opo.conf.template +224 -0
  74. data/lib/wab/impl/templates/spawn.rb.template +42 -0
  75. data/lib/wab/impl/templates/ui_controller.rb.template +12 -0
  76. data/lib/wab/impl/templates/wabur.conf.template +40 -0
  77. data/lib/wab/ui.rb +19 -0
  78. data/lib/wab/ui/create.rb +26 -0
  79. data/lib/wab/ui/display.rb +34 -0
  80. data/lib/wab/ui/flow.rb +54 -0
  81. data/lib/wab/ui/list.rb +59 -0
  82. data/lib/wab/ui/multi_flow.rb +23 -0
  83. data/lib/wab/ui/rest_flow.rb +89 -0
  84. data/lib/wab/ui/update.rb +27 -0
  85. data/lib/wab/ui/view.rb +62 -0
  86. data/lib/wab/utils.rb +4 -4
  87. data/lib/wab/version.rb +1 -1
  88. data/pages/Architecture.md +104 -1
  89. data/test/test_configuration.rb +1 -1
  90. data/test/test_impl.rb +1 -0
  91. data/test/test_init.rb +33 -0
  92. metadata +94 -7
  93. data/pages/Plan.md +0 -27
@@ -0,0 +1,74 @@
1
+ @font-face {
2
+ font-family: 'WAB';
3
+ src: url('fonts/WAB.eot');
4
+ src: url('fonts/WAB.eot') format('embedded-opentype'),
5
+ url('fonts/WAB.ttf') format('truetype'),
6
+ url('fonts/WAB.woff') format('woff'),
7
+ url('fonts/WAB.svg') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+
12
+ .icon {
13
+ /* use !important to prevent issues with browser extensions that change fonts */
14
+ font-family: 'WAB' !important;
15
+ speak: none;
16
+ font-style: normal;
17
+ font-weight: normal;
18
+ font-variant: normal;
19
+ text-transform: none;
20
+ line-height: 1;
21
+
22
+ /* Better Font Rendering =========== */
23
+ -webkit-font-smoothing: antialiased;
24
+ -moz-osx-font-smoothing: grayscale;
25
+ }
26
+
27
+ .icon-plus:before {
28
+ content: "\f067";
29
+ }
30
+ .icon-search:before {
31
+ content: "\f002";
32
+ }
33
+ .icon-trash-o:before {
34
+ content: "\f014";
35
+ }
36
+ .icon-refresh:before {
37
+ content: "\f021";
38
+ }
39
+ .icon-lock:before {
40
+ content: "\f023";
41
+ }
42
+ .icon-pencil:before {
43
+ content: "\f040";
44
+ }
45
+ .icon-plus-circle:before {
46
+ content: "\f055";
47
+ }
48
+ .icon-info-circle:before {
49
+ content: "\f05a";
50
+ }
51
+ .icon-eye:before {
52
+ content: "\f06e";
53
+ }
54
+ .icon-github:before {
55
+ content: "\f09b";
56
+ }
57
+ .icon-unlock:before {
58
+ content: "\f09c";
59
+ }
60
+ .icon-floppy-o:before {
61
+ content: "\f0c7";
62
+ }
63
+ .icon-save:before {
64
+ content: "\f0c7";
65
+ }
66
+ .icon-unlock-alt:before {
67
+ content: "\f13e";
68
+ }
69
+ .icon-file-text:before {
70
+ content: "\f15c";
71
+ }
72
+ .icon-diamond:before {
73
+ content: "\f219";
74
+ }
@@ -0,0 +1,8 @@
1
+ SystemJS.config({
2
+ map: {
3
+ 'plugin-babel': 'assets/js/vendor/plugin-babel/plugin-babel.js',
4
+ 'systemjs-babel-build': 'assets/js/vendor/plugin-babel/systemjs-babel-browser.js'
5
+ },
6
+ transpiler: 'plugin-babel'
7
+ });
8
+ System.import("assets/js/ui.js");
@@ -0,0 +1,377 @@
1
+
2
+ import * as wab from './wab.js';
3
+
4
+ function displayError(msg) {
5
+ // TBD handle this better than an alert. Create an error display and call master.setFlow
6
+ alert(msg);
7
+ }
8
+
9
+ function _objGet(obj, path, index) {
10
+ if (path.length - 1 == index) {
11
+ return obj[path[index]];
12
+ }
13
+ if (index < path.length - 1) {
14
+ let node = obj[path[index]];
15
+
16
+ if (null != node) {
17
+ return _objGet(node, path, index + 1);
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+
23
+ function objGet(obj, path) {
24
+ if ('$ref' == path) {
25
+ return obj.id;
26
+ }
27
+ return _objGet(obj.data, path.split('.'), 0);
28
+ }
29
+
30
+ function objSet(obj, path, index, value) {
31
+ if (path.length - 1 == index) {
32
+ obj[path[index]] = value;
33
+ } else if (index < path.length - 1) {
34
+ let node = obj[path[index]];
35
+
36
+ if (null == node) {
37
+ node = {};
38
+ }
39
+ objSet(node, path, index + 1, value);
40
+ }
41
+ }
42
+
43
+ // This fuunction is not intended for public use.
44
+ function buildDisplay(spec) {
45
+ switch (spec.display_class) {
46
+ case 'ui.List':
47
+ return new List(spec);
48
+ case 'ui.Create':
49
+ return new Create(spec);
50
+ case 'ui.View':
51
+ return new View(spec);
52
+ case 'ui.Update':
53
+ return new Update(spec);
54
+ default:
55
+ displayError(`${spec.display_class} is not a known display class.`);
56
+ }
57
+ return null;
58
+ }
59
+
60
+ export class Master {
61
+ constructor() {
62
+ this.view = document.getElementById("view");
63
+ this.flow = {};
64
+
65
+ // If no response or error response expect the setFlow() method will
66
+ // be called later.
67
+ wab.list('ui', null).then(flow => {
68
+ this.setFlow(flow);
69
+ }).catch(function (response) {});
70
+ }
71
+
72
+ setFlow(spec) {
73
+ if (0 != spec.code) {
74
+ displayError(spec.error);
75
+ return;
76
+ }
77
+ let entry = null;
78
+ for (let display of spec.results) {
79
+ this.flow[display.name] = buildDisplay(display);
80
+ if (display.entry) {
81
+ entry = display.name;
82
+ }
83
+ }
84
+ if (null != entry) {
85
+ this.setDisplay(entry, null);
86
+ }
87
+ }
88
+
89
+ setDisplay(displayId, ref) {
90
+ let child;
91
+
92
+ // Clear out any existing elements in the view.
93
+ while (null != (child = this.view.firstChild)) {
94
+ this.view.removeChild(child);
95
+ }
96
+ let display = this.flow[displayId];
97
+ if (null == display) {
98
+ displayError(`Display ${displayId} not found.`);
99
+ return;
100
+ }
101
+ display.display(this.view, ref);
102
+ }
103
+ }
104
+
105
+ export class Display {
106
+ constructor(spec) {
107
+ this.spec = spec;
108
+ }
109
+
110
+ _transition(target, ref) {
111
+ if (null != target) {
112
+ master.setDisplay(target, ref);
113
+ }
114
+ }
115
+
116
+ _del(target, ref) {
117
+ wab.del(this.spec.kind, ref).then(response => {
118
+ if (null != target) {
119
+ master.setDisplay(target, ref);
120
+ }
121
+ }).catch(function (response) {
122
+ displayError(response);
123
+ });
124
+ }
125
+
126
+ display(view, ref) {}
127
+ }
128
+
129
+ export class List extends Display {
130
+ constructor(spec) {
131
+ super(spec);
132
+ this.table = null;
133
+ }
134
+
135
+ _appendObjects(response) {
136
+ if (0 != response.code) {
137
+ displayError(response.error);
138
+ return;
139
+ }
140
+ for (let obj of response.results) {
141
+ let tr = document.createElement('tr');
142
+ tr.innerHTML = this.spec.row;
143
+ this.table.appendChild(tr);
144
+ for (let child of tr.childNodes) {
145
+ let path = child.getAttribute('path');
146
+ if (null != path) {
147
+ child.appendChild(document.createTextNode(String(objGet(obj, path))));
148
+ }
149
+ }
150
+ for (let child of tr.getElementsByTagName('*')) {
151
+ switch (child.getAttribute('title')) {
152
+ case 'View':
153
+ child.onclick = event => {
154
+ this._transition(this.spec.transitions.view, obj.id);
155
+ };
156
+ break;
157
+ case 'Edit':
158
+ child.onclick = event => {
159
+ this._transition(this.spec.transitions.edit, obj.id);
160
+ };
161
+ break;
162
+ case 'Delete':
163
+ child.onclick = event => {
164
+ this._del(this.spec.transitions['delete'], obj.id);
165
+ };
166
+ break;
167
+ default:
168
+ break;
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ display(view, ref) {
175
+ view.innerHTML = this.spec.table;
176
+ this.table = document.getElementById(`${this.spec.name}.table`);
177
+
178
+ let button = document.getElementById(`${this.spec.name}.create_button`);
179
+
180
+ if (null != button) {
181
+ button.onclick = event => {
182
+ this._transition(this.spec.transitions.create, null);
183
+ };
184
+ }
185
+ wab.list(this.spec.kind, null).then(response => {
186
+ this._appendObjects(response);
187
+ }).catch(function (response) {
188
+ displayError(response);
189
+ });
190
+ }
191
+ }
192
+
193
+ export class ObjectDisplay extends Display {
194
+ constructor(spec) {
195
+ super(spec);
196
+ this.ref = 0;
197
+ }
198
+
199
+ _setFields(path, obj) {
200
+ let element;
201
+ let value;
202
+
203
+ for (let key in obj) {
204
+ if (obj.hasOwnProperty(key) && null != (element = document.getElementById(`${path}.${key}`))) {
205
+ value = obj[key];
206
+ if (value instanceof Object) {
207
+ this._setFields(`${path}.${key}`, value);
208
+ } else {
209
+ element.value = obj[key];
210
+ }
211
+ }
212
+ }
213
+ }
214
+
215
+ _populate(ref) {
216
+ wab.get(this.spec.kind, ref).then(response => {
217
+ if (0 != response.code) {
218
+ throw response.error;
219
+ }
220
+ let obj = response.results[0];
221
+
222
+ if (null != obj) {
223
+ this.ref = obj.id;
224
+ this._setFields(this.spec.name, obj.data);
225
+ }
226
+ }).catch(function (response) {
227
+ displayError(response);
228
+ });
229
+ }
230
+
231
+ display(view, ref) {
232
+ view.innerHTML = this.spec.html;
233
+ this._setupButtons();
234
+ this._populate(ref);
235
+ }
236
+ }
237
+
238
+ export class View extends ObjectDisplay {
239
+ constructor(spec) {
240
+ super(spec);
241
+ }
242
+
243
+ _setupButtons() {
244
+ let button;
245
+
246
+ if (null != (button = document.getElementById(`${this.spec.name}.list_button`))) {
247
+ button.onclick = event => {
248
+ this._transition(this.spec.transitions.list, null);
249
+ };
250
+ }
251
+ if (null != (button = document.getElementById(`${this.spec.name}.edit_button`))) {
252
+ button.onclick = event => {
253
+ this._transition(this.spec.transitions.edit, this.ref);
254
+ };
255
+ }
256
+ if (null != (button = document.getElementById(`${this.spec.name}.delete_button`))) {
257
+ button.onclick = event => {
258
+ this._del(this.spec.transitions['delete'], this.ref);
259
+ };
260
+ }
261
+ }
262
+ }
263
+
264
+ function addToObject(obj, input) {
265
+ let value;
266
+
267
+ if ('checkbox' == input.type) {
268
+ value = input.checked;
269
+ } else if ('number' == input.type || 'range' == input.type) {
270
+ value = parseFloat(input.value);
271
+ } else {
272
+ value = input.value;
273
+ }
274
+ // the id is if the form Entry.edit.field
275
+ objSet(obj, input.id.split('.'), 2, value);
276
+ }
277
+
278
+ export class Create extends ObjectDisplay {
279
+ constructor(spec) {
280
+ super(spec);
281
+ }
282
+
283
+ _save(target) {
284
+ let obj = { kind: this.spec.kind };
285
+
286
+ for (let input of document.getElementsByTagName('INPUT')) {
287
+ addToObject(obj, input);
288
+ }
289
+ for (let input of document.getElementsByTagName('TEXTAREA')) {
290
+ addToObject(obj, input);
291
+ }
292
+
293
+ wab.create(this.spec.kind, obj, null).then(response => {
294
+ if (0 != response.code) {
295
+ throw response.error;
296
+ }
297
+ this.ref = response.ref;
298
+ if (null != target) {
299
+ master.setDisplay(target, this.ref);
300
+ }
301
+ }).catch(function (response) {
302
+ displayError(response);
303
+ });
304
+ }
305
+
306
+ _setupButtons() {
307
+ let button;
308
+
309
+ if (null != (button = document.getElementById(`${this.spec.name}.save_button`))) {
310
+ button.onclick = event => {
311
+ this._save(this.spec.transitions.save);
312
+ };
313
+ }
314
+ if (null != (button = document.getElementById(`${this.spec.name}.cancel_button`))) {
315
+ button.onclick = event => {
316
+ this._transition(this.spec.transitions.cancel, null);
317
+ };
318
+ }
319
+ }
320
+ _populate(ref) {}
321
+ }
322
+
323
+ export class Update extends ObjectDisplay {
324
+ constructor(spec) {
325
+ super(spec);
326
+ }
327
+
328
+ _save(target) {
329
+ let obj = { kind: this.spec.kind };
330
+
331
+ for (let input of document.getElementsByTagName('INPUT')) {
332
+ addToObject(obj, input);
333
+ }
334
+ for (let input of document.getElementsByTagName('TEXTAREA')) {
335
+ addToObject(obj, input);
336
+ }
337
+
338
+ wab.update(this.spec.kind, this.ref, obj, null).then(response => {
339
+ if (0 != response.code) {
340
+ throw response.error;
341
+ }
342
+ this.ref = response.updated[0];
343
+ if (null != target) {
344
+ master.setDisplay(target, this.ref);
345
+ }
346
+ }).catch(function (response) {
347
+ displayError(response);
348
+ });
349
+ }
350
+
351
+ _setupButtons() {
352
+ let button;
353
+
354
+ if (null != (button = document.getElementById(`${this.spec.name}.save_button`))) {
355
+ button.onclick = event => {
356
+ this._save(this.spec.transitions.save, this.ref);
357
+ };
358
+ }
359
+ if (null != (button = document.getElementById(`${this.spec.name}.cancel_button`))) {
360
+ button.onclick = event => {
361
+ this._transition(this.spec.transitions.cancel, this.ref);
362
+ };
363
+ }
364
+ if (null != (button = document.getElementById(`${this.spec.name}.list_button`))) {
365
+ button.onclick = event => {
366
+ this._transition(this.spec.transitions.list, null);
367
+ };
368
+ }
369
+ if (null != (button = document.getElementById(`${this.spec.name}.delete_button`))) {
370
+ button.onclick = event => {
371
+ this._del(this.spec.transitions['delete'], this.ref);
372
+ };
373
+ }
374
+ }
375
+ }
376
+
377
+ export const master = new Master();