Skip to content

Commit

Permalink
Add userid to html meta
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Jul 2, 2024
1 parent f5ad894 commit fd08108
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion daiquiri/core/assets/js/api/BaseApi.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cookies from 'js-cookie'
import isUndefined from 'lodash/isUndefined'

import { baseUrl } from '../utils/location'
import { baseUrl } from '../utils/meta'

function ApiError(statusText, status) {
this.status = status
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// take the baseurl from the <head> of the django template
const baseUrl = document.querySelector('meta[name="baseurl"]').content.replace(/\/+$/, '')
const userId = document.querySelector('meta[name="userid"]').content.replace(/\/+$/, '')

export { baseUrl }
export { baseUrl, userId }
5 changes: 3 additions & 2 deletions daiquiri/core/templates/core/new/base_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<meta property="og:title" content="{{ request.site.name }}" />
<meta property="og:url" content="{{ request.site.domain }}" />

<meta name='baseurl' content="{% url 'home' %}" />
<meta name='staticurl' content="{% static '' %}" />
<meta name="baseurl" content="{% url 'home' %}" />
<meta name="staticurl" content="{% static '' %}" />
<meta name="userid" content="{{ request.user.id|default_if_none:'' }}" />

<link rel="shortcut icon" href="{% static 'core/img/favicon.png' %}" type="image/png" />
16 changes: 10 additions & 6 deletions daiquiri/query/assets/js/query/components/Jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import classNames from 'classnames'
import { isEmpty, isNil } from 'lodash'

import { baseUrl } from '../../../../../core/assets/js/utils/location'
import { baseUrl, userId } from '../../../../../core/assets/js/utils/meta'
import { useLsState } from '../../../../../core/assets/js/hooks/ls'

import { useJobsQuery } from '../hooks/query'
Expand Down Expand Up @@ -116,11 +116,15 @@ const Jobs = ({ jobId, loadJob }) => {
</ul>
)
}
<div className="card-footer">
<a href={`${baseUrl}/query/jobs/new/`} target="_blank" rel="noreferrer">
{gettext('View verbose job list')}
</a>
</div>
{
userId && (
<div className="card-footer">
<a href={`${baseUrl}/query/jobs/new/`} target="_blank" rel="noreferrer">
{gettext('View verbose job list')}
</a>
</div>
)
}
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion daiquiri/query/assets/js/query/components/Status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { isNil } from 'lodash'

import { baseUrl } from '../../../../../core/assets/js/utils/location'
import { baseUrl } from '../../../../../core/assets/js/utils/meta'

import { useStatusQuery } from '../hooks/query'

Expand Down
2 changes: 1 addition & 1 deletion daiquiri/query/assets/js/query/utils/location.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isEmpty, isNil, trim } from 'lodash'

import { baseUrl } from '../../../../../core/assets/js/utils/location'
import { baseUrl } from '../../../../../core/assets/js/utils/meta'

const basePath = `${baseUrl}/query/new/`

Expand Down

0 comments on commit fd08108

Please sign in to comment.