This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/channel-icon/channel-icon.component.ts
Alec Merdler 7a352ddfbc Use ng-metadata as a Backport of Angular 2+ API (#2486)
* starting UtilService refactor

* pre find-replace angular.module('quay') => angular.module('QuayModule')

* successfully switched to ng-metadata for backported Angular2 API

* working with parent component reference in child

* fixing @Output to use EventEmitter

* fixed @Output events for custom git trigger

* more fixes

* refactored QuayPages module for backwards-compatibility

* reinitialized test.db

* use minified libraries

* replaced references for angular-ts-decorators

* fixed ng-show
2017-04-05 14:14:08 -07:00

47 lines
No EOL
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Input, Component, Inject } from 'ng-metadata/core';
/**
* A component that displays the icon of a channel.
*/
@Component({
selector: 'channel-icon',
templateUrl: '/static/js/directives/ui/channel-icon/channel-icon.component.html',
})
export class ChannelIconComponent {
@Input('<') public name: string;
private colors: any;
constructor(@Inject('Config') Config: any, @Inject('md5') private md5: any) {
this.colors = Config['CHANNEL_COLORS'];
}
private initial(name: string): string {
if (name == 'alpha') {
return 'α';
}
if (name == 'beta') {
return 'β';
}
if (name == 'stable') {
return 'S';
}
return name[0].toUpperCase();
}
private color(name: string): string {
if (name == 'alpha') {
return this.colors[0];
}
if (name == 'beta') {
return this.colors[1];
}
if (name == 'stable') {
return this.colors[2];
}
var hash: string = this.md5.createHash(name);
var num: number = parseInt(hash.substr(0, 4));
return this.colors[num % this.colors.length];
}
}