[frontend] Add telegram public component

This commit is contained in:
Cathy Hu 2020-09-03 19:53:10 +02:00
parent 9199f4f0ce
commit 9fd29e5501
8 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,32 @@
<div *ngIf="telegrams$ | async as telegrams">
<mat-card *ngIf="telegrams.length !== 0">
<mat-card-header>
<div mat-card-avatar class="telegram"></div>
<mat-card-title class="platform-title">
Telegram
<button mat-icon-button aria-label="How to use">
<mat-icon
matTooltip="How to send and receive hood broadcast messages with telegram"
class="info-button"
(click)="onInfoClick()"
>info</mat-icon
>
</button>
</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-selection-list [multiple]="false" class="list">
<a
*ngFor="let telegram of telegrams"
href="https://t.me/{{ telegram.username }}"
routerLinkActive="router-link-active"
>
<mat-list-option>
@{{ telegram.username }}
<mat-divider></mat-divider>
</mat-list-option>
</a>
</mat-selection-list>
</mat-card-content>
</mat-card>
</div>

View file

@ -0,0 +1,11 @@
.telegram {
background-image: url("../../../../assets/telegram.png");
background-size: cover;
}
.platform-title {
display: grid;
grid-template-columns: 1fr 40px;
width: 100%;
align-items: center;
}

View file

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TelegramBotCardComponent } from './telegram-bot-card.component';
describe('TelegramBotCardComponent', () => {
let component: TelegramBotCardComponent;
let fixture: ComponentFixture<TelegramBotCardComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TelegramBotCardComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TelegramBotCardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,27 @@
import { Component, OnInit, Input } from '@angular/core';
import { TelegramService } from 'src/app/core/api';
import { TelegramBotInfoDialogComponent } from './telegram-bot-info-dialog/telegram-bot-info-dialog.component';
import { MatDialog } from '@angular/material/dialog';
@Component({
selector: 'app-telegram-bot-card',
templateUrl: './telegram-bot-card.component.html',
styleUrls: ['./telegram-bot-card.component.scss'],
})
export class TelegramBotCardComponent implements OnInit {
@Input() hoodId;
telegrams$;
constructor(
private telegramService: TelegramService,
private dialog: MatDialog
) {}
ngOnInit(): void {
this.telegrams$ = this.telegramService.getTelegramsPublic(this.hoodId);
}
onInfoClick() {
this.dialog.open(TelegramBotInfoDialogComponent);
}
}

View file

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-telegram-bot-info-dialog',
templateUrl: './telegram-bot-info-dialog.component.html',
styleUrls: ['./telegram-bot-info-dialog.component.scss'],
})
export class TelegramBotInfoDialogComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB