Created cards and mock db

This commit is contained in:
Kaloian Venkov 2021-03-12 11:16:13 +02:00
parent 15e2160502
commit 785a4141a4
58 changed files with 37506 additions and 0 deletions

View File

@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

View File

@ -0,0 +1,14 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

46
apollo-frontend/.gitignore vendored Normal file
View File

@ -0,0 +1,46 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

27
apollo-frontend/README.md Normal file
View File

@ -0,0 +1,27 @@
# ApolloFrontend
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.1.1.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

View File

@ -0,0 +1,128 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"apollo-frontend": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/apollo-frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [ "./node_modules/hammerjs/hammer.min.js"]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "apollo-frontend:build"
},
"configurations": {
"production": {
"browserTarget": "apollo-frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "apollo-frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [ "./node_modules/hammerjs/hammer.min.js"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "apollo-frontend:serve"
},
"configurations": {
"production": {
"devServerTarget": "apollo-frontend:serve:production"
}
}
}
}
}
},
"defaultProject": "apollo-frontend"
}

View File

@ -0,0 +1,37 @@
// @ts-check
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
/**
* @type { import("protractor").Config }
*/
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome'
},
directConnect: true,
SELENIUM_PROMISE_MANAGER: false,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.json')
});
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: StacktraceOption.PRETTY
}
}));
}
};

View File

@ -0,0 +1,23 @@
import { browser, logging } from 'protractor';
import { AppPage } from './app.po';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getTitleText()).toEqual('apollo-frontend app is running!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});

View File

@ -0,0 +1,11 @@
import { browser, by, element } from 'protractor';
export class AppPage {
async navigateTo(): Promise<unknown> {
return browser.get(browser.baseUrl);
}
async getTitleText(): Promise<string> {
return element(by.css('app-root .content span')).getText();
}
}

View File

@ -0,0 +1,13 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es2018",
"types": [
"jasmine",
"node"
]
}
}

View File

@ -0,0 +1,19 @@
{
"version": "7.0.2",
"project": {
"defaultPort": 4200,
"framework": "angular",
"projectType": "igx-ts",
"projectTemplate": "ng-cli",
"theme": "Custom",
"isBundle": false,
"bundleFilePath": "",
"igniteuiSource": "",
"components": [],
"sourceFiles": [],
"isShowcase": false,
"version": ""
},
"build": {},
"packagesInstalled": true
}

View File

@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/apollo-frontend'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

35915
apollo-frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
{
"name": "apollo-frontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~11.1.0",
"@angular/common": "~11.1.0",
"@angular/compiler": "~11.1.0",
"@angular/core": "~11.1.0",
"@angular/forms": "~11.1.0",
"@angular/platform-browser": "~11.1.0",
"@angular/platform-browser-dynamic": "~11.1.0",
"@angular/router": "~11.1.0",
"@igniteui/material-icons-extended": "^2.4.0",
"hammerjs": "^2.0.8",
"igniteui-angular": "^11.0.15",
"jszip": "^3.5.0",
"resize-observer-polyfill": "^1.5.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"web-animations-js": "^2.3.2",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1101.1",
"@angular/cli": "~11.1.1",
"@angular/compiler-cli": "~11.1.0",
"@igniteui/angular-schematics": "~11.0.700",
"@types/hammerjs": "^2.0.36",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.2.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.2"
}
}

View File

@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

View File

@ -0,0 +1 @@
<app-dashboard></app-dashboard>

View File

@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'apollo-frontend'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('apollo-frontend');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('apollo-frontend app is running!');
});
});

View File

@ -0,0 +1,20 @@
import { Component, OnInit } from '@angular/core';
import { IgxIconService } from 'igniteui-angular';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'apollo-frontend';
constructor(
private icons: IgxIconService,
) {}
ngOnInit(): void {
this.icons.addSvgIcon('danger', '/assets/icons/risk-skull.svg');
}
}

View File

@ -0,0 +1,41 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {
IgxButtonModule,
IgxIconModule,
IgxRippleModule,
} from 'igniteui-angular';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CardComponent } from './card/card.component';
import { DashboardCardsComponent } from './dashboard-cards/dashboard-cards.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { DashboardMinigamesComponent } from './dashboard-minigames/dashboard-minigames.component';
import { MinigameCardComponent } from './minigame-card/minigame-card.component';
@NgModule({
declarations: [
AppComponent,
CardComponent,
DashboardCardsComponent,
DashboardComponent,
DashboardMinigamesComponent,
MinigameCardComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
IgxButtonModule,
IgxRippleModule,
IgxIconModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}

View File

@ -0,0 +1,21 @@
<div class="container" #container>
<div class="tags">
<div class="contents" *ngFor="let type of card.types" >
<div [class]="[type, 'icon']" *ngIf="type !== 'normal'"></div>
</div>
</div>
<div class="main">
<div class="contents" #frontSide *ngIf="!flipped">
<h6>{{card.name}}</h6>
<div class="img-fitter" [style.background-image]="'url(\'' + card.imageUrl + '\')'">
</div>
</div>
<div class="contents" #backSide *ngIf="flipped">
<div class="contents" *ngFor="let paragraph of card.info">
<h6 class="small">{{paragraph.heading}}</h6>
<p class="small">{{paragraph.content}}</p>
</div>
</div>
</div>
<button igxButton igxRipple (click)="flip()">Обърни</button>
</div>

View File

@ -0,0 +1,82 @@
.container {
.main {
display: flex;
flex-direction: column;
box-sizing: border-box;
flex: 1 0 auto;
&>* {
flex: 1 0 auto;
}
h6 {
margin: 0;
text-align: center;
&.small {
margin-top: .5em;
}
}
p {
margin: 0;
&.small::before {
content: '';
width: 2em;
height: 3px;
display: inline-block;
}
}
.small {
font-size: .75em;
line-height: 1em;
text-align: start;
}
.img-fitter{
margin-top: .5em;
width: 100%;
display: inline-block;
flex: 1 0 auto;
background: center no-repeat;
background-size: cover;
}
margin-top: .5em;
margin-bottom: 1em;
}
.tags {
display: flex;
justify-content: end;
gap: 3px;
height: 18px;
flex: 0 1 18px;
.icon {
width: 18px;
height: 18px;
padding: 2px;
border-radius: 5px;
background-repeat: no-repeat;
background-origin: content-box;
&.endangered {
background-image: url('/assets/icons/risk-skull.svg');
background-color: red;
}
}
}
display: flex;
flex-direction: column;
width: 200px;
height: 300px;
border-radius: 1em;
padding: 1em;
box-shadow: #0004 3px 3px 5px;
background-color: #f8f8f8;
button {
margin: 0 auto;
display: block;
height: min-content;
}
}

View File

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

View File

@ -0,0 +1,75 @@
import { Component, ElementRef, Input, NgZone, OnInit, ViewChild } from '@angular/core';
import { IgxIconService } from 'igniteui-angular';
import { Card } from '../db.service';
@Component({
selector: 'app-card',
templateUrl: './card.component.html',
styleUrls: ['./card.component.scss']
})
export class CardComponent implements OnInit {
@ViewChild('container') containerRef: ElementRef;
@Input() card: Card = {
imageUrl: '/assets/images/test-card.png',
name: 'Полярна мечка',
types: ['endangered'],
info: [
{
heading: 'ОТКРИТИЕ',
content: 'Полярните мечки имат 4 крака',
},
{
heading: 'ОТКРИТИЕ 2',
content: 'Полярните мечки имат 2 крака',
},
{
heading: 'ОТКРИТИЕ 3',
content: 'Полярните мечки имат -69 крака',
},
],
};
flipped: boolean = false;
constructor(
private icons: IgxIconService,
private zone: NgZone,
) { }
ngOnInit(): void {
this.icons.addSvgIcon('danger', 'http://192.168.0.104:8054/assets/icons/risk-skull.svg', 'filter-icons');
}
flip() {
const container = this.containerRef.nativeElement as HTMLDivElement;
container.style.pointerEvents = 'none';
container.animate([
{
transform: 'perspective(1000px) rotateY(0deg)',
},
{
transform: 'perspective(1000px) rotateY(90deg)',
},
], {
duration: 100,
easing: 'cubic-bezier(.62,0,.83,.67)',
}).onfinish = () => {
this.zone.run(() => {
this.flipped = !this.flipped;
container.animate([
{
transform: 'perspective(1000px) rotateY(90deg) scaleX(-1)',
},
{
transform: 'perspective(1000px) rotateY(180deg) scaleX(-1)',
},
], {
duration: 100,
easing: 'cubic-bezier(0,.59,.63,.83)',
}).onfinish = () => {
container.style.pointerEvents = 'inherit';
}
});
}
}
}

View File

@ -0,0 +1,5 @@
<h4 style="margin-bottom: 1em; text-align: center;">Вашите карти:</h4>
<div class="cards">
<app-card [card]="{ name: 'test', imageUrl: 'no-image', types: [ 'normal' ], info: [] }"></app-card>
<app-card></app-card>
</div>

View File

@ -0,0 +1,4 @@
.cards {
display: flex;
gap: 2em;
}

View File

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

View File

@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dashboard-cards',
templateUrl: './dashboard-cards.component.html',
styleUrls: ['./dashboard-cards.component.scss']
})
export class DashboardCardsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@ -0,0 +1,5 @@
<h4 style="margin-bottom: 1em; text-align: center;">Миниигри:</h4>
<div class="cards">
<app-minigame-card *ngFor="let minigame of getMinigames()"
[minigame]="minigame.el" [minigameUserdata]="getMinigameUserdata(minigame.id)"></app-minigame-card>
</div>

View File

@ -0,0 +1,4 @@
.cards {
display: flex;
gap: 2em;
}

View File

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

View File

@ -0,0 +1,26 @@
import { Component, OnInit } from '@angular/core';
import { DbService, Minigame, Saved } from '../db.service';
import { MinigameUserdata, UserdataService } from '../userdata.service';
@Component({
selector: 'app-dashboard-minigames',
templateUrl: './dashboard-minigames.component.html',
styleUrls: ['./dashboard-minigames.component.scss']
})
export class DashboardMinigamesComponent implements OnInit {
constructor(
private db: DbService,
private userdata: UserdataService,
) { }
ngOnInit(): void {
}
getMinigames(): Saved<Minigame>[] {
return this.db.getAllMinigames();
}
getMinigameUserdata(id: string): MinigameUserdata {
return this.userdata.getMinigameUserdata(id);
}
}

View File

@ -0,0 +1,2 @@
<app-dashboard-minigames></app-dashboard-minigames>
<app-dashboard-cards></app-dashboard-cards>

View File

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

View File

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

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { DbService } from './db.service';
describe('DbService', () => {
let service: DbService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DbService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,72 @@
import { Injectable } from '@angular/core';
export interface Minigame {
name: string;
url: string;
}
export interface CardParagraph {
heading: string;
content: string;
}
export interface Card {
info: CardParagraph[];
imageUrl: string;
name: string;
types: Array<"endangered" | "normal">;
}
export interface Saved<T> {
id: string;
el: T;
}
@Injectable({
providedIn: 'root'
})
export class DbService {
private mock_minigames: Saved<Minigame>[] = [
{
id: '0',
el: {
name: 'test',
url: 'none',
}
},
{
id: '1',
el: {
name: 'test2',
url: 'none',
}
}
];
private mock_card_types: Saved<Card>[];
private getRandomEl<T>(array: T[]): T {
const index = Math.floor(Math.random() * array.length);
return array[index];
}
getAllMinigames(): Saved<Minigame>[] {
return this.mock_minigames;
}
getAllCards(): Saved<Card>[] {
return this.mock_card_types;
}
getMinigame(id: string): Minigame {
const index = this.mock_minigames.findIndex(v => v.id === id);
if (index < 0) return null;
else return this.mock_minigames[index].el;
}
getCard(id: string): Card {
const index = this.mock_card_types.findIndex(v => v.id === id);
if (index < 0) return null;
else return this.mock_card_types[index].el;
}
constructor() { }
}

View File

@ -0,0 +1,14 @@
<div class="container" #container>
<div class="main">
<div class="contents" #frontSide *ngIf="!flipped">
<h6>{{minigame.name}}</h6>
</div>
<p *ngIf="minigameUserdata.played">
Вече сте играли тази игра и {{hasMedal() ? 'имате' : 'нямате'}} {{getMedalType()}} медал
</p>
<p *ngIf="!minigameUserdata.played">
Все още не сте играли тази игра
</p>
</div>
<button igxButton igxRipple (click)="play()">Играй {{minigameUserdata.played ? 'отново' : ''}}</button>
</div>

View File

@ -0,0 +1,61 @@
.container {
.main {
display: flex;
flex-direction: column;
box-sizing: border-box;
flex: 1 0 auto;
&>* {
flex: 1 0 auto;
}
h6 {
margin: 0;
margin-bottom: .5em;
text-align: center;
}
p {
margin: 0;
line-height: 1.5em;
}
margin-top: .5em;
margin-bottom: 1em;
}
.tags {
display: flex;
justify-content: end;
gap: 3px;
height: 18px;
flex: 0 1 18px;
.icon {
width: 18px;
height: 18px;
padding: 2px;
border-radius: 5px;
background-repeat: no-repeat;
background-origin: content-box;
&.endangered {
background-image: url('/assets/icons/risk-skull.svg');
background-color: red;
}
}
}
display: flex;
flex-direction: column;
width: 200px;
height: 200px;
border-radius: 1em;
padding: 1em;
box-shadow: #0004 3px 3px 5px;
background-color: #f8f8f8;
button {
margin: 0 auto;
display: block;
height: min-content;
}
}

View File

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

View File

@ -0,0 +1,49 @@
import { Component, ElementRef, Input, NgZone, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { Minigame } from '../db.service';
import { Medal, MinigameUserdata } from '../userdata.service';
@Component({
selector: 'app-minigame-card',
templateUrl: './minigame-card.component.html',
styleUrls: ['./minigame-card.component.scss']
})
export class MinigameCardComponent implements OnInit {
@ViewChild('container') containerRef: ElementRef;
@Input() minigame: Minigame = {
name: 'None',
url: '/',
};
@Input() minigameUserdata: MinigameUserdata = {
played: true,
medal: Medal.None,
};
flipped: boolean = false;
constructor(
private zone: NgZone,
private router: Router,
) { }
ngOnInit(): void {
}
hasMedal(): boolean {
return this.minigameUserdata.medal !== Medal.None;
}
getMedalType(): string {
switch (this.minigameUserdata.medal) {
case Medal.None: return 'никакъв';
case Medal.Bronze: return 'бронзов';
case Medal.Silfer: return 'сребърен';
case Medal.Gold: return 'златен';
}
}
play() {
this.router.navigate([this.minigame.url], {
replaceUrl: true,
});
}
}

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { UserdataService } from './userdata.service';
describe('UserdataService', () => {
let service: UserdataService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(UserdataService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 612 612" style="enable-background:new 0 0 612 612;" xml:space="preserve">
<g>
<g>
<path d="M122.855,335.491c3.514,11.463,7.147,23.318,8.96,35.258c0.741,4.866,3.647,40.261,5.218,59.707
c0.602,7.451,6.252,13.508,13.643,14.626l25.821,3.904c3.723,0.563,6.692,3.402,7.417,7.097l3.402,17.401
c1.479,7.563,8.108,13.018,15.814,13.014l200.241-0.119c7.572-0.005,14.118-5.283,15.726-12.682l3.896-17.915
c0.86-3.536,3.782-6.193,7.383-6.717l31.437-4.566c7.554-1.097,13.3-7.344,13.759-14.964c1.206-20.008,3.457-56.434,4.155-61.425
c1.653-11.784,5.131-23.432,8.49-34.764c4.709-15.857,9.578-32.225,9.578-49.248c0.006-108.709-86.402-197.132-192.608-197.132
s-192.613,88.471-192.613,197.204C112.575,301.952,117.801,319.004,122.855,335.491z M330.285,325.459
c1.221-30.877,28.91-38.641,59.787-37.421c30.877,1.221,53.249,10.965,52.028,41.842c-1.221,30.877-27.241,54.918-58.118,53.697
C353.105,382.356,329.064,356.336,330.285,325.459z M312.119,386.048l20.042,29.679c1.778,2.632,2.021,6.011,0.639,8.871
l-2.875,5.951c-1.489,3.081-4.609,5.038-8.03,5.038h-17.167h-17.167c-3.422,0-6.542-1.958-8.03-5.038l-2.875-5.951
c-1.382-2.86-1.138-6.238,0.639-8.871l20.042-29.679C300.873,380.811,308.583,380.811,312.119,386.048z M220.299,288.039
c30.877-1.221,58.566,6.543,59.787,37.421c1.221,30.877-22.82,56.897-53.697,58.118c-30.877,1.221-56.897-22.82-58.118-53.697
C167.05,299.003,189.422,289.259,220.299,288.039z"/>
<path d="M556.35,58.611c2.402-14.75-2.089-30.405-13.499-41.757c-18.326-18.234-48.224-18.566-66.929-0.721
c-19.558,18.659-19.834,49.646-0.828,68.652l-17.47,17.47c-6.98,6.981-6.98,18.299,0,25.28l29.802,29.802
c6.98,6.981,18.299,6.981,25.279,0l17.47-17.47c19.007,19.007,49.994,18.73,68.652-0.828
c17.845-18.705,17.512-48.604-0.722-66.929C586.754,60.7,571.1,56.209,556.35,58.611z"/>
<path d="M81.824,139.866l17.47,17.47c6.981,6.981,18.299,6.981,25.279,0l29.802-29.802c6.981-6.981,6.981-18.299,0-25.28
l-17.47-17.47c19.007-19.006,18.73-49.993-0.828-68.652C117.372-1.712,87.474-1.38,69.148,16.854
C57.739,28.206,53.248,43.861,55.65,58.611C40.9,56.209,25.246,60.7,13.893,72.109c-18.234,18.325-18.567,48.224-0.722,66.929
C31.83,158.596,62.817,158.872,81.824,139.866z"/>
<path d="M598.829,472.962c-18.659-19.559-49.646-19.834-68.652-0.828l-17.47-17.47c-6.981-6.981-18.299-6.981-25.279,0
l-29.802,29.802c-6.98,6.981-6.98,18.299,0,25.28l17.47,17.47c-19.007,19.007-18.73,49.994,0.828,68.652
c18.705,17.845,48.604,17.513,66.929-0.721c11.41-11.352,15.901-27.007,13.499-41.757c14.75,2.402,30.404-2.089,41.756-13.499
C616.341,521.565,616.673,491.667,598.829,472.962z"/>
<path d="M55.65,553.389c-2.402,14.75,2.089,30.405,13.499,41.757c18.326,18.234,48.224,18.566,66.929,0.721
c19.558-18.659,19.834-49.646,0.828-68.652l17.47-17.47c6.981-6.98,6.981-18.299,0-25.28l-29.802-29.802
c-6.981-6.981-18.299-6.981-25.279,0l-17.47,17.47c-19.007-19.007-49.994-18.731-68.652,0.828
c-17.845,18.705-17.513,48.603,0.721,66.929C25.246,551.3,40.9,555.791,55.65,553.389z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 KiB

View File

@ -0,0 +1,3 @@
export const environment = {
production: true
};

View File

@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

View File

@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ApolloFrontend</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Titillium+Web" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body class="igx-typography">
<app-root></app-root>
</body>
</html>

View File

@ -0,0 +1,12 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

View File

@ -0,0 +1,65 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/**
* IE11 requires the following for NgClass support on SVG elements
*/
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

View File

@ -0,0 +1,30 @@
/* You can add global styles to this file, and also import other style files */
body, html {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
// Uncomment the following lines if you want to add a custom palette:
// $primary: #731963 !default;
// $secondary: #ce5712 !default;
// $app-palette: igx-palette($primary, $secondary);
/* autoprefixer grid: on */
@import "~igniteui-angular/lib/core/styles/themes/index";
$company-color: rgb(139, 39, 39); // Some green shade I like
$secondary-color: rgb(139, 39, 39); // Watermelon pink
$my-color-palette: igx-palette(
$primary: $company-color,
$secondary: $secondary-color
);
@include igx-core();
@include igx-theme($my-color-palette);
.contents {
display: contents;
}

View File

@ -0,0 +1,25 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: {
context(path: string, deep?: boolean, filter?: RegExp): {
keys(): string[];
<T>(id: string): T;
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@ -0,0 +1,15 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}

View File

@ -0,0 +1,24 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"module": "es2020",
"lib": [
"es2018",
"dom"
],
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictTemplates":true
}
}

View File

@ -0,0 +1,18 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

155
apollo-frontend/tslint.json Normal file
View File

@ -0,0 +1,155 @@
{
"extends": "tslint:recommended",
"rulesDirectory": [
"codelyzer"
],
"rules": {
"align": {
"options": [
"parameters",
"statements"
]
},
"array-type": false,
"arrow-return-shorthand": true,
"curly": false,
"deprecation": {
"severity": "warning"
},
"eofline": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": {
"options": [
"spaces"
]
},
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"quotemark": [
false,
"single",
"double"
],
"semicolon": {
"options": [
"always"
]
},
"space-before-function-paren": {
"options": {
"anonymous": "never",
"asyncArrow": "always",
"constructor": "never",
"method": "never",
"named": "never"
}
},
"typedef": [
true,
"call-signature"
],
"typedef-whitespace": {
"options": [
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace"
}
]
},
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"allow-pascal-case",
"allow-leading-underscore",
"allow-snake-case"
]
},
"whitespace": {
"options": [
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
},
"component-class-suffix": true,
"contextual-lifecycle": true,
"directive-class-suffix": true,
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-inputs-metadata-property": true,
"no-output-native": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"no-outputs-metadata-property": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true,
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}