Skip to content

Commit db3990f

Browse files
authored
Some more RDM fixes (#297)
* fix "RDM personality index: null" in UI * add RDM ID max bound to schema * add HTML IDs to RDM modes and allow linking to it
1 parent 1e8f6e7 commit db3990f

File tree

7 files changed

+41
-18
lines changed

7 files changed

+41
-18
lines changed

fixtures/schema.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const schema = require('js-schema');
1212
*
1313
* @type {string}
1414
*/
15-
module.exports.VERSION = '2.1.0';
15+
module.exports.VERSION = '2.1.1';
1616

1717
/**
1818
* see https://github.com/molnarg/js-schema
@@ -149,7 +149,7 @@ const Fixture = schema({
149149
'?comment': NonEmptyMultiLineString,
150150
'?manualURL': URL,
151151
'?rdm': schema({
152-
'modelId': Number.min(0).step(1),
152+
'modelId': Number.min(0).max(65535).step(1),
153153
'?softwareVersion': String,
154154
'*': Function
155155
}),
@@ -169,7 +169,7 @@ const Manufacturers = schema({
169169
'name': NonEmptyString,
170170
'?comment': NonEmptyMultiLineString,
171171
'?website': URL,
172-
'?rdmId': Number.min(0).step(1),
172+
'?rdmId': Number.min(0).max(65536).step(1),
173173
'*': Function
174174
})
175175
});

lib/create-github-pr.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const fs = require('fs');
33
const path = require('path');
44
const env = require('node-env-file');
55

6-
const repository = process.env.NODE_ENV === 'production' ? 'open-fixture-library' : 'ofl-test';
7-
86
const github = new GitHubApi({
97
debug: false,
108
protocol: 'https',
@@ -19,6 +17,7 @@ const github = new GitHubApi({
1917
let branchName;
2018
let warnings;
2119
let changedFiles;
20+
let repository;
2221

2322
/**
2423
* out parameter is an object like returned from the import plugins:
@@ -42,6 +41,8 @@ module.exports = function createPullRequest(out, callback) {
4241
env(envFile);
4342
}
4443

44+
repository = process.env.NODE_ENV === 'production' ? 'open-fixture-library' : 'ofl-test';
45+
4546
let userToken = process.env.GITHUB_USER_TOKEN;
4647
if (userToken === undefined) {
4748
console.error('.env file does not contain GITHUB_USER_TOKEN variable');
@@ -84,10 +85,6 @@ module.exports = function createPullRequest(out, callback) {
8485
.then(() => {
8586
console.log('done');
8687

87-
if (Object.keys(out.manufacturers).length === 0) {
88-
return Promise.resolve();
89-
}
90-
9188
return addOrUpdateFile('fixtures/manufacturers.json', 'manufacturers.json', oldFileContent => {
9289
if (oldFileContent == null) {
9390
return prettyStringify(out.manufacturers);

main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ app.get('/search', (request, response) => {
142142
app.get('/rdm', (request, response) => {
143143
const manufacturerId = request.query.manufacturerId;
144144
const modelId = request.query.modelId;
145+
const personalityIndex = request.query.personalityIndex;
145146

146147
if (manufacturerId === undefined || manufacturerId === '') {
147148
response.render('pages/rdm-lookup');
@@ -157,7 +158,8 @@ app.get('/rdm', (request, response) => {
157158
}
158159

159160
if (modelId in register.rdm[manufacturerId].models) {
160-
response.redirect(301, `/${manufacturer.key}/${manufacturer.models[modelId]}`);
161+
const hash = (personalityIndex === undefined || personalityIndex === '') ? '' : `#rdm-personality-${personalityIndex}`;
162+
response.redirect(301, `/${manufacturer.key}/${manufacturer.models[modelId]}${hash}`);
161163
return;
162164
}
163165
}

views/pages/rdm-lookup.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ module.exports = function(options) {
1010
str += '<form action="/rdm" method="get">';
1111
str += '<section><label>';
1212
str += ' <span class="label">Manufacturer ID</span>';
13-
str += ' <span class="value"><input type="number" name="manufacturerId" min="0" step="1" required /></span>';
13+
str += ' <span class="value"><input type="number" name="manufacturerId" min="0" max="65535" step="1" required /></span>';
1414
str += '</label></section>';
1515
str += '<section><label>';
1616
str += ' <span class="label">Model ID</span>';
17-
str += ' <span class="value"><input type="number" name="modelId" min="0" step="1" /><span class="hint">Leave this field empty to find the manufacturer.</span></span>';
17+
str += ' <span class="value"><input type="number" name="modelId" min="0" max="65535" step="1" /><span class="hint">Leave this field empty to find the manufacturer.</span></span>';
18+
str += '</label></section>';
19+
str += '<section><label>';
20+
str += ' <span class="label">Personality index</span>';
21+
str += ' <span class="value"><input type="number" name="personalityIndex" min="1" step="1" /><span class="hint">Optional</span></span>';
1822
str += '</label></section>';
1923
str += '<div class="button-bar">';
2024
str += ' <button type="submit" class="primary">Lookup fixture / manufacturer</button>';

views/pages/single_fixture.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function(options) {
1111
const {man, fix} = options;
1212

1313
fixture = Fixture.fromRepository(man, fix);
14-
14+
1515
options.title = `${fixture.manufacturer.name} ${fixture.name} - Open Fixture Library`;
1616

1717
const githubRepoPath = 'https://github.com/' + (process.env.TRAVIS_REPO_SLUG || 'FloEdelmann/open-fixture-library');
@@ -104,7 +104,7 @@ function handleFixtureInfo() {
104104
str += ` <span class="value"><a href="${fixture.manualURL}" rel="nofollow">${fixture.manualURL}</a></span>`;
105105
str += '</section>';
106106
}
107-
107+
108108
if (fixture.rdm !== null) {
109109
const rdmLink = `http://rdm.openlighting.org/model/display?manufacturer=${fixture.manufacturer.rdmId}&model=${fixture.rdm.modelId}`;
110110
const olaIcon = require('../includes/svg.js')({svgBasename: 'ola'});
@@ -255,11 +255,18 @@ function handlePhysicalData(physical) {
255255
}
256256

257257
function handleMode(mode) {
258-
let str = '<section class="fixture-mode card">';
258+
let sectionId = '';
259+
let rdmPersonalityIndexHint = '';
260+
if (mode.rdmPersonalityIndex !== null) {
261+
sectionId = ` id="rdm-personality-${mode.rdmPersonalityIndex}"`;
262+
rdmPersonalityIndexHint = `<span class="hint">RDM personality index: ${mode.rdmPersonalityIndex}</span>`;
263+
}
264+
265+
let str = `<section class="fixture-mode card"${sectionId}>`;
259266

260267
const heading = mode.name + ' mode' + (mode.hasShortName ? ` <code>${mode.shortName}</code>` : '');
261268
str += `<h2>${heading}</h2>`;
262-
str += `<span class="hint">RDM personality index: ${mode.rdmPersonalityIndex}</span>`;
269+
str += rdmPersonalityIndexHint;
263270

264271
if (mode.physicalOverride !== null) {
265272
str += '<h3>Physical overrides</h3>';
@@ -448,7 +455,7 @@ function handleSwitchingChannel(channel, mode) {
448455

449456
let str = `<div>Switch depending on ${channel.triggerChannel.name}'s value (channel ${triggerChannelIndex}):</div>`;
450457
str += '<ol>';
451-
458+
452459
for (const switchToChannelKey of Object.keys(channel.triggerRanges)) {
453460
const switchToChannel = fixture.getChannelByKey(switchToChannelKey);
454461

views/scripts/fixture-editor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ function submitFixture() {
874874
xhr.setRequestHeader('Content-Type', 'application/json');
875875
xhr.send(JSON.stringify(sendObject));
876876

877-
this.submit.rawData = '```\n' + JSON.stringify(sendObject, null, 2) + '\n```';
877+
this.submit.rawData = '```json\n' + JSON.stringify(sendObject, null, 2) + '\n```';
878878
console.log(this.submit.rawData);
879879
}
880880

views/stylesheets/content.scss

+13
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@
4242
&.orange {
4343
background: $orange-500;
4444
}
45+
46+
&:target {
47+
animation: card-highlight 2s ease;
48+
}
49+
}
50+
51+
@keyframes card-highlight {
52+
0% {
53+
background-color: #fd0;
54+
}
55+
100% {
56+
background-color: #fff;
57+
}
4558
}
4659

4760
.list {

0 commit comments

Comments
 (0)