JILS-50: Load project avatars



Issue Information

Issue Type: Task
 
Priority: Major
Status: Closed

Reported By:
Ben Tasker
Assigned To:
Ben Tasker
Project: Jira Issue Listing Script (JILS)
Resolution: Done (2021-06-03 12:18:08)
Affects Version: 0.01b,

Created: 2021-06-03 09:54:16
Time Spent Working


Description
This project has sat idle for quite some time, but this is something that's periodically bugged me, so I want to put it in quickly.

Within JIRA itself, projects have been assigned various avatars - really we should have the ability to display those


Toggle State Changes

Activity


So, if we look at the schema in the DB as well as on disk:
mysql> select PROJECT_ID from project_key where PROJECT_KEY="LAN";
+------------+
| PROJECT_ID |
+------------+
|      10502 |
+------------+
1 row in set (0.00 sec)


-- The query select AVATAR from project where pname="Home LAN"; would also work, but we want to lookup by key
mysql> select AVATAR from project where ID=10502;
+--------+
| AVATAR |
+--------+
|  10602 |
+--------+
1 row in set (0.00 sec)



mysql> describe avatar;
+--------------+---------------+------+-----+---------+-------+
| Field        | Type          | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| ID           | decimal(18,0) | NO   | PRI | NULL    |       |
| filename     | varchar(255)  | YES  |     | NULL    |       |
| contenttype  | varchar(255)  | YES  |     | NULL    |       |
| avatartype   | varchar(60)   | YES  | MUL | NULL    |       |
| owner        | varchar(255)  | YES  |     | NULL    |       |
| systemavatar | decimal(9,0)  | YES  |     | NULL    |       |
+--------------+---------------+------+-----+---------+-------+
6 rows in set (0.01 sec)

mysql> select * from avatar where ID=10602;
+-------+------------+-------------+------------+-------+--------------+
| ID    | filename   | contenttype | avatartype | owner | systemavatar |
+-------+------------+-------------+------------+-------+--------------+
| 10602 | 644062.png | image/png   | project    | 10502 |            0 |
+-------+------------+-------------+------------+-------+--------------+

[root@Rimmer ben]# ls /var/atlassian/application-data/jira/data/avatars/10602*
/var/atlassian/application-data/jira/data/avatars/10602_644062.png         /var/atlassian/application-data/jira/data/avatars/10602_small_644062.png   /var/atlassian/application-data/jira/data/avatars/10602_xsmall_644062.png      /var/atlassian/application-data/jira/data/avatars/10602_xxlarge_644062.png      /var/atlassian/application-data/jira/data/avatars/10602_xxxlarge_644062.png
/var/atlassian/application-data/jira/data/avatars/10602_medium_644062.png  /var/atlassian/application-data/jira/data/avatars/10602_xlarge_644062.png  /var/atlassian/application-data/jira/data/avatars/10602_xxlarge@<Domain Hidden>  /var/atlassian/application-data/jira/data/avatars/10602_xxxlarge@<Domain Hidden>



Putting that into a single query

SELECT filename FROM avatar a
LEFT JOIN project p ON a.ID = p.AVATAR
LEFT JOIN project_key pk ON p.ID = pk.PROJECT_ID
WHERE pk.PROJECT_KEY="LAN";

+------------+
| filename   |
+------------+
| 644062.png |
+------------+
1 row in set (0.00 sec)


We probably also want contenttype too so that we can set an appropriate response header.
Repo: JILS_Fork-BTasker
Host:Rimmer

commit 01560c6dd5c6badb9c555cb917830dd211322046
Author: B Tasker <github@<Domain Hidden>>
Date: Thu Jun 3 10:26:33 2021 +0100

Commit Message: JILS-50 add utility functions to get avatar filenames.

Template currently prints one in a HTML comment just to verify it's working

templates/html/issue_page.php | 7 ++++++
utils.class.php | 48 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)


View Commit | View Changes
Repo: JILS_Fork-BTasker
Host:Rimmer

commit a745fc6983f9966793511a76bf8f581ac5b1acf2
Author: B Tasker <github@<Domain Hidden>>
Date: Thu Jun 3 10:51:03 2021 +0100

Commit Message: JILS-50 Implement support for serving avatars

index.php | 10 ++++++++
utils.class.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 76 insertions(+), 2 deletions(-)


View Commit | View Changes
Repo: JILS_Fork-BTasker
Host:Rimmer

commit 1f24a20abd6aee952ba2870aefd9ec97ee5f7a1d
Author: B Tasker <github@<Domain Hidden>>
Date: Thu Jun 3 11:14:35 2021 +0100

Commit Message: JILS-50 Display avatar on project index pages

This commit also changes the underlying query to check whether the avatar is a system avatar or not - if it is, it isn't displayed (as they're not stored in the same place) and div logoarea will be displayed instead

queries/project-index.php | 16 +++++++++++++++-
static/core.css | 4 ++++
templates/html/issue_page.php | 2 +-
utils.class.php | 4 ++--
4 files changed, 22 insertions(+), 4 deletions(-)


View Commit | View Changes
Repo: JILS_Fork-BTasker
Host:Rimmer

commit d3601ebd85de0434c0ec38821aff4c4a1d2fbad3
Author: B Tasker <github@<Domain Hidden>>
Date: Thu Jun 3 11:27:48 2021 +0100

Commit Message: JILS-50 Show project icons on issue page

templates/html/issue_page.php | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)


View Commit | View Changes
Repo: JILS_Fork-BTasker
Host:Rimmer

commit 605604b13a7009b69425db54a84348079a3a8d8b
Author: B Tasker <github@<Domain Hidden>>
Date: Thu Jun 3 11:50:36 2021 +0100

Commit Message: JILS-50 Show project icon in relations table

static/core.css | 4 +++-
templates/html/issue_page.php | 20 ++++++++++++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)


View Commit | View Changes
Repo: JILS_Fork-BTasker
Host:Rimmer

commit be3ae5c185716707642793e4bfa52b4e349954e5
Author: B Tasker <github@<Domain Hidden>>
Date: Thu Jun 3 11:56:30 2021 +0100

Commit Message: JILS-50 Add avatars to the main project listing page

static/core.css | 4 ++--
templates/html/projects.php | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)


View Commit | View Changes
This is done (in my forked repo). I don't think there's anywhere else that avatars could be added

- Avatars show alongside projects on the projects listing index page
- Avatar shows in the title bar of project page instead of logoarea if a non-system avatar has been used
- Avatar shows alongside relations
btasker changed status from 'Open' to 'Resolved'
btasker added 'Done' to resolution
btasker changed status from 'Resolved' to 'Closed'
Although JIRA has a range of image sizes, we're only using medium and xxlarge.

The names are, perhaps, a bit misleading - xxlarge is still only 96x96.