github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/static/app/events/events.controller.js (about)

     1  (function(){
     2  	'use strict';
     3  
     4  	angular
     5  		.module('shipyard.events')
     6  		.controller('EventsController', EventsController);
     7  
     8  	EventsController.$inject = ['events', 'EventsService'];
     9  	function EventsController(events, EventsService) {
    10              var vm = this;
    11              vm.events = events;
    12              vm.refresh = refresh;
    13              vm.showClearEventsDialog = showClearEventsDialog;
    14              vm.clearEvents = clearEvents;
    15  
    16              function showClearEventsDialog() {
    17                  $('#clear-modal').modal('show');
    18              };
    19  
    20              function clearEvents() {
    21                  EventsService.remove().$promise
    22                      .then(function(data) {
    23                          refresh();
    24                      }, function(data) {
    25                          vm.error = data;
    26                      });
    27                  vm.error = "";
    28              }
    29  
    30              function refresh() {
    31                  EventsService.query().$promise
    32                      .then(function(data) {
    33                          vm.events = data; 
    34                      }, function(data) {
    35                          vm.error = data;
    36                      });
    37                  vm.error = "";
    38              }
    39  	}
    40  })();