Skip to content

Commit d293cce

Browse files
committed
18-Oct-2019
1 parent 8f467af commit d293cce

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/router": "~7.2.0",
2222
"core-js": "^2.5.4",
2323
"jquery": "^3.4.1",
24+
"ng-circle-progress": "^1.5.1",
2425
"ngx-slick-carousel": "^0.4.6",
2526
"rxjs": "~6.3.3",
2627
"slick-carousel": "^1.8.1",

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BrowserModule } from "@angular/platform-browser";
22
import { NgModule } from "@angular/core";
33
import { HttpClientModule } from "@angular/common/http";
4+
import { NgCircleProgressModule } from 'ng-circle-progress';
45

56
import { AppComponent } from "./app.component";
67
import { HomeComponent } from "./home/home.component";
@@ -35,7 +36,8 @@ const routes: Routes = [
3536
HttpClientModule,
3637
BrowserAnimationsModule,
3738
SlickCarouselModule,
38-
RouterModule.forRoot(routes)
39+
RouterModule.forRoot(routes),
40+
NgCircleProgressModule.forRoot({})
3941
],
4042
entryComponents: [
4143
HomeComponent,

src/app/home/home.component.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
</div>
77

88
<div class="app-slider-content">
9+
10+
<h5 style="text-align: center;color:#fff;">
11+
<circle-progress
12+
[percent]="completePercent"
13+
[radius]="70"
14+
[unitsColor]="'#fff'"
15+
[titleColor]="'#fff'"
16+
[outerStrokeWidth]="10"
17+
[innerStrokeWidth]="10"
18+
[outerStrokeColor]="'#00c853'"
19+
[innerStrokeColor]="'#fff'"
20+
[animation]="true"
21+
[showSubtitle] = "true"
22+
subtitle = "complete"
23+
subtitleColor = "#ffffff"
24+
[animationDuration]="400"
25+
></circle-progress>
26+
</h5>
927
<div class="row app-slider">
1028
<ngx-slick-carousel class="carousel"
1129
#slickModal="slick-carousel"

src/app/home/home.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class HomeComponent implements OnInit, AfterContentChecked {
1616
posts: any;
1717
indexPost: any;
1818
indexSlide: any;
19+
completePercent: any;
1920
userLoggedIn = false;
2021
isComplete = 0;
2122
redirectUrl: any;
@@ -40,6 +41,11 @@ export class HomeComponent implements OnInit, AfterContentChecked {
4041
this.loadSignInStatus();
4142
this.data.currentData.subscribe((data: any) => {
4243
this.posts = data;
44+
let allLength = data.length;
45+
let totalLesson = 0;
46+
while (allLength > 0) {
47+
totalLesson = totalLesson + data[--allLength].lesson.length;
48+
}
4349
const tempIndex = JSON.parse(localStorage.getItem("LastLesson"));
4450
let mainIndex: number;
4551

@@ -57,6 +63,7 @@ export class HomeComponent implements OnInit, AfterContentChecked {
5763

5864
this.completedLesson = JSON.parse(localStorage.getItem("Lesson"));
5965
this.completedIndex = JSON.parse(localStorage.getItem("Index"));
66+
this.completePercent = ((100 * this.completedLesson.length) / totalLesson).toFixed();
6067

6168
this.allComplete();
6269
this.route.queryParamMap.subscribe(params => {

src/app/lesson/lesson.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ export class LessonComponent implements OnInit {
164164
IndexArray = [];
165165
LessonArray = [];
166166
}
167-
IndexArray.push(completedIndex);
168-
LessonArray.push(completedLesson);
167+
168+
if ( !LessonArray.includes(completedLesson)) {
169+
IndexArray.push(completedIndex);
170+
LessonArray.push(completedLesson);
171+
}
172+
169173
localStorage.setItem("Lesson", JSON.stringify(LessonArray));
170174
localStorage.setItem("Index", JSON.stringify(IndexArray));
171175
const UserId = localStorage.getItem("UserID");

0 commit comments

Comments
 (0)