Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BBC] Make additional fields visible on the UI via configuration #3183

Merged
merged 1 commit into from
Mar 5, 2021

Conversation

ochiengolanga
Copy link
Contributor

@ochiengolanga ochiengolanga commented Feb 23, 2021

What does this change?

It introduces a way of rendering additional fields on the UI via configuration. This is achieved by adding the following configuration to Kahuna service and Media API service configuration file i.e.

  • $USER/.grid/kahuna.conf or /etc/grid/kahuna.conf
  • $USER/.grid/media-api.conf or /etc/grid/media-api.conf

where applicable (dev stage or prod stage respectively).

# Field aliases configurations that are used to define which metadata field is visible, searchable and has an alias on the UI
field.aliases = [
  {
    # Sets the image metadata tag to be used when filtering FileMetadata field
    elasticsearchPath = "fileMetadata.xmp.bbc:Programme-Maker"
    # Sets an alias for use in search, shouldn't have whitespace or special characters
    alias = "BBCProgrammeMaker"
    # Sets a human readable label that will rendered on the UI
    label = "BBC Programme Maker"
    # Sets the field alias to be displayed as a search hint when you type `+`
    displaySearchHint = false
  }
  {
    elasticsearchPath = "fileMetadata.xmp.xmp:CreatorTool"
    alias = "creatorTool"
    label = "Creator Tool"
    displaySearchHint = false
  }
  {
    elasticsearchPath = "fileMetadata.exif.Artist"
    alias = "artist"
    label = "Artist"
    displaySearchHint = true
  }
  {
    elasticsearchPath = "fileMetadata.iptc.Caption Writer/Editor"
    alias = "captionWriter"
    label = "Caption Writer / Editor"
    displaySearchHint = true
  }
  {
    elasticsearchPath = "fileMetadata.xmp.Iptc4xmpExt:DigitalSourceType"
    alias = "digitalSourceType"
    label = "Digital Source Type"
    displaySearchHint = false
  }
]

The approach is described in the proposal: #3167

How can success be measured?

On the Image view page, the configured fields are visible on the “Show additional metadata” section when expanded.

Screenshots

Screenshot at 2021-03-02 20-44-10

Screenshot at 2021-03-02 20-45-57

Who should look at this?

@AWare , @sihil , @paperboyo and @akash1810

Tested?

  • locally by committer
  • locally by Guardian reviewer
  • on the Guardian's TEST environment

@ochiengolanga
Copy link
Contributor Author

Sample image used:

sample-image

@Asmau1234 Asmau1234 force-pushed the visible-file-metadata branch 2 times, most recently from 1c57811 to f08b18a Compare February 23, 2021 15:08
@ochiengolanga ochiengolanga marked this pull request as ready for review February 23, 2021 15:42
@ochiengolanga ochiengolanga requested a review from a team as a code owner February 23, 2021 15:42
@sihil sihil added the bbc label Feb 24, 2021
@sihil
Copy link
Contributor

sihil commented Feb 24, 2021

We'll do a code review shortly but wanted to put this here as a general comment on the structure of the configuration.

We think that the configuration can be more generic. Specifically:

  • Rather than have discreet objects for each metadata type it can be only one
  • elasticsearchPath replaces tag and contains the full path instead of the suffix (means that it can be used for any field in ES)
  • the alias is used in searching and chips
  • label is introduced to be the human readable name
  • The whole config becomes an array instead of an object as the keys are redundant and it means that ordering in the UI can be derived from the order here

Taking your example:

  • xmp.bbc:Programme-Maker as Visible and Searchable with an alias “BBCProgrammeMaker”
  • xmp.aux:Lens as Visible with an alias “AuxLens”
  • xmp.CreatorTool as visible with an alias “Creator Tool”
  • exif:Artist as visible and searchable with an alias “Artist”
# FileMetadata configurations that are used to define which metadata field is visible, searchable and has an alias on the UI
fieldAliases [
  {
    # Sets the image metadata tag to be used when filtering FileMetadata field
    elasticsearchPath = "fileMetadata.xmp.bbc:Programme-Maker"
    # Sets an alias for use in search, shouldn't have whitespace or special characters
    alias = "BBCProgrammeMaker"
    # Sets a human readable label that will rendered on the UI
    label = "BBC Programme Maker"
    # Sets the field alias to be displayed as a search hint when you type `+`
    displaySearchHint = false
  },
  {
    elasticsearchPath = "fileMetadata.xmp.aux:Lens"
    alias = "auxLens"
    label = "Aux Lens"
    displaySearchHint = false
  },
  {
    elasticsearchPath = "fileMetadata.xmp.CreatorTool"
    alias = "creatorTool"
    label = "Creator Tool"
    displaySearchHint = false
  },
  {
    elasticsearchPath = "fileMetadata.exif.Artist"
    alias = "artist"
    label = "Artist"
    displaySearchHint = true
  }
]

Copy link
Contributor

@sihil sihil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts for you to look at. We're very happy to run through in a call if you have any questions or want to discuss further.

Copy link
Contributor

@sihil sihil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Morning @ochiengolanga. This PR is in good shape and very close to being ready. Comments are mainly tidying up this time around. With a little refactor of the ImageResponse code. Let me know if you have any questions.

If you're able to update the description of the PR to match the updated code that would be super helpful.

dev/script/generate-config/service-config.js Outdated Show resolved Hide resolved
kahuna/app/lib/KahunaConfig.scala Outdated Show resolved Hide resolved
kahuna/app/views/main.scala.html Outdated Show resolved Hide resolved
kahuna/public/js/services/api/media-api.js Outdated Show resolved Hide resolved
media-api/app/lib/ImageResponse.scala Outdated Show resolved Hide resolved
@ochiengolanga ochiengolanga changed the title [BBC] Make filemetadata fields visible on the UI via configuration [BBC] Make additional fields visible on the UI via configuration Mar 2, 2021
Copy link
Contributor

@sihil sihil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice piece of additional functionality. Thanks @ochiengolanga!

This is fundamentally ready to go. I left a couple of minor comments but I'd be OK merging it as it is.

Please do go ahead and squash your commits and then I'll look to merge shortly after that.

@sihil
Copy link
Contributor

sihil commented Mar 4, 2021

Hi @ochiengolanga,
Have confirmed that this squash is good and will merge in the morning. Thanks again for this PR!

Copy link
Contributor

@sihil sihil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested at Guardian towers. Two minor points around the labels losing their casing and formatting of array values but we'll 🚢 this and raise an issue to resolve those.

image

@prout-bot
Copy link

Seen on usage, collections, auth, image-loader-projection (created by @ochiengolanga and merged by @sihil 8 minutes and 36 seconds ago) Please check your changes!

@prout-bot
Copy link

Seen on kahuna, metadata-editor (created by @ochiengolanga and merged by @sihil 8 minutes and 41 seconds ago) Please check your changes!

@prout-bot
Copy link

Seen on media-api (created by @ochiengolanga and merged by @sihil 8 minutes and 51 seconds ago) Please check your changes!

@prout-bot
Copy link

Seen on leases (created by @ochiengolanga and merged by @sihil 8 minutes and 56 seconds ago) Please check your changes!

@prout-bot
Copy link

Seen on cropper (created by @ochiengolanga and merged by @sihil 9 minutes and 1 second ago) Please check your changes!

@prout-bot
Copy link

Seen on image-loader (created by @ochiengolanga and merged by @sihil 9 minutes and 8 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants