PageSourceSearch

https://gradana.co.id/assets/js/controllers/header.js

js gradana.co.id collected 2026-10-07 21:52:56 UTC 6,088 bytes, 137 lines download raw bytes

1'use strict';
2
3/* Controllers */
4
5angular
6    .module('app')
7    .controller('HeaderCtrl', HeaderController);
8    HeaderController.$inject = ['$scope', '$rootScope', 'ServerService', 'SettingsService', '$state', '$http'];
9
10    function HeaderController($scope, $rootScope ,ServerService, SettingsService, $state, $http){
11        var currentUser = SettingsService.GetCredentials();
12        $scope.currentUser = currentUser;
13
14        if (currentUser) {
15            if (currentUser.user) {
16                if(currentUser.user.role === 'admin'){
17                    // $scope.userRole = 'Customer Service'
18                    $scope.userRole = 'Admin'
19                } else if(currentUser.user.role === 'superAdmin'){
20                    $scope.userRole = 'Super Admin'
21                } else if(currentUser.user.role === 'creditAnalyst'){
22                    $scope.userRole = 'Credit Analyst'
23                } else if(currentUser.user.role === 'borrower'){
24                    $scope.userRole = 'Peminjam'
25                } else if(currentUser.user.role === 'lender'){
26                    $scope.userRole = 'Pendana'
27                } else if(currentUser.user.role === 'agent'){
28                    $scope.userRole = 'Agen'
29                }
30            }
31        }
32
33        // $scope.baseImageURL = "https://s3-ap-southeast-1.amazonaws.com/gradana/";
34        // $scope.baseImageURL = "https://gradana-backup-test.oss-ap-southeast-5.aliyuncs.com/";
35        $scope.baseImageURL = "https://gradana-prod.oss-ap-southeast-5.aliyuncs.com/";
36
37        $rootScope.$on('$locationChangeSuccess',function() {
38            currentUser = SettingsService.GetCredentials();
39            $scope.currentUser = currentUser;
40
41            if (currentUser) {
42                if (currentUser.user) {
43                    if(currentUser.user.role === 'admin'){
44                        $scope.userRole = 'Admin'
45                        // $scope.userRole = 'Customer Service'
46                    } else if(currentUser.user.role === 'superAdmin'){
47                        $scope.userRole = 'Super Admin'
48                    } else if(currentUser.user.role === 'creditAnalyst'){
49                        $scope.userRole = 'Credit Analyst'
50                    } else if(currentUser.user.role === 'borrower'){
51                        $scope.userRole = 'Borrower'
52                    } else if(currentUser.user.role === 'lender'){
53                        $scope.userRole = 'Lender'
54                    } else if(currentUser.user.role === 'Agent'){
55                        $scope.userRole = 'Agent'
56                    }
57                }
58            }
59        });
60        // $scope.getUser = function() {
61        //     ServerService.GetUserById(currentUser, currentUser.user._id, function(response) {
62        //         if(response) {
63        //             if(response.statusCode === 200){
64        //                 if(response.data != null){
65        //                     $scope.user = response.data;
66        //                 }
67        //             }else{
68        //                 SweetAlert.swal(response.status, response.message, 'error')
69        //             }
70        //         } else {
71        //             SweetAlert.swal('Tidak ada tanggapan dari server', 'Coba refresh halaman atau cek koneksi internet', 'error');
72        //         }
73        //     })
74        // }
75
76        // $scope.getUser();
77
78        $scope.logoutButton = function() {
79            ServerService.Logout(currentUser, function(response){
80                SettingsService.ClearLocalStorage();
81                SettingsService.ClearCredentials();
82                window.sessionStorage.clear();
83                if($scope.currentUser.user.role == "admin" || $scope.currentUser.user.role == "superAdmin" || $scope.currentUser.user.role == "creditAnalyst"){
84                    $state.go('admin_access.login')
85                }else{
86                    let roleLast = 'agent';
87                    if($scope.currentUser.user.role === 'lender'){
88                        roleLast = 'pendana';
89                    }else if($scope.currentUser.user.role === 'borrower'){
90                        roleLast = 'peminjam';
91                    }
92                    $state.go('access.login', { role : roleLast })
93                }
94            });
95        }
96
97        $scope.profileButton = function(userId) {
98            if(currentUser.user.role == 'borrower') {
99                $state.go("app.borrower_profile", { userId })
100            }else if(currentUser.user.role == 'lender'){
101                $state.go("app.lender_profile", { userId })
102            }else if(currentUser.user.role == 'agent'){
103                $state.go("app.agent_profile", { userId })
104            }else if(currentUser.user.role == 'admin' || currentUser.user.role == 'superAdmin' || currentUser.user.role == 'creditAnalyst'){
105                $state.go("admin.profile", { userId })
106            }
107        }
108
109        function loadLanguageContent(language) {
110            $http.get(`assets/i18n/header/${language}.json`).then(function (response) {
111                $scope.textContent = response.data;
112            }, function (error) {
113                console.error("Error loading language file:", error);
114            });
115        }
116    
117        $scope.currentLanguage = localStorage.getItem("language") || "id";
118    
119        $scope.$watch(function () {
120            return localStorage.getItem("language");
121        }, function (newValue) {
122            if (newValue) {
123                $scope.currentLanguage = newValue;
124                loadLanguageContent(newValue);
125                console.log("Current Language changed to:", $scope.currentLanguage);
126            }
127        });
128
129        $scope.currentLanguage = localStorage.getItem("language") || "id";
130        loadLanguageContent($scope.currentLanguage);
131    
132        $scope.changeLanguage = function () {
133            $scope.currentLanguage = $scope.currentLanguage === 'id' ? 'en' : 'id';
134            loadLanguageContent($scope.currentLanguage);
135            localStorage.setItem("language", $scope.currentLanguage);
136        };
137    }

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.