-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Worked on UI for reversing floors + added a even based communication …
…services across components
- Loading branch information
Showing
13 changed files
with
127 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
|
||
import { inject as service } from '@ember/service'; | ||
|
||
export default class FloorComponent extends Component { | ||
@service('lift-mover') liftMoverService; | ||
constructor(){ | ||
super(...arguments) | ||
// console.log("moveIt", this.moveIt); | ||
} | ||
|
||
@action | ||
goUp(level) { | ||
console.log(level) | ||
// alert(`Go to level ${level}!`); | ||
this.analyseLift('UP', level); | ||
this.liftMoverService.trigger('move', {level, direction : 1, lift : 1}) | ||
} | ||
|
||
@action | ||
goDown(level) { | ||
console.log(level) | ||
this.analyseLift('DOWN', level); | ||
// alert(`Go to level ${level}!`); | ||
this.liftMoverService.trigger('move', {level, direction : 0, lift : 1}) | ||
} | ||
|
||
analyseLift(level, direction) { | ||
console.log(level, direction); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<div class="d-flex"> | ||
{{#each @building.lifts as |lift|}} | ||
<img src="assets/images/lift.png" id="lift_{{lift.num}}" class="lift" style="left: {{lift.width}}px;" height="70px" width="40px"> | ||
<img src="assets/images/lift.png" id="lift_{{lift.num}}" class="lift" style="left: {{lift.width}}px; bottom:{{lift.levelHeight}}px" height="70px" width="40px"> | ||
{{/each}} | ||
</div> | ||
<div class="d-flex"> | ||
{{#each @building.lifts as |lift|}} | ||
<span class="lift-count" style="left: {{lift.num_width}}px;">{{lift.num}}</span> | ||
<span class="lift-count" style="left: {{lift.num_width}}px;">{{lift.num}}</span> | ||
{{/each}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import Component from '@glimmer/component'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class LiftComponent extends Component { | ||
constructor(liftNum, noOfFloors) { | ||
super(); | ||
this.liftNum = liftNum; | ||
this.direction = 'UP'; | ||
this.state = 0; // 0 is idle, 1 is moving up, -1 is moving down | ||
this.currentFloor = 0; | ||
this.liftId = 'lift_' + liftNum; | ||
this.noOfFloors = noOfFloors; | ||
@service('lift-mover') liftMoverService; | ||
constructor() { | ||
super(...arguments) | ||
// this.liftNum = liftNum; | ||
// this.direction = 'UP'; | ||
// this.state = 0; // 0 is idle, 1 is moving up, -1 is moving down | ||
// this.currentFloor = 0; | ||
// this.liftId = 'lift_' + liftNum; | ||
// this.noOfFloors = noOfFloors; | ||
// console.log("this", this.element) | ||
|
||
this.liftMoverService.on('move', (data) => { | ||
console.log("data - ->", data) | ||
// this.model({level : data.level, lift : data.lift}) | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Model from '@ember-data/model'; | ||
|
||
export default class FloorModel extends Model { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Model from '@ember-data/model'; | ||
|
||
export default class LiftModel extends Model { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,60 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
import { action } from '@ember/object'; | ||
import { inject as service } from '@ember/service'; | ||
export default class TheElevatorGameRoute extends Route { | ||
@service('lift-mover') liftMoverService; | ||
constructor(){ | ||
super(...arguments) | ||
// console.log("moveIt", this.moveIt); | ||
|
||
// this.liftMoverService.on('move', (data) => { | ||
// console.log("data", data) | ||
// // this.model({level : data.level, lift : data.lift}) | ||
// }) | ||
} | ||
|
||
model() { | ||
const noOfFloors = 6; | ||
const noOfLifts = 3; | ||
model(selectedLift) { | ||
const noOfFloors = 6, noOfLifts = 3,groundFloor = 0; | ||
const lifts = []; | ||
const floors = []; | ||
|
||
for (let i = 1; i <= noOfFloors; i++) { | ||
const upBtn = i > 1 ? true : false; | ||
const downBtn = i < noOfFloors ? true : false; | ||
const floorName = i == 1 ? 'Ground' : i + 'th'; | ||
floors.push({ up: upBtn, down: downBtn, num: i, name: floorName }); | ||
|
||
for (let i = groundFloor; i <= noOfFloors; i++) { | ||
const upBtn = i >= groundFloor && i < noOfFloors; | ||
const downBtn = i > groundFloor && i <= noOfFloors; | ||
const floorName = i == groundFloor ? 'Ground' : i + 'th'; | ||
floors.push({ | ||
up: upBtn, | ||
down: downBtn, | ||
num: i, | ||
name: floorName | ||
}); | ||
} | ||
for (let i = 1; i <= noOfLifts; i++) { | ||
lifts.push({ num: i, width: 200 * i, num_width: 200 * i + 20 }); | ||
for (let i = groundFloor; i < noOfLifts; i++) { | ||
let level = 0; | ||
let liftNo = i + 1; | ||
let levelHeight = 0; | ||
if(selectedLift && selectedLift.lift === liftNo){ | ||
level = selectedLift.level; | ||
} | ||
lifts.push({ | ||
level, | ||
levelHeight : 100 * level, | ||
num: liftNo, | ||
width: 200 * liftNo, | ||
num_width: 200 * liftNo + 20 }); | ||
} | ||
|
||
console.log("levels", lifts); | ||
return { | ||
levels: Array.from(floors), | ||
levels: Array.from(floors).reverse(), | ||
lifts: Array.from(lifts), | ||
}; | ||
} | ||
|
||
// @action | ||
// move(){ | ||
// console.log("on change") | ||
// } | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default Ember.Service.extend(Ember.Evented); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Model | floor', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = store.createRecord('floor', {}); | ||
assert.ok(model); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Model | lift', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = store.createRecord('lift', {}); | ||
assert.ok(model); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Service | lift-mover', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let service = this.owner.lookup('service:lift-mover'); | ||
assert.ok(service); | ||
}); | ||
}); |