25 Commits

Author SHA1 Message Date
msramalho
854d744806 cleaning UI links to localhost only 2022-02-16 12:27:20 +01:00
msramalho
0155830cad making cors customizable 2022-02-16 12:27:05 +01:00
msramalho
96558a0cf7 updating example config 2022-02-16 12:26:37 +01:00
msramalho
b3d6d08289 updating package 2022-02-16 12:26:25 +01:00
msramalho
315adf0653 updated example config 2022-02-16 12:15:21 +01:00
msramalho
b19664ae33 adding config.js.example 2022-02-16 12:09:40 +01:00
msramalho
4e748a156a ignoring config.js 2022-02-16 12:09:18 +01:00
msramalho
14d6fe6db2 deleted config.js 2022-02-16 12:09:11 +01:00
Lachlan Kermode
a6337e9cba Use npm in Dockerfile rather than yarn 2022-01-15 01:48:55 -05:00
Lachlan Kermode
18b20356b5 Update source data to point to live URLs 2021-10-22 12:15:11 -04:00
Lachlan Kermode
75cb1a43cf Fix/package lock; better example data (#79)
* Update package-lock.json

* Update caniuse-lite

* Update XLSX data to be more descriptive of timemap's features
2021-10-21 17:36:19 +02:00
Ebrahem Farooqui
71a8687003 Merge pull request #74 from forensic-architecture/feature/add-shapes-filter-panel
Adding export_shapes endpoint
2021-05-24 22:47:57 -07:00
Ebrahem Farooqui
63d168a964 changing push branch to dev 2021-05-24 22:18:28 -07:00
Ebrahem Farooqui
4d310270d5 changing push branch temp 2021-05-24 22:17:10 -07:00
efarooqui
a6cc9491c6 Adding export_shapes endpoint 2021-05-24 16:10:34 -07:00
efarooqui
0ee207dc75 Linting fixes 2021-04-30 19:34:29 -07:00
efarooqui
7e97c5c227 Minor comment to trigger job 2021-04-30 19:31:16 -07:00
efarooqui
978d572660 Minor comment to trigger job 2021-04-14 19:58:55 -07:00
efarooqui
8bd5f38ac4 Error logging for gsheet fetch 2021-04-14 18:07:48 -07:00
efarooqui
6ab37ccb70 Extraneous comment added to trigger job 2021-04-14 16:35:27 -07:00
efarooqui
4976bfd985 Merge branch 'develop' of https://www.github.com/forensic-architecture/datasheet-server into develop 2021-04-14 16:12:46 -07:00
efarooqui
d713a15879 Adding comment to trigger job 2021-04-14 16:11:40 -07:00
Ebrahem Farooqui
679407f421 adding env vars for test and lint 2021-03-01 16:05:16 -08:00
Ebrahem Farooqui
3eebf811fb Incorrect syntax for unpacking head ref 2021-02-22 09:50:46 -08:00
Ebrahem Farooqui
be03a3983a Adding branch to checkout
Adding the correct branch to checkout with for workflow
2021-02-22 09:47:05 -08:00
18 changed files with 9522 additions and 46 deletions

View File

@@ -10,11 +10,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v2-beta - uses: actions/setup-node@v2-beta
with: with:
node-version: '12' node-version: '12'
- run: npm install - run: npm install
- run: npm test - run: npm test
env:
CI: true
- run: npm run lint - run: npm run lint
env:
CI: true

1
.gitignore vendored
View File

@@ -15,3 +15,4 @@ tags.lock
tags.temp tags.temp
src/config.js src/config.js
src/local.config.js src/local.config.js
src/config.js

View File

@@ -4,12 +4,12 @@ LABEL authors="Lachlan Kermode <lk@forensic-architecture.org>"
# Install app dependencies # Install app dependencies
COPY package.json /www/package.json COPY package.json /www/package.json
RUN cd /www; yarn RUN cd /www; npm install
# Copy app source # Copy app source
COPY . /www COPY . /www
WORKDIR /www WORKDIR /www
RUN yarn build RUN npm run build
RUN mkdir -p data RUN mkdir -p data
# set your port # set your port
@@ -17,4 +17,4 @@ ENV PORT 4040
EXPOSE 4040 EXPOSE 4040
# start command as per package.json # start command as per package.json
CMD ["yarn", "start"] CMD ["npm", "start"]

View File

@@ -59,6 +59,11 @@ Clone the repository to your local:
git clone https://www.github.com/forensic-architecture/datasheet-server git clone https://www.github.com/forensic-architecture/datasheet-server
``` ```
Copy [src/example.config.js](src/example.config.js) into `src/config.js` and modify
```
cp src/example.config.js src/config.js
```
Follow the steps in the [configuration](#configuration) section of this Follow the steps in the [configuration](#configuration) section of this
document. document.

Binary file not shown.

9480
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -30,10 +30,10 @@ export default ({ config, controller }) => {
success: msg success: msg
}) })
) )
.catch(err => .catch(err => {
res.status(404) res.status(404)
.send({ error: err.message, err }) .send({ error: err.message, err })
) })
}) })
api.get('/:sheet/:tab/:resource/:frag', (req, res) => { api.get('/:sheet/:tab/:resource/:frag', (req, res) => {

View File

@@ -1,12 +0,0 @@
import { timemap } from './lib'
export default {
gsheets: [],
xlsx: [
{
name: 'timemap_data',
path: 'data/timemap_data.xlsx',
tabs: timemap.default
}
]
}

View File

@@ -1 +0,0 @@
CONFIG=../configs/timemap/grenfell/datasheet.config.js

19
src/example.config.js Normal file
View File

@@ -0,0 +1,19 @@
import { timemap } from './lib'
export default {
gsheets: [],
xlsx: [
{
name: 'timemap_data',
path: 'data/timemap_data.xlsx',
tabs: timemap.default
}
],
cors: {
active: false,
corsOptions: { // meaningless unless active=true
origin: 'http://example.com',
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
}
}
}

View File

@@ -7,6 +7,14 @@ import api from './api'
import dotenv from 'dotenv' import dotenv from 'dotenv'
const hbs = require('express-handlebars') const hbs = require('express-handlebars')
let configJS
try {
configJS = require('./local.config.js').default
} catch (_) {
configJS = require('./config.js').default
}
dotenv.config() dotenv.config()
let app = express() let app = express()
@@ -17,13 +25,17 @@ app.engine('.hbs', hbs({
})) }))
app.set('view engine', '.hbs') app.set('view engine', '.hbs')
// enable cross origin requests explicitly in development // enable cross origin requests explicitly in development OR if active in prod
const cors = require('cors')
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
const cors = require('cors')
console.log('Enabling CORS in development...') console.log('Enabling CORS in development...')
app.use(cors()) app.use(cors())
} else if (configJS.cors.active === true) {
console.log('Enabling CORS in from config.js in prod...')
app.use(cors(configJS.cors.corsOptions))
} }
const config = process.env const config = process.env
initialize(controller => { initialize(controller => {

View File

@@ -7,6 +7,7 @@ function prefixedTabs (prefix, cfg) {
[`${prf('events')}export_events`]: BP.deeprows, [`${prf('events')}export_events`]: BP.deeprows,
[`${prf('associations')}export_associations`]: BP.deeprows, [`${prf('associations')}export_associations`]: BP.deeprows,
[`${prf('sources')}export_sources`]: BP.deepids, [`${prf('sources')}export_sources`]: BP.deepids,
[`${prf('shapes')}export_shapes`]: BP.deeprows,
[`${prf('sites')}export_sites`]: BP.rows [`${prf('sites')}export_sites`]: BP.rows
} }
} }

View File

@@ -1,7 +1,7 @@
import copy from '../copy/en' import copy from '../copy/en'
/** /**
* Controller * Controller class
* *
*/ */
class Controller { class Controller {

View File

@@ -217,7 +217,10 @@ class GsheetFetcher extends Fetcher {
}) })
.then(this._buildBlueprintsAsync()) .then(this._buildBlueprintsAsync())
.then(() => true) .then(() => true)
.catch(() => false) .catch((err) => {
console.log(`Error fetching gsheets: ${err.message} `)
return false
})
} }
} }

View File

@@ -19,7 +19,6 @@ class StoreJson {
save (url, data) { save (url, data) {
const parts = url.split('/') const parts = url.split('/')
return fs.writeFile( return fs.writeFile(
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`, `${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
JSON.stringify(data) JSON.stringify(data)

View File

@@ -12,6 +12,8 @@ const egInput1 = [
[4, 5, 6] [4, 5, 6]
] ]
// Test default blueprint exports
// Smoke tests
test('defaultBlueprint exports', t => { test('defaultBlueprint exports', t => {
const expected = { const expected = {
sheet: { sheet: {

View File

@@ -3,7 +3,7 @@ import fetch from 'node-fetch'
import childProcess from 'child_process' import childProcess from 'child_process'
const SERVER_LAUNCH_WAIT_TIME = 10 * 1000 const SERVER_LAUNCH_WAIT_TIME = 10 * 1000
const SERVER_ROOT = 'http://localhost:4040' const SERVER_ROOT = ''
let serverProc = null let serverProc = null
let serverExited = false let serverExited = false
function checkStatus (res) { function checkStatus (res) {

View File

@@ -8,7 +8,7 @@
<div class="bp-source">{{ source }}</div> <div class="bp-source">{{ source }}</div>
</div> </div>
{{#each urls}} {{#each urls}}
<div><a target="_blank" href="http://localhost:4040{{ this }}">{{ this }}</a></div> <div><a target="_blank" href="{{ this }}">{{ this }}</a></div>
{{/each}} {{/each}}
</div> </div>
{{ else }} {{ else }}
@@ -16,7 +16,7 @@
{{/each}} {{/each}}
</div> </div>
<a class="bp-update-container" target="_blank" href="http://localhost:4040/api/update"> <a class="bp-update-container" target="_blank" href="/api/update">
<div class="bp-button">Update</div> <div class="bp-button">Update</div>
</div> </div>