test: remove test client files

The test client has been moved to its own repository, Arksine/moontest.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-07-11 14:32:07 -04:00
parent 87444f5bcb
commit a921b4269e
18 changed files with 0 additions and 13533 deletions

View File

@ -1,128 +0,0 @@
#lean_overlay {
position: fixed;
z-index:100;
top: 0px;
left: 0px;
height:100%;
width:100%;
background: #000;
display: none;
}
.user {
width: 404px;
padding-bottom: 2px;
display:none;
background: #FFF;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 0px 0px 4px rgba(0,0,0,0.7);
-webkit-box-shadow: 0 0 4px rgba(0,0,0,0.7);
-moz-box-shadow: 0 0px 4px rgba(0,0,0,0.7);
}
.user-header {
/*background: url(../img/hd-bg.png);*/
background: #cecece;
padding: 8px 8px 8px 8px;
border-bottom: 1px solid #CCC;
border-top-left-radius: 5px;
-moz-border-radius-topleft: 5px;
-webkit-border-top-left-radius: 5px;
border-top-right-radius: 5px;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius: 5px;
}
.user-header h2 {
color: #444;
font-size: 1.2em;
font-weight: 700;
margin-bottom: 3px;
text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}
.user-header p {
color: #444;
font-size: 1em;
margin: 0;
text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
text-shadow: none;
}
.user .text-field {
position: relative;
width: 364px;
padding: 14px 20px;
border-bottom: 1px solid #EEE;
text-align: right;
}
.user .button-field {
width: 254px;
overflow: hidden;
padding: 12px 20px 12px 130px;
}
.user .text-field label {
display: block;
float: left;
width: 90px;
padding-top: 8px;
color: #222;
font-size: 1em;
text-align: left;
}
.user .text-field input {
width: 244px;
padding: 8px;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
font-size: 1em; color: #222;
background: #F7F7F7;
font-family: "Helvetica Neue";
outline: none;
border-top: 1px solid #CCC;
border-left: 1px solid #CCC;
border-right: 1px solid #E7E6E6;
border-bottom: 1px solid #E7E6E6;
}
/*.user .text-field input.good_input {
background: #DEF5E1 url(../img/good.png) 236px center no-repeat;
}*/
.user .text-field input.error_input {
background: #FDE0E0;
}
.user-button {
float: right;
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
background: #cecece;
border: none;
width: auto;
overflow: visible;
font-size: 1.1em;
color: rgb(0, 0, 0);
padding: 7px 10px;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.modal_close {
position: absolute;
top: 12px;
right: 12px;
display: inline-block;
border: none;
width: 20px;
height: 20px;
background: url(../img/close-button.png);
z-index: 2;
}

View File

@ -1,5 +0,0 @@
// leanModal v1.1 by Ray Stone - http://finelysliced.com.au
// Dual licensed under the MIT and GPL
(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null};var overlay=$("<div id='lean_overlay'></div>");$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");$("#lean_overlay").click(function(){close_modal(modal_id)});$(o.closeButton).click(function(){close_modal(modal_id)});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();
$("#lean_overlay").css({"display":"block",opacity:0});$("#lean_overlay").fadeTo(200,o.overlay);$(modal_id).css({"display":"block","position":"fixed","opacity":0,"z-index":11000,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault()})});function close_modal(modal_id){$("#lean_overlay").fadeOut(200);$(modal_id).css({"display":"none"})}}})})(jQuery);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 643 B

View File

@ -1,186 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="dist/themes/default/style.min.css"/>
<link rel="stylesheet" href="css/login_dialog.css"/>
<script src="//cdn.jsdelivr.net/npm/sha256-uint8array/dist/sha256-uint8array.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="dist/jstree.min.js"></script>
<script src="dist/jquery.leanModal.min.js"></script>
<script src="/js/main.js?v=0.1.3" type="module"></script>
</head>
<body>
<h3>Klippy Web API Test</h3>
<div id="term" style="width: 60em; height: 20em; overflow:auto; border: 1px solid black">
</div>
<br/>
<input id="cbxAuto" type="checkbox" name="Autoscroll" checked="true"/> Autoscroll
<input id="cbxSub" type="checkbox" name="AutoSub" checked="true"/> Subscribe on Ready
<input id="cbxFileTransfer" type="checkbox" checked="true" name="FileEnable"/> Allow File Operations While Printing
<br/><br/>
<input type="radio" name="test_type" value="http" checked="true">Test HTTP API
<input type="radio" name="test_type" value="websocket">Test Websocket API
<br/><br/>
<form id="gcform">
<input type="text" />
<input type="submit" value="Send GCode"/>
</form>
<br/>
<form id="apiform">
<input type="text" style="width: 30em" id="apirequest" name="apirequest" value="/printer/objects/list"
title="Should be a url for a http request, ie: /printer/objects/list, or a json-rpc registered
method name."/>
<input type="text" style="width: 20em" id="apiargs" name="apiargs"
title="Arguments for a websocket request. Arguments should be specified in as a JSON object, without
brackets." hidden/>
<input type="submit" value="Send API Command"/>
<span id="apimethod">
<input type="radio" name="api_cmd_type" value="get" checked="true">GET
<input type="radio" name="api_cmd_type" value="post">POST
<input type="radio" name="api_cmd_type" value="delete">DELETE
</span>
</form>
<br/>
<div style="display: flex">
<div style="width: 10em">
<button id="btnpauseresume" style="width: 9em">Pause Print</button><br/><br/>
<button id="btncancelprint" style="width: 9em">Cancel Print</button><br/><br/>
</div>
<a id="hidden_link" href="#" hidden>hidden</a>
<input type="file" style="display:none" id="upload-file" />
<div id="filelist">
</div>
</div>
<br/>
Progress: <progress id="progressbar" value="0" max="100"></progress>
<span id="upload_progress">0%</span><br/><br/>
<button id="btnqueryendstops" style="width: 9em">Query Endstops</button>
<button id="btnsubscribe" style="width: 9em">Post Subscription</button>
<button id="btngetfiles" style="width: 9em">Get File List</button>
<button id="btngethelp" style="width: 9em">Get Gcode Help</button>
<button id="btngetobjs" style="width: 9em">Get Object List</button>
<button id="btntestmesh" style="width: 9em">Get Bed Mesh</button>
<button id="btnsendbatch" class="reqws" style="width: 9em">Test GC Batch</button>
<button id="btnsendmacro" class="reqws" style="width: 9em">Test GC Macro</button>
<br/><br/>
<button id="btnestop" style="width: 9em">E-Stop</button>
<button id="btnrestart" style="width: 9em">Restart</button>
<button id="btnfirmwarerestart" style="width: 9em">Firmware Restart</button>
<button id="btnreboot" style="width: 9em">Reboot OS</button>
<button id="btnshutdown" style="width: 9em">Shutdown OS</button>
<button id="btngetlog" style="width: 9em">Klippy Log</button>
<button id="btnmoonlog" style="width: 9em">Moonraker Log</button>
<br/><br/>
<button id="btnloginuser" style="width: 9em">Login User</button>
<button id="btncreateuser" style="width: 9em">Create User</button>
<button id="btnsetapikey" style="width: 9em">Set API Key</button>
<button id="btnlogout" style="width: 9em" class="req-login">Log Out</button>
<button id="btndeluser" style="width: 9em" class="req-login">Delete User</button>
<button id="btnchangepass" style="width: 9em" class="req-login">Change Pass</button>
<br/><br/>
<span id="filename" hidden></span></br>
<div id="streamdiv">
</div>
<a id="nav_home" href="#" hidden>Hidden Home</a>
<a id="do_login" rel="leanModal" name="login" href="#login" hidden>Hidden Login</a>
<div id="login" class="user">
<div id="login-ct">
<div id="login-header" class="user-header">
<h2>Moonraker Login</h2>
<button id="login_close" class="modal_close"></a>
</div>
<form id="login_form" class="user-form">
<div class="text-field">
<label for="login_username">Username</label>
<input id="login_username" class="good_input" name="login_username" type="text" />
</div>
<div class="text-field">
<label for="login_password">Password</label>
<input id="login_password" name="login_password" type="password" />
</div>
<div class="button-field">
<button type="submit" class="user-button">Login</button>
</div>
</form>
</div>
</div>
<a id="do_deleteuser" rel="leanModal" name="deleteuser" href="#deleteuser" hidden>Hidden Delete</a>
<div id="deleteuser" class="user">
<div id="login-ct">
<div id="deleteuser-header" class="user-header">
<h2>Delete User</h2>
<button id="deleteuser_close" class="modal_close"></a>
</div>
<form id="deleteuser_form" class="user-form">
<div class="text-field">
<label for="deleteuser_username">Username</label>
<input id="deleteuser_username" class="good_input" name="deleteuser_username" type="text" />
</div>
<div class="button-field">
<button type="submit" class="user-button">Submit</button>
</div>
</form>
</div>
</div>
<a id="do_signup" rel="leanModal" name="signup" href="#signup" hidden>Hidden Signup</a>
<div id="signup" class="user">
<div id="signup-ct">
<div id="signup-header" class="user-header">
<h2>Create User</h2>
<button id="signup_close" class="modal_close"></a>
</div>
<form id="signup_form" class="user-form">
<div class="text-field">
<label for="signup_username">Username</label>
<input id="signup_username" class="good_input" name="signup_username" type="text" />
</div>
<div class="text-field">
<label for="signup_password">Password</label>
<input id="signup_password" name="signup_password" type="password" />
</div>
<div class="text-field">
<label for="signup_verify_pass">Re-Enter Password</label>
<input id="signup_verify_pass" name="signup_verify_pass" type="password" />
</div>
<div class="button-field">
<button type="submit" class="user-button">Signup</button>
</div>
</form>
</div>
</div>
<a id="do_changepass" rel="leanModal" name="changepass" href="#changepass" hidden></a>
<div id="changepass" class="user">
<div id="changepass-ct">
<div id="changepass-header" class="user-header">
<h2>Change Password</h2>
<button id="changepass_close" class="modal_close"></a>
</div>
<form id="changepass_form" class="user-form">
<div class="text-field">
<label for="changepass_oldpass">Current Password</label>
<input id="changepass_oldpass" name="changepass_oldpass" type="password" />
</div>
<div class="text-field">
<label for="changepass_newpass">New Password</label>
<input id="changepass_newpass" name="changepass_newpass" type="password" />
</div>
<div class="text-field">
<label for="changepass_verify_pass">Re-Enter New Password</label>
<input id="changepass_verify_pass" name="changepass_verify_pass" type="password" />
</div>
<div class="button-field">
<button type="submit" class="user-button">Submit</button>
</div>
</form>
</div>
</div>
</body>
</html>

View File

@ -1,228 +0,0 @@
// Base JSON-RPC Client implementation
export default class JsonRPC {
constructor() {
this.id_counter = 0;
this.methods = new Object();
this.pending_callbacks = new Object();
this.transport = null;
}
_create_uid() {
let uid = this.id_counter;
this.id_counter++;
return uid.toString();
}
_build_request(method_name, uid, kwargs, ...args) {
let request = {
jsonrpc: "2.0",
method: method_name};
if (uid != null) {
request.id = uid;
}
if (kwargs != null) {
request.params = kwargs
}
else if (args.length > 0) {
request.params = args;
}
return request;
}
register_method(method_name, method) {
this.methods[method_name] = method
}
register_transport(transport) {
// The transport must have a send method. It should
// have an onmessage callback that fires when it
// receives data, but it would also be valid to directly call
// JsonRPC.process_received if necessary
this.transport = transport;
this.transport.onmessage = this.process_received.bind(this)
}
send_batch_request(requests) {
// Batch requests take an array of requests. Each request
// should be an object with the following attribtues:
// 'method' - The name of the method to execture
// 'type' - May be "request" or "notification"
// 'params' - method parameters, if applicable
//
// If a method has no parameters then the 'params' attribute
// should not be included.
if (this.transport == null)
return Promise.reject(Error("No Transport Initialized"));
let batch_request = [];
let promises = [];
requests.forEach((request, idx) => {
let name = request.method;
let args = [];
let kwargs = null;
let uid = null;
if ('params' in request) {
if (request.params instanceof Object)
kwargs = request.params;
else
args = request.params;
}
if (request.type == "request") {
uid = this._create_uid();
promises.push(new Promise((resolve, reject) => {
this.pending_callbacks[uid] = (result, error) => {
let response = {method: name, index: idx};
if (error != null) {
response.error = error;
reject(response);
} else {
response.result = result;
resolve(response);
}
}
}));
}
batch_request.push(this._build_request(
name, uid, kwargs, ...args));
});
this.transport.send(JSON.stringify(batch_request));
return Promise.all(promises);
}
call_method(method_name, ...args) {
let uid = this._create_uid();
let request = this._build_request(
method_name, uid, null, ...args);
if (this.transport != null) {
this.transport.send(JSON.stringify(request));
return new Promise((resolve, reject) => {
this.pending_callbacks[uid] = (result, error) => {
if (error != null) {
reject(error);
} else {
resolve(result);
}
}
});
}
return Promise.reject(Error("No Transport Initialized"));
}
call_method_with_kwargs(method_name, kwargs) {
let uid = this._create_uid();
let request = this._build_request(method_name, uid, kwargs);
if (this.transport != null) {
this.transport.send(JSON.stringify(request));
return new Promise((resolve, reject) => {
this.pending_callbacks[uid] = (result, error) => {
if (error != null) {
reject(error);
} else {
resolve(result);
}
}
});
}
return Promise.reject(Error("No Transport Initialized"));
}
notify(method_name, ...args) {
let notification = this._build_request(
method_name, null, null, ...args);
if (this.transport != null) {
this.transport.send(JSON.stringify(notification));
}
}
process_received(encoded_data) {
let rpc_data = JSON.parse(encoded_data);
if (rpc_data instanceof Array) {
// batch request/response
for (let data of rpc_data) {
this._validate_and_dispatch(data);
}
} else {
this._validate_and_dispatch(rpc_data);
}
}
_validate_and_dispatch(rpc_data) {
if (rpc_data.jsonrpc != "2.0") {
console.log("Invalid JSON-RPC data");
console.log(rpc_data);
return;
}
if ("result" in rpc_data || "error" in rpc_data) {
// This is a response to a client request
this._handle_response(rpc_data);
} else if ("method" in rpc_data) {
// This is a server side notification/event
this._handle_request(rpc_data);
} else {
// Invalid RPC data
console.log("Invalid JSON-RPC data");
console.log(rpc_data);
}
}
_handle_request(request) {
// Note: This implementation does not fully conform
// to the JSON-RPC protocol. The server only sends
// events (notifications) to the client, and it is
// not concerned with client-side errors. Thus
// this implementation does not attempt to track
// request id's, nor does it send responses back
// to the server
let method = this.methods[request.method];
if (method == null) {
console.log("Invalid Method: " + request.method);
return;
}
if ("params" in request) {
let args = request.params;
if (args instanceof Array)
method(...args);
else if (args instanceof Object) {
// server passed keyword arguments which we currently do not support
console.log("Keyword Parameters Not Supported:");
console.log(request);
} else {
console.log("Invalid Parameters");
console.log(request);
}
} else {
method();
}
}
_handle_response(response) {
if (response.result != null && response.id != null) {
let uid = response.id;
let response_finalize = this.pending_callbacks[uid];
if (response_finalize != null) {
response_finalize(response.result);
delete this.pending_callbacks[uid];
} else {
console.log("No Registered RPC Call for uid:");
console.log(response);
}
} else if (response.error != null) {
// Check ID, depending on the error it may or may not be available
let uid = response.id;
let response_finalize = this.pending_callbacks[uid];
if (response_finalize != null) {
response_finalize(null, response.error);
delete this.pending_callbacks[uid];
} else {
console.log("JSON-RPC error recieved");
console.log(response.error);
}
} else {
console.log("Invalid JSON-RPC response");
console.log(response);
}
}
}

File diff suppressed because it is too large Load Diff