Skip to content

Commit

Permalink
Issues board (closes #82)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanierAvide committed Oct 24, 2020
1 parent 0618157 commit 29e42a8
Show file tree
Hide file tree
Showing 13 changed files with 950 additions and 211 deletions.
169 changes: 169 additions & 0 deletions website/images/empty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions website/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ app.get('/projects/:id/map', async (req, res) => {
res.render('pages/map', Object.assign({ CONFIG, isActive }, p, mapstyle));
});

// Project notes list
app.get('/projects/:id/issues', (req, res) => {
if(!req.params.id || !projects[req.params.id]) {
return res.redirect('/error/404');
}

const p = projects[req.params.id];
const all = filterProjects(projects);
const isActive = all.current && all.current.id === req.params.id;
res.render('pages/issues', Object.assign({ CONFIG, isActive }, p));
});

// Project statistics
app.get('/projects/:id/stats', (req, res) => {
if(!req.params.id || !projects[req.params.id]) {
Expand Down
28 changes: 4 additions & 24 deletions website/templates/common/head.pug
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,6 @@ include ../components/user_button
script.
Chart.defaults.global.defaultFontSize = 15;

function stringQs(str) {
const u = str.split('?');

if(u.length > 1) {
const p = u[1].split('#')[0];

return p.split('&').filter(function (pair) {
return pair !== '';
}).reduce(function(obj, pair){
var parts = pair.split('=');
obj[decodeURIComponent(parts[0])] = (null === parts[1]) ?
'' : decodeURIComponent(parts[1]);
return obj;
}, {});
}
else {
return {};
}
}

const osmApi = new OsmRequest({
endpoint: "#{CONFIG.OSM_URL}",
oauthConsumerKey: "#{CONFIG.OSM_API_KEY}",
Expand All @@ -65,14 +45,14 @@ script.
url: "#{CONFIG.OSM_URL}",
oauth_consumer_key: "#{CONFIG.OSM_API_KEY}",
oauth_secret: "#{CONFIG.OSM_API_SECRET}",
landing: window.location.href,
landing: window.location.href.replace(window.location.search, ""),
singlepage: true
};
const auth = osmAuth(authOpts);
let authWait;

const params = stringQs(window.location.href);
const token = params.oauth_token || localStorage.getItem("oauth_token") || null;
const params = new URLSearchParams((window.location.search || "?").substring(1));
const token = params.get("oauth_token") || localStorage.getItem("oauth_token") || null;

function checkAuth() {
if(auth.authenticated()) {
Expand Down Expand Up @@ -142,7 +122,7 @@ script.
if(token) {
auth.bootstrapToken(token, () => {
checkAuth();
window.history.replaceState(null, null, window.location.href.replace("?oauth_token="+token, ""));
window.history.replaceState(null, null, window.location.href.replace(window.location.search, ""));
localStorage.setItem("oauth_token", token);
});
}
Expand Down
Loading

0 comments on commit 29e42a8

Please sign in to comment.