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

Commit

Permalink
Merge branch 'release/1.0.0-alpha.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
paxtonhare committed Feb 27, 2017
2 parents 60782c2 + da7160c commit 8c3b115
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 55 deletions.
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Change Log

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

[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.6...HEAD)
[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.7...v1.0.0-alpha.8)

**Closed issues:**

- Clear button collapses console window [\#26](https://github.com/paxtonhare/marklogic-debugger/issues/26)
- Stack browser doesn't work correctly [\#25](https://github.com/paxtonhare/marklogic-debugger/issues/25)
- Error dialog is too big [\#24](https://github.com/paxtonhare/marklogic-debugger/issues/24)

## [v1.0.0-alpha.7](https://github.com/paxtonhare/marklogic-debugger/tree/v1.0.0-alpha.7) (2017-02-27)
[Full Changelog](https://github.com/paxtonhare/marklogic-debugger/compare/v1.0.0-alpha.6...v1.0.0-alpha.7)

**Closed issues:**

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


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.0.0-alpha.7
version=1.0.0-alpha.8

10 changes: 10 additions & 0 deletions src/main/java/com/marklogic/debugger/web/ApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@ public String getRequests(@PathVariable String serverId) throws InvalidRequestEx
return evalQuery(auth, "get-requests.xqy", hm);
}

@RequestMapping(value = "/servers/{serverId}/requests/{requestId}", method = RequestMethod.GET)
@ResponseBody
public String getRequest(@PathVariable String serverId, @PathVariable String requestId) throws InvalidRequestException {
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
HashMap<String, String> hm = new HashMap<>();
hm.put("serverId", serverId);
hm.put("requestId", requestId);
return evalQuery(auth, "get-request.xqy", hm);
}

@RequestMapping(value = "/servers/{serverId}/invoke", method = RequestMethod.POST)
public ResponseEntity<?> invokeModule(@PathVariable String serverId, @RequestParam String uri) throws InvalidRequestException {
ConnectionAuthenticationToken auth = (ConnectionAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/modules/get-files.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ declare option xdmp:mapping "false";

declare variable $serverId external;

declare variable $ml-dir := xdmp:filesystem-filepath('.') || '/Modules';

declare function local:build-files($uris as xs:string*, $parent as xs:string, $a as json:array)
{
let $parent :=
Expand Down Expand Up @@ -46,6 +44,10 @@ declare function local:build-dirs($uris as xs:string*, $parent as xs:string)
$dir
)
let $a := json:array()
let $_ :=
if ($parent eq '/') then
local:build-files($uris, $parent, $a)
else ()
let $_ :=
for $dir in $dirs
let $o := json:object()
Expand Down
27 changes: 27 additions & 0 deletions src/main/resources/modules/get-request.xqy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
xquery version "1.0-ml";

declare namespace server = "http://marklogic.com/xdmp/status/server";

import module namespace functx = "http://www.functx.com"
at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";

declare variable $serverId external;
declare variable $requestId external;

let $current-request := xs:unsignedLong($requestId)
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)]
let $o :=
if (fn:exists($status)) then
map:new((
map:entry("server", xdmp:server-name($status/*:server-id)),
map:entry("host", xdmp:host-name($status/*:host-id)),
map:entry("modules", if ($status/*:modules = 0) then "FileSystem" else xdmp:database-name($status/*:modules)),
map:entry("database", if ($status/*:database = 0) then "FileSystem" else xdmp:database-name($status/*:database)),
for $item in $status/*[fn:not(self::*:server-id or self::*:host-id or self::*:modules or self::*:database)]
return
map:entry(functx:words-to-camel-case(fn:replace(fn:local-name($item), "-", " ")), $item/fn:data())
))
else
map:new(())
return
$o
5 changes: 5 additions & 0 deletions src/main/ui/app/error/error.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ pre {
overflow: auto;
}

.mdl-dialog__content {
max-height: 500px;
overflow-y: scroll;
}

.mdl-dialog__title {

font-size: 1.5rem;
Expand Down
22 changes: 15 additions & 7 deletions src/main/ui/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<div class="section-body">
<app-subsection [title]="'Stack'">
<ul *ngIf="hasFrames()" class="frames">
<li *ngFor="let frame of stack.frames" [ngClass]="{'active' : frame.uri === currentUri}" (click)="showFile(frame.uri, frame.line)">
<i class="fa fa-long-arrow-right" *ngIf="frame.uri === currentUri"></i>
<li *ngFor="let frame of stack.frames; let idx = index" [ngClass]="{'active' : idx === currentStackPosition}" (click)="showFile(frame, idx)">
<i class="fa fa-long-arrow-right" [ngClass]="{'visible': idx === currentStackPosition}"></i>
{{frame.uri}}:{{frame.line}}
</li>
</ul>
Expand All @@ -78,21 +78,29 @@
</app-subsection>
<app-subsection [title]="'Variables'">
<ul *ngIf="hasVariables()" class="frames">
<li *ngFor="let variable of stack.frames[0].variables">{{variable.name}}: {{variable.value}}</li>
<template [ngIf]="stack.frames[currentStackPosition] && stack.frames[currentStackPosition].externalVariables">
<li *ngFor="let variable of stack.frames[currentStackPosition].externalVariables">{{variable.name}}: {{variable.value}}</li>
</template>
<template [ngIf]="stack.frames[currentStackPosition] && stack.frames[currentStackPosition].globalVariables">
<li *ngFor="let variable of stack.frames[currentStackPosition].globalVariables">{{variable.name}}: {{variable.value}}</li>
</template>
<template [ngIf]="stack.frames[currentStackPosition] && stack.frames[currentStackPosition].variables">
<li *ngFor="let variable of stack.frames[currentStackPosition].variables">{{variable.name}}: {{variable.value}}</li>
</template>
</ul>
<p *ngIf="!hasVariables()">&nbsp;</p>
</app-subsection>
<app-subsection [title]="'Console'">
<app-subsection [title]="'Console'" (clickHandler)="focusConsole($event)">
<div class="console-buttons" section-header>
<button md-button (click)="clearConsole()">Clear</button>
<button md-button (click)="clearConsole($event)">Clear</button>
</div>
<div *ngFor="let output of consoleOutput" class="console-output">
<span *ngIf="output.type === 'e'" class="error">Server Error <a (click)="showError(output.txt)">(show)</a></span>
<span *ngIf="output.type !== 'e'">
<span class="prompt">{{output.type === 'i' ? '>' : '<-' }} </span><span>{{output.txt}}</span>
</span>
</div>
<span class="prompt">&gt; </span><input class="console-input" type="text" [(ngModel)]="consoleInput" (keyup)="consoleKeyPressed($event)">
<span class="prompt">&gt; </span><input #consoleInputCtrl class="console-input" type="text" [(ngModel)]="consoleInput" (keyup)="consoleKeyPressed($event)">
</app-subsection>
</div>
</div>
Expand Down Expand Up @@ -126,7 +134,7 @@
<ul *ngIf="requests && requests.length > 0">
<li *ngFor="let request of requests" (click)="debugRequest(request.requestId)">
<i class="fa fa-long-arrow-right" *ngIf="requestId === request.requestId"></i>
{{request.requestRewrittenText || request.requestText}} <span class="request-id">({{request.requestId}})</span>
{{getRequestName(request)}} <span class="request-id">({{request.requestId}})</span>
<span *ngIf="request.debuggingStatus === 'attached'" class="clickable" title="continue" (click)="continueRequest(request.requestId)"><mdl-icon>play_arrow</mdl-icon></span>
<span *ngIf="request.debuggingStatus !== 'attached'" class="clickable" title="pause" (click)="pauseRequest(request.requestId)"><mdl-icon>pause</mdl-icon></span>
</li>
Expand Down
7 changes: 7 additions & 0 deletions src/main/ui/app/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ ul.frames {
&:hover {
background-color: $hover-color;
}

.fa-long-arrow-right {
visibility: hidden;
&.visible {
visibility: visible;
}
}
}
}

Expand Down
155 changes: 115 additions & 40 deletions src/main/ui/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, OnInit, OnDestroy } from '@angular/core';
import { Component, EventEmitter, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Response } from '@angular/http';
import { MarkLogicService } from '../marklogic';
Expand Down Expand Up @@ -26,6 +26,8 @@ export class HomeComponent implements OnInit, OnDestroy {
requests: any;
currentUri: string;
currentLine: number;
currentRequest: any;
currentStackPosition: number;
showLine: number;
currentExpression: string;
fileText: string;
Expand All @@ -43,6 +45,8 @@ export class HomeComponent implements OnInit, OnDestroy {

breakpointsSet: boolean = false;

@ViewChild('consoleInputCtrl') consoleInputCtrl;

codeMirrorConfig = {
lineNumbers: true,
indentWithTabs: true,
Expand Down Expand Up @@ -82,37 +86,51 @@ export class HomeComponent implements OnInit, OnDestroy {
this.router.navigate(['login']);
}

this.marklogic.getServers().subscribe((servers: any) => {
this.appservers = servers;
if (this.appserverName) {
let server = _.find(this.appservers, (appserver) => { return appserver.name === this.appserverName; });
if (server) {
this.selectedServer = server;
this.showFiles();
this.getRequests();
this.getBreakpoints();
if (!this.appservers || !this.selectedServer) {
this.marklogic.getServers().subscribe((servers: any) => {
this.appservers = servers;
if (this.appserverName) {
let server = _.find(this.appservers, (appserver) => { return appserver.name === this.appserverName; });
if (server) {
this.selectedServer = server;
this.showFiles();
this.getRequests();
this.getBreakpoints();
}
}
}

if (this.requestId) {
this.getStack(this.requestId);
} else {
this.fileBreakpoints = null;
this.currentLine = null;
this.showLine = null;
this.currentUri = null;
}
this.updateStack();
},
() => {
this.router.navigate(['login']);
});
}
else {
this.getRequests();
this.updateStack();
}
});

if (!this.welcomeShown && localStorage.getItem('_show_welcome_') !== 'false') {
this.showWelcome();
this.welcomeShown = true;
}
if (!this.welcomeShown && localStorage.getItem('_show_welcome_') !== 'false') {
this.showWelcome();
this.welcomeShown = true;
}

},
() => {
this.router.navigate(['login']);
}

updateStack() {
if (this.requestId) {
this.marklogic.getRequest(this.selectedServer.id, this.requestId).subscribe((request) => {
this.currentRequest = request;
this.getStack(this.requestId);
});
});
} else {
this.currentRequest = null;
this.fileBreakpoints = null;
this.currentLine = null;
this.showLine = null;
this.currentUri = null;
}
}

showWelcome() {
Expand Down Expand Up @@ -161,8 +179,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.marklogic.getStack(requestId).subscribe((stack: any) => {
this.stack = stack;
if (this.stack && this.stack.frames && this.stack.frames.length > 0) {
const frame = this.stack.frames[0];
this.showFile(frame.uri, frame.line);
this.showFile(this.stack.frames[0], 0);
}
}, () => {
this.router.navigate(['server', this.appserverName]);
Expand All @@ -178,9 +195,21 @@ export class HomeComponent implements OnInit, OnDestroy {
hasVariables() {
return this.stack &&
this.stack.frames &&
this.stack.frames[0] &&
this.stack.frames[0].variables &&
this.stack.frames[0].variables.length > 0;
this.stack.frames[this.currentStackPosition] &&
(
(
this.stack.frames[this.currentStackPosition].variables &&
this.stack.frames[this.currentStackPosition].variables.length > 0
) ||
(
this.stack.frames[this.currentStackPosition].externalVariables &&
this.stack.frames[this.currentStackPosition].externalVariables.length > 0
) ||
(
this.stack.frames[this.currentStackPosition].globalVariables &&
this.stack.frames[this.currentStackPosition].globalVariables.length > 0
)
);
}

debugRequest(requestId) {
Expand Down Expand Up @@ -356,18 +385,48 @@ export class HomeComponent implements OnInit, OnDestroy {
});
}

showFile(uri: string, line: number) {
showEval(frame, index: number) {
this.currentLine = null;
this.showLine = null;
this.marklogic.getFile(this.selectedServer.id, uri).subscribe((txt: any) => {
this.currentUri = uri;
this.fileText = txt;
this.currentLine = line;
if (this.currentRequest) {
this.currentUri = '/eval';
this.fileText = this.currentRequest.requestText;
this.currentLine = frame.line;
this.currentStackPosition = index;
this.getBreakpoints();
if (this.stack.expressions && this.stack.expressions.length > 0) {
this.currentExpression = this.stack.expressions[0].expressionSource;
if (index === 0) {
this.currentExpression = this.stack.expressions[index].expressionSource;
}
else {
this.currentExpression = null;
}
}
});
}
}

showFile(frame: any, index: number) {
if (frame.uri === '/eval') {
this.showEval(frame, index);
} else {
this.currentLine = null;
this.showLine = null;
this.marklogic.getFile(this.selectedServer.id, frame.uri).subscribe((txt: any) => {
this.currentUri = frame.uri;
this.fileText = txt;
this.currentLine = frame.line;
this.currentStackPosition = index;
this.getBreakpoints();
if (this.stack.expressions && this.stack.expressions.length > 0) {
if (index === 0) {
this.currentExpression = this.stack.expressions[index].expressionSource;
}
else {
this.currentExpression = null;
}
}
});
}
}

consoleKeyPressed($event: KeyboardEvent) {
Expand Down Expand Up @@ -426,7 +485,23 @@ export class HomeComponent implements OnInit, OnDestroy {
});
}

clearConsole() {
clearConsole($event: MouseEvent) {
this.consoleOutput = [];
$event.preventDefault();
$event.stopPropagation();
}

focusConsole($event) {
this.consoleInputCtrl.nativeElement.focus();
}

getRequestName(request) {
let name;
if (request.requestKind === 'eval') {
name = 'eval';
} else {
name = (request.requestRewrittenText || request.requestText);
}
return name;
}
}
Loading

0 comments on commit 8c3b115

Please sign in to comment.