This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit bf0a1981 authored by Eduard Frankford's avatar Eduard Frankford
Browse files

achievements now configureable

parent 12486c7b
2 merge requests!62created achievementService and separated some functionality out of...,!45Achievements
{
"views": {
"More than 10 views": 10,
"More than 100 views": 100,
"More than 500 views": 500
},
"downloads": {
"More than 10 downloads": 10,
"More than 100 downloads": 100,
"More than 500 downloads": 500
}
}
...@@ -3,73 +3,72 @@ ...@@ -3,73 +3,72 @@
<ul class="list-group" *ngIf="statistics"> <ul class="list-group" *ngIf="statistics">
<li class="list-group-item justify-content-between align-items-center"> <li class="list-group-item justify-content-between align-items-center">
<div id="parent"> <div id="parent">
<div id="narrow">More than 500 views</div> <div id="narrow">More than {{config.views[2]}} views</div>
<div id="wide"> <div id="wide">
<ngb-progressbar type="success" [value]="statistics?.views / 500 * 100" [striped]="true" <ngb-progressbar type="success" [value]="statistics?.views / config.views[2] * 100" [striped]="true"
*ngIf="statistics?.views <= 500"> *ngIf="statistics?.views <= config.views[2]">
</ngb-progressbar> </ngb-progressbar>
<fa-icon icon="check" *ngIf="statistics?.views > 500" class="greeniconcolor"></fa-icon> <fa-icon icon="check" *ngIf="statistics?.views > config.views[2]" class="greeniconcolor"></fa-icon>
</div> </div>
</div> </div>
</li> </li>
<li class="list-group-item justify-content-between align-items-center"> <li class="list-group-item justify-content-between align-items-center">
<div id="parent"> <div id="parent">
<div id="narrow">More than 100 views</div> <div id="narrow">More than {{config.views[1]}} views</div>
<div id="wide"> <div id="wide">
<ngb-progressbar type="success" [value]="statistics?.views / 100 * 100" [striped]="true" <ngb-progressbar type="success" [value]="statistics?.views / config.views[1] * 100" [striped]="true"
*ngIf="statistics?.views <= 100"> *ngIf="statistics?.views <= config.views[1]">
</ngb-progressbar> </ngb-progressbar>
<fa-icon icon="check" *ngIf="statistics?.views > 100" class="greeniconcolor"></fa-icon> <fa-icon icon="check" *ngIf="statistics?.views > config.views[1]" class="greeniconcolor"></fa-icon>
</div> </div>
</div> </div>
</li> </li>
<li class="list-group-item justify-content-between align-items-center"> <li class="list-group-item justify-content-between align-items-center">
<div id="parent"> <div id="parent">
<div id="narrow">More than 10 views</div> <div id="narrow">More than {{config.views[0]}} views</div>
<div id="wide"> <div id="wide">
<ngb-progressbar *ngIf="statistics?.views <= 10" type="success" [value]="statistics?.views / 10 * 100" [striped]="true"> <ngb-progressbar *ngIf="statistics?.views <= config.views[0]" type="success" [value]="statistics?.views / config.views[0] * 100" [striped]="true">
</ngb-progressbar> </ngb-progressbar>
<fa-icon icon="check" *ngIf="statistics?.views > 10" class="greeniconcolor"></fa-icon> <fa-icon icon="check" *ngIf="statistics?.views > config.views[0]" class="greeniconcolor"></fa-icon>
</div> </div>
</div> </div>
</li> </li>
<li class="list-group-item justify-content-between align-items-center"> <li class="list-group-item justify-content-between align-items-center">
<div id="parent"> <div id="parent">
<div id="narrow">More than 500 downloads</div> <div id="narrow">More than {{config.downloads[2]}} downloads</div>
<div id="wide"> <div id="wide">
<ngb-progressbar type="success" [value]="statistics?.downloads / 500 * 100" [striped]="true" <ngb-progressbar type="success" [value]="statistics?.downloads / config.downloads[2] * 100" [striped]="true"
*ngIf="statistics?.downloads <= 500"> *ngIf="statistics?.downloads <= config.downloads[2]">
</ngb-progressbar> </ngb-progressbar>
<fa-icon icon="check" *ngIf="statistics?.downloads > 500" class="greeniconcolor"></fa-icon> <fa-icon icon="check" *ngIf="statistics?.downloads > config.downloads[2]" class="greeniconcolor"></fa-icon>
</div> </div>
</div> </div>
</li> </li>
<li class="list-group-item justify-content-between align-items-center"> <li class="list-group-item justify-content-between align-items-center">
<div id="parent"> <div id="parent">
<div id="narrow">More than 100 downloads</div> <div id="narrow">More than {{config.downloads[1]}} downloads</div>
<div id="wide"> <div id="wide">
<ngb-progressbar type="success" [value]="statistics?.downloads / 100 * 100" [striped]="true" <ngb-progressbar type="success" [value]="statistics?.downloads / config.downloads[1] * 100" [striped]="true"
*ngIf="statistics?.downloads <= 100"> *ngIf="statistics?.downloads <= config.downloads[1]">
</ngb-progressbar> </ngb-progressbar>
<fa-icon icon="check" *ngIf="statistics?.downloads > 100" class="greeniconcolor"></fa-icon> <fa-icon icon="check" *ngIf="statistics?.downloads > config.downloads[1]" class="greeniconcolor"></fa-icon>
</div> </div>
</div> </div>
</li> </li>
<li class="list-group-item justify-content-between align-items-center"> <li class="list-group-item justify-content-between align-items-center">
<div id="parent"> <div id="parent">
<div id="narrow">More than 10 downloads</div> <div id="narrow">More than {{config.downloads[0]}}downloads</div>
<div id="wide"> <div id="wide">
<ngb-progressbar type="success" [value]="statistics?.downloads / 10 * 100" [striped]="true" <ngb-progressbar type="success" [value]="statistics?.downloads / config.downloads[0] * 100" [striped]="true"
*ngIf="statistics?.downloads <= 10"> *ngIf="statistics?.downloads <= config.downloads[0]">
</ngb-progressbar> </ngb-progressbar>
<fa-icon icon="check" *ngIf="statistics?.downloads > 10" class="greeniconcolor"></fa-icon> <fa-icon icon="check" *ngIf="statistics?.downloads > config.downloads[0]" class="greeniconcolor"></fa-icon>
</div> </div>
</div> </div>
</li> </li>
</ul> </ul>
<!-- <button (click) = "getTotalNumberOfViews()" class="btn btn-primary"> Get number of views </button> --> <!-- <button (click) = "buildAchievements()" class="btn btn-primary"> Get number of views </button> -->
<!-- <ul class="list-group" *ngIf="statistics"> <!-- <ul class="list-group" *ngIf="statistics">
<li class="list-group-item d-flex justify-content-between align-items-center"> <li class="list-group-item d-flex justify-content-between align-items-center">
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { SearchService } from 'app/search/service/search-service'; import { SearchService } from 'app/search/service/search-service';
import { HttpClient } from '@angular/common/http';
import { AccountService } from 'app/core/auth/account.service'; import { AccountService } from 'app/core/auth/account.service';
import { Account } from 'app/core/user/account.model'; import { Account } from 'app/core/user/account.model';
...@@ -15,8 +16,8 @@ import { Statistics } from 'app/shared/model/statistics.model'; ...@@ -15,8 +16,8 @@ import { Statistics } from 'app/shared/model/statistics.model';
export class AchievementsComponent implements OnInit { export class AchievementsComponent implements OnInit {
account!: Account; account!: Account;
statistics!: Statistics; statistics!: Statistics;
config = require('./achievements_config.json');
constructor(private accountService: AccountService, protected searchService: SearchService) {} constructor(private accountService: AccountService, protected searchService: SearchService, private httpClient: HttpClient) {}
public getTotalNumberOfViews(): void { public getTotalNumberOfViews(): void {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
...@@ -35,7 +36,8 @@ export class AchievementsComponent implements OnInit { ...@@ -35,7 +36,8 @@ export class AchievementsComponent implements OnInit {
' for account ' + ' for account ' +
this.account.firstName + this.account.firstName +
' ' + ' ' +
this.account.lastName this.account.lastName +
this.config.views[0]
); );
} }
}, },
......
{
"views": [10, 100, 500],
"downloads": [10, 100, 500]
}
...@@ -7,5 +7,10 @@ ...@@ -7,5 +7,10 @@
{ {
"path": "./tsconfig.e2e.json" "path": "./tsconfig.e2e.json"
} }
] ],
"compilerOptions": {
"module": "commonjs",
"resolveJsonModule": true,
"esModuleInterop": true
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment