Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// you probably want to extend eslint recommended or at least put
// in no unused vars and other syntax help
{
"parserOptions": {
"ecmaVersion": 6,
Expand Down
1 change: 1 addition & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ app.config(routes);

const dev = 'https://pawsio.herokuapp.com/api';

// need to use the DefinePlugin or EnvironmentPlugin in webpack to manage url
// app.value('apiUrl', process.env.API_URL || '/api');
app.value('apiUrl', dev);
app.config(http);
Expand Down
15 changes: 12 additions & 3 deletions src/components/all-pets/all-pets.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ controller.$inject = [ 'petsService', '$state' ];
function controller(petsService, $state){
this.styles = styles;

// better to use a single object:
// this.reset = () => this.pet = {};
// and let the bindings create the properties

this.reset = () => {
this.name = '';
this.age = '';
Expand All @@ -26,6 +30,7 @@ function controller(petsService, $state){

this.reset();

// should come from db?
this.breeds = [
{ breed: 'Working Dog', exerciseNeed: 120 },
{ breed: 'Terrier', exerciseNeed: 110 },
Expand All @@ -40,8 +45,6 @@ function controller(petsService, $state){

this.addPet = function(){

let breedName = '';
let exercise = null;
let petToAdd = {
name: this.name,
age: this.age,
Expand All @@ -54,8 +57,14 @@ function controller(petsService, $state){
petsService.addPet(petToAdd)
.then(savedPet => {
this.pets.push(savedPet);
// 3. better to just do here, synchronous activity:
this.reset();
})
.then(this.reset());
// 1. this calls the reset function and passes the return
// as the callback :(
// .then(this.reset());
// 2. this is what you meant:
// .then(() => this.reset());
};

}
4 changes: 4 additions & 0 deletions src/components/pet/pet.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function controller(petsService, $state, snapService) {
this.styles = styles;

this.$onInit = function () {
// time to work on model/variable naming when
// you have meanless names like this that only describe data structure
let dataArr = this.petData.data;

// Data formatting logic could be moved into custom filter
for (var i = 0; i < dataArr.length; i++) {
let longDate = dataArr[i].date;
let dateChunk = longDate.slice(0, 10);
Expand Down
4 changes: 4 additions & 0 deletions src/components/snapshot/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ function controller(kineticsService, petSnapshotService, temperatureService, use
this.$onInit = function () {
console.log('distanceGoal: ', this.pet.distanceGoal);
let temp = temperatureService.getAvgTemp(this.snapshot.dataPayload);
// why isn't this part of the getAvgTemp service method?
this.averageTemp = Math.round(temp);

// hmm, this seems odd here. Logic seems duplicative of some of services.
// I wonder if data on server should be better massaged
this.snapshot.dataPayload.forEach((element, index, array) => {
this.threshold.push(element.threshold);
this.time.push((Date.parse(element.date) - Date.parse(array[0].date))/1000);
Expand All @@ -59,6 +62,7 @@ function controller(kineticsService, petSnapshotService, temperatureService, use
kineticsService
.getVelocity(this.snapshot.dataPayload)
.then(velArr => {
// again, not sure why this isn't part of service
let rawHikeLength = velArr[(velArr.length) - 1].timeStamp;
if ((rawHikeLength/60) < .5) {
this.hikeLengthMin = Math.ceil(rawHikeLength/60);
Expand Down
2 changes: 2 additions & 0 deletions src/components/stats/stats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import template from './stats.html';
import styles from './stats.scss';

// duplicate of "profile" component ????

export default {
template,
controller,
Expand Down
5 changes: 5 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function routes($stateProvider, $urlRouterProvider) {
pets: ['petsService', pets => {
return pets.getAll()
.then(pets => {
// pets.pets? sounds like model should be cleaned up or service should hide this bit...
return pets.pets;
});
}]
Expand Down Expand Up @@ -39,6 +40,10 @@ export default function routes($stateProvider, $urlRouterProvider) {
abstract: true,
default: '.pets',
resolve: {
// since 'about', 'profile', and 'snapshot' use the same pets data,
// you could create single top level 'app' state that applies to both.
// as you currently have it, there are two pets arrays in memory and
// you loose syncing data across staes
pets: ['petsService', pets => {
return pets.getAll()
.then(pets => {
Expand Down
2 changes: 2 additions & 0 deletions src/services/kinetics-service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// these calculations seem deterministic. Could they be done
// on save of data on the server?
export default function kineticsService() {
return {
getVelocity(accelArray) {
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

// either use this instance or stick with static methods, but don't mix the two
const cssExtract = new ExtractTextPlugin('main.css');

module.exports = {
Expand Down