Compare commits

...
4 Commits
8 changed files with 84 additions and 22 deletions
@@ -113,6 +113,7 @@ const opText = {
edit: "edited",
import: "imported",
tag: "tagged",
untag: "untagged",
"move-in": "moved in",
"move-out": "moved-out",
"move-out": "moved out",
}
+12 -1
View File
@@ -24,11 +24,12 @@ module.exports = class {
} else {
this.state.filter = Object.assign({}, this.state.filter, {search: null})
}
} else {
this.state.filter = Object.assign({}, this.state.filter, {[type]: (this.state.filter[type] || []).filter(f => f !== filter).concat(filter)})
}
this.state.filter = Object.assign({}, this.state.filter, {limit: 0})
this.updateQuery(this.state.filter)
this.refresh()
@@ -67,6 +68,9 @@ module.exports = class {
if (filter.search) {
queries.push("search=" + encodeURIComponent(filter.search))
}
if (filter.limit) {
queries.push("limit=" + encodeURIComponent(filter.limit.toString()))
}
if (queries.length > 0) {
history.replaceState("", "", `/logs/?${queries.join("&")}`)
@@ -75,6 +79,13 @@ module.exports = class {
}
}
clearLimit() {
this.state.filter = Object.assign({}, this.state.filter, {limit: 0})
this.refresh()
this.updateQuery(this.state.filter)
}
refresh() {
logHeaderApi.list(this.state.filter).then(logs => {
this.state.logs = logs
+6 -1
View File
@@ -1,8 +1,13 @@
<background src="/assets/images/bg.png" opacity=0.25 />
<logs-menu key="menu" on-select("open") selected=(input.selected || {}) user=input.user filter=state.filter characters=input.characters />
<filter-menu on-add("addFilter") on-remove("removeFilter") filter=state.filter characters=input.characters channels=input.channels eventNames=input.eventNames />
<main class="with-right">
<main class="logs-page with-right">
<logs-table logs=state.logs on-addfilter("addFilter") />
<if(state.filter.limit > 0)>
<div class="show-more-button" on-click("clearLimit")>
<span>Show All</span>
</div>
</if>
</main>
<add-log-modal enabled=(state.modal === "log.add") on-close("close") />
<import-log-modal enabled=(state.modal === "log.import") on-close("close") />
@@ -0,0 +1,17 @@
main.logs-page {
div.show-more-button {
margin: 1em 0;
padding: 0.5em 2em;
font-size: 2em;
text-align: center;
user-select: none;
color: #DA1;
}
div.show-more-button:hover {
cursor: pointer;
text-decoration: underline;
}
}
@@ -8,11 +8,11 @@
<a on-click("open", "story.edit") class="color-menu">Edit</a>
</if-permitted>
<if-permitted user=input.user author=state.story.author permission="story.remove">
<a on-click("open", "story.remove") class="color-menu">Remove</a>
<a on-click("open", "story.remove") class="color-menu">Remove</a>
</if-permitted>
</if>
</div>
<story-tags tags=state.story.tags author=state.story.author user=(!state.removed ? input.user : null) on-select("open", "story.tags")/>
<story-tags tags=state.story.tags open=state.story.open author=state.story.author user=(!state.removed ? input.user : null) on-select("open", "story.tags")/>
<annotation if(state.removed) level="error">
<p>
This story has been removed. Your browser has not refreshed the page yet,
@@ -1,6 +1,14 @@
<div class="story-tags">
<a for(tag in input.tags) href=("/story/by-tag/" + tag.kind + "/" + encodeURIComponent(tag.name)) class=["tag", "color-tag-" + tag.kind.toLowerCase()]>${tag.name}</a>
<if-permitted user=input.user author=input.author permission="story.edit">
<a on-click("select", "edit") class="option color-menu">Manage Tags</a>
</if-permitted>
<if(input.open)>
<if-permitted user=input.user permission="member">
<a on-click("select", "edit") class="option color-menu">Manage Tags (Open)</a>
</if-permitted>
</if>
<else>
<if-permitted user=input.user author=input.author permission="story.edit">
<a on-click("select", "edit") class="option color-menu">Manage Tags</a>
</if-permitted>
</else>
</div>
+8 -1
View File
@@ -8,19 +8,26 @@ const {channelApi} = require("../../rpdata/api/Channel")
const listTemplate = require("../../marko/page/logs/list.marko")
router.get("/", async(req, res) => {
const filter = {limit: 0}
const filter = {limit: 75}
if (req.query.characters) {
filter.characters = req.query.characters.split(",")
filter.limit = 0
}
if (req.query.channels) {
filter.channels = req.query.channels.split(",")
filter.limit = 0
}
if (req.query.events) {
filter.events = req.query.events.split(",")
filter.limit = 0
}
if (req.query.search) {
filter.search = req.query.search
filter.limit = 0
}
if (req.query.limit) {
filter.limit = parseInt(req.query.limit)
}
try {
+26 -13
View File
@@ -33,20 +33,33 @@ if (config.trustedProxy != null) {
console.log("Trusting proxy", config.trustedProxy);
} else {
dns.resolve4(config.trustedProxy, (err, res) => {
if (err != null) {
console.error("Failed to resolve trustedProxy hostname")
console.error(err)
process.exit(1)
}
if (res.length === 0) {
console.error("No results for trustedProxy hostname")
process.exit(1)
}
let trusted = null
console.log("Trusting proxy", res[0], `(${config.trustedProxy})`);
app.set('trust proxy', res[0])
})
setInterval(() => {
dns.resolve4(config.trustedProxy, (err, res) => {
if (err != null) {
if (trusted === null) {
console.error("Failed to resolve trustedProxy hostname")
}
return
}
if (res.length === 0) {
if (trusted === null) {
console.error("No results for trustedProxy hostname")
}
return
}
if (trusted !== res[0]) {
console.log("Trusting proxy", res[0], `(${config.trustedProxy})`);
app.set('trust proxy', res[0])
trusted = res[0]
}
})
}, 1000)
}
}