3 Copyright 2016-2017, Huawei Technologies Co., Ltd.
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
19 app.factory("DataService", function($http, $log){
21 getAllData: function (value) {
22 //var value = $scope.param;
24 url: 'http://localhost:8080/POC_NodeToServletPorting_Server/?widgetType=' + value,
25 headers: {'Content-Type': 'application/json'},
27 }).then(function (response) {
28 $log.info(response.data);
33 getAllProvinceData : function() {
35 url: 'http://localhost:3000/api/getAllProvinceData',
37 headers: {'Content-Type': 'application/json'}
38 }).then(function(response){
39 //$log.info(response);
43 addProvinceData : function(provinceDetail) {
45 url: 'http://localhost:3000/api/addProvinceData',
48 headers: {'Content-Type': 'application/json '}
49 }).then(function(response){
50 console.log("Response : ");
51 $log.info(response.data);
55 deleteProvinceData : function(idList) {
57 url: 'http://localhost:3000/api/deleteProvinceData',
59 data: {'idList':idList},
60 headers: {'Content-Type': 'application/json'}
61 }).then(function(response){
62 console.log("Successfully Deleted..");
67 editProvinceData : function(provinceDetail) {
69 url: 'http://localhost:3000/api/editProvinceData',
72 headers: {'Content-Type': 'application/json'}
73 }).then(function(response){
74 console.log("Successfully Edited...");
82 app.factory('LoginService', function($http, $log) {
85 var isAuthenticated = false;
88 login : function(user) {
91 url: 'http://localhost:8081/api/signin',//http://192.168.4.161:3000/api/login
93 data: {'name':user.username, 'pswd':user.password},
94 headers: {'Content-Type': 'application/json'}
95 }).then(function(response){
97 if(response.status == 200) {
98 console.log("Success");
100 isAuthenticated = true;
104 isAuthenticated = false;
106 console.log("isAuthenticated: " + isAuthenticated);
107 return isAuthenticated;
111 isAuthenticated = false;
114 /*isAuthenticated = user.username === admin && user.password === pass;
115 return isAuthenticated;*/
117 isAuthenticated : function() {
118 return isAuthenticated;
120 registerUser: function(user){
121 console.log("New Registration: " + JSON.stringify(user));
123 url: 'http://localhost:8081/api/signup',//http://192.168.4.161:3000/api/login
125 data: {'name':user.username, 'pswd':user.password, 'email':user.email},
126 headers: {'Content-Type': 'application/json'}
127 }).then(function(response){