Skip to content

Commit 6897487

Browse files
authored
Merge pull request #116 from node-red/add-downloads-to-catalog
Add downloads to catalog
2 parents 54a37f3 + 3851268 commit 6897487

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

lib/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function ensureExists (login, userData) {
2323
}
2424
const userRecord = extractGitHubInfo(userData)
2525
userRecord.npm_verified = false
26-
await db.users.insert(userRecord)
26+
await db.users.insertOne(userRecord)
2727
}
2828

2929
async function refreshUserGitHub (login) {

lib/view.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ module.exports = {
111111
}
112112
}
113113
// const typeNode = !findQuery.type || findQuery.type === 'node' || (Array.isArray(query.type) && query.type.indexOf('node') > -1)
114-
if (includeCategories && query.category) {
115-
const categories = Array.isArray(query.category) ? query.category : [query.category]
116-
findQuery.categories = { $in: categories }
117-
countQuery.categories = { $in: categories }
118-
} else if (query.username || query.npm_username) {
114+
if (query.username || query.npm_username) {
119115
findQuery.$or = [{ gitOwners: query.username }, { npmOwners: query.npm_username || query.username }]
120116
countQuery.$or = findQuery.$or
121117
} else {
118+
if (includeCategories && query.category) {
119+
const categories = Array.isArray(query.category) ? query.category : [query.category]
120+
findQuery.categories = { $in: categories }
121+
countQuery.categories = { $in: categories }
122+
}
122123
// General search - exclude empty collections
123124
findQuery.$or = [{ items: { $exists: false } }, { items: { $elemMatch: { $exists: true } } }]
124125
if (query.term) {

public/js/utils.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,26 @@ const utils = (function () {
121121
let done
122122
$.getJSON(thingUrl, function (data) {
123123
if (data.links.prev) {
124-
thingList.find('.thing-list-nav-prev').attr('href', data.links.prev).css('opacity', 1)
124+
thingList.find('.thing-list-nav-prev').attr('href', data.links.prev).css({
125+
opacity: 1,
126+
'pointer-events': 'auto'
127+
})
125128
} else {
126-
thingList.find('.thing-list-nav-prev').css('opacity', 0)
129+
thingList.find('.thing-list-nav-prev').css({
130+
opacity: 0,
131+
'pointer-events': 'none'
132+
})
127133
}
128134
if (data.links.next) {
129-
thingList.find('.thing-list-nav-next').attr('href', data.links.next).css('opacity', 1)
135+
thingList.find('.thing-list-nav-next').attr('href', data.links.next).css({
136+
opacity: 1,
137+
'pointer-events': 'auto'
138+
})
130139
} else {
131-
thingList.find('.thing-list-nav-next').css('opacity', 0)
140+
thingList.find('.thing-list-nav-next').css({
141+
opacity: 0,
142+
'pointer-events': 'none'
143+
})
132144
}
133145
if (data.meta.results.count === 0) {
134146
thingList.find('.thing-list-nav-page-info').hide()
@@ -173,6 +185,7 @@ $(function () {
173185
thingList.find('a.thing-list-nav-link').on('click', function (evt) {
174186
evt.preventDefault()
175187
utils.loadThingList(thingList, true, $(this).attr('href'))
188+
$(window).scrollTop(0)
176189
})
177190

178191
utils.initThingList(thingList)

tasks/generate_catalog.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const viewster = require('../lib/view')
1212
description: 1,
1313
keywords: 1,
1414
types: 1,
15-
categories: 1
15+
categories: 1,
16+
downloads: 1
1617
})
1718
const modules = things.map(function (t) {
1819
return {
@@ -23,7 +24,8 @@ const viewster = require('../lib/view')
2324
types: t.types,
2425
keywords: t.keywords,
2526
categories: t.categories,
26-
url: 'https://flows.nodered.org/node/' + t._id
27+
url: 'https://flows.nodered.org/node/' + t._id,
28+
downloads: t.downloads
2729
}
2830
})
2931

template/_gistlist.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{{/hideTypeFilter}}
3232
</ul>
3333
</span>
34-
<span class="filter-options-section" {{^isAdmin}}style="display: none;"{{/isAdmin}}>
34+
<span class="filter-options-section">
3535
<div>Category</div>
3636
<ul class="filter-options-category">
3737
{{#categories}}

template/node.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ <h4>Node Info</h4>
4343
</div>
4444
{{/scorecard}}
4545
</div>
46-
{{#isAdmin}}
4746
<div class="flowmeta">
4847
<h4>Categories</h4>
4948
<ul class="flow-tags">
@@ -57,7 +56,6 @@ <h4>Categories</h4>
5756
{{/isAdmin}}
5857
{{/sessionuser}}
5958
</div>
60-
{{/isAdmin}}
6159

6260
<div class="flowmeta">
6361
<h4>Actions</h4>

0 commit comments

Comments
 (0)