Skip to content

Commit

Permalink
work on ng app
Browse files Browse the repository at this point in the history
  • Loading branch information
thanpolas committed Nov 21, 2015
1 parent 009013c commit 54f9488
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 48 deletions.
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% include head.html %}

<body>

<base href="/" />
{% include header.html %}

{{ content }}
Expand Down
12 changes: 8 additions & 4 deletions _scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* BorderShare Learn where to make donations for people in need.
* http://bordershare.gr/
*
* Copyright (c) 2015 SheShar & SKGTech
* Copyright (c) 2015 SheSharp & SKGTech
* @author Theodore Kelloglou
* @author Thanasis Polychronakis
* @author Andigoni Founta
*
* @fileOverview The Front Application bootstrap file.
*/

var Parse = require('parse');
require('angular/angular');
require('angular-route/angular-route');

Expand All @@ -21,10 +22,13 @@ angular.module('app', [
'ngRoute',
]);

// Templates

// Templates

// Require components
require('./config/logger.config');
require('./config/route.config');

// Page scripts
require('./parse');
// initialize parse
Parse.initialize('ka61YPSHXHZgsaVEUwIZpWeOvLoBD63sRgoBi85N',
'7kKk2X1i2RKJVr19Dw7F2Gldq9tsf304GBP0thIe');
3 changes: 2 additions & 1 deletion _scripts/config/route.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @fileOverview Create and configure the routes.
*/

// load controllers
require('../controllers/place.ctrl');

/**
Expand All @@ -15,7 +16,7 @@ var routeConfig = module.exports = function ($routeProvider, $locationProvider)
// enable html5 routing
$locationProvider.html5Mode(true);

var partialsPath = 'ngtpl';
var partialsPath = 'ngtpl/';

$routeProvider
.when('/', {
Expand Down
14 changes: 8 additions & 6 deletions _scripts/controllers/place.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ require('../services/place.service');
var PlacesCtrl = module.exports = function($scope, $log, $location,
placesService) {

$log.log('app.ctrl.PlacesCtrl() :: Init');

/** @type {Array} Places records */
this.data = null;

this.$log = $log;
this.placesService = placesService;

this.initData();
};

/**
Expand All @@ -20,14 +23,13 @@ var PlacesCtrl = module.exports = function($scope, $log, $location,
*/
PlacesCtrl.prototype.initData = function() {
this.placesService.get()
.success(function(data) {
this.data = data;
this.$log.log(this.data);
});
// .success(function(data) {
// this.data = data;
// this.$log.log(this.data);
// });
};

angular.module('app')
.controller('PlacesCtrl', ['$scope', '$log', '$location',
'placesService',
.controller('PlacesCtrl', ['$scope', '$log', '$location', 'PlacesService',
PlacesCtrl
]);
17 changes: 0 additions & 17 deletions _scripts/parse.js

This file was deleted.

35 changes: 18 additions & 17 deletions _scripts/services/place.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* @fileOverview Places Service.
*/
var Parse = require('parse');

/**
* Places service.
Expand All @@ -18,25 +19,25 @@ var PlacesService = module.exports = function ($http) {
* @return {Promise} A Promise.
*/
PlacesService.prototype.get = function () {
return this.$http({
method: 'GET',
url: '/summary',
transformResponse: function (data) {
try {
data = JSON.parse(data);
} catch(ex) {
return data;
}

if (data && data.usage && data.usage.isPolicyCount) {
// in case of Count policy types reduce one from the usage count.
// kansas inits the value starting from 1.
data.usage.usage--;
}

return data;
var Places = Parse.Object.extend('Test');
var query = new Parse.Query(Places);
// query.equalTo('city', 'Thessaloniki');
query.find({
success: function(results) {
console.log('GOT:', results);
},
error: function(error) {
console.error('ERROR:', error);
}
});

return this.$http({
method: 'GET',
url: 'https://api.parse.com/1/classes/Places'
})
.then(function(res) {
console.log('GOT RES:', res);
});
};

angular.module('app')
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ gulp.task('scripts', function () {
});

gulp.task('watch', function () {
gulp.watch(['./scripts/**/*.js'], ['scripts']);
gulp.watch(['./_scripts/**/*.js'], ['scripts']);
});
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
---

<div class="home" ng-app="app" ng-controller="PlacesCtrl as placesCtrl">

<div ng-view></div>
<div class="row">
<div class="col-md-3">
<div class="name">
Expand Down

0 comments on commit 54f9488

Please sign in to comment.