blob: a8b93f50f2d52433760f38e98c5c0c5f46040a4a [file] [log] [blame]
Matteo Scandolo388795a2016-02-22 09:57:55 -08001(function () {
2 'use strict';
Matteo Scandolo04564952016-02-24 11:22:48 -08003 angular.module('xos.diagnostic')
Matteo Scandolo574c73f2016-03-01 17:08:45 -08004 .directive('selectSubscriberModal', function(){
Matteo Scandolo388795a2016-02-22 09:57:55 -08005 return {
6 scope: {
7 subscribers: '=',
8 open: '='
9 },
10 bindToController: true,
11 restrict: 'E',
Matteo Scandolo574c73f2016-03-01 17:08:45 -080012 templateUrl: 'templates/select-subscriber-modal.tpl.html',
Matteo Scandolo388795a2016-02-22 09:57:55 -080013 controllerAs: 'vm',
14 controller: function($rootScope){
15
16 this.close = () => {
17 this.open = false;
18 };
19
20 this.select = (subscriber) => {
21 $rootScope.$emit('subscriber.selected', subscriber);
22 this.close();
23 };
24 }
25 };
Matteo Scandolo574c73f2016-03-01 17:08:45 -080026 })
27 .directive('subscriberStatusModal', function(){
28 return {
29 scope: {
30 open: '=',
31 subscriber: '='
32 },
33 bindToController: true,
34 restrict: 'E',
35 templateUrl: 'templates/subscriber-status-modal.tpl.html',
36 controllerAs: 'vm',
37 controller: function($log, $scope){
38
39 // mock until api
40 $scope.$watch(() => this.subscriber, (subscriber) => {
41 if(subscriber){
42 subscriber.status = 'enabled';
43 }
44 });
45
46 this.close = () => {
47 this.open = false;
48 };
49
50 this.setStatus = (status) => {
51 this.subscriber.status = status;
52 $log.info(`Set subscriber status to: ${status}`);
53 };
54 }
55 };
Matteo Scandolo388795a2016-02-22 09:57:55 -080056 });
57})();