Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
catlaser
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chris Prince
catlaser
Commits
822e9cd5
Commit
822e9cd5
authored
May 14, 2021
by
Chris Prince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates and style modifications
parent
ab4ec820
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
184 additions
and
6 deletions
+184
-6
nginx.conf
node_config/nginx.conf
+21
-4
package.json
website/lasercat-ui/package.json
+1
-1
proxy.config.json
website/lasercat-ui/proxy.config.json
+23
-0
app.component.css
website/lasercat-ui/src/app/app.component.css
+22
-0
app.component.html
website/lasercat-ui/src/app/app.component.html
+5
-0
app.module.ts
website/lasercat-ui/src/app/app.module.ts
+3
-1
free-canvas.component.css
...lasercat-ui/src/app/free-canvas/free-canvas.component.css
+0
-0
free-canvas.component.html
...asercat-ui/src/app/free-canvas/free-canvas.component.html
+3
-0
free-canvas.component.spec.ts
...rcat-ui/src/app/free-canvas/free-canvas.component.spec.ts
+25
-0
free-canvas.component.ts
.../lasercat-ui/src/app/free-canvas/free-canvas.component.ts
+81
-0
No files found.
node_config/nginx.conf
View file @
822e9cd5
location
~
/(start|stop|move|random)
{
server
{
listen
80
;
server_name
kittylaser
;
root
/opt/KTS/htdocs
;
index
index.html
;
server_name
_
;
location
/
{
try_files
$uri
$uri
/
=
404
;
}
location
~
/(start|stop|move|random)*
{
proxy_read_timeout
300
;
proxy_connect_timeout
300
;
...
...
@@ -12,9 +26,11 @@ location ~ /(start|stop|move|random) {
proxy_set_header
X-Frame-Options
SAMEORIGIN
;
# Forward WebSocket.
proxy_http_version
1
.1
;
proxy_set_header
Upgrade
$http_upgrade
;
proxy_set_header
Connection
$connection_upgrade
;
#
proxy_http_version 1.1;
#
proxy_set_header Upgrade $http_upgrade;
#
proxy_set_header Connection $connection_upgrade;
proxy_pass
http://<esp-ip-address>:80
;
proxy_pass_request_headers
on
;
}
}
\ No newline at end of file
website/lasercat-ui/package.json
View file @
822e9cd5
...
...
@@ -3,7 +3,7 @@
"version"
:
"0.0.0"
,
"scripts"
:
{
"ng"
:
"ng"
,
"start"
:
"ng serve"
,
"start"
:
"ng serve
--proxy-config proxy.config.json
"
,
"build"
:
"ng build"
,
"test"
:
"ng test"
,
"lint"
:
"ng lint"
,
...
...
website/lasercat-ui/proxy.config.json
0 → 100644
View file @
822e9cd5
{
"/move*"
:
{
"target"
:
"http://IP:80"
,
"secure"
:
false
,
"logLevel"
:
"debug"
},
"/random*"
:
{
"target"
:
"http://IP:80"
,
"secure"
:
false
,
"logLevel"
:
"debug"
},
"/start"
:
{
"target"
:
"http://IP:80"
,
"secure"
:
false
,
"logLevel"
:
"debug"
},
"/stop"
:
{
"target"
:
"http://IP:80"
,
"secure"
:
false
,
"logLevel"
:
"debug"
}
}
\ No newline at end of file
website/lasercat-ui/src/app/app.component.css
View file @
822e9cd5
...
...
@@ -17,3 +17,24 @@
.btn
{
margin
:
auto
1em
;
}
/* Portrait */
@media
only
screen
and
(
min-device-width
:
320px
)
and
(
max-device-width
:
480px
)
and
(
-webkit-min-device-pixel-ratio
:
2
)
and
(
orientation
:
portrait
)
{
.centered
{
width
:
100%
;
}
}
/* Landscape */
@media
only
screen
and
(
min-device-width
:
320px
)
and
(
max-device-width
:
480px
)
and
(
-webkit-min-device-pixel-ratio
:
2
)
and
(
orientation
:
landscape
)
{
}
\ No newline at end of file
website/lasercat-ui/src/app/app.component.html
View file @
822e9cd5
...
...
@@ -24,4 +24,9 @@
</div>
</div>
</div>
<div
class=
"centered"
>
<div
class=
"freedraw"
>
<app-free-canvas></app-free-canvas>
</div>
</div>
<router-outlet></router-outlet>
website/lasercat-ui/src/app/app.module.ts
View file @
822e9cd5
...
...
@@ -5,10 +5,12 @@ import { AppRoutingModule } from './app-routing.module';
import
{
AppComponent
}
from
'./app.component'
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
'@angular/forms'
;
import
{
HttpClientModule
}
from
'@angular/common/http'
;
import
{
FreeCanvasComponent
}
from
'./free-canvas/free-canvas.component'
;
@
NgModule
({
declarations
:
[
AppComponent
AppComponent
,
FreeCanvasComponent
],
imports
:
[
BrowserModule
,
...
...
website/lasercat-ui/src/app/free-canvas/free-canvas.component.css
0 → 100644
View file @
822e9cd5
website/lasercat-ui/src/app/free-canvas/free-canvas.component.html
0 → 100644
View file @
822e9cd5
<p>
free-canvas works!
</p>
website/lasercat-ui/src/app/free-canvas/free-canvas.component.spec.ts
0 → 100644
View file @
822e9cd5
import
{
async
,
ComponentFixture
,
TestBed
}
from
'@angular/core/testing'
;
import
{
FreeCanvasComponent
}
from
'./free-canvas.component'
;
describe
(
'FreeCanvasComponent'
,
()
=>
{
let
component
:
FreeCanvasComponent
;
let
fixture
:
ComponentFixture
<
FreeCanvasComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
FreeCanvasComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
FreeCanvasComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'should create'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
website/lasercat-ui/src/app/free-canvas/free-canvas.component.ts
0 → 100644
View file @
822e9cd5
import
{
Component
,
Input
,
ElementRef
,
AfterViewInit
,
ViewChild
}
from
'@angular/core'
;
import
{
fromEvent
}
from
'rxjs'
;
import
{
switchMap
,
takeUntil
,
pairwise
}
from
'rxjs/operators'
@
Component
({
selector
:
'app-free-canvas'
,
template
:
'<canvas #canvas></canvas>'
,
styles
:
[
'canvas { border: 1px solid #000; }'
]
})
export
class
FreeCanvasComponent
implements
AfterViewInit
{
@
ViewChild
(
'canvas'
)
public
canvas
:
ElementRef
;
private
cx
:
CanvasRenderingContext2D
;
public
ngAfterViewInit
()
{
const
canvasEl
:
HTMLCanvasElement
=
this
.
canvas
.
nativeElement
;
this
.
cx
=
canvasEl
.
getContext
(
'2d'
);
canvasEl
.
width
=
180
;
canvasEl
.
height
=
180
;
this
.
cx
.
lineWidth
=
3
;
this
.
cx
.
lineCap
=
'round'
;
this
.
cx
.
strokeStyle
=
'#000'
;
this
.
captureEvents
(
canvasEl
);
}
private
captureEvents
(
canvasEl
:
HTMLCanvasElement
)
{
// this will capture all mousedown events from the canvas element
fromEvent
(
canvasEl
,
'mousedown'
)
.
pipe
(
switchMap
((
e
)
=>
{
// after a mouse down, we'll record all mouse moves
return
fromEvent
(
canvasEl
,
'mousemove'
)
.
pipe
(
// we'll stop (and unsubscribe) once the user releases the mouse
// this will trigger a 'mouseup' event
takeUntil
(
fromEvent
(
canvasEl
,
'mouseup'
)),
// we'll also stop (and unsubscribe) once the mouse leaves the canvas (mouseleave event)
takeUntil
(
fromEvent
(
canvasEl
,
'mouseleave'
)),
// pairwise lets us get the previous value to draw a line from
// the previous point to the current point
pairwise
()
)
})
)
.
subscribe
((
res
:
[
MouseEvent
,
MouseEvent
])
=>
{
const
rect
=
canvasEl
.
getBoundingClientRect
();
// previous and current position with the offset
const
prevPos
=
{
x
:
res
[
0
].
clientX
-
rect
.
left
,
y
:
res
[
0
].
clientY
-
rect
.
top
};
const
currentPos
=
{
x
:
res
[
1
].
clientX
-
rect
.
left
,
y
:
res
[
1
].
clientY
-
rect
.
top
};
// this method we'll implement soon to do the actual drawing
this
.
drawOnCanvas
(
prevPos
,
currentPos
);
});
}
private
drawOnCanvas
(
prevPos
:
{
x
:
number
,
y
:
number
},
currentPos
:
{
x
:
number
,
y
:
number
})
{
if
(
!
this
.
cx
)
{
return
;
}
this
.
cx
.
beginPath
();
if
(
prevPos
)
{
this
.
cx
.
moveTo
(
prevPos
.
x
,
prevPos
.
y
);
// from
this
.
cx
.
lineTo
(
currentPos
.
x
,
currentPos
.
y
);
this
.
cx
.
stroke
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment