Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('starter.controllers', [])
- .controller('AppCtrl', function($scope, $ionicModal, $timeout, $ionicLoading, $http) {
- // With the new view caching in Ionic, Controllers are only called
- // when they are recreated or on app start, instead of every page change.
- // To listen for when this page is active (for example, to refresh data),
- // listen for the $ionicView.enter event:
- //$scope.$on('$ionicView.enter', function(e) {
- //});
- // Form data for the login modal
- $scope.loginData = {};
- // Create the login modal that we will use later
- $ionicModal.fromTemplateUrl('templates/login.html', {
- scope: $scope
- }).then(function(modal) {
- $scope.modal = modal;
- });
- // Triggered in the login modal to close it
- $scope.closeLogin = function() {
- $scope.modal.hide();
- };
- // Open the login modal
- $scope.login = function() {
- $scope.modal.show();
- };
- // Perform the login action when the user submits the login form
- $scope.doLogin = function() {
- console.log('Doing login', $scope.loginData);
- // Simulate a login delay. Remove this and replace with your login
- // code if using a login system
- $timeout(function() {
- $scope.closeLogin();
- }, 1000);
- };
- $scope.saveConn = function() {
- // $scope.config = {};
- // $scope.username = this.config.username;
- // $scope.password = this.config.password;
- $ionicLoading.show({
- template: 'Checking server connection...',
- showBackdrop: true
- });
- // var somplak = {
- // method: 'POST',
- // url: 'http://mobiloutlet.id/panel/Api/Login',
- // headers: {
- // 'Content-Type': 'application/json'
- // },
- // timeout: 5000,
- // data: $scope.config,
- // };
- $http({
- url: 'http://mobiloutlet.id/panel/Api/Login',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- data: {username:this.username,password:this.password}
- }).
- then(function(response) {
- // $ionicLoading.hide();
- if (response.Success == 'true') {
- $location.path("/home");
- } else {
- $ionicLoading.show({
- template: 'Username and Password Missmatch',
- showBackdrop: true
- });
- }
- });
- }
- })
- .controller('HomeCtrl', function($scope, $ionicSideMenuDelegate, $http, $ionicLoading, $location, $timeout, $cordovaFileTransfer, $cordovaCamera, $cordovaFile, $cordovaDevice, $ionicPopup, $cordovaActionSheet) {
- $ionicSideMenuDelegate.canDragContent(false);
- $http.get('http://mobiloutlet.id/panel/Api/getVehicleBrands').then(function(result){
- $scope.items = result.data.content;
- console.log(result.data.content);
- });
- $http.get('http://mobiloutlet.id/panel/Api/getVehicleCategory').then(function(result){
- $scope.category = result.data.content;
- console.log(result.data.content);
- });
- $scope.saveProspect = function(config) {
- $scope.config = {};
- $scope.config.VehicleProspectBrandId = config.VehicleProspectBrandId;
- $scope.config.VehicleProspectCategoryId = config.VehicleProspectCategoryId;
- $scope.config.VehicleProspectName = config.VehicleProspectName;
- $scope.config.VehicleProspectModels = config.VehicleProspectModels;
- $scope.config.VehicleProspectColor = config.VehicleProspectColor;
- $scope.config.VehicleProspectTransmision = config.VehicleProspectTransmision;
- $scope.config.VehicleProspectBuildYear = config.VehicleProspectBuildYear;
- $scope.config.VehicleProspectLastKm = config.VehicleProspectLastKm;
- $scope.config.VehicleProspectPrice = config.VehicleProspectPrice;
- $scope.config.VehicleProspectOfferPrice = config.VehicleProspectOfferPrice;
- $scope.config.VehicleProspectSalesName = config.VehicleProspectSalesName;
- $scope.config.VehicleProspectSalesPhone = config.VehicleProspectSalesPhone;
- $scope.config.VehicleProspectSalesDealer = config.VehicleProspectSalesDealer;
- $scope.config.VehicleProspectCreateDate = config.VehicleProspectCreateDate;
- $scope.config.VehicleProspectUserId = '30';
- $scope.config.VehiclePhotoProspectPhotoPath = config.file;
- $ionicLoading.show({
- template: 'Menyimpan...',
- showBackdrop: true
- });
- var somplak = {
- method: 'POST',
- url: 'http://mobiloutlet.id/panel/Api/saveProspect',
- headers: {
- 'Content-Type': 'application/json'
- },
- timeout: 5000,
- data: $scope.config,
- };
- console.log($scope.config);
- $http(somplak).
- then(function(response) {
- if (response.data.Success == true) {
- $ionicLoading.show({
- template: 'Data Tersimpan',
- showBackdrop: true
- });
- $location.path("app/data");
- $ionicLoading.hide();
- } else {
- console.log(response.data.Success);
- $ionicLoading.show({
- template: 'Error Menyimpan Data',
- showBackdrop: true
- });
- $location.path("app/home");
- }
- });
- }
- })
- .controller('PlaylistsCtrl', function($scope) {
- $scope.playlists = [
- { title: 'Reggae', id: 1 },
- { title: 'Chill', id: 2 },
- { title: 'Dubstep', id: 3 },
- { title: 'Indie', id: 4 },
- { title: 'Rap', id: 5 },
- { title: 'Cowbell', id: 6 }
- ];
- })
- .controller('PlaylistCtrl', function($scope, $stateParams) {
- })
- .controller('LoginCtrl', function($scope, $ionicModal, $timeout, $ionicLoading, $http, $location) {
- event.preventDefault();
- $scope.saveConn = function(config) {
- $scope.config = {};
- $ionicLoading.show({
- template: 'Checking server connection...',
- showBackdrop: true
- });
- console.log($scope.config);
- $http({
- url: 'http://mobiloutlet.id/panel/Api/Login',
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- timeout: 5000,
- data: {username:config.username,password:config.password}
- }).
- then(function(response) {
- if (response.data.hasil == 'benar') {
- $ionicLoading.hide();
- $location.path("app/home");
- } else {
- // $ionicLoading.hide();
- console.log(response.data.Success);
- $ionicLoading.show({
- template: 'Username atau Password Salah',
- showBackdrop: true
- });
- // $location.path("app/home");
- }
- // }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement