Skip to content

Commit d98d7cf

Browse files
committed
Merge branch 'lcjs-4.0' into 'master'
LCJS v4.0.0 compatibility See merge request arction/lcjs/lcjs-templates/lcjs-node-template!1
2 parents 9ea7cb8 + 1558cef commit d98d7cf

File tree

11 files changed

+2969
-4355
lines changed

11 files changed

+2969
-4355
lines changed

copyStaticAssets.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs-extra";
22

3+
fs.copySync('src/public/css/','dist/public/css', {recursive: true})
34
fs.copySync('src/public/js/lib/','dist/public/js', {recursive: true})
45
fs.copySync('src/public/fonts/','dist/public/', {recursive: true})
56
fs.copySync('src/public/images/','dist/public/', {recursive: true})

package-lock.json

Lines changed: 2942 additions & 4325 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"author": "Arction Ltd.",
2727
"license": "MIT",
2828
"dependencies": {
29-
"@arction/lcjs": "^3.4.0",
30-
"@arction/lcjs-headless": "1.5.0",
29+
"@arction/lcjs": "^4.0.1",
30+
"@arction/lcjs-headless": "^1.6.0",
3131
"@arction/xydata": "^1.4.0",
3232
"body-parser": "^1.19.0",
3333
"express": "^4.17.1",
@@ -59,6 +59,6 @@
5959
"prettier": "^2.0.4",
6060
"pug": "^2.0.4",
6161
"ts-node": "^8.8.2",
62-
"typescript": "^3.8.3"
62+
"typescript": "^4.9.4"
6363
}
6464
}

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ app.use(
3636

3737
declare module 'express-session' {
3838
interface SessionData {
39-
theme: 'dark' | 'light'
39+
theme: 'darkGold' | 'light'
4040
chartTitle: string
4141
}
4242
}

src/chart/chart.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface ChartOptions {
5353
/**
5454
* Chart theme
5555
*/
56-
theme: 'dark' | 'light'
56+
theme: 'darkGold' | 'light'
5757
/**
5858
* Chart title
5959
*/
@@ -68,7 +68,7 @@ export const generateChart = async (options: ChartOptions): Promise<PNG> => {
6868
// generate data
6969
const data = await generator.generate().toPromise()
7070
// prepare theme, based on options
71-
const theme = options.theme === 'light' ? Themes.light : Themes.dark
71+
const theme = options.theme === 'light' ? Themes.light : Themes.darkGold
7272
// initialize the chart
7373
const chart = lc
7474
.ChartXY({
@@ -102,7 +102,7 @@ export const generateChart = async (options: ChartOptions): Promise<PNG> => {
102102
*/
103103
export const generateMapChart = async (options: ChartOptions): Promise<PNG> => {
104104
// prepare theme, based on options
105-
const theme = options.theme === 'light' ? Themes.light : Themes.dark
105+
const theme = options.theme === 'light' ? Themes.light : Themes.darkGold
106106
// initialize the chart
107107
const chart = lc
108108
.Map({
@@ -131,7 +131,7 @@ export const generateMapChart = async (options: ChartOptions): Promise<PNG> => {
131131
export const getChartOptionsFromSession = (req: Request, type: string): ChartOptions => {
132132
return {
133133
title: req.session.chartTitle || type === 'map' ? 'Map' : 'ChartXY',
134-
theme: req.session.theme || 'dark',
134+
theme: req.session.theme || 'darkGold',
135135
}
136136
}
137137

@@ -142,7 +142,7 @@ const populateLatest = async () => {
142142
for (let i = 0; i < nCharts; i += 1) {
143143
generateChart({
144144
title: 'ChartXY',
145-
theme: 'dark',
145+
theme: 'darkGold',
146146
}).then(addToLatest)
147147
}
148148
}

src/controllers/charts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ export const getLatestChart = async (req: Request, res: Response) => {
2222
*/
2323
export const postChart = async (req: Request, res: Response) => {
2424
// resolve theme
25-
let theme: 'dark' | 'light' = 'dark'
25+
let theme: 'darkGold' | 'light' = 'darkGold'
2626
switch (req.body.theme.toLowerCase()) {
2727
case 'light':
2828
theme = 'light'
2929
break
3030
default:
31-
theme = 'dark'
31+
theme = 'darkGold'
3232
}
3333
const chartType = req.query.type ? req.query.type.toString() : 'xy'
3434
// store chart generation settings in the session

src/controllers/home.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Request, Response } from 'express'
77
export const index = async (req: Request, res: Response) => {
88
res.render('home', {
99
title: 'Home',
10-
theme: req.session.theme || 'dark',
10+
theme: req.session.theme || 'darkGold',
1111
chartTitle: req.session.chartTitle || 'ChartXY',
1212
})
1313
}

src/controllers/map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export const index = async (req: Request, res: Response) => {
1212
addToLatest(img)
1313
res.render('map', {
1414
title: 'Map',
15-
theme: req.session.theme || 'dark',
15+
theme: req.session.theme || 'darkGold',
1616
})
1717
}

views/home.pug

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ block content
1414
.form-group
1515
label(for="theme-select") Choose theme:
1616
select.form-control(name="theme" id="theme-select")
17-
- var isDarkTheme = theme == 'dark'
17+
- var isDarkTheme = theme == 'darkGold'
1818
option(value="Dark", selected=isDarkTheme) Dark
1919
option(value="Light", selected=!isDarkTheme) Light
2020
.form-group
@@ -24,12 +24,12 @@ block content
2424
input.btn.btn-primary(type="submit", value="Submit")
2525
.row.mt-2
2626
a.col(href="/chart/1")
27-
img.col.p-0(src="/chart/1")
27+
img.col.p-0(src="/chart/1" height="220px")
2828
a.col(href="/chart/2")
29-
img.col.p-0(src="/chart/2")
29+
img.col.p-0(src="/chart/2" height="220px")
3030
a.col(href="/chart/3")
31-
img.col.p-0(src="/chart/3")
31+
img.col.p-0(src="/chart/3" height="220px")
3232
a.col(href="/chart/4")
33-
img.col.p-0(src="/chart/4")
33+
img.col.p-0(src="/chart/4" height="220px")
3434
a.col(href="/chart/5")
35-
img.col.p-0(src="/chart/5")
35+
img.col.p-0(src="/chart/5" height="220px")

views/layout.pug

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ html(lang='')
99
meta(name='theme-color' content='#4DA5F4')
1010
meta(name='csrf-token', content=_csrf)
1111
link(rel='shortcut icon', href='/images/favicon.png')
12-
link(rel='stylesheet', href='/css/bootstrap.min.css')
1312
link(rel='stylesheet', href='/css/main.css')
13+
link(rel='stylesheet', href='/css/bootstrap.min.css')
1414

1515
body
1616
include partials/header
@@ -19,7 +19,3 @@ html(lang='')
1919
block content
2020

2121
include partials/footer
22-
23-
script(src='/js/lib/jquery.min.js')
24-
script(src='/js/lib/bootstrap.min.js')
25-

views/map.pug

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ block content
1414
.form-group
1515
label(for="theme-select") Choose theme:
1616
select.form-control(name="theme" id="theme-select")
17-
- var isDarkTheme = theme == 'dark'
17+
- var isDarkTheme = theme == 'darkGold'
1818
option(value="Dark", selected=isDarkTheme) Dark
1919
option(value="Light", selected=!isDarkTheme) Light
2020
.form-group
@@ -24,12 +24,12 @@ block content
2424
input.btn.btn-primary(type="submit", value="Submit")
2525
.row.mt-2
2626
a.col(href="/chart/1")
27-
img.col.p-0(src="/chart/1")
27+
img.col.p-0(src="/chart/1" height="220px")
2828
a.col(href="/chart/2")
29-
img.col.p-0(src="/chart/2")
29+
img.col.p-0(src="/chart/2" height="220px")
3030
a.col(href="/chart/3")
31-
img.col.p-0(src="/chart/3")
31+
img.col.p-0(src="/chart/3" height="220px")
3232
a.col(href="/chart/4")
33-
img.col.p-0(src="/chart/4")
33+
img.col.p-0(src="/chart/4" height="220px")
3434
a.col(href="/chart/5")
35-
img.col.p-0(src="/chart/5")
35+
img.col.p-0(src="/chart/5" height="220px")

0 commit comments

Comments
 (0)