mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-01 22:05:47 +00:00

* Releases updated version of datahub-web client UI code * Fix typo in yarn lock * Change yarn lock to match yarn registry directories * Previous commit missed some paths * Even more changes to yarnlock missing in previous commit * Include codegen file for typings * Add files to get parity for datahub-web and current OS datahub-midtier * Add in typo fix from previous commit - change to proper license * Implement proper OS fix for person entity picture url * Workarounds for open source DH issues * Fixes institutional memory api and removes unopensourced tabs for datasets * Fixes search dataset deprecation and user search issue as a result of changes * Remove internal only options in the avatar menu
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import Component from '@ember/component';
|
|
import { IAvatar } from 'datahub-web/typings/app/avatars';
|
|
import { alias } from '@ember/object/computed';
|
|
import { set } from '@ember/object';
|
|
import { classNames, tagName, attribute } from '@ember-decorators/component';
|
|
import { task } from 'ember-concurrency';
|
|
import { run } from '@ember/runloop';
|
|
import { ETaskPromise } from '@datahub/utils/types/concurrency';
|
|
|
|
@tagName('img')
|
|
@classNames('avatar')
|
|
export default class AvatarImage extends Component {
|
|
/**
|
|
* The avatar object to render
|
|
* @type {IAvatar}
|
|
*/
|
|
avatar!: IAvatar;
|
|
|
|
/**
|
|
* Returns the image url for the avatar
|
|
* @type {ComputedProperty<IAvatar['imageUrl']>}
|
|
*/
|
|
@attribute
|
|
@alias('avatar.imageUrl')
|
|
src: IAvatar['imageUrl'];
|
|
|
|
/**
|
|
* Aliases the name property on the related avatar
|
|
* @type {ComputedProperty<IAvatar['name']>}
|
|
*/
|
|
@attribute('alt')
|
|
@alias('avatar.name')
|
|
name: IAvatar['name'];
|
|
|
|
/**
|
|
* Handler for image error event
|
|
* @memberof AvatarImage
|
|
*/
|
|
@attribute
|
|
onerror = (): void => {
|
|
// Change avatar if an error occurs when the image is loaded
|
|
|
|
run(() => this.onImageFallback.perform());
|
|
};
|
|
|
|
/**
|
|
* Task to set the fallback image for an avatar
|
|
* @memberof AvatarImage
|
|
*/
|
|
@task(function*(this: AvatarImage): IterableIterator<void> {
|
|
set(this, 'src', this.avatar.imageUrlFallback || '/assets/images/default_avatar.png');
|
|
})
|
|
onImageFallback!: ETaskPromise<void>;
|
|
}
|