Skip to content

Commit

Permalink
Realizacao do merge da branch 6-dashboardCategoria
Browse files Browse the repository at this point in the history
US06 - Eu, como administrador, quero ver as estatísticas de visualizações por categoria, para monitorar o desempenho por tópico.
  • Loading branch information
GabrielRoger07 authored Aug 10, 2024
2 parents cf000c1 + fc027fb commit 18a94e4
Show file tree
Hide file tree
Showing 15 changed files with 793 additions and 15 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"primeng": "^16.9.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.13.3"
"zone.js": "~0.13.3",
"xlsx": "^0.18.5",
"chart.js": "^4.4.3",
"ng2-charts": "^4.0.0"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^16.0.1",
Expand Down
8 changes: 6 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import { HomeAdminComponent } from './pages/home-admin/home-admin.component';
import { AdminActivateComponent } from './pages/admin-activate/admin-activate.component';
import { CategoryTableComponent } from './pages/category-table/category-table.component';
import { VideoViewsComponent } from './pages/video-views/video-views.component';


import { DashboardCategoryComponent } from './pages/dashboard-category/dashboard-category.component';

import { WithTokenGuard } from './guard/with-token.guard';
import { TokenAdminGuard } from './guard/admin.guard';
Expand Down Expand Up @@ -112,6 +111,11 @@ const routes: Routes = [
component: VideoViewsComponent,
canActivate: [TokenAdminGuard],
},
{
path: 'dashboard',
component: DashboardCategoryComponent,
canActivate: [TokenAdminGuard],
},
];

@NgModule({
Expand Down
7 changes: 5 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ import { NgxGoogleAnalyticsModule, NgxGoogleAnalyticsRouterModule } from 'ngx-go
import { CatalogComponent } from './pages/catalog/catalog.component';
import { PrivacyPolicyComponent } from './pages/privacy-policy/privacy-policy.component';
import { ServiceWorkerModule } from '@angular/service-worker';

import { NgChartsModule } from 'ng2-charts';
import { HomeAdminComponent } from './pages/home-admin/home-admin.component';
import { AdminActivateComponent } from './pages/admin-activate/admin-activate.component';

import { CategoryTableComponent } from './pages/category-table/category-table.component';
import { VideoViewsComponent } from './pages/video-views/video-views.component';
import { DashboardCategoryComponent } from './pages/dashboard-category/dashboard-category.component';

@NgModule({
imports: [
Expand All @@ -78,7 +79,8 @@ import { VideoViewsComponent } from './pages/video-views/video-views.component';
// Register the ServiceWorker as soon as the application is stable
// or after 30 seconds (whichever comes first).
registrationStrategy: 'registerWhenStable:30000'
})
}),
NgChartsModule,
],

declarations: [
Expand Down Expand Up @@ -106,6 +108,7 @@ import { VideoViewsComponent } from './pages/video-views/video-views.component';
HomeAdminComponent,
CategoryTableComponent,
VideoViewsComponent,
DashboardCategoryComponent,
],

providers: [
Expand Down
13 changes: 11 additions & 2 deletions src/app/pages/category-table/category-table.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

aside {
width: 11em;
width: 13.2em;
background-color: white;
padding: 1em 0.75em;
box-shadow: 0.125em 0 0.3125em rgba(0,0,0,0.1);
Expand Down Expand Up @@ -75,7 +75,16 @@ nav ul li a.linkSelecionado {
main {
flex: 1;
padding: 0.25em;
margin-left: 12em;
margin-left: 14.2em;
}

header {
display: flex;
justify-content: space-between;
}

.download-button {
margin-right: 3em;
}

header h1 {
Expand Down
6 changes: 4 additions & 2 deletions src/app/pages/category-table/category-table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
<ul>
<li><a href="/video-views">Dados - Vídeos</a></li>
<li><a href="/category-views" class="linkSelecionado">Dados - Categorias</a></li>
<li><a href="/dashboard">Dashboard - Categorias</a></li>
</ul>
</nav>
</aside>
<main>
<header>
<h1>Dados - Categorias</h1>
<hr class="solid2">
<button class="download-button w-full h-[50px] max-w-[160px] bg-blue-brand rounded-lg text-white" (click)="exportExcel()">Exportar para Excel</button>
</header>
<hr class="solid2">
<div class="containerConteudo">
<div class="containerFiltro">
<div class="dropdown">
Expand All @@ -33,7 +35,7 @@ <h1>Dados - Categorias</h1>
</div>
</div>
</div>
<table>
<table id="tabela-categoria">
<thead>
<tr>
<th>Categoria</th>
Expand Down
19 changes: 19 additions & 0 deletions src/app/pages/category-table/category-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Catalog } from 'src/shared/model/catalog.model';
import { IVideo } from 'src/shared/model/video.model';
import { AuthService } from 'src/app/services/auth.service';
import { ConfirmationService } from 'primeng/api';
import * as XLSX from 'xlsx'

@Component({
selector: 'app-category-table',
Expand Down Expand Up @@ -35,6 +36,7 @@ export class CategoryTableComponent {
filteredAggregatedVideos: any[] = [];
selectedCategories: { [key: string]: boolean } = {};

fileName = "DadosCategoriasUnBTV.xlsx";

constructor(
private videoService: VideoService,
Expand Down Expand Up @@ -166,4 +168,21 @@ export class CategoryTableComponent {
reject: () => {},
});
}

exportExcel() {
let data = document.getElementById("tabela-categoria");
const ws: XLSX.WorkSheet = XLSX.utils.table_to_sheet(data);
const wb: XLSX.WorkBook = XLSX.utils.book_new();

const columnWidths = [
{ wch:20 },
{ wch:10 },
{ wch:15 },
{ wch:20 },
];

ws['!cols'] = columnWidths;
XLSX.utils.book_append_sheet(wb, ws,'Sheet1');
XLSX.writeFile(wb, this.fileName);
}
}
157 changes: 157 additions & 0 deletions src/app/pages/dashboard-category/dashboard-category.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
@font-face {
font-family: 'Helvetic';
src: url('../../../assets/fonts/Helvetica.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}

* {
font-family: Helvetic, sans-serif;
}

.containerPrincipal {
display: flex;
min-height: 100vh;
flex-direction: column;
}

aside {
width: 13.2em;
background-color: white;
padding: 1em 0.75em;
box-shadow: 0.125em 0 0.3125em rgba(0,0,0,0.1);
text-align: left;
position: fixed;
height: 100%;
margin: 0;
}

.informacoesUsuario p {
margin: 0;
font-size: 1.2em;
}

.linksBarraLateral {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0.75em 0;
}

.linkLogout, .linkVoltar {
color: #0087c8;
text-decoration: none;
}

.linkLogout:hover, .linkVoltar:hover {
text-decoration: underline;
color: #0056b3;
cursor: pointer;
}

hr.solid {
border-top: 0.0625em solid #bbb;
}

nav ul {
list-style: none;
padding: 0;
}

nav ul li {
margin: 0.9375em 0;
}

nav ul li a {
text-decoration: none;
color: #1d1d1d;
font-size: 1.1em;
}

nav ul li a:hover,
nav ul li a.linkSelecionado {
color: #00a550;
}

main {
flex: 1;
padding: 0.25em;
margin-left: 14.2em;
display: flex;
flex-direction: column;
}

header h1 {
font-size: 2.4em;
color: #00a550;
}

hr.solid2 {
border-top: 0.125em solid #bbb;
}

.containerGraficos {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 10px;
}

.grafico {
width: 30%;
min-width: 300px;
border: 1px solid #c0c0c0;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.15);
padding: 10px;
text-align: center;
}

.itemLegenda {
display: flex;
align-items: center;
margin-right: 15px;
}

.containerLegenda {
display: flex;
justify-content: center;
margin: 20px 0;
}

@media (max-width: 1150px) {
.containerLegenda {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
justify-items: center;
}
}

.corLegenda {
display: inline-block;
width: 20px;
height: 20px;
margin-right: 5px;
}

.containerCard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
justify-items: center;
gap: 20px;
}

.card {
background-color: #00aaff;
color: white;
padding: 20px;
margin: 10px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
width: 250px;
}

.card p {
margin: 0;
font-size: 1.2em;
}
64 changes: 64 additions & 0 deletions src/app/pages/dashboard-category/dashboard-category.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<div class="containerPrincipal">
<aside>
<div class="informacoesUsuario">
<p>Olá, Admin!</p>
<div class="linksBarraLateral">
<a class="linkLogout" (click)="logoutUser()">Sair</a>
<a href="/homeAdmin" class="linkVoltar">Voltar</a>
</div>
</div>
<hr class="solid">
<nav>
<ul>
<li><a href="/video-views">Dados - Vídeos</a></li>
<li><a href="/category-views">Dados - Categorias</a></li>
<li><a href="/dashboard" class="linkSelecionado">Dashboard - Categorias</a></li>
</ul>
</nav>
</aside>
<main>
<header>
<h1>Dashboard - Categorias</h1>
<hr class="solid2">
</header>
<div class="containerCard">
<div class="card">
<p>{{ viewsAllCategories }}</p>
<p>Visualizações totais</p>
</div>
<div class="card">
<p>{{ videosAllCategories }}</p>
<p>Vídeos totais</p>
</div>
</div>

<div class="containerLegenda">
<div *ngFor="let color of categories" class="itemLegenda">
<span class="corLegenda" [ngStyle]="{'background-color': categoryColors[color]}"></span>
<span>{{ color }}</span>
</div>
</div>
<div class="containerGraficos">
<div class="grafico">
<canvas #videoCountChart></canvas>
<h2>Quantidade de videos por categorias</h2>
</div>
<div class="grafico">
<canvas #totalViewsChart></canvas>
<h2>Quantidade de visualizações por categorias</h2>
</div>
<div class="grafico">
<canvas #viewsPerVideoChart></canvas>
<h2>Quantidade de visualizações por vídeo</h2>
</div>
<div class="grafico">
<canvas #videoCountChartPizza></canvas>
<h2>Porcentagem de videos por categorias</h2>
</div>
<div class="grafico">
<canvas #totalViewsChartPizza></canvas>
<h2>Porcentagem de visualizações por categorias</h2>
</div>
</div>
</main>
</div>
Loading

0 comments on commit 18a94e4

Please sign in to comment.