Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Commit 8c3b115

Browse files
committed
Merge branch 'release/1.0.0-alpha.8'
2 parents 60782c2 + da7160c commit 8c3b115

File tree

12 files changed

+207
-55
lines changed

12 files changed

+207
-55
lines changed

CHANGELOG.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# Change Log
22

3-
## [Unreleased](https://github.com/paxtonhare/marklogic-debugger/tree/HEAD)
3+
## [v1.0.0-alpha.8](https://github.com/paxtonhare/marklogic-debugger/tree/v1.0.0-alpha.8)
44

5-
[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.6...HEAD)
5+
[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.7...v1.0.0-alpha.8)
6+
7+
**Closed issues:**
8+
9+
- Clear button collapses console window [\#26](https://github.com/paxtonhare/marklogic-debugger/issues/26)
10+
- Stack browser doesn't work correctly [\#25](https://github.com/paxtonhare/marklogic-debugger/issues/25)
11+
- Error dialog is too big [\#24](https://github.com/paxtonhare/marklogic-debugger/issues/24)
12+
13+
## [v1.0.0-alpha.7](https://github.com/paxtonhare/marklogic-debugger/tree/v1.0.0-alpha.7) (2017-02-27)
14+
[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.6...v1.0.0-alpha.7)
615

716
**Closed issues:**
817

@@ -62,4 +71,4 @@
6271
## [1.0.0-alpha.1](https://github.com/paxtonhare/marklogic-debugger/tree/1.0.0-alpha.1) (2017-02-02)
6372

6473

65-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
74+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=1.0.0-alpha.7
1+
version=1.0.0-alpha.8
22

src/main/java/com/marklogic/debugger/web/ApiController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ public String getRequests(@PathVariable String serverId) throws InvalidRequestEx
159159
return evalQuery(auth, "get-requests.xqy", hm);
160160
}
161161

162+
@RequestMapping(value = "/servers/{serverId}/requests/{requestId}", method = RequestMethod.GET)
163+
@ResponseBody
164+
public String getRequest(@PathVariable String serverId, @PathVariable String requestId) throws InvalidRequestException {
165+
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
166+
HashMap<String, String> hm = new HashMap<>();
167+
hm.put("serverId", serverId);
168+
hm.put("requestId", requestId);
169+
return evalQuery(auth, "get-request.xqy", hm);
170+
}
171+
162172
@RequestMapping(value = "/servers/{serverId}/invoke", method = RequestMethod.POST)
163173
public ResponseEntity<?> invokeModule(@PathVariable String serverId, @RequestParam String uri) throws InvalidRequestException {
164174
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();

src/main/resources/modules/get-files.xqy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ declare option xdmp:mapping "false";
77

88
declare variable $serverId external;
99

10-
declare variable $ml-dir := xdmp:filesystem-filepath('.') || '/Modules';
11-
1210
declare function local:build-files($uris as xs:string*, $parent as xs:string, $a as json:array)
1311
{
1412
let $parent :=
@@ -46,6 +44,10 @@ declare function local:build-dirs($uris as xs:string*, $parent as xs:string)
4644
$dir
4745
)
4846
let $a := json:array()
47+
let $_ :=
48+
if ($parent eq '/') then
49+
local:build-files($uris, $parent, $a)
50+
else ()
4951
let $_ :=
5052
for $dir in $dirs
5153
let $o := json:object()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
xquery version "1.0-ml";
2+
3+
declare namespace server = "http://marklogic.com/xdmp/status/server";
4+
5+
import module namespace functx = "http://www.functx.com"
6+
at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
7+
8+
declare variable $serverId external;
9+
declare variable $requestId external;
10+
11+
let $current-request := xs:unsignedLong($requestId)
12+
let $status := xdmp:server-status(xdmp:host(), (xdmp:server("TaskServer"), xs:unsignedLong($serverId)))/server:request-statuses/server:request-status[fn:not(server:request-id = $current-request)]
13+
let $o :=
14+
if (fn:exists($status)) then
15+
map:new((
16+
map:entry("server", xdmp:server-name($status/*:server-id)),
17+
map:entry("host", xdmp:host-name($status/*:host-id)),
18+
map:entry("modules", if ($status/*:modules = 0) then "FileSystem" else xdmp:database-name($status/*:modules)),
19+
map:entry("database", if ($status/*:database = 0) then "FileSystem" else xdmp:database-name($status/*:database)),
20+
for $item in $status/*[fn:not(self::*:server-id or self::*:host-id or self::*:modules or self::*:database)]
21+
return
22+
map:entry(functx:words-to-camel-case(fn:replace(fn:local-name($item), "-", " ")), $item/fn:data())
23+
))
24+
else
25+
map:new(())
26+
return
27+
$o

src/main/ui/app/error/error.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ pre {
1616
overflow: auto;
1717
}
1818

19+
.mdl-dialog__content {
20+
max-height: 500px;
21+
overflow-y: scroll;
22+
}
23+
1924
.mdl-dialog__title {
2025

2126
font-size: 1.5rem;

src/main/ui/app/home/home.component.html

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<div class="section-body">
6868
<app-subsection [title]="'Stack'">
6969
<ul *ngIf="hasFrames()" class="frames">
70-
<li *ngFor="let frame of stack.frames" [ngClass]="{'active' : frame.uri === currentUri}" (click)="showFile(frame.uri, frame.line)">
71-
<i class="fa fa-long-arrow-right" *ngIf="frame.uri === currentUri"></i>
70+
<li *ngFor="let frame of stack.frames; let idx = index" [ngClass]="{'active' : idx === currentStackPosition}" (click)="showFile(frame, idx)">
71+
<i class="fa fa-long-arrow-right" [ngClass]="{'visible': idx === currentStackPosition}"></i>
7272
{{frame.uri}}:{{frame.line}}
7373
</li>
7474
</ul>
@@ -78,21 +78,29 @@
7878
</app-subsection>
7979
<app-subsection [title]="'Variables'">
8080
<ul *ngIf="hasVariables()" class="frames">
81-
<li *ngFor="let variable of stack.frames[0].variables">{{variable.name}}: {{variable.value}}</li>
81+
<template [ngIf]="stack.frames[currentStackPosition] && stack.frames[currentStackPosition].externalVariables">
82+
<li *ngFor="let variable of stack.frames[currentStackPosition].externalVariables">{{variable.name}}: {{variable.value}}</li>
83+
</template>
84+
<template [ngIf]="stack.frames[currentStackPosition] && stack.frames[currentStackPosition].globalVariables">
85+
<li *ngFor="let variable of stack.frames[currentStackPosition].globalVariables">{{variable.name}}: {{variable.value}}</li>
86+
</template>
87+
<template [ngIf]="stack.frames[currentStackPosition] && stack.frames[currentStackPosition].variables">
88+
<li *ngFor="let variable of stack.frames[currentStackPosition].variables">{{variable.name}}: {{variable.value}}</li>
89+
</template>
8290
</ul>
8391
<p *ngIf="!hasVariables()">&nbsp;</p>
8492
</app-subsection>
85-
<app-subsection [title]="'Console'">
93+
<app-subsection [title]="'Console'" (clickHandler)="focusConsole($event)">
8694
<div class="console-buttons" section-header>
87-
<button md-button (click)="clearConsole()">Clear</button>
95+
<button md-button (click)="clearConsole($event)">Clear</button>
8896
</div>
8997
<div *ngFor="let output of consoleOutput" class="console-output">
9098
<span *ngIf="output.type === 'e'" class="error">Server Error <a (click)="showError(output.txt)">(show)</a></span>
9199
<span *ngIf="output.type !== 'e'">
92100
<span class="prompt">{{output.type === 'i' ? '>' : '<-' }} </span><span>{{output.txt}}</span>
93101
</span>
94102
</div>
95-
<span class="prompt">&gt; </span><input class="console-input" type="text" [(ngModel)]="consoleInput" (keyup)="consoleKeyPressed($event)">
103+
<span class="prompt">&gt; </span><input #consoleInputCtrl class="console-input" type="text" [(ngModel)]="consoleInput" (keyup)="consoleKeyPressed($event)">
96104
</app-subsection>
97105
</div>
98106
</div>
@@ -126,7 +134,7 @@
126134
<ul *ngIf="requests && requests.length > 0">
127135
<li *ngFor="let request of requests" (click)="debugRequest(request.requestId)">
128136
<i class="fa fa-long-arrow-right" *ngIf="requestId === request.requestId"></i>
129-
{{request.requestRewrittenText || request.requestText}} <span class="request-id">({{request.requestId}})</span>
137+
{{getRequestName(request)}} <span class="request-id">({{request.requestId}})</span>
130138
<span *ngIf="request.debuggingStatus === 'attached'" class="clickable" title="continue" (click)="continueRequest(request.requestId)"><mdl-icon>play_arrow</mdl-icon></span>
131139
<span *ngIf="request.debuggingStatus !== 'attached'" class="clickable" title="pause" (click)="pauseRequest(request.requestId)"><mdl-icon>pause</mdl-icon></span>
132140
</li>

src/main/ui/app/home/home.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ ul.frames {
249249
&:hover {
250250
background-color: $hover-color;
251251
}
252+
253+
.fa-long-arrow-right {
254+
visibility: hidden;
255+
&.visible {
256+
visibility: visible;
257+
}
258+
}
252259
}
253260
}
254261

src/main/ui/app/home/home.component.ts

Lines changed: 115 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, OnInit, OnDestroy } from '@angular/core';
1+
import { Component, EventEmitter, OnInit, OnDestroy, ViewChild } from '@angular/core';
22
import { Observable } from 'rxjs/Observable';
33
import { Response } from '@angular/http';
44
import { MarkLogicService } from '../marklogic';
@@ -26,6 +26,8 @@ export class HomeComponent implements OnInit, OnDestroy {
2626
requests: any;
2727
currentUri: string;
2828
currentLine: number;
29+
currentRequest: any;
30+
currentStackPosition: number;
2931
showLine: number;
3032
currentExpression: string;
3133
fileText: string;
@@ -43,6 +45,8 @@ export class HomeComponent implements OnInit, OnDestroy {
4345

4446
breakpointsSet: boolean = false;
4547

48+
@ViewChild('consoleInputCtrl') consoleInputCtrl;
49+
4650
codeMirrorConfig = {
4751
lineNumbers: true,
4852
indentWithTabs: true,
@@ -82,37 +86,51 @@ export class HomeComponent implements OnInit, OnDestroy {
8286
this.router.navigate(['login']);
8387
}
8488

85-
this.marklogic.getServers().subscribe((servers: any) => {
86-
this.appservers = servers;
87-
if (this.appserverName) {
88-
let server = _.find(this.appservers, (appserver) => { return appserver.name === this.appserverName; });
89-
if (server) {
90-
this.selectedServer = server;
91-
this.showFiles();
92-
this.getRequests();
93-
this.getBreakpoints();
89+
if (!this.appservers || !this.selectedServer) {
90+
this.marklogic.getServers().subscribe((servers: any) => {
91+
this.appservers = servers;
92+
if (this.appserverName) {
93+
let server = _.find(this.appservers, (appserver) => { return appserver.name === this.appserverName; });
94+
if (server) {
95+
this.selectedServer = server;
96+
this.showFiles();
97+
this.getRequests();
98+
this.getBreakpoints();
99+
}
94100
}
95-
}
96101

97-
if (this.requestId) {
98-
this.getStack(this.requestId);
99-
} else {
100-
this.fileBreakpoints = null;
101-
this.currentLine = null;
102-
this.showLine = null;
103-
this.currentUri = null;
104-
}
102+
this.updateStack();
103+
},
104+
() => {
105+
this.router.navigate(['login']);
106+
});
107+
}
108+
else {
109+
this.getRequests();
110+
this.updateStack();
111+
}
112+
});
105113

106-
if (!this.welcomeShown && localStorage.getItem('_show_welcome_') !== 'false') {
107-
this.showWelcome();
108-
this.welcomeShown = true;
109-
}
114+
if (!this.welcomeShown && localStorage.getItem('_show_welcome_') !== 'false') {
115+
this.showWelcome();
116+
this.welcomeShown = true;
117+
}
110118

111-
},
112-
() => {
113-
this.router.navigate(['login']);
119+
}
120+
121+
updateStack() {
122+
if (this.requestId) {
123+
this.marklogic.getRequest(this.selectedServer.id, this.requestId).subscribe((request) => {
124+
this.currentRequest = request;
125+
this.getStack(this.requestId);
114126
});
115-
});
127+
} else {
128+
this.currentRequest = null;
129+
this.fileBreakpoints = null;
130+
this.currentLine = null;
131+
this.showLine = null;
132+
this.currentUri = null;
133+
}
116134
}
117135

118136
showWelcome() {
@@ -161,8 +179,7 @@ export class HomeComponent implements OnInit, OnDestroy {
161179
this.marklogic.getStack(requestId).subscribe((stack: any) => {
162180
this.stack = stack;
163181
if (this.stack && this.stack.frames && this.stack.frames.length > 0) {
164-
const frame = this.stack.frames[0];
165-
this.showFile(frame.uri, frame.line);
182+
this.showFile(this.stack.frames[0], 0);
166183
}
167184
}, () => {
168185
this.router.navigate(['server', this.appserverName]);
@@ -178,9 +195,21 @@ export class HomeComponent implements OnInit, OnDestroy {
178195
hasVariables() {
179196
return this.stack &&
180197
this.stack.frames &&
181-
this.stack.frames[0] &&
182-
this.stack.frames[0].variables &&
183-
this.stack.frames[0].variables.length > 0;
198+
this.stack.frames[this.currentStackPosition] &&
199+
(
200+
(
201+
this.stack.frames[this.currentStackPosition].variables &&
202+
this.stack.frames[this.currentStackPosition].variables.length > 0
203+
) ||
204+
(
205+
this.stack.frames[this.currentStackPosition].externalVariables &&
206+
this.stack.frames[this.currentStackPosition].externalVariables.length > 0
207+
) ||
208+
(
209+
this.stack.frames[this.currentStackPosition].globalVariables &&
210+
this.stack.frames[this.currentStackPosition].globalVariables.length > 0
211+
)
212+
);
184213
}
185214

186215
debugRequest(requestId) {
@@ -356,18 +385,48 @@ export class HomeComponent implements OnInit, OnDestroy {
356385
});
357386
}
358387

359-
showFile(uri: string, line: number) {
388+
showEval(frame, index: number) {
360389
this.currentLine = null;
361390
this.showLine = null;
362-
this.marklogic.getFile(this.selectedServer.id, uri).subscribe((txt: any) => {
363-
this.currentUri = uri;
364-
this.fileText = txt;
365-
this.currentLine = line;
391+
if (this.currentRequest) {
392+
this.currentUri = '/eval';
393+
this.fileText = this.currentRequest.requestText;
394+
this.currentLine = frame.line;
395+
this.currentStackPosition = index;
366396
this.getBreakpoints();
367397
if (this.stack.expressions && this.stack.expressions.length > 0) {
368-
this.currentExpression = this.stack.expressions[0].expressionSource;
398+
if (index === 0) {
399+
this.currentExpression = this.stack.expressions[index].expressionSource;
400+
}
401+
else {
402+
this.currentExpression = null;
403+
}
369404
}
370-
});
405+
}
406+
}
407+
408+
showFile(frame: any, index: number) {
409+
if (frame.uri === '/eval') {
410+
this.showEval(frame, index);
411+
} else {
412+
this.currentLine = null;
413+
this.showLine = null;
414+
this.marklogic.getFile(this.selectedServer.id, frame.uri).subscribe((txt: any) => {
415+
this.currentUri = frame.uri;
416+
this.fileText = txt;
417+
this.currentLine = frame.line;
418+
this.currentStackPosition = index;
419+
this.getBreakpoints();
420+
if (this.stack.expressions && this.stack.expressions.length > 0) {
421+
if (index === 0) {
422+
this.currentExpression = this.stack.expressions[index].expressionSource;
423+
}
424+
else {
425+
this.currentExpression = null;
426+
}
427+
}
428+
});
429+
}
371430
}
372431

373432
consoleKeyPressed($event: KeyboardEvent) {
@@ -426,7 +485,23 @@ export class HomeComponent implements OnInit, OnDestroy {
426485
});
427486
}
428487

429-
clearConsole() {
488+
clearConsole($event: MouseEvent) {
430489
this.consoleOutput = [];
490+
$event.preventDefault();
491+
$event.stopPropagation();
492+
}
493+
494+
focusConsole($event) {
495+
this.consoleInputCtrl.nativeElement.focus();
496+
}
497+
498+
getRequestName(request) {
499+
let name;
500+
if (request.requestKind === 'eval') {
501+
name = 'eval';
502+
} else {
503+
name = (request.requestRewrittenText || request.requestText);
504+
}
505+
return name;
431506
}
432507
}

0 commit comments

Comments
 (0)