Example #1
0
import Ember from 'ember';

export default Ember.Route.extend({
  model(){
    return this.store.findAll('friend');
  }
});
import Ember from 'ember';
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin, {
  model() {
    return this.store.find('cup');
  }
});
Example #3
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function () {
    return this.store.find('step');
  }
});
Example #4
0
import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    return this.store.findRecord('blog', params.blog_id);
  },
  actions: {
    update(blog, params) {
      console.log('hi rob');
      Object.keys(params).forEach(function(key) {
        if(params[key]!==undefined) {
          blog.set(key,params[key]);
        }
      });
      blog.save();
      this.transitionTo('blog');
    },
    destroyBlog(blog) {
      rental.destroyRecord();
      this.transitionTo('index');
    }
  }
});
Example #5
0
import Ember from 'ember';
import SaveModelMixin from '../../mixins/save-model-mixin';

export default Ember.Route.extend(SaveModelMixin, {
  model: function() {
    return this.store.createRecord('bloque');
  }
});
import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return Ember.RSVP.hash({
      users: this.store.findAll('user'),
      games: this.store.findAll('game')
    });
  },
  actions: {
    save(params) {
      var newUser = this.store.createRecord('user', params);
      newUser.save();
      this.transitionTo('index');
    }
  }
});
Example #7
0
import Ember from 'ember';

export default Ember.Route.extend({
  // if the user is logged out, go to the home page
  beforeModel() {
    if (!this.get('session.currentUser')) {
      this.transitionTo('home');
    }
  }
});
Example #8
0
import Ember from 'ember';

export
default Ember.Route.extend({

    model: function() {

        var user = this.modelFor('user');  // look up modelFor!
        // console.log('followers of', user.id);

        return this.store.find('user', {operation: 'followers', userId: user.id});
    }
});
import Ember from 'ember';

export
default Ember.Route.extend({
	model: function(){
    return this.store.find('invoiced');
	},
  
  renderTemplate: function() {
    this.render('nav', {
      into: 'application',
      outlet: 'nav',
      controller: 'nav'
    });

    this.render();
  },

  setupController: function(controller) {

  }
});
Example #10
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    var account = this.get('store').createRecord({type: 'account', kind: 'user'});
    var credential = this.get('store').createRecord({type: 'password'});

    return Ember.Object.create({
      account: account,
      credential: credential
    });
  },
});
Example #11
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function () {
    return [];
  }
});
import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    var model;
    model = this.get('store').createRecord('credentials');
    return model;
  }
});
Example #13
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function(params) {
    return this.store.find('porpoiseflow/processDef')
    .then((processDefs) => processDefs.sortBy('name'));
  }
});
import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    // TODO - findRecord('object', params.resourceId, params.predicateId, params.rdfObjectId) ?
    return this.store.findRecord('resource', params.resourceId)
      .then(resource => {
        return resource
          .get('predicates').findBy('id', params.predicateId)
          .get('objects').findBy('id', params.rdfObjectId)
      });
  }
});
Example #15
0
import Ember from 'ember';

export default Ember.Route.extend({
  beforeModel: function() {
    this.csrf.fetchToken();
  },
  actions: {
    openModal: function(modalName, model) {
      this.controllerFor(modalName).set('model', model);
      return this.render(modalName, {
        into: 'application',
        outlet: 'modal'
      });
    },
    closeModal: function() {
      return this.disconnectOutlet({
        outlet: 'modal',
        parentView: 'application'
      });
    }
  }
});
import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
    accessDenied: function() {
      this.transitionTo('signin');
    },
    signin: function(){
      this.get('session').open('arcgis-oauth-bearer')
        .then((authorization) => {
          Ember.debug('AUTH SUCCESS: ', authorization);
          //transition to some secured route or... so whatever is needed
          //this.controller.transitionToRoute('secure');
        })
        .catch((err)=>{
          Ember.debug('AUTH ERROR: ', err);
        });
    },
    signout: function() {
      //kill the session...
      this.get('session').close();
      //transition to the home page
      this.transitionTo('index');

    }
  }
});
Example #17
0
import Ember from 'ember';

export default Ember.Route.extend({
  ajax: Ember.inject.service(),

  model() {
    let { user_id } = this.paramsFor('user');
    return this.get('ajax').request(`/api/users/${user_id}/followers`);
  },

  setupController(controller, model) {
    this._super(...arguments);
    controller.set('user', this.modelFor('user'));
    controller.set('followers', model.followers);
  },
});
Example #18
0
import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, {

    model() {
        return Ember.RSVP.hash({
            posts: this.store.findAll('post'),
            cUser: this.get('session.currentUser')
        });
    },

    actions: {
        createPost(model) {
            let post = this.store.createRecord('post', model);
            post.save();
        }


    }
});
Example #19
0
import Ember from 'ember';

export default Ember.Route.extend({
    model(){
        const access_token = this.get('current-user.session.access_token');

        this.store.queryRecord('venue/items', { access_token: access_token });
    }
});
Example #20
0
export default Ember.Route.extend({
  favorites: Ember.inject.service('favorites'),
  model(params) {
    return this.store.findRecord('question', params.question_id);
  },
  actions: {
    saveAnswer(params) {
      var newAnswer = this.store.createRecord('answer', params);
      var question = params.question;
      question.get('answers').addObject(newAnswer);
      newAnswer.save().then(function(){
        return question.save();
      });
      this.transitionTo('question');
    },
    destroyQuestion(question) {
      question.destroyRecord();
      this.transitionTo('index');
    },
    update(question, params) {
      Object.keys(params).forEach(function(key) {
        if(params[key]!==undefined) {
          question.set(key,params[key]);
        }
      });
      question.save();
      this.transitionTo('question');
    }
  }
});
Example #21
0
export default Ember.Route.extend({
  titleToken: 'Restaurants / Administration',

  listItems: null,
  itemPages: [],
  currentPageNumber: 1,
  itemsPerPage:20,
  filter: Filter.create(),
  notification: Notification.create(),

  exit: function(){
    this.set('notification.visible', false);
  },

  getItems: function(){
    var self = this;

    //Set additional data
    this.set('filter.itemsPerPage', this.get('itemsPerPage'));
    this.set('filter.pageNumber', this.get('currentPageNumber'));
    var data = JSON.stringify(self.get('filter'));

    $.ajax({ //No return here
      url: "/api/v1/admin/getFilteredRestaurants",
      type: "POST",
      data: data,
      processData: false,
      async:false, //Need to wait
      contentType: "application/json; charset=UTF-8",
    }).fail(function(data) {
      console.log(data);
    }).then(function(data) {
      //Set info about number of pages
      var numberOfPages = JSON.parse(data.numberOfRestaurantPages);
      self.set('itemPages', []);
      for(var i = 1; i <= numberOfPages; i++){
        self.get('itemPages').push(i);
      }

      //Set fetched items
      self.set('listItems', data.restaurants);

    });
  },

  model: function(){
    var self = this;

    //Get all items
    this.getItems();

    //Scroll to top
    $("html, body").animate({ scrollTop: 0 }, 500);

    //Return model to template
    return Ember.RSVP.hash({
      listItems: self.get('listItems'),
      itemPages: self.get('itemPages'),
      filter: self.get('filter'),
      notification: self.get('notification')
    });
  },

  actions: {
    changePage: function(pageNumber){
      this.set('currentPageNumber', pageNumber);
      this.refresh();
    },
    editItem: function(id){
      this.transitionTo('admin.restaurants.add.info', id);
    },
    deleteItem: function(id){
      var self = this;

      $.ajax({ //No return here
        url: "/api/v1/admin/deleteRestaurant",
        type: "POST",
        data: '{"id": '+id+'}',
        processData: false,
        async:false, //Need to wait
        contentType: "application/json; charset=UTF-8",
      }).fail(function(data) {
        console.log(data);
      }).then(function(data) {
        //Display notification
        self.set('notification.visible', true);
        self.set('notification.classStyle', 'alert-success');
        self.set('notification.text', 'Successful remove!');
        self.refresh();
      });
    },
    searchTextChanged: function(){
      this.refresh();
    }
  }
});
Example #22
0
import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
  return this.store.findRecord('question', params.question_id);
},

  actions: {
      saveAnswer(params) {
        var newAnswer = this.store.createRecord('answer', params);
        var question = params.question;
        question.get('answers').addObject(newAnswer);
        newAnswer.save().then(function() {
          return question.save();
        });
        this.transitionTo('question', params.question.id);
      }
    }
  });
Example #23
0
import Ember from 'ember';

export default Ember.Route.extend({  
    model() {
        return this.store.filter('todo', function(todo) {
            return !todo.get('complete');
        });
    },
    renderTemplate(controller, model) {
        this.render('todos/index', {
            model: model
        });
    }
});
Example #24
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function(params) {
    return this.store.findAll('contact').findBy('id', params.contact_id);
  }
});
Example #25
0
import Ember from 'ember';

export default Ember.Route.extend({
  model(params) {
    return this.store.findRecord('table', params.table_id);
  }
});
Example #26
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    return this.store.findAll('permission');
  },
  actions: {
    // action to trigger authentication with Facebook
    authenticateWithFacebook: function() {
      this.controller.set('invokeDialog', true);
      this.get('session').authenticate('authenticator:facebook', this);
    }
  }
});
Example #27
0
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin, {
  actions: {
    remove: function(model) {
      if(confirm('Are you sure?')) {
        model.destroyRecord();
      }
    }
  },
  model: function() {
    return this.store.find('role');
  }
});
Example #28
0
import Ember from 'ember';

export default Ember.Route.extend({
  beforeModel() {
    this.transitionTo('pets.new');
  }
});
Example #29
0
import Ember from 'ember';

export default Ember.Route.extend({
  model: function(){
    return this.store.findAll('artist');
  }
});
Example #30
0
import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
    refresh: function() {
      this.refresh();
    },
  },

  model: function() {
    return this.get('store').rawRequest({url: 'volumes'}).then((volumes) => {
      var keys = Object.keys(volumes);
      var out = [];

      keys.forEach((key) => {
        out.push(volumes[key]);
      });

      return out;
    });
  }
});