Skip to content

Commit

Permalink
#158 percents of loading
Browse files Browse the repository at this point in the history
  • Loading branch information
emilt27 committed Jun 11, 2018
1 parent 25ebcf8 commit 1391007
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/data/scene/entities/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@ export class Room implements RoomProperty {
private backgroundVideo: MediaFile = new MediaFile();
private backgroundIsVideo = false;
private _isLoadedAssets: boolean = true;
private _loadingPercents: string = '0';

public get isLoadedAssets(): boolean {
return this._isLoadedAssets;
}

public get loadingPercents(): string {
return this._loadingPercents;
}

public setAssetsLoadedState(isLoaded: boolean) {
this._isLoadedAssets = isLoaded;
}

public setProgressLoading(percents: number): void {
this._loadingPercents = percents.toFixed(0);
}

getId(): string {
return this.id;
}
Expand Down
8 changes: 7 additions & 1 deletion src/data/storage/deserializationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,10 @@ export class DeserializationService {
for (let i = 0; i < remoteMediaFilesByRoom.length; i++) {
const { roomId, roomMediaFiles } = remoteMediaFilesByRoom[i];
const room: Room = this.roomManager.getRoomById(roomId);
const filesCount = roomMediaFiles.length;
let filesLoaded = 0;

for (let j = 0; j < roomMediaFiles.length; j++) {
for (let j = 0; j < filesCount; j++) {
const remoteFile: MediaFile = roomMediaFiles[j];

await this.afStorage
Expand All @@ -480,10 +482,14 @@ export class DeserializationService {
.then((blob) => this.fileLoaderUtil.getBinaryFileData(blob))
.then((binaryData) => {
remoteFile.setUploadedBinaryFileData(binaryData);
filesLoaded += 1;
room.setProgressLoading(100 * (filesLoaded / filesCount));
})
.catch((error) => {
console.log('Error to load remote file:', remoteFile);
console.log(error);
filesLoaded += 1;
room.setProgressLoading(100 * (filesLoaded / filesCount));
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/editor/bottombar/story-scroll/story-scroll.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<storymap-item
[roomProperty]="getRoomById(roomId)"
[isActive]="roomIsSelected(roomId)"
(click)="onRoomSelect(roomId)"
(click)="roomIsLoaded(roomId) && onRoomSelect(roomId)"
(infoEvent)="onInfoClick($event)"
class="story-scroll__storymap-item">
</storymap-item>
Expand Down
1 change: 1 addition & 0 deletions src/ui/editor/bottombar/story-scroll/story-scroll.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ $right-buffer: $room-icon-size + 5px;
.story-scroll__storymap-item {
color: $color-grey-dark;
font-size: $tiny-font-size;

&:hover {
color: $color-black;
}
Expand Down
7 changes: 7 additions & 0 deletions src/ui/editor/bottombar/story-scroll/story-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class StoryScroll {
observedData => {
const propertyId: string = observedData.propertyId;
const activeRoomId: string = this.sceneInteractor.getActiveRoomId();

this.activeProperty =
this.sceneInteractor.getPropertyById(activeRoomId, propertyId) ||
this.sceneInteractor.getRoomById(activeRoomId);
Expand Down Expand Up @@ -114,6 +115,12 @@ export class StoryScroll {
return roomId === this.sceneInteractor.getActiveRoomId();
}

public roomIsLoaded(roomId: string): boolean {
const room: Room = this.sceneInteractor.getRoomById(roomId);

return room.isLoadedAssets;
}

public roomIsExpanded(roomId: string): boolean {
return this.roomIsSelected(roomId)
&& this.activeRoomIsExpanded
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="storymap-item">
<div
[ngClass]="{'loading': !roomProperty.isLoadedAssets}"
class="storymap-item">

<div class="storymap-item__roomname">
<text-input
Expand Down Expand Up @@ -28,11 +30,13 @@
</div>

<div class='storymap-item__thumbnailbox'>
<div class="loading-progress" *ngIf="!roomProperty.isLoadedAssets">
<span>{{roomProperty.loadingPercents}}%</span>
</div>
<img
*ngIf="roomProperty.isLoadedAssets"
[attr.src]="getBackgroundThumbnail()"
class="storymap-item__thumbnail"
[ngClass]="{'storymap-item__thumbnail--active': isActive}">
</div>


</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
align-items: center;
width: 100%;
cursor: pointer;
margin: 0px 0;
margin: 0;

&:hover {
.story-map-item__buttons {
visibility: visible;
}

}

}

.story-map-item__buttons {
Expand All @@ -39,7 +38,7 @@

.storymap-item__roomname {
justify-content: center;
margin: 0px 0px 0px 0px;
margin: 0;
transform: translate(0%, 40px);
z-index: 1;
}
Expand Down Expand Up @@ -67,6 +66,18 @@
background-color: $color-grey-light;
height: $room-icon-thumbnail-height;
margin: 0 5px;

.loading-progress {
width: $room-icon-thumbnail-width;
height: $room-icon-thumbnail-height;
opacity: 0.5;
transition: opacity 0.25s ease-in-out;
text-align: center;

span {
line-height: $room-icon-thumbnail-height;
}
}
}

.storymap-item__thumbnail {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, EventEmitter, Input, NgZone, Output } from '@angular/core';
import { SceneInteractor } from 'core/scene/sceneInteractor';

import { Room } from 'data/scene/entities/room';
import { RoomProperty } from 'data/scene/interfaces/roomProperty';

import { PropertyRemovalService } from 'ui/editor/util/propertyRemovalService';
import { RoomPropertyTypeService } from 'ui/editor/util/roomPropertyTypeService';
Expand All @@ -14,7 +13,7 @@ import { RoomPropertyTypeService } from 'ui/editor/util/roomPropertyTypeService'
})
export class StorymapItem {

@Input() roomProperty: RoomProperty;
@Input() roomProperty: Room;
@Input() isActive: boolean;
@Output() infoEvent = new EventEmitter();
@Output() deleteEvent = new EventEmitter();
Expand Down

0 comments on commit 1391007

Please sign in to comment.