Преглед изворни кода

submodule plugins with production-like working imports

master
peter пре 2 година
родитељ
комит
d5abeb4e9b

+ 3
- 1
angular.json Прегледај датотеку

@@ -108,7 +108,9 @@
108 108
               "e2e/tsconfig.json"
109 109
             ],
110 110
             "exclude": [
111
-              "**/node_modules/**"
111
+              "**/node_modules/**",
112
+              "**/backend/**",
113
+              "**/frontend/**"
112 114
             ]
113 115
           }
114 116
         },

+ 3
- 3
package-lock.json Прегледај датотеку

@@ -4581,9 +4581,9 @@
4581 4581
       }
4582 4582
     },
4583 4583
     "frontblock-generic": {
4584
-      "version": "0.22.0",
4585
-      "resolved": "https://registry.npmjs.org/frontblock-generic/-/frontblock-generic-0.22.0.tgz",
4586
-      "integrity": "sha512-hhojVEeQYt1wakBTBTZAKuCNqvw4CxI9+WuWb7Ark2gaJJMD2+q/FxkrE+VAPDv82Uy7AT3Pn39DkMbyF52hCg==",
4584
+      "version": "0.23.0",
4585
+      "resolved": "https://registry.npmjs.org/frontblock-generic/-/frontblock-generic-0.23.0.tgz",
4586
+      "integrity": "sha512-5KukScUCAsomGP9xMp6gQjA5xKBMfctTSQhIoaoxEkXpXoX9F2pjlYIkfP11NYNSsk2gVf3xg7VIhhSzhizy/A==",
4587 4587
       "requires": {
4588 4588
         "@types/node": "^12.7.1",
4589 4589
         "bsock": "^0.1.9",

+ 4
- 3
package.json Прегледај датотеку

@@ -3,8 +3,9 @@
3 3
   "version": "0.0.0",
4 4
   "scripts": {
5 5
     "ng": "ng",
6
-    "start": "ng serve --aot=false --optimization=false --proxy-config proxy.conf.json",
7
-    "build": "ng build --prod --aot=false --optimization=false --build-optimizer=false",
6
+    "start": "npm run copy-dev-gui; ng serve --aot=false --optimization=false --proxy-config proxy.conf.json ",
7
+    "build": "rm -f src/assets/*.js; ng build --prod --aot=false --optimization=false --build-optimizer=false",
8
+    "copy-dev-gui": "cp src/app/apiclient/dist/FrontendPlugin.js src/assets/apiclient.js; cp src/app/wallet/dist/FrontendPlugin.js src/assets/wallet.js; cp src/app/pluginmanager/dist/FrontendPlugin.js src/assets/pluginmanager.js;",
8 9
     "test": "ng test",
9 10
     "lint": "ng lint",
10 11
     "e2e": "ng e2e",
@@ -27,7 +28,7 @@
27 28
     "btc-hdkey": "0.0.17",
28 29
     "coinselect": "^3.1.11",
29 30
     "frontblock": "latest",
30
-    "frontblock-generic": "^0.22.0",
31
+    "frontblock-generic": "^0.23.0",
31 32
     "key-file-storage": "^2.2.4",
32 33
     "node-fetch": "^2.6.0",
33 34
     "rxjs": "~6.5.2",

+ 1
- 1
src/app/apiclient

@@ -1 +1 @@
1
-Subproject commit dedf6e3779c5d4009d918dd3d6693b5b73b8b555
1
+Subproject commit 08d9914da48fef30389798f64cf636a20f65f2d3

+ 1
- 1
src/app/app.component.ts Прегледај датотеку

@@ -15,7 +15,7 @@ export class AppComponent implements AfterContentInit {
15 15
   constructor(private zone:NgZone, private sidebarService: SidebarEntryService){
16 16
     window["refresh"] = setInterval(() => zone.run(()=>{ /*this triggers an angular reload*/}), 200)
17 17
     if(isDevMode()){
18
-      require("../assets/FrontblockLib")
18
+      require("../assets/dev/FrontblockLib")
19 19
     }
20 20
   }
21 21
 

+ 7
- 3
src/app/dynamic-loader/dynamic-loader.component.ts Прегледај датотеку

@@ -20,6 +20,8 @@ import * as frontblockGenericTypes from 'frontblock-generic/Types.js'
20 20
 import * as browserAnimationsModule from "@angular/platform-browser/animations";
21 21
 import * as btcHdkey from "btc-hdkey"
22 22
 import * as bitcoinjslib from "bitcoinjs-lib"
23
+import * as fetch from "node-fetch"
24
+import * as coinselect from "coinselect/accumulative"
23 25
 
24 26
 SystemJS.set('@clr/angular', SystemJS.newModule(clarityModule));
25 27
 SystemJS.set('@angular/router', SystemJS.newModule(angularRouter));
@@ -35,6 +37,8 @@ SystemJS.set('@angular/platform-browser-dynamic', SystemJS.newModule(angularPlat
35 37
 SystemJS.set('frontblock-generic/Types', SystemJS.newModule(frontblockGenericTypes));
36 38
 SystemJS.set('btc-hdkey', SystemJS.newModule(btcHdkey))
37 39
 SystemJS.set('bitcoinjs-lib', SystemJS.newModule(bitcoinjslib))
40
+SystemJS.set('node-fetch', SystemJS.newModule(fetch))
41
+SystemJS.set('coinselect/accumulative', SystemJS.newModule(coinselect))
38 42
 
39 43
 
40 44
 SystemJS.config({ meta: { '*': { authorization: true } } });
@@ -48,7 +52,7 @@ import { environment } from "../../environments/environment"
48 52
 
49 53
 const fb = environment.production ? window["fb"] : {
50 54
   PluginManager: {
51
-    getLoadedPluginNames: () => ["ApiClient", "PluginManager", "Wallet"]
55
+    getLoadedPluginNames: () => [/*"ApiClient", "PluginManager",*/ "Wallet"]
52 56
   }
53 57
 }
54 58
 
@@ -80,10 +84,10 @@ export class DynamicLoaderComponent implements AfterViewInit {
80 84
 
81 85
   private async installWidget(pluginName: string) {
82 86
     let module: FrontendPlugin
83
-    if (environment.production)
87
+    if (!angularCore.isDevMode())
84 88
       module = await SystemJS.import("plugins/" + pluginName + ".js");
85 89
     else
86
-      module = await import("../" + pluginName + "/module")
90
+      module = await SystemJS.import("assets/" + pluginName.toLowerCase() + ".js")
87 91
 
88 92
     const plugin = new module['PluginModule']()
89 93
     const entry: SidebarEntries | SidebarEntry = plugin.getSidebarEntry()

+ 1
- 1
src/app/pluginmanager

@@ -1 +1 @@
1
-Subproject commit ba2a3f59f27734d01c7ed5dea1d828a76d1d826c
1
+Subproject commit ca427ed2e67c86a2b58a96730e719342c20f1adc

+ 1
- 1
src/app/wallet

@@ -1 +1 @@
1
-Subproject commit c65fdbf219c1bd7959f7743dee240b650e0cc4b5
1
+Subproject commit 02e7c8aaa614dd6b0eb0445a62c1503335cd5673

+ 417
- 0
src/assets/apiclient.js Прегледај датотеку

@@ -0,0 +1,417 @@
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
+});

src/assets/FrontblockLib.js → src/assets/dev/FrontblockLib.js Прегледај датотеку


+ 283
- 0
src/assets/pluginmanager.js Прегледај датотеку

@@ -0,0 +1,283 @@
1
+System.register(['@angular/core', '@angular/common', '@angular/router', '@clr/angular', '@angular/forms'], function (exports, module) {
2
+'use strict';
3
+var Component, isDevMode, NgModule, CommonModule, RouterModule, ClarityModule, FormsModule;
4
+return {
5
+setters: [function (module) {
6
+Component = module.Component;
7
+isDevMode = module.isDevMode;
8
+NgModule = module.NgModule;
9
+}, function (module) {
10
+CommonModule = module.CommonModule;
11
+}, function (module) {
12
+RouterModule = module.RouterModule;
13
+}, function (module) {
14
+ClarityModule = module.ClarityModule;
15
+}, function (module) {
16
+FormsModule = module.FormsModule;
17
+}],
18
+execute: function () {
19
+
20
+/*! *****************************************************************************
21
+Copyright (c) Microsoft Corporation. All rights reserved.
22
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
23
+this file except in compliance with the License. You may obtain a copy of the
24
+License at http://www.apache.org/licenses/LICENSE-2.0
25
+
26
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
27
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
28
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
29
+MERCHANTABLITY OR NON-INFRINGEMENT.
30
+
31
+See the Apache Version 2.0 License for specific language governing permissions
32
+and limitations under the License.
33
+***************************************************************************** */
34
+/* global Reflect, Promise */
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+function __decorate(decorators, target, key, desc) {
43
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
44
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
45
+    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;
46
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
47
+}
48
+
49
+
50
+
51
+
52
+
53
+function __awaiter(thisArg, _arguments, P, generator) {
54
+    return new (P || (P = Promise))(function (resolve, reject) {
55
+        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
56
+        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
57
+        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
58
+        step((generator = generator.apply(thisArg, _arguments || [])).next());
59
+    });
60
+}
61
+
62
+let PluginmanagerDEBUG = class PluginmanagerDEBUG {
63
+    constructor() { }
64
+    ngOnInit() { }
65
+};
66
+PluginmanagerDEBUG = __decorate([
67
+    Component({
68
+        selector: 'debug',
69
+        template: `
70
+  <div class="clr-row">
71
+    <div class="clr-col">
72
+        <div class="card">
73
+            <div class="card-header">
74
+                DEBUG
75
+            </div>
76
+            <div class="card-block">
77
+                <div class="card-title">
78
+                    SETUP
79
+                </div>
80
+                <div class="card-text">
81
+                  <p>
82
+                    Press this button to install all plugins.
83
+                    <br>
84
+                    Once the installation is done the page will refresh automatically
85
+                  </p>
86
+                </div>
87
+            </div>
88
+            <div class="card-footer">
89
+              <button class="btn btn-warning-outline" onclick="setup()">SETUP</button>
90
+            </div>
91
+        </div>
92
+    </div>
93
+  </div>
94
+  `
95
+    })
96
+], PluginmanagerDEBUG);
97
+
98
+let PluginsComponent = class PluginsComponent {
99
+    constructor() {
100
+        this.plugins = [{
101
+                name: "test",
102
+                available: "0.0.1",
103
+                installed: "0.0.1",
104
+                status: "Running"
105
+            }, {
106
+                name: "test II: Return of test",
107
+                available: "0.0.1",
108
+                installed: "0.0.1",
109
+                status: "Stopped"
110
+            }, {
111
+                name: "test 3",
112
+                available: "0.0.2",
113
+                installed: "",
114
+                status: "Available"
115
+            }, {
116
+                name: "test IV: minor bump",
117
+                available: "0.9.27",
118
+                installed: "0.0.11",
119
+                status: "Stopped"
120
+            },];
121
+        this.reloading = false;
122
+        this.updatepending = false;
123
+        this.updateCandidate = "";
124
+    }
125
+    start(name) {
126
+        this.plugins.find((el) => el.name === name).status = "Running";
127
+    }
128
+    stop(name) {
129
+        this.plugins.find((el) => el.name === name).status = "Stopped";
130
+    }
131
+    delete(name) {
132
+        let plugin = this.plugins.find((el) => el.name === name);
133
+        plugin.status = "Available";
134
+        plugin.installed = "";
135
+    }
136
+    showConfirmation(name) {
137
+        this.updateCandidate = name;
138
+        this.updatepending = !this.updatepending;
139
+    }
140
+    download(name) {
141
+        let plugin = this.plugins.find((el) => el.name === name);
142
+        plugin.status = "Stopped";
143
+        plugin.installed = plugin.available;
144
+        this.updatepending = !this.updatepending;
145
+    }
146
+    cancelModal() {
147
+        this.updateCandidate = "";
148
+        this.updatepending = !this.updatepending;
149
+    }
150
+    reload() {
151
+        return __awaiter(this, void 0, void 0, function* () {
152
+            this.reloading = true;
153
+            if (isDevMode()) {
154
+                yield new Promise((resolve, reject) => {
155
+                    setTimeout(resolve, 1000);
156
+                });
157
+                this.plugins = this.plugins.map(plugin => {
158
+                    const parts = plugin.available.split('.');
159
+                    plugin.available = parts[0] + "." + parts[1] + "." + (parseInt(parts[2]) + 1);
160
+                    return plugin;
161
+                });
162
+                this.reloading = false;
163
+            }
164
+        });
165
+    }
166
+    ngOnInit() { }
167
+};
168
+PluginsComponent = __decorate([
169
+    Component({
170
+        selector: 'plugins',
171
+        template: `
172
+  <clr-modal [(clrModalOpen)]="updatepending">
173
+    <h3 class="modal-title">Confirm installation</h3>
174
+    <div class="modal-body">
175
+        <p>{{updateCandidate}} But not much to say...</p>
176
+    </div>
177
+    <div class="modal-footer">
178
+        <button class="btn btn-icon btn-success" (click)="download(updateCandidate)"><clr-icon shape="check"></clr-icon></button>
179
+        <button class="btn btn-icon btn-danger" (click)="cancelModal()"><clr-icon shape="times"></clr-icon></button>
180
+    </div>
181
+  </clr-modal>
182
+
183
+  <div class="clr-row">
184
+    <div class="card clr-col-12 clr-col-sm-12 clr-col-md-12 clr-col-lg-12 clr-col-xl-12">
185
+        <div class="card-header">
186
+            Plugins
187
+        </div>
188
+        <clr-alert *ngFor="let entry of alerts" [clrAlertType]="line.severity">
189
+            <clr-alert-item>
190
+                <span class="alert-text">
191
+                    {{line.message}}
192
+                </span>
193
+            </clr-alert-item>
194
+        </clr-alert>
195
+    
196
+        <div *ngIf="loading" class="card-block">
197
+        <span class="spinner spinner-inline"></span>
198
+        </div>
199
+        <div *ngIf="plugins.length !== 0 && !loading" class="card-block">
200
+            <div class="card-text">
201
+                <clr-datagrid>
202
+                    <clr-dg-column>Name</clr-dg-column>
203
+                    <clr-dg-column>Available</clr-dg-column>
204
+                    <clr-dg-column>Installed</clr-dg-column>
205
+                    <clr-dg-column>Status</clr-dg-column>
206
+    
207
+                    <clr-dg-row *clrDgItems="let line of plugins">
208
+                        <clr-dg-cell>{{line.name}}</clr-dg-cell>
209
+                        <clr-dg-cell>
210
+                            <span *ngIf="line.installed != line.available" class="label info">{{line.available}}</span>
211
+                            <span *ngIf="line.installed == line.available">{{line.available}}</span>
212
+                        </clr-dg-cell>
213
+                        <clr-dg-cell>{{line.installed}}</clr-dg-cell>
214
+                        <clr-dg-cell>{{line.status}}</clr-dg-cell>
215
+                        
216
+                        <clr-dg-row-detail *clrIfExpanded>
217
+                            <button *ngIf="line.status === 'Stopped'" class="btn btn-icon btn-success-outline" (click)="start(line.name)"><clr-icon shape="play"></clr-icon></button>
218
+                            <button *ngIf="line.status === 'Running'" class="btn btn-icon btn-warning-outline" (click)="stop(line.name)"><clr-icon shape="pause"></clr-icon></button>
219
+                            <button *ngIf="line.status === 'Stopped'" class="btn btn-icon btn-danger-outline" (click)="delete(line.name)"><clr-icon shape="trash"></clr-icon></button>
220
+                            <button *ngIf="line.status === 'Available'" class="btn btn-icon btn-info-outline" (click)="showConfirmation(line.name)"><clr-icon shape="download"></clr-icon></button>
221
+                            <button *ngIf="line.available !== line.installed && line.status === 'Stopped'" class="btn btn-icon btn-outline " (click)="showConfirmation(line.name)">
222
+                                <clr-icon shape="sync"></clr-icon>
223
+                            </button>                        
224
+                        </clr-dg-row-detail>
225
+                    </clr-dg-row>
226
+                    <clr-dg-footer>
227
+                        <clr-dg-pagination #pagination [clrDgPageSize]="10">
228
+                            <clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">per page</clr-dg-page-size>
229
+                            {{pagination.firstItem + 1}} - {{pagination.lastItem + 1}}
230
+                            of {{pagination.totalItems}}
231
+                        </clr-dg-pagination>
232
+                    </clr-dg-footer>
233
+                </clr-datagrid>
234
+            </div>
235
+        </div>
236
+        <div class="card-footer">
237
+            <button *ngIf="!reloading" class="btn btn-sm btn-link" (click)="reload()">Check</button>
238
+    
239
+        </div>
240
+    </div>
241
+    </div>
242
+  `
243
+    })
244
+], PluginsComponent);
245
+
246
+let PluginModule = exports('PluginModule', class PluginModule {
247
+    getSidebarEntry() {
248
+        return {
249
+            icon: "plugin",
250
+            text: "Plugin manager",
251
+            parentRoute: "pluginmanager",
252
+            links: [{
253
+                    route: "debug",
254
+                    text: "DEBUG"
255
+                }, {
256
+                    route: "plugins",
257
+                    text: "Plugins"
258
+                }]
259
+        };
260
+    }
261
+});
262
+PluginModule = exports('PluginModule', __decorate([
263
+    NgModule({
264
+        imports: [
265
+            FormsModule,
266
+            ClarityModule,
267
+            CommonModule,
268
+            RouterModule.forChild([
269
+                { path: "debug", component: PluginmanagerDEBUG },
270
+                { path: "plugins", component: PluginsComponent }
271
+            ]),
272
+        ],
273
+        exports: [RouterModule],
274
+        declarations: [
275
+            PluginmanagerDEBUG,
276
+            PluginsComponent
277
+        ]
278
+    })
279
+], PluginModule));
280
+
281
+}
282
+};
283
+});

+ 1106
- 0
src/assets/wallet.js
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 6
- 1
tsconfig.app.json Прегледај датотеку

@@ -10,6 +10,11 @@
10 10
   "exclude": [
11 11
     "node_modules",
12 12
     "src/test.ts",
13
-    "src/**/*.spec.ts"
13
+    "src/**/*.spec.ts",
14
+    "src/app/**/*/backend/**/*",
15
+    "src/app/**/*/frontend/**/*",
16
+    "src/app/**/*/node_modules/**/*",
17
+    "src/app/**/*/dist/**/*"
18
+
14 19
   ]
15 20
 }

+ 2
- 2
tsconfig.json Прегледај датотеку

@@ -2,12 +2,12 @@
2 2
   "compileOnSave": false,
3 3
   "compilerOptions": {
4 4
     "baseUrl": "./",
5
-    "outDir": "./dist/out-tsc",
5
+    "outDir": "./out-tsc",
6 6
     "sourceMap": true,
7 7
     "declaration": false,
8 8
     "downlevelIteration": true,
9 9
     "experimentalDecorators": true,
10
-    "module": "esnext",
10
+    "module": "commonjs",
11 11
     "moduleResolution": "node",
12 12
     "importHelpers": true,
13 13
     "target": "es2015",

Loading…
Откажи
Сачувај