|
@@ -1,417 +0,0 @@
|
1
|
|
-System.register(['@angular/core', 'frontblock-generic/Types', '@angular/common', '@angular/router', '@clr/angular', '@angular/forms'], function (exports, module) {
|
2
|
|
-'use strict';
|
3
|
|
-var Component, NgModule, parseResponse, SuccessResponse, CommonModule, RouterModule, ClarityModule, FormsModule;
|
4
|
|
-return {
|
5
|
|
-setters: [function (module) {
|
6
|
|
-Component = module.Component;
|
7
|
|
-NgModule = module.NgModule;
|
8
|
|
-}, function (module) {
|
9
|
|
-parseResponse = module.parseResponse;
|
10
|
|
-SuccessResponse = module.SuccessResponse;
|
11
|
|
-}, function (module) {
|
12
|
|
-CommonModule = module.CommonModule;
|
13
|
|
-}, function (module) {
|
14
|
|
-RouterModule = module.RouterModule;
|
15
|
|
-}, function (module) {
|
16
|
|
-ClarityModule = module.ClarityModule;
|
17
|
|
-}, function (module) {
|
18
|
|
-FormsModule = module.FormsModule;
|
19
|
|
-}],
|
20
|
|
-execute: function () {
|
21
|
|
-
|
22
|
|
-/*! *****************************************************************************
|
23
|
|
-Copyright (c) Microsoft Corporation. All rights reserved.
|
24
|
|
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
25
|
|
-this file except in compliance with the License. You may obtain a copy of the
|
26
|
|
-License at http://www.apache.org/licenses/LICENSE-2.0
|
27
|
|
-
|
28
|
|
-THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
29
|
|
-KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
30
|
|
-WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
31
|
|
-MERCHANTABLITY OR NON-INFRINGEMENT.
|
32
|
|
-
|
33
|
|
-See the Apache Version 2.0 License for specific language governing permissions
|
34
|
|
-and limitations under the License.
|
35
|
|
-***************************************************************************** */
|
36
|
|
-/* global Reflect, Promise */
|
37
|
|
-
|
38
|
|
-
|
39
|
|
-
|
40
|
|
-
|
41
|
|
-
|
42
|
|
-
|
43
|
|
-
|
44
|
|
-function __decorate(decorators, target, key, desc) {
|
45
|
|
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
46
|
|
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
47
|
|
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
48
|
|
- return c > 3 && r && Object.defineProperty(target, key, r), r;
|
49
|
|
-}
|
50
|
|
-
|
51
|
|
-
|
52
|
|
-
|
53
|
|
-
|
54
|
|
-
|
55
|
|
-function __awaiter(thisArg, _arguments, P, generator) {
|
56
|
|
- return new (P || (P = Promise))(function (resolve, reject) {
|
57
|
|
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
58
|
|
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
59
|
|
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
60
|
|
- step((generator = generator.apply(thisArg, _arguments || [])).next());
|
61
|
|
- });
|
62
|
|
-}
|
63
|
|
-
|
64
|
|
-let ApiclientFormComponent = class ApiclientFormComponent {
|
65
|
|
- constructor() {
|
66
|
|
- this.testnet = true;
|
67
|
|
- this.saving = false;
|
68
|
|
- this.advanced = false;
|
69
|
|
- this.data = {
|
70
|
|
- apiHost: "api.testnet.frontblock.me",
|
71
|
|
- apiPort: 10001,
|
72
|
|
- tls: false,
|
73
|
|
- apiKey: ""
|
74
|
|
- };
|
75
|
|
- }
|
76
|
|
- ngOnInit() { }
|
77
|
|
- setAdvanced() { this.advanced = true; }
|
78
|
|
- checkData() {
|
79
|
|
- return (typeof this.data.apiPort === "number" &&
|
80
|
|
- typeof this.data.apiHost === "string" &&
|
81
|
|
- typeof this.data.tls === "boolean" &&
|
82
|
|
- typeof this.data.apiKey === "string");
|
83
|
|
- }
|
84
|
|
- updateTestnet() {
|
85
|
|
- if (this.testnet) {
|
86
|
|
- this.data.apiHost = "api.testnet.frontblock.me";
|
87
|
|
- this.data.apiPort = 10001;
|
88
|
|
- }
|
89
|
|
- else {
|
90
|
|
- this.data.apiHost = "api.frontblock.me";
|
91
|
|
- this.data.apiPort = 10000;
|
92
|
|
- }
|
93
|
|
- }
|
94
|
|
- updatePort(obj) {
|
95
|
|
- switch (this.data.apiHost) {
|
96
|
|
- case "api.testnet.frontblock.me":
|
97
|
|
- this.data.apiPort = 10001;
|
98
|
|
- break;
|
99
|
|
- case "api.frontblock.me":
|
100
|
|
- this.data.apiPort = 10000;
|
101
|
|
- break;
|
102
|
|
- default:
|
103
|
|
- console.warn("A non-standard api host was chosen: " + this.data.apiPort);
|
104
|
|
- break;
|
105
|
|
- }
|
106
|
|
- console.log(this.data);
|
107
|
|
- }
|
108
|
|
- save() {
|
109
|
|
- return __awaiter(this, void 0, void 0, function* () {
|
110
|
|
- this.saving = true;
|
111
|
|
- if (typeof this.data.apiPort === "string")
|
112
|
|
- this.data.apiPort = parseInt(this.data.apiPort);
|
113
|
|
- if (this.checkData()) {
|
114
|
|
- const conf = yield fb.ApiClient.setConfig(this.data);
|
115
|
|
- console.log(conf);
|
116
|
|
- }
|
117
|
|
- else {
|
118
|
|
- //show error in gui
|
119
|
|
- console.error("bad data :(");
|
120
|
|
- }
|
121
|
|
- this.saving = false;
|
122
|
|
- });
|
123
|
|
- }
|
124
|
|
-};
|
125
|
|
-ApiclientFormComponent = __decorate([
|
126
|
|
- Component({
|
127
|
|
- selector: 'settings',
|
128
|
|
- template: `
|
129
|
|
- <div class="clr-row">
|
130
|
|
- <div class="card clr-col-12 clr-col-sm-12 clr-col-md-12 clr-col-lg-auto clr-col-xl-auto">
|
131
|
|
- <div class="card-header">
|
132
|
|
- Settings
|
133
|
|
- </div>
|
134
|
|
- <div class="card-block">
|
135
|
|
- <div class="card-text">
|
136
|
|
- <form clrForm clrLayout="horizontal">
|
137
|
|
- <div class="clr-row clr-form-control ng-star-inserted">
|
138
|
|
- <label class="clr-col-12 clr-col-md-4 clr-control-label">testnet</label>
|
139
|
|
- <div class="clr-col-12 clr-col-md-8">
|
140
|
|
- <input type="checkbox" [(ngModel)]="testnet" (change)="updateTestnet($event)" name="testnetToggle" clrToggle />
|
141
|
|
- </div>
|
142
|
|
- </div>
|
143
|
|
-
|
144
|
|
- <clr-input-container *ngIf="!testnet">
|
145
|
|
- <label class="clr-col-12 clr-col-md-4">API key</label>
|
146
|
|
- <input class="clr-col-12 clr-col-md-8" clrInput type="text" name="apiKey" required />
|
147
|
|
- </clr-input-container>
|
148
|
|
-
|
149
|
|
- <clr-input-container *ngIf="advanced" class="clr-row">
|
150
|
|
- <label class="clr-col-12 clr-col-md-4">API address</label>
|
151
|
|
- <input class="clr-col-12 clr-col-md-8" type="text" [(ngModel)]="data.apiHost" (change)="updatePort($event)" clrInput name="apiHost" required />
|
152
|
|
- <clr-control-error>This field is required!</clr-control-error>
|
153
|
|
- </clr-input-container>
|
154
|
|
-
|
155
|
|
- <div class="clr-row clr-form-control ng-star-inserted" *ngIf="advanced">
|
156
|
|
- <label class="clr-col-12 clr-col-md-4 clr-control-label">Use TLS</label>
|
157
|
|
- <div class="clr-col-12 clr-col-md-8">
|
158
|
|
- <input [(ngModel)]="data.tls" type="checkbox" clrCheckbox value="tls" name="options" />
|
159
|
|
- </div>
|
160
|
|
- </div>
|
161
|
|
-
|
162
|
|
- <clr-input-container class="clr-row" *ngIf="advanced">
|
163
|
|
- <label class="clr-col-12 clr-col-md-4">Port</label>
|
164
|
|
- <input class="clr-col-12 clr-col-md-8" [(ngModel)]="data.apiPort" clrInput type="number" name="lastName" required />
|
165
|
|
- <clr-control-error>Valid range 1024 - 65536
|
166
|
|
- </clr-control-error>
|
167
|
|
- </clr-input-container>
|
168
|
|
- </form>
|
169
|
|
- </div>
|
170
|
|
- </div>
|
171
|
|
- <div class="card-footer">
|
172
|
|
- <button *ngIf="!saving" class="btn btn-success-outline" (click)="save()">
|
173
|
|
- <span>Save</span>
|
174
|
|
- </button>
|
175
|
|
-
|
176
|
|
- <button *ngIf="saving" class="btn btn-disabled" (click)="save()" disabled>
|
177
|
|
- <span class="spinner spinner-inline"></span>
|
178
|
|
- </button>
|
179
|
|
- <button *ngIf="!advanced" class="btn btn-sm btn-link" (click)="setAdvanced()">Advanced</button>
|
180
|
|
- </div>
|
181
|
|
- </div>
|
182
|
|
- </div>
|
183
|
|
- `
|
184
|
|
- })
|
185
|
|
-], ApiclientFormComponent);
|
186
|
|
-
|
187
|
|
-let ApiclientConsumptionComponent = class ApiclientConsumptionComponent {
|
188
|
|
- constructor() {
|
189
|
|
- this.loading = false;
|
190
|
|
- this.actionName = "load";
|
191
|
|
- this.entries = [];
|
192
|
|
- this.alerts = [];
|
193
|
|
- }
|
194
|
|
- ngOnInit() { }
|
195
|
|
- load() {
|
196
|
|
- return __awaiter(this, void 0, void 0, function* () {
|
197
|
|
- this.loading = true;
|
198
|
|
- this.entries = yield fb.ApiClient.getConsumptions();
|
199
|
|
- if (this.entries.length === 0) {
|
200
|
|
- this.alerts.push({ severity: "warning", message: "0 results were returned" });
|
201
|
|
- }
|
202
|
|
- this.loading = false;
|
203
|
|
- this.actionName = "refresh";
|
204
|
|
- });
|
205
|
|
- }
|
206
|
|
- quit(uid) {
|
207
|
|
- return __awaiter(this, void 0, void 0, function* () {
|
208
|
|
- const r = yield fb.ApiClient.quit(uid);
|
209
|
|
- const res = parseResponse(r);
|
210
|
|
- if (res instanceof SuccessResponse) {
|
211
|
|
- this.alerts.push({ severity: "success", message: "Quit consuming " + uid });
|
212
|
|
- this.load();
|
213
|
|
- }
|
214
|
|
- else {
|
215
|
|
- this.alerts.push({ severity: "danger", message: "Error " + res.message });
|
216
|
|
- }
|
217
|
|
- });
|
218
|
|
- }
|
219
|
|
-};
|
220
|
|
-ApiclientConsumptionComponent = __decorate([
|
221
|
|
- Component({
|
222
|
|
- selector: 'consumers',
|
223
|
|
- template: `
|
224
|
|
- <div class="clr-row">
|
225
|
|
- <div class="card clr-col-12 clr-col-sm-12 clr-col-md-12 clr-col-lg-auto clr-col-xl-auto">
|
226
|
|
- <div class="card-header">
|
227
|
|
- Consumers
|
228
|
|
- </div>
|
229
|
|
- <clr-alert *ngFor="let entry of alerts" [clrAlertType]="entry.severity">
|
230
|
|
- <clr-alert-item>
|
231
|
|
- <span class="alert-text">
|
232
|
|
- {{entry.message}}
|
233
|
|
- </span>
|
234
|
|
- </clr-alert-item>
|
235
|
|
- </clr-alert>
|
236
|
|
-
|
237
|
|
- <div *ngIf="loading" class="card-block">
|
238
|
|
- <span class="spinner spinner-inline"></span>
|
239
|
|
- </div>
|
240
|
|
- <div *ngIf="entries.length !== 0 && !loading" class="card-block limit-height">
|
241
|
|
- <div class="card-text limit-height">
|
242
|
|
- <clr-datagrid>
|
243
|
|
- <clr-dg-column>UUID</clr-dg-column>
|
244
|
|
- <clr-dg-column>Subscription UUID</clr-dg-column>
|
245
|
|
- <clr-dg-column>Expiry</clr-dg-column>
|
246
|
|
- <clr-dg-column>Creation</clr-dg-column>
|
247
|
|
-
|
248
|
|
- <clr-dg-row *clrDgItems="let line of entries">
|
249
|
|
- <clr-dg-cell>{{line.uid}}</clr-dg-cell>
|
250
|
|
- <clr-dg-cell>{{line.message}}</clr-dg-cell>
|
251
|
|
- <clr-dg-cell>{{line.expiry | date}}</clr-dg-cell>
|
252
|
|
- <clr-dg-cell>{{line.created | date}}</clr-dg-cell>
|
253
|
|
-
|
254
|
|
- <clr-dg-row-detail *clrIfExpanded>
|
255
|
|
- <button class="btn btn-icon btn-danger-outline" (click)="quit(line.uid)"><clr-icon shape="times"></clr-icon> Quit</button>
|
256
|
|
- </clr-dg-row-detail>
|
257
|
|
- </clr-dg-row>
|
258
|
|
- <clr-dg-footer>
|
259
|
|
- <clr-dg-pagination #pagination [clrDgPageSize]="10">
|
260
|
|
- <clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">Users per page</clr-dg-page-size>
|
261
|
|
- {{pagination.firstItem + 1}} - {{pagination.lastItem + 1}}
|
262
|
|
- of {{pagination.totalItems}} users
|
263
|
|
- </clr-dg-pagination>
|
264
|
|
- </clr-dg-footer>
|
265
|
|
- </clr-datagrid>
|
266
|
|
- </div>
|
267
|
|
- </div>
|
268
|
|
- <div class="card-footer">
|
269
|
|
- <button *ngIf="!loading" class="btn btn-sm btn-link" (click)="load()">{{actionName}}</button>
|
270
|
|
- </div>
|
271
|
|
- </div>
|
272
|
|
- `
|
273
|
|
- })
|
274
|
|
-], ApiclientConsumptionComponent);
|
275
|
|
-
|
276
|
|
-let ApiclientSubscriptionComponent = class ApiclientSubscriptionComponent {
|
277
|
|
- constructor() {
|
278
|
|
- this.loading = false;
|
279
|
|
- this.actionName = "load";
|
280
|
|
- this.entries = [];
|
281
|
|
- this.alerts = [];
|
282
|
|
- }
|
283
|
|
- ngOnInit() { }
|
284
|
|
- load() {
|
285
|
|
- return __awaiter(this, void 0, void 0, function* () {
|
286
|
|
- this.loading = true;
|
287
|
|
- this.entries = yield fb.ApiClient.getSubscriptions();
|
288
|
|
- if (this.entries.length === 0) {
|
289
|
|
- this.alerts.push({ severity: "warning", message: "0 results were returned" });
|
290
|
|
- }
|
291
|
|
- this.loading = false;
|
292
|
|
- this.actionName = "refresh";
|
293
|
|
- });
|
294
|
|
- }
|
295
|
|
- quit(uid) {
|
296
|
|
- return __awaiter(this, void 0, void 0, function* () {
|
297
|
|
- const r = yield fb.ApiClient.unsubscribe(uid);
|
298
|
|
- const res = parseResponse(r);
|
299
|
|
- if (res instanceof SuccessResponse) {
|
300
|
|
- this.alerts.push({ severity: "success", message: "Stopped subscription " + uid });
|
301
|
|
- this.load();
|
302
|
|
- }
|
303
|
|
- else {
|
304
|
|
- this.alerts.push({ severity: "danger", message: "Error " + res.message });
|
305
|
|
- }
|
306
|
|
- });
|
307
|
|
- }
|
308
|
|
-};
|
309
|
|
-ApiclientSubscriptionComponent = __decorate([
|
310
|
|
- Component({
|
311
|
|
- selector: 'subscriptions',
|
312
|
|
- template: `
|
313
|
|
- <div class="clr-row">
|
314
|
|
- <div class="card clr-col-12 clr-col-sm-12 clr-col-md-12 clr-col-lg-12 clr-col-xl-12">
|
315
|
|
- <div class="card-header">
|
316
|
|
- Subscriptions
|
317
|
|
- </div>
|
318
|
|
- <clr-alert *ngFor="let entry of alerts" [clrAlertType]="entry.severity">
|
319
|
|
- <clr-alert-item>
|
320
|
|
- <span class="alert-text">
|
321
|
|
- {{entry.message}}
|
322
|
|
- </span>
|
323
|
|
- </clr-alert-item>
|
324
|
|
- </clr-alert>
|
325
|
|
-
|
326
|
|
- <div *ngIf="loading" class="card-block">
|
327
|
|
- <span class="spinner spinner-inline"></span>
|
328
|
|
- </div>
|
329
|
|
- <div *ngIf="entries.length !== 0 && !loading" class="card-block">
|
330
|
|
- <div class="card-text">
|
331
|
|
- <clr-datagrid>
|
332
|
|
- <clr-dg-column>UUID</clr-dg-column>
|
333
|
|
- <!--
|
334
|
|
- <clr-dg-column>Currency</clr-dg-column>
|
335
|
|
- <clr-dg-column>Address</clr-dg-column>
|
336
|
|
- <clr-dg-column>Memo</clr-dg-column>
|
337
|
|
- <clr-dg-column>Expiry</clr-dg-column>
|
338
|
|
- <clr-dg-column>Creation</clr-dg-column>
|
339
|
|
- -->
|
340
|
|
-
|
341
|
|
- <clr-dg-row *clrDgItems="let line of entries">
|
342
|
|
- <clr-dg-cell>{{line.uid}}</clr-dg-cell>
|
343
|
|
- <!--
|
344
|
|
- <clr-dg-cell>{{line.currency}}</clr-dg-cell>
|
345
|
|
- <clr-dg-cell>{{line.address}}</clr-dg-cell>
|
346
|
|
- <clr-dg-cell>{{line.memo}}</clr-dg-cell>
|
347
|
|
- <clr-dg-cell>{{line.expiry | date}}</clr-dg-cell>
|
348
|
|
- <clr-dg-cell>{{line.created | date}}</clr-dg-cell>
|
349
|
|
- -->
|
350
|
|
-
|
351
|
|
- <clr-dg-row-detail *clrIfExpanded>
|
352
|
|
- <button class="btn btn-icon btn-danger-outline" (click)="quit(line.uid)"><clr-icon shape="times"></clr-icon> Unsubscribe</button>
|
353
|
|
- </clr-dg-row-detail>
|
354
|
|
- </clr-dg-row>
|
355
|
|
- <clr-dg-footer>
|
356
|
|
- <clr-dg-pagination #pagination [clrDgPageSize]="10">
|
357
|
|
- <clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">Users per page</clr-dg-page-size>
|
358
|
|
- {{pagination.firstItem + 1}} - {{pagination.lastItem + 1}}
|
359
|
|
- of {{pagination.totalItems}} users
|
360
|
|
- </clr-dg-pagination>
|
361
|
|
- </clr-dg-footer>
|
362
|
|
- </clr-datagrid>
|
363
|
|
- </div>
|
364
|
|
- </div>
|
365
|
|
- <div class="card-footer">
|
366
|
|
- <button *ngIf="!loading" class="btn btn-sm btn-link" (click)="load()">{{actionName}}</button>
|
367
|
|
-
|
368
|
|
- </div>
|
369
|
|
- </div>
|
370
|
|
- </div>
|
371
|
|
-`
|
372
|
|
- })
|
373
|
|
-], ApiclientSubscriptionComponent);
|
374
|
|
-
|
375
|
|
-let PluginModule = exports('PluginModule', class PluginModule {
|
376
|
|
- getSidebarEntry() {
|
377
|
|
- return {
|
378
|
|
- icon: "key",
|
379
|
|
- parentRoute: "apiclient",
|
380
|
|
- text: "Api client",
|
381
|
|
- links: [{
|
382
|
|
- route: "settings",
|
383
|
|
- text: "Settings"
|
384
|
|
- }, {
|
385
|
|
- route: "consumers",
|
386
|
|
- text: "Consumers"
|
387
|
|
- }, {
|
388
|
|
- route: "subscriptions",
|
389
|
|
- text: "Subscriptions"
|
390
|
|
- },]
|
391
|
|
- };
|
392
|
|
- }
|
393
|
|
-});
|
394
|
|
-PluginModule = exports('PluginModule', __decorate([
|
395
|
|
- NgModule({
|
396
|
|
- imports: [
|
397
|
|
- FormsModule,
|
398
|
|
- ClarityModule,
|
399
|
|
- CommonModule,
|
400
|
|
- RouterModule.forChild([
|
401
|
|
- { path: "settings", component: ApiclientFormComponent },
|
402
|
|
- { path: "subscriptions", component: ApiclientSubscriptionComponent },
|
403
|
|
- { path: "consumers", component: ApiclientConsumptionComponent },
|
404
|
|
- ]),
|
405
|
|
- ],
|
406
|
|
- exports: [RouterModule],
|
407
|
|
- declarations: [
|
408
|
|
- ApiclientFormComponent,
|
409
|
|
- ApiclientConsumptionComponent,
|
410
|
|
- ApiclientSubscriptionComponent
|
411
|
|
- ]
|
412
|
|
- })
|
413
|
|
-], PluginModule));
|
414
|
|
-
|
415
|
|
-}
|
416
|
|
-};
|
417
|
|
-});
|