1 Commits

Author SHA1 Message Date
NourAbuZaid
9455348001 add grenfell to config 2021-12-14 23:49:25 +00:00
18 changed files with 46 additions and 9522 deletions

View File

@@ -10,16 +10,11 @@ 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,4 +15,3 @@ 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; npm install RUN cd /www; yarn
# Copy app source # Copy app source
COPY . /www COPY . /www
WORKDIR /www WORKDIR /www
RUN npm run build RUN yarn 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 ["npm", "start"] CMD ["yarn", "start"]

View File

@@ -59,11 +59,6 @@ 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) => {

12
src/config.js Normal file
View File

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

1
src/datasheet.config.js Symbolic link
View File

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

View File

@@ -1,19 +0,0 @@
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,14 +7,6 @@ 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()
@@ -25,17 +17,13 @@ app.engine('.hbs', hbs({
})) }))
app.set('view engine', '.hbs') app.set('view engine', '.hbs')
// enable cross origin requests explicitly in development OR if active in prod // enable cross origin requests explicitly in development
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,7 +7,6 @@ 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 class * Controller
* *
*/ */
class Controller { class Controller {

View File

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

View File

@@ -19,6 +19,7 @@ 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,8 +12,6 @@ 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 = '' const SERVER_ROOT = 'http://localhost:4040'
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="{{ this }}">{{ this }}</a></div> <div><a target="_blank" href="http://localhost:4040{{ 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="/api/update"> <a class="bp-update-container" target="_blank" href="http://localhost:4040/api/update">
<div class="bp-button">Update</div> <div class="bp-button">Update</div>
</div> </div>