24ae3ef203d11d7b8c94c934ad8263c985c13632
[vnfsdk/refrepo.git] /
1 /*
2
3     Copyright 2016-2017, Huawei Technologies Co., Ltd.
4
5     Licensed under the Apache License, Version 2.0 (the "License");
6     you may not use this file except in compliance with the License.
7     You may obtain a copy of the License at
8
9             http://www.apache.org/licenses/LICENSE-2.0
10
11     Unless required by applicable law or agreed to in writing, software
12     distributed under the License is distributed on an "AS IS" BASIS,
13     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14     See the License for the specific language governing permissions and
15     limitations under the License.
16
17 */
18 (function () {
19         'use strict';
20
21         /**
22         * @ngdoc function
23         * @name app.controller:LayoutCtrl
24         * @description
25         * # LayoutCtrl
26         * Controller of the app
27         */
28
29         angular
30                 .module('vnfmarket')
31                 .controller('LayoutCtrl', Layout);
32
33         Layout.$inject = ['$mdSidenav', '$cookies', '$state', '$mdToast', '$mdDialog'];
34
35         /*
36         * recommend
37         * Using function declarations
38         * and bindable members up top.
39         */
40
41         function Layout($mdSidenav, $cookies, $state, $mdToast, $mdDialog ) {
42                 /*jshint validthis: true */
43                 var vm = this;
44
45                 vm.toggleSidenav = function (menuId) {
46                         $mdSidenav(menuId).toggle();
47                 };
48
49                 vm.changePassword = function () {
50                         $mdToast.show(
51                                 $mdToast.simple()
52                                 .content('Password clicked!')
53                                 .position('top right')
54                                 .hideDelay(2000)
55                         );
56                 };
57
58                 vm.changeProfile = function (ev) {
59                         $mdDialog.show({
60                                 controller: DialogController,
61                                 templateUrl: 'tabDialog.tmpl.html',
62                                 parent: angular.element(document.body),
63                                 targetEvent: ev,
64                                 clickOutsideToClose:true
65                         })
66                         .then(function(answer) {
67                                 $mdToast.show(
68                                         $mdToast.simple()
69                                         .content('You said the information was "' + answer + '".')
70                                         .position('top right')
71                                         .hideDelay(2000)
72                                 );
73
74                         }, function() {
75                                 $mdToast.show(
76                                         $mdToast.simple()
77                                         .content('You cancelled the dialog.')
78                                         .position('top right')
79                                         .hideDelay(2000)
80                                 );
81                         });
82
83                         function DialogController($scope, $mdDialog) {
84                                 $scope.hide = function() {
85                                         $mdDialog.hide();
86                                 };
87
88                                 $scope.cancel = function() {
89                                         $mdDialog.cancel();
90                                 };
91
92                                 $scope.answer = function(answer) {
93                                         $mdDialog.hide(answer);
94                                 };
95                         }
96                 };
97
98
99                 vm.logOut = function () {
100
101                         alert('Implement your Function Here');
102                         // $cookies.put('dev_appserver_login', ' ');
103                         //$state.go('out', {}, {reload: true});
104
105                 };
106
107                 var originatorEv;
108                 vm.openMenu = function ($mdOpenMenu, ev) {
109                         originatorEv = ev;
110                         $mdOpenMenu(ev);
111                 };
112
113         }
114
115 })();