pro-xy-ui 0.5.8 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.esformatter +28 -28
- package/.eslintrc +15 -15
- package/bin/pro-xy-ui +25 -27
- package/index.html +38 -38
- package/lib/app/_common/app-menu.js +42 -42
- package/lib/app/_common/app-menu.ts +41 -41
- package/lib/app/_common/patchResize.js +33 -33
- package/lib/app/_common/patchResize.ts +32 -32
- package/lib/app/_common/pipes.js +33 -33
- package/lib/app/_common/pipes.ts +21 -21
- package/lib/app/_common/rxjs-extensions.js +20 -20
- package/lib/app/_common/rxjs-extensions.ts +21 -21
- package/lib/app/app.component.css +39 -39
- package/lib/app/app.component.html +35 -35
- package/lib/app/app.module.js +92 -92
- package/lib/app/app.module.ts +89 -89
- package/lib/app/main.js +11 -11
- package/lib/app/main.ts +11 -11
- package/lib/app/model/config.js +69 -69
- package/lib/app/model/config.ts +79 -79
- package/lib/app/model/http.js +116 -116
- package/lib/app/service/config.defaultConfig.js +74 -74
- package/lib/app/service/config.defaultConfig.ts +72 -72
- package/lib/app/service/config.service.js +44 -44
- package/lib/app/service/config.service.ts +39 -39
- package/lib/app/service/socket.service.js +109 -109
- package/lib/app/service/socket.service.ts +131 -131
- package/lib/app/service/traffic.service.js +98 -98
- package/lib/app/views/auto-responder/auto-responder.component.css +37 -37
- package/lib/app/views/auto-responder/auto-responder.component.html +41 -41
- package/lib/app/views/auto-responder/auto-responder.component.js +102 -102
- package/lib/app/views/auto-responder/auto-responder.component.ts +110 -110
- package/lib/app/views/composer/composer.component.css +7 -7
- package/lib/app/views/composer/composer.component.html +9 -9
- package/lib/app/views/composer/composer.component.js +147 -147
- package/lib/app/views/composer/composer.component.ts +148 -148
- package/lib/app/views/config/config.component.css +13 -13
- package/lib/app/views/config/config.component.html +14 -14
- package/lib/app/views/config/config.component.js +163 -163
- package/lib/app/views/config/diff.dialog.html +3 -3
- package/lib/app/views/config/diff.dialog.js +29 -29
- package/lib/app/views/config/diff.dialog.ts +17 -17
- package/lib/app/views/config/plugins.dialog.html +17 -17
- package/lib/app/views/config/plugins.dialog.js +29 -29
- package/lib/app/views/config/plugins.dialog.ts +17 -17
- package/lib/app/views/config-list-base.js +44 -44
- package/lib/app/views/config-list-base.ts +66 -66
- package/lib/app/views/connection/connection.component.html +9 -9
- package/lib/app/views/connection/connection.component.js +87 -89
- package/lib/app/views/connection/connection.component.ts +83 -85
- package/lib/app/views/delay/delay.component.css +23 -23
- package/lib/app/views/delay/delay.component.html +35 -35
- package/lib/app/views/delay/delay.component.js +34 -34
- package/lib/app/views/find/find.component.css +30 -30
- package/lib/app/views/find/find.component.html +10 -10
- package/lib/app/views/find/find.component.js +113 -113
- package/lib/app/views/find/find.component.ts +111 -111
- package/lib/app/views/inspector/inspector.component.css +14 -14
- package/lib/app/views/inspector/inspector.component.html +17 -17
- package/lib/app/views/inspector/inspector.component.js +64 -64
- package/lib/app/views/inspector/inspector.component.ts +54 -54
- package/lib/app/views/logs/logs.component.css +7 -7
- package/lib/app/views/logs/logs.component.html +13 -13
- package/lib/app/views/logs/logs.component.js +56 -56
- package/lib/app/views/logs/logs.component.ts +46 -46
- package/lib/app/views/requests/request-row.component.css +15 -15
- package/lib/app/views/requests/request-row.component.html +7 -7
- package/lib/app/views/requests/request-row.component.js +68 -68
- package/lib/app/views/requests/request.bodyMenu.js +41 -41
- package/lib/app/views/requests/request.bodyMenu.ts +61 -61
- package/lib/app/views/requests/request.headMenu.js +25 -25
- package/lib/app/views/requests/requests.component.css +49 -49
- package/lib/app/views/requests/requests.component.html +33 -33
- package/lib/app/views/requests/requests.component.js +127 -127
- package/lib/app/views/status/status.component.css +18 -18
- package/lib/app/views/status/status.component.html +8 -8
- package/lib/app/views/status/status.component.js +49 -49
- package/lib/app/views/status/status.component.ts +45 -45
- package/lib/app/views/url-replace/url-replace.component.css +32 -32
- package/lib/app/views/url-replace/url-replace.component.html +36 -36
- package/lib/app/views/url-replace/url-replace.component.js +34 -34
- package/lib/index.js +23 -23
- package/lib/lib.d.ts +2 -2
- package/lib/style.css +100 -100
- package/lib/systemjs.config.js +75 -75
- package/package.json +64 -64
- package/readme.md +5 -5
- package/tsconfig.json +23 -23
- package/typings.json +11 -11
- package/npm-shrinkwrap.json +0 -2568
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const core_1 = require("@angular/core");
|
|
13
|
-
const socket_service_1 = require("./socket.service");
|
|
14
|
-
const http_1 = require("../model/http");
|
|
15
|
-
let TrafficService = class TrafficService {
|
|
16
|
-
constructor(socketService) {
|
|
17
|
-
this.socketService = socketService;
|
|
18
|
-
this._list = [];
|
|
19
|
-
this._maxRows = Infinity;
|
|
20
|
-
this._replacedOnly = false;
|
|
21
|
-
this._urlPattern = "";
|
|
22
|
-
this._cache = new Map();
|
|
23
|
-
this.traffic = socketService.reqObservable
|
|
24
|
-
.filter(req => !this._replacedOnly || !!req.headers["x-pro-xy-url-replace"])
|
|
25
|
-
.filter(req => !this._urlPatterRegex || this._urlPatterRegex.test(req.url))
|
|
26
|
-
.scan(this._hReq.bind(this), this._list);
|
|
27
|
-
socketService.resObservable.subscribe(evt => this._hRes(evt));
|
|
28
|
-
socketService.reqBodyChunkObservable.subscribe(evt => this._hReqChunk(evt));
|
|
29
|
-
socketService.resBodyChunkObservable.subscribe(evt => this._hResChunk(evt));
|
|
30
|
-
socketService.reqBodyEndObservable.subscribe(evt => this._hReqEnd(evt));
|
|
31
|
-
socketService.resBodyEndObservable.subscribe(evt => this._hResEnd(evt));
|
|
32
|
-
}
|
|
33
|
-
set maxRows(maxRows) {
|
|
34
|
-
this._maxRows = maxRows;
|
|
35
|
-
if (this._list.length > maxRows) {
|
|
36
|
-
this._list.splice(maxRows - this._list.length);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
set replacedOnly(replacedOnly) {
|
|
40
|
-
this._replacedOnly = replacedOnly;
|
|
41
|
-
// if (this._list.length > maxRows) {
|
|
42
|
-
// this._list.splice(maxRows - this._list.length);
|
|
43
|
-
// }
|
|
44
|
-
// if (replacedOnly) {
|
|
45
|
-
// this._list.splice(0).forEach(item => {
|
|
46
|
-
// if (item.headers["x-pro-xy-url-replace"]) {
|
|
47
|
-
// this._list.push(item);
|
|
48
|
-
// }
|
|
49
|
-
// });
|
|
50
|
-
// }
|
|
51
|
-
}
|
|
52
|
-
set urlPattern(urlPattern) {
|
|
53
|
-
this._urlPattern = urlPattern;
|
|
54
|
-
try {
|
|
55
|
-
this._urlPatterRegex = urlPattern && new RegExp(urlPattern) || null;
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
this._urlPatterRegex = null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
clear() {
|
|
62
|
-
this._list.splice(0);
|
|
63
|
-
}
|
|
64
|
-
_hReq(list, item) {
|
|
65
|
-
var rr = new http_1.ReqRes(item);
|
|
66
|
-
list.push(rr);
|
|
67
|
-
this._cache.set(item.id, rr);
|
|
68
|
-
if (list.length > this._maxRows) {
|
|
69
|
-
list.shift();
|
|
70
|
-
}
|
|
71
|
-
return list;
|
|
72
|
-
}
|
|
73
|
-
_hRes(res) {
|
|
74
|
-
var rr = this._cache.get(res.id);
|
|
75
|
-
rr && (rr.res = res);
|
|
76
|
-
}
|
|
77
|
-
_hReqChunk(evt) {
|
|
78
|
-
var rr = this._cache.get(evt.id);
|
|
79
|
-
rr && rr.addReqChunk(evt.chunk);
|
|
80
|
-
}
|
|
81
|
-
_hResChunk(evt) {
|
|
82
|
-
var rr = this._cache.get(evt.id);
|
|
83
|
-
rr && rr.addResChunk(evt.chunk);
|
|
84
|
-
}
|
|
85
|
-
_hReqEnd(evt) {
|
|
86
|
-
var rr = this._cache.get(evt.id);
|
|
87
|
-
rr && rr.endReq();
|
|
88
|
-
}
|
|
89
|
-
_hResEnd(evt) {
|
|
90
|
-
var rr = this._cache.get(evt.id);
|
|
91
|
-
rr && rr.endRes();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
TrafficService = __decorate([
|
|
95
|
-
core_1.Injectable(),
|
|
96
|
-
__metadata("design:paramtypes", [socket_service_1.SocketService])
|
|
97
|
-
], TrafficService);
|
|
98
|
-
exports.TrafficService = TrafficService;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const core_1 = require("@angular/core");
|
|
13
|
+
const socket_service_1 = require("./socket.service");
|
|
14
|
+
const http_1 = require("../model/http");
|
|
15
|
+
let TrafficService = class TrafficService {
|
|
16
|
+
constructor(socketService) {
|
|
17
|
+
this.socketService = socketService;
|
|
18
|
+
this._list = [];
|
|
19
|
+
this._maxRows = Infinity;
|
|
20
|
+
this._replacedOnly = false;
|
|
21
|
+
this._urlPattern = "";
|
|
22
|
+
this._cache = new Map();
|
|
23
|
+
this.traffic = socketService.reqObservable
|
|
24
|
+
.filter(req => !this._replacedOnly || !!req.headers["x-pro-xy-url-replace"])
|
|
25
|
+
.filter(req => !this._urlPatterRegex || this._urlPatterRegex.test(req.url))
|
|
26
|
+
.scan(this._hReq.bind(this), this._list);
|
|
27
|
+
socketService.resObservable.subscribe(evt => this._hRes(evt));
|
|
28
|
+
socketService.reqBodyChunkObservable.subscribe(evt => this._hReqChunk(evt));
|
|
29
|
+
socketService.resBodyChunkObservable.subscribe(evt => this._hResChunk(evt));
|
|
30
|
+
socketService.reqBodyEndObservable.subscribe(evt => this._hReqEnd(evt));
|
|
31
|
+
socketService.resBodyEndObservable.subscribe(evt => this._hResEnd(evt));
|
|
32
|
+
}
|
|
33
|
+
set maxRows(maxRows) {
|
|
34
|
+
this._maxRows = maxRows;
|
|
35
|
+
if (this._list.length > maxRows) {
|
|
36
|
+
this._list.splice(maxRows - this._list.length);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
set replacedOnly(replacedOnly) {
|
|
40
|
+
this._replacedOnly = replacedOnly;
|
|
41
|
+
// if (this._list.length > maxRows) {
|
|
42
|
+
// this._list.splice(maxRows - this._list.length);
|
|
43
|
+
// }
|
|
44
|
+
// if (replacedOnly) {
|
|
45
|
+
// this._list.splice(0).forEach(item => {
|
|
46
|
+
// if (item.headers["x-pro-xy-url-replace"]) {
|
|
47
|
+
// this._list.push(item);
|
|
48
|
+
// }
|
|
49
|
+
// });
|
|
50
|
+
// }
|
|
51
|
+
}
|
|
52
|
+
set urlPattern(urlPattern) {
|
|
53
|
+
this._urlPattern = urlPattern;
|
|
54
|
+
try {
|
|
55
|
+
this._urlPatterRegex = urlPattern && new RegExp(urlPattern) || null;
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
this._urlPatterRegex = null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
clear() {
|
|
62
|
+
this._list.splice(0);
|
|
63
|
+
}
|
|
64
|
+
_hReq(list, item) {
|
|
65
|
+
var rr = new http_1.ReqRes(item);
|
|
66
|
+
list.push(rr);
|
|
67
|
+
this._cache.set(item.id, rr);
|
|
68
|
+
if (list.length > this._maxRows) {
|
|
69
|
+
list.shift();
|
|
70
|
+
}
|
|
71
|
+
return list;
|
|
72
|
+
}
|
|
73
|
+
_hRes(res) {
|
|
74
|
+
var rr = this._cache.get(res.id);
|
|
75
|
+
rr && (rr.res = res);
|
|
76
|
+
}
|
|
77
|
+
_hReqChunk(evt) {
|
|
78
|
+
var rr = this._cache.get(evt.id);
|
|
79
|
+
rr && rr.addReqChunk(evt.chunk);
|
|
80
|
+
}
|
|
81
|
+
_hResChunk(evt) {
|
|
82
|
+
var rr = this._cache.get(evt.id);
|
|
83
|
+
rr && rr.addResChunk(evt.chunk);
|
|
84
|
+
}
|
|
85
|
+
_hReqEnd(evt) {
|
|
86
|
+
var rr = this._cache.get(evt.id);
|
|
87
|
+
rr && rr.endReq();
|
|
88
|
+
}
|
|
89
|
+
_hResEnd(evt) {
|
|
90
|
+
var rr = this._cache.get(evt.id);
|
|
91
|
+
rr && rr.endRes();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
TrafficService = __decorate([
|
|
95
|
+
core_1.Injectable(),
|
|
96
|
+
__metadata("design:paramtypes", [socket_service_1.SocketService])
|
|
97
|
+
], TrafficService);
|
|
98
|
+
exports.TrafficService = TrafficService;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
.table td,
|
|
2
|
-
.table th {
|
|
3
|
-
font-size: 12px;
|
|
4
|
-
padding: 2px;
|
|
5
|
-
border-top-color: white;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.table tr * {
|
|
9
|
-
vertical-align: bottom;
|
|
10
|
-
white-space: nowrap;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.table label {
|
|
14
|
-
margin-bottom: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.table thead label {
|
|
18
|
-
font-weight: bold;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.table input {
|
|
22
|
-
margin-right: 6px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
[dnd-droppable] {
|
|
26
|
-
border: 1px solid white;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
[dnd-droppable]>table {
|
|
30
|
-
margin-top: -1px;
|
|
31
|
-
margin-left: -1px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.dnd-drag-enter[dnd-droppable],
|
|
35
|
-
.dnd-drag-over[dnd-droppable] {
|
|
36
|
-
border: 1px dashed #333;
|
|
37
|
-
}
|
|
1
|
+
.table td,
|
|
2
|
+
.table th {
|
|
3
|
+
font-size: 12px;
|
|
4
|
+
padding: 2px;
|
|
5
|
+
border-top-color: white;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.table tr * {
|
|
9
|
+
vertical-align: bottom;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.table label {
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.table thead label {
|
|
18
|
+
font-weight: bold;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.table input {
|
|
22
|
+
margin-right: 6px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[dnd-droppable] {
|
|
26
|
+
border: 1px solid white;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[dnd-droppable]>table {
|
|
30
|
+
margin-top: -1px;
|
|
31
|
+
margin-left: -1px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.dnd-drag-enter[dnd-droppable],
|
|
35
|
+
.dnd-drag-over[dnd-droppable] {
|
|
36
|
+
border: 1px dashed #333;
|
|
37
|
+
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
<div [ngSwitch]="(configObservable|async).autoResponder.missing" class="flex-grow">
|
|
2
|
-
<div *ngSwitchCase="true">
|
|
3
|
-
Auto responder configuration is missing.
|
|
4
|
-
<br>See <a href="https://github.com/adros/pro-xy-auto-responder" (click)="openUrl($event)">pro-xy-auto-responder</a> web page for configuration options.
|
|
5
|
-
<br><br>
|
|
6
|
-
<div>
|
|
7
|
-
<button class="btn btn-default" (click)="addEmptyConfig()">Add empty configuration</button>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
10
|
-
<div *ngSwitchDefault dnd-droppable (onDropSuccess)="add($event.dragData)" [allowDrop]="checkDropAllow" class="flex-grow">
|
|
11
|
-
|
|
12
|
-
<table class="table table-hover">
|
|
13
|
-
<thead>
|
|
14
|
-
<tr>
|
|
15
|
-
<th>
|
|
16
|
-
<label>
|
|
17
|
-
<input type="checkbox" [checked]="!(configObservable|async).autoResponder.disabled" (change)="toggleDisabled()">Auto responder enabled
|
|
18
|
-
</label>
|
|
19
|
-
</th>
|
|
20
|
-
<th>Target</th>
|
|
21
|
-
<th>Method</th>
|
|
22
|
-
<th>Status</th>
|
|
23
|
-
<th>Headers</th>
|
|
24
|
-
</tr>
|
|
25
|
-
</thead>
|
|
26
|
-
<tr *ngFor="let item of (configObservable|async).autoResponder.responses; let i = index" (contextmenu)="hCtxMenu(item,$event)">
|
|
27
|
-
<td class="replace-name">
|
|
28
|
-
<div class="checkbox">
|
|
29
|
-
<label title="{{item.urlPattern}}">
|
|
30
|
-
<input type="checkbox" [checked]="!item.disabled" (change)="hChange(item, i)" [disabled]="(configObservable|async).autoResponder.disabled">{{item.shortUrlPattern}}
|
|
31
|
-
</label>
|
|
32
|
-
</div>
|
|
33
|
-
</td>
|
|
34
|
-
<td class="replace-detail"><a href="#" title="Open in system editor" (click)="openFile($event,item)">{{item.target}}</a></td>
|
|
35
|
-
<td class="replace-detail">{{item.method}}</td>
|
|
36
|
-
<td class="replace-detail">{{item.status}}</td>
|
|
37
|
-
<td class="replace-detail" [style.cursor]="item.headers?'help':'default'" title="{{item.headers|json}}">{{item.headers ? "{ JSON }" : ""}}</td>
|
|
38
|
-
</tr>
|
|
39
|
-
</table>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
1
|
+
<div [ngSwitch]="(configObservable|async).autoResponder.missing" class="flex-grow">
|
|
2
|
+
<div *ngSwitchCase="true">
|
|
3
|
+
Auto responder configuration is missing.
|
|
4
|
+
<br>See <a href="https://github.com/adros/pro-xy-auto-responder" (click)="openUrl($event)">pro-xy-auto-responder</a> web page for configuration options.
|
|
5
|
+
<br><br>
|
|
6
|
+
<div>
|
|
7
|
+
<button class="btn btn-default" (click)="addEmptyConfig()">Add empty configuration</button>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<div *ngSwitchDefault dnd-droppable (onDropSuccess)="add($event.dragData)" [allowDrop]="checkDropAllow" class="flex-grow">
|
|
11
|
+
|
|
12
|
+
<table class="table table-hover">
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<th>
|
|
16
|
+
<label>
|
|
17
|
+
<input type="checkbox" [checked]="!(configObservable|async).autoResponder.disabled" (change)="toggleDisabled()">Auto responder enabled
|
|
18
|
+
</label>
|
|
19
|
+
</th>
|
|
20
|
+
<th>Target</th>
|
|
21
|
+
<th>Method</th>
|
|
22
|
+
<th>Status</th>
|
|
23
|
+
<th>Headers</th>
|
|
24
|
+
</tr>
|
|
25
|
+
</thead>
|
|
26
|
+
<tr *ngFor="let item of (configObservable|async).autoResponder.responses; let i = index" (contextmenu)="hCtxMenu(item,$event)">
|
|
27
|
+
<td class="replace-name">
|
|
28
|
+
<div class="checkbox">
|
|
29
|
+
<label title="{{item.urlPattern}}">
|
|
30
|
+
<input type="checkbox" [checked]="!item.disabled" (change)="hChange(item, i)" [disabled]="(configObservable|async).autoResponder.disabled">{{item.shortUrlPattern}}
|
|
31
|
+
</label>
|
|
32
|
+
</div>
|
|
33
|
+
</td>
|
|
34
|
+
<td class="replace-detail"><a href="#" title="Open in system editor" (click)="openFile($event,item)">{{item.target}}</a></td>
|
|
35
|
+
<td class="replace-detail">{{item.method}}</td>
|
|
36
|
+
<td class="replace-detail">{{item.status}}</td>
|
|
37
|
+
<td class="replace-detail" [style.cursor]="item.headers?'help':'default'" title="{{item.headers|json}}">{{item.headers ? "{ JSON }" : ""}}</td>
|
|
38
|
+
</tr>
|
|
39
|
+
</table>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const core_1 = require("@angular/core");
|
|
13
|
-
const socket_service_1 = require("../../service/socket.service");
|
|
14
|
-
const config_list_base_1 = require("../config-list-base");
|
|
15
|
-
var path = nw.require("path");
|
|
16
|
-
var url = nw.require("url");
|
|
17
|
-
var fs = nw.require("fs");
|
|
18
|
-
var format = nw.require('date-format');
|
|
19
|
-
var escapeStringRegexp = nw.require('escape-string-regexp');
|
|
20
|
-
let AutoResponder = class AutoResponder extends config_list_base_1.ConfigListBase {
|
|
21
|
-
//TODO: how can we move this to parent?
|
|
22
|
-
constructor(socketService) {
|
|
23
|
-
super();
|
|
24
|
-
this.configProperty = "autoResponder";
|
|
25
|
-
this.itemsProperty = "responses";
|
|
26
|
-
this.socketService = socketService;
|
|
27
|
-
this.menuItems.splice(1, 0, new nw.MenuItem({ label: "Delete with target", click: () => this.deleteItem(this._lastCtxItem, true) }));
|
|
28
|
-
}
|
|
29
|
-
openFile(event, item) {
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
var path = this.getFileLocation(item.target);
|
|
32
|
-
if (!fs.existsSync(path)) {
|
|
33
|
-
fs.writeFileSync(path, "");
|
|
34
|
-
}
|
|
35
|
-
nw.Shell.openItem(path);
|
|
36
|
-
}
|
|
37
|
-
getFileLocation(target) {
|
|
38
|
-
if (path.isAbsolute(target)) {
|
|
39
|
-
return target;
|
|
40
|
-
}
|
|
41
|
-
return path.join(process.env.HOME, ".auto-respond", target);
|
|
42
|
-
}
|
|
43
|
-
add(reqRes) {
|
|
44
|
-
if (!this.config) {
|
|
45
|
-
alert("Config not availible");
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
var headers = reqRes.resHeaders;
|
|
49
|
-
if (reqRes.isGzip) {
|
|
50
|
-
//we have unzipped the response
|
|
51
|
-
delete headers["content-encoding"];
|
|
52
|
-
}
|
|
53
|
-
delete headers["content-length"]; //node will count it automatically
|
|
54
|
-
var fileName = makeName(reqRes.url);
|
|
55
|
-
var filePath = this.getFileLocation(fileName);
|
|
56
|
-
var autoRespFolder = path.join(process.env.HOME, ".auto-respond");
|
|
57
|
-
if (!fs.existsSync(autoRespFolder)) {
|
|
58
|
-
fs.mkdirSync(autoRespFolder);
|
|
59
|
-
}
|
|
60
|
-
fs.writeFileSync(filePath, reqRes.resBody);
|
|
61
|
-
this.config.addAutoResponse({
|
|
62
|
-
urlPattern: "^" + escapeStringRegexp(reqRes.url) + "$",
|
|
63
|
-
status: reqRes.statusCode,
|
|
64
|
-
headers: headers,
|
|
65
|
-
method: reqRes.method,
|
|
66
|
-
target: fileName,
|
|
67
|
-
disabled: false
|
|
68
|
-
});
|
|
69
|
-
this.socketService.replaceConfig(this.config);
|
|
70
|
-
function makeName(_url) {
|
|
71
|
-
var path = url.parse(_url).pathname.replace(/\/$/, "");
|
|
72
|
-
return `${path.split("/").slice(-2).join("_")}_${format('yyyyMMdd_hhmmss', new Date())}.txt`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
checkDropAllow(reqRes) {
|
|
76
|
-
return reqRes.isFinished;
|
|
77
|
-
}
|
|
78
|
-
deleteItem(item, deleteTarget) {
|
|
79
|
-
super.deleteItem(item);
|
|
80
|
-
if (deleteTarget) {
|
|
81
|
-
var path = this.getFileLocation(item.target);
|
|
82
|
-
if (!fs.existsSync(path)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
fs.unlinkSync(path);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
AutoResponder = __decorate([
|
|
90
|
-
core_1.Component({
|
|
91
|
-
moduleId: module.id,
|
|
92
|
-
templateUrl: 'auto-responder.component.html',
|
|
93
|
-
styleUrls: [
|
|
94
|
-
'auto-responder.component.css'
|
|
95
|
-
],
|
|
96
|
-
selector: 'auto-responder',
|
|
97
|
-
host: { class: 'flex-grow' },
|
|
98
|
-
changeDetection: core_1.ChangeDetectionStrategy.OnPush
|
|
99
|
-
}),
|
|
100
|
-
__metadata("design:paramtypes", [socket_service_1.SocketService])
|
|
101
|
-
], AutoResponder);
|
|
102
|
-
exports.AutoResponder = AutoResponder;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const core_1 = require("@angular/core");
|
|
13
|
+
const socket_service_1 = require("../../service/socket.service");
|
|
14
|
+
const config_list_base_1 = require("../config-list-base");
|
|
15
|
+
var path = nw.require("path");
|
|
16
|
+
var url = nw.require("url");
|
|
17
|
+
var fs = nw.require("fs");
|
|
18
|
+
var format = nw.require('date-format');
|
|
19
|
+
var escapeStringRegexp = nw.require('escape-string-regexp');
|
|
20
|
+
let AutoResponder = class AutoResponder extends config_list_base_1.ConfigListBase {
|
|
21
|
+
//TODO: how can we move this to parent?
|
|
22
|
+
constructor(socketService) {
|
|
23
|
+
super();
|
|
24
|
+
this.configProperty = "autoResponder";
|
|
25
|
+
this.itemsProperty = "responses";
|
|
26
|
+
this.socketService = socketService;
|
|
27
|
+
this.menuItems.splice(1, 0, new nw.MenuItem({ label: "Delete with target", click: () => this.deleteItem(this._lastCtxItem, true) }));
|
|
28
|
+
}
|
|
29
|
+
openFile(event, item) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
var path = this.getFileLocation(item.target);
|
|
32
|
+
if (!fs.existsSync(path)) {
|
|
33
|
+
fs.writeFileSync(path, "");
|
|
34
|
+
}
|
|
35
|
+
nw.Shell.openItem(path);
|
|
36
|
+
}
|
|
37
|
+
getFileLocation(target) {
|
|
38
|
+
if (path.isAbsolute(target)) {
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
return path.join(process.env.HOME, ".auto-respond", target);
|
|
42
|
+
}
|
|
43
|
+
add(reqRes) {
|
|
44
|
+
if (!this.config) {
|
|
45
|
+
alert("Config not availible");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var headers = reqRes.resHeaders;
|
|
49
|
+
if (reqRes.isGzip) {
|
|
50
|
+
//we have unzipped the response
|
|
51
|
+
delete headers["content-encoding"];
|
|
52
|
+
}
|
|
53
|
+
delete headers["content-length"]; //node will count it automatically
|
|
54
|
+
var fileName = makeName(reqRes.url);
|
|
55
|
+
var filePath = this.getFileLocation(fileName);
|
|
56
|
+
var autoRespFolder = path.join(process.env.HOME, ".auto-respond");
|
|
57
|
+
if (!fs.existsSync(autoRespFolder)) {
|
|
58
|
+
fs.mkdirSync(autoRespFolder);
|
|
59
|
+
}
|
|
60
|
+
fs.writeFileSync(filePath, reqRes.resBody);
|
|
61
|
+
this.config.addAutoResponse({
|
|
62
|
+
urlPattern: "^" + escapeStringRegexp(reqRes.url) + "$",
|
|
63
|
+
status: reqRes.statusCode,
|
|
64
|
+
headers: headers,
|
|
65
|
+
method: reqRes.method,
|
|
66
|
+
target: fileName,
|
|
67
|
+
disabled: false
|
|
68
|
+
});
|
|
69
|
+
this.socketService.replaceConfig(this.config);
|
|
70
|
+
function makeName(_url) {
|
|
71
|
+
var path = url.parse(_url).pathname.replace(/\/$/, "");
|
|
72
|
+
return `${path.split("/").slice(-2).join("_")}_${format('yyyyMMdd_hhmmss', new Date())}.txt`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
checkDropAllow(reqRes) {
|
|
76
|
+
return reqRes.isFinished;
|
|
77
|
+
}
|
|
78
|
+
deleteItem(item, deleteTarget) {
|
|
79
|
+
super.deleteItem(item);
|
|
80
|
+
if (deleteTarget) {
|
|
81
|
+
var path = this.getFileLocation(item.target);
|
|
82
|
+
if (!fs.existsSync(path)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
fs.unlinkSync(path);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
AutoResponder = __decorate([
|
|
90
|
+
core_1.Component({
|
|
91
|
+
moduleId: module.id,
|
|
92
|
+
templateUrl: 'auto-responder.component.html',
|
|
93
|
+
styleUrls: [
|
|
94
|
+
'auto-responder.component.css'
|
|
95
|
+
],
|
|
96
|
+
selector: 'auto-responder',
|
|
97
|
+
host: { class: 'flex-grow' },
|
|
98
|
+
changeDetection: core_1.ChangeDetectionStrategy.OnPush
|
|
99
|
+
}),
|
|
100
|
+
__metadata("design:paramtypes", [socket_service_1.SocketService])
|
|
101
|
+
], AutoResponder);
|
|
102
|
+
exports.AutoResponder = AutoResponder;
|