Commit 8b8c4034 authored by đinh thị đầm's avatar đinh thị đầm

new page

parent 19c5ecee
package com.itsol.quantrivanphong.access.homepage.business; package com.itsol.quantrivanphong.access.homepage.business;
import com.itsol.quantrivanphong.access.homepage.repository.CatalogiRepository; import com.itsol.quantrivanphong.access.homepage.repository.CatalogiRepository;
import com.itsol.quantrivanphong.exception.ResourceNotFoundException;
import com.itsol.quantrivanphong.model.Catalogi; import com.itsol.quantrivanphong.model.Catalogi;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -23,4 +24,13 @@ public class CatalogiBusiness { ...@@ -23,4 +24,13 @@ public class CatalogiBusiness {
public Catalogi save(Catalogi catalogi){ public Catalogi save(Catalogi catalogi){
return catalogiRepository.save(catalogi); return catalogiRepository.save(catalogi);
} }
public String deleteCatalogi(int catalogiId){
Catalogi catalogi = catalogiRepository.findCatalogiById(catalogiId);
if(catalogi == null){
throw new ResourceNotFoundException("News" ,"newsId",catalogiId);
}
catalogiRepository.delete(catalogi);
return "ok";
}
} }
...@@ -30,9 +30,17 @@ public class CatalogiController { ...@@ -30,9 +30,17 @@ public class CatalogiController {
return catalogi; return catalogi;
} }
@PostMapping("/catalogi") @PostMapping("HR/catalogi")
public Catalogi createCatalogi(@Valid@RequestBody Catalogi catalogi) { public Catalogi createCatalogi(@Valid@RequestBody Catalogi catalogi) {
return catalogiBusiness.save(catalogi); return catalogiBusiness.save(catalogi);
} }
@DeleteMapping("HR/catalogi/{catalogiId}")
public ResponseEntity<?> deleteNews(@PathVariable (value = "catalogiId") int catalogiId) {
if(catalogiBusiness.findCatalogiById(catalogiId)== null){
throw new ResourceNotFoundException("News","newsId",catalogiId);
}
return ResponseEntity.ok(catalogiBusiness.deleteCatalogi(catalogiId));
}
} }
package com.itsol.quantrivanphong.model; package com.itsol.quantrivanphong.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -31,9 +30,9 @@ public class Catalogi { ...@@ -31,9 +30,9 @@ public class Catalogi {
private String descriptions; private String descriptions;
@JsonIgnore @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "catalogi")
@OneToMany(mappedBy = "catalogi", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private List<News> news = new ArrayList<>();
private List<News> newsList = new ArrayList<>();
} }
package com.itsol.quantrivanphong.model; package com.itsol.quantrivanphong.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.itsol.quantrivanphong.audit.DateAudit; import com.itsol.quantrivanphong.audit.DateAudit;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*; import javax.persistence.*;
...@@ -14,7 +17,7 @@ import javax.persistence.*; ...@@ -14,7 +17,7 @@ import javax.persistence.*;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@EntityListeners(AuditingEntityListener.class) @EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = {"createdAt", "updatedAt"},allowGetters = true) @JsonIgnoreProperties(value = {"createdAt", "updatedAt"}, allowGetters = true)
@Table(name = "news") @Table(name = "news")
public class News extends DateAudit { public class News extends DateAudit {
...@@ -37,16 +40,17 @@ public class News extends DateAudit { ...@@ -37,16 +40,17 @@ public class News extends DateAudit {
@Column(name = "status") @Column(name = "status")
private boolean status; private boolean status;
// @JsonIgnore
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.LAZY, optional = false)
// @JoinColumn(name = "catalogid", nullable = false) @JoinColumn(name = "catalogi_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Catalogi catalogi; private Catalogi catalogi;
// @JsonIgnore
@ManyToOne(fetch = FetchType.EAGER) @ManyToOne(fetch = FetchType.EAGER)
// @JoinColumn(name = "employeeid", nullable = false)
private Employee employee;
private Employee employee;
} }
...@@ -33,6 +33,7 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony ...@@ -33,6 +33,7 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script>
<script src="js/angular-route.js"></script> <script src="js/angular-route.js"></script>
<script src="js/angular-ui-router.min.js"></script> <script src="js/angular-ui-router.min.js"></script>
<script src="js/angular-resource.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script> <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
...@@ -45,9 +46,10 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony ...@@ -45,9 +46,10 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony
<script src="pages/issue/IssueAddControlelr.js"></script> <script src="pages/issue/IssueAddControlelr.js"></script>
<script src="pages/issue/IssueController.js"></script> <script src="pages/issue/IssueController.js"></script>
<script src="pages/issue/IssuesDetailController.js"></script> <script src="pages/issue/IssuesDetailController.js"></script>
<script src="pages/issue/IssuesDeleteController.js"></script>> <script src="pages/issue/IssuesDeleteController.js"></script>
<script src="pages/leaveform/leaveFormController.js"></script> <script src="pages/leaveform/leaveFormController.js"></script>
<script src="pages/homepage/homeController.js"></script> <script src="pages/homepage/MyHomeController.js"></script>
<script src="pages/homepage/HomeService.js"></script>
<script src="pages/timesheet/timeSheetController.js"></script> <script src="pages/timesheet/timeSheetController.js"></script>
<script src="pages/timesheet/timeSheetDetailController.js"></script> <script src="pages/timesheet/timeSheetDetailController.js"></script>
<script src="pages/leaveform/leaveFormDetailController.js"></script> <script src="pages/leaveform/leaveFormDetailController.js"></script>
...@@ -119,6 +121,7 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony ...@@ -119,6 +121,7 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony
</script> </script>
</head> </head>
<body class="cbp-spmenu-push" ng-app="myApp"> <body class="cbp-spmenu-push" ng-app="myApp">
<div ui-view="layout"></div> <div ui-view="layout"></div>
......
This diff is collapsed.
/** /**
* *
*/ */
angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(function ($stateProvider, $urlRouterProvider, $locationProvider) { angular.module("myApp", ["ngAnimate","ngResource", "ui.router", "ui.bootstrap"]).config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.hashPrefix(''); $locationProvider.hashPrefix('');
$urlRouterProvider.otherwise("/employees"); $urlRouterProvider.otherwise("/employees");
...@@ -107,13 +107,50 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -107,13 +107,50 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
}) })
.state("news",{ .state("CatagoriManagement",{
parent:'layout1', parent:'layout1',
url:"/news", url:"/management/catagori",
views:{ views:{
"content":{ "content":{
templateUrl:"pages/homepage/catagoriManagements.html", templateUrl: "pages/homepage/catagoriManagements.html",
controller:"homeController" controller: "MyHomeController"
}
}
})
.state("newsManagement",{
parent:'layout1',
url:"/management/catagori/:myCatagoriId",
params:{
myCatagoriId : null
},
views:{
"content":{
templateUrl: "pages/homepage/newsManagements.html",
controller: "MyHomeController"
}
}
})
.state("newsEditManagement",{
parent:'layout1',
url:"/management/catagori/:myCatagoriEditId/news/:myNewsEditId",
views:{
"content":{
templateUrl: "pages/homepage/newsEditManagement.html",
controller: "MyHomeController"
}
}
})
.state("newsAddManagement",{
parent:'layout1',
url:"/management/HR/:employeeId/catagori/:myCatagoriAddId/createNews",
views:{
"content":{
templateUrl: "pages/homepage/newsAddManagement.html",
controller: "MyHomeController"
} }
} }
}) })
...@@ -195,9 +232,6 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -195,9 +232,6 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
}) })
//danh sách các dự án
.state("project", { .state("project", {
parent: 'layout1', parent: 'layout1',
url: "/project", url: "/project",
...@@ -208,7 +242,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -208,7 +242,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
//thêm mới dự án
.state("addproject", { .state("addproject", {
parent: 'layout1', parent: 'layout1',
url: "/addproject", url: "/addproject",
...@@ -219,7 +253,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -219,7 +253,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
//sửa thông tin dự án
.state("editproject", { .state("editproject", {
parent: 'layout1', parent: 'layout1',
url: "/editproject/:ID", url: "/editproject/:ID",
...@@ -230,7 +264,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -230,7 +264,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
//danh sách thành viên trong nhóm dự án
.state("groupProjectByProjectId", { .state("groupProjectByProjectId", {
parent: 'layout1', parent: 'layout1',
url: "/groupProjectByProjectId/:ID", url: "/groupProjectByProjectId/:ID",
...@@ -242,7 +276,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -242,7 +276,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
//thêm thành viên vào nhóm dự án
.state("addEmployeeProject", { .state("addEmployeeProject", {
parent: 'layout1', parent: 'layout1',
url: "/addEmployeeProject", url: "/addEmployeeProject",
...@@ -253,7 +287,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -253,7 +287,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
//sửa thông tin nhân viên trong nhóm
.state("editEmployeeProject", { .state("editEmployeeProject", {
parent: 'layout1', parent: 'layout1',
url: "/editEmployeeProject/:ID", url: "/editEmployeeProject/:ID",
...@@ -264,7 +298,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -264,7 +298,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
// danh sách project vào các issues
.state("issues", { .state("issues", {
parent: 'layout1', parent: 'layout1',
url: "/issues", url: "/issues",
...@@ -275,7 +309,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -275,7 +309,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
// thêm mới issues
.state("addIssues", { .state("addIssues", {
parent: 'layout1', parent: 'layout1',
url: "/addIssues", url: "/addIssues",
...@@ -286,7 +320,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct ...@@ -286,7 +320,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
} }
} }
}) })
// thêm mới issues
.state("IssuesComment", { .state("IssuesComment", {
parent: 'layout1', parent: 'layout1',
url: "/issuescomment/:IssuesId", url: "/issuescomment/:IssuesId",
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<!-- END DUng--> <!-- END DUng-->
<li class="treeview"> <li class="treeview">
<li class="treeview"> <li class="treeview">
<a ui-sref="news"> <a ui-sref="CatagoriManagement">
<i class="fa fa-newspaper-o" aria-hidden="true"></i> <i class="fa fa-newspaper-o" aria-hidden="true"></i>
<span>News</span> <span>News</span>
</a> </a>
......
<div class="container"> <div class="container">
<table class="table"> <table class="table">
<form> <form>
<div class="form-row"> <div class="form-row">
<div class="col"> <div class="col">
<tr> <tr>
<td><label>User Name</label></td> <td><label>User Name</label></td>
<td> <td>
<input type="text" maxlength="29" ng-model="emp.username"/> <input type="text" maxlength="29" ng-model="emp.username"/>
</td> <span style="color:red" ng-show="myForm.emp.username.$dirty && myForm.emp.username.$invalid">
</tr> <span ng-show="myForm.emp.username.$error.required">Username is required.</span>
<tr> </span>
<td><label>First Name</label></td>
<td> </td>
<input type="text" maxlength="29" ng-model="emp.firstName"/> </tr>
</td> <tr>
</tr> <td><label>First Name</label></td>
<tr> <td>
<td><label>Last Name</label></td> <input type="text" maxlength="29" ng-model="emp.firstName"/>
<td> </td>
<input type="text" maxlength="29" ng-model="emp.lastName"/> </tr>
</td> <tr>
</tr> <td><label>Last Name</label></td>
<tr> <td>
<td><label id="email" for="email">Email</label></td> <input type="text" maxlength="29" ng-model="emp.lastName"/>
<td> </td>
<input class="form-check-label" type="email" maxlength="150" ng-model="emp.emailAddress"/> </tr>
</td> <tr>
</tr> <td><label id="email" for="email">Email</label></td>
<tr> <td>
<td><label>Phone</label></td> <input class="form-check-label" type="email" maxlength="150" ng-model="emp.emailAddress"/>
<td> </td>
<input type="text" maxlength="10" value="" ng-model="emp.phoneNumber"/> </tr>
</td> <tr>
</tr> <td><label>Phone</label></td>
</div> <td>
<div class="col"> <input type="text" maxlength="10" value="" ng-model="emp.phoneNumber"/>
<tr> </td>
<td><label>Education</label></td> </tr>
<td> </div>
<input type="text" ng-model="emp.education"/> <div class="col">
</td> <tr>
</tr> <td><label>Education</label></td>
<tr> <td>
<td><label>Home town</label></td> <input type="text" ng-model="emp.education"/>
<td><input type="text" ng-model="emp.homeTown"/></td> </td>
</tr> </tr>
<tr> <tr>
<td><label>Department</label></td> <td><label>Home town</label></td>
<td><input type="text" ng-model="emp.department"/></td> <td><input type="text" ng-model="emp.homeTown"/></td>
</tr> </tr>
<tr> <tr>
<td><label>Position</label></td> <td><label>Department</label></td>
<td><input type="text" ng-model="emp.position"/></td> <td><input type="text" ng-model="emp.department"/></td>
</tr> </tr>
<tr> <tr>
</div> <td><label>Position</label></td>
<td><input type="text" ng-model="emp.position"/></td>
</tr>
<tr>
</div> </div>
</form> </div>
<td></td> </form>
<td> <td></td>
<input class="btn btn-primary" type="submit" name="submit" value="submit" ng-click="save();"/> <td>
<input class="btn btn-primary" type="submit" name="clear" value="clear" ng-click=" emp = null"/> <input class="btn btn-primary" type="submit" name="submit" value="submit" ng-click="save();"/>
</td> <input class="btn btn-primary" type="submit" name="clear" value="clear" ng-click=" emp = null"/>
</tr> </td>
</table> </tr>
</table>
</div> </div>
\ No newline at end of file
angular.module("myApp").factory('News', function ($resource) { angular.module("myApp").factory('News', function ($resource) {
return $resource('http://localhost:8080/api/news/:id', {id: '@myNewsId'},{ return $resource('http://localhost:8081/api/news/:id', {id: '@myNewsId'},{
'get': { 'get': {
method: 'GET', method: 'GET',
isArray: false isArray: false
...@@ -9,11 +9,11 @@ angular.module("myApp").factory('News', function ($resource) { ...@@ -9,11 +9,11 @@ angular.module("myApp").factory('News', function ($resource) {
}); });
angular.module('myApp').factory('Catagories', function ($resource) { angular.module('myApp').factory('Catagories', function ($resource) {
return $resource('http://localhost:8080/api/catalogies/:id', {id: '@myCatagoriesId'}); return $resource('http://localhost:8081/api/catalogies/:id', {id: '@myCatagoriesId'});
}); });
angular.module('myApp').factory('LatestNews', function ($resource) { angular.module('myApp').factory('LatestNews', function ($resource) {
return $resource('http://localhost:8080/api/catalogi/:id/latestNews', {id: '@CatagoriesId'},{ return $resource('http://localhost:8081/api/catalogi/:id/latestNews', {id: '@CatagoriesId'},{
'get': { 'get': {
method: 'GET', method: 'GET',
isArray: true isArray: true
...@@ -22,7 +22,7 @@ angular.module('myApp').factory('LatestNews', function ($resource) { ...@@ -22,7 +22,7 @@ angular.module('myApp').factory('LatestNews', function ($resource) {
}); });
angular.module('myApp').factory('NewsByCatagori', function ($resource) { angular.module('myApp').factory('NewsByCatagori', function ($resource) {
return $resource('http://localhost:8080/api/catalogi/:id/news', {id: '@catagoriesId'},{ return $resource('http://localhost:8081/api/catalogi/:id/news', {id: '@catagoriesId'},{
'get': { 'get': {
method: 'GET', method: 'GET',
isArray: true isArray: true
......
angular.module("myApp").controller('MyHomeController', function ($scope,$http, $state,News, $window,$stateParams,Catagories,LatestNews) {
$scope.catagories = Catagories.query();
$scope.currentPage = 1
,$scope.numPerPage = 6
,$scope.maxSize = 5;
$scope.catagoriDetail = Catagories.get({}, {myCatagoriesId: $stateParams.catagoriId}).$promise.then(
function (value) {
$scope.todos = value.news;
$scope.catagori = value;
$scope.numPages = function () {
return Math.ceil($scope.todos.length / $scope.numPerPage);
};
console.log( $scope.todos.length);
$scope.$watch('currentPage + numPerPage', function () {
var begin = (($scope.currentPage - 1) * $scope.numPerPage)
, end = begin + $scope.numPerPage;
$scope.myNews = $scope.todos.slice(begin, end);
});
},
function (error) {
console.log()
}
);
$scope.newsById = News.get({}, {myNewsId: $stateParams.Id1});
$scope.show = function(id){
$scope.newestNews = LatestNews.get({}, {CatagoriesId: id});
};
$scope.catagoriById = Catagories.get({}, {myCatagoriesId: $stateParams.myCatagoriId});
//Delete News
$scope.deleteNews = function(newsId) {
if (confirm("Delete?")) {
$http({
method: 'DELETE',
url: 'http://localhost:8080/api/HR/news/' + newsId,
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("delete OK");
$state.reload();
}, function (data, status) {
$state.reload();
});
}
};
//Edit news
$scope.newsEditById = News.get({}, {myNewsId: $stateParams.myNewsEditId});
$scope.editNews = function(newsEditById) {
if(confirm("Update?")) {
$http({
method: 'PUT',
url: 'http://localhost:8081/api/HR/news/' + newsEditById.id,
data: angular.toJson(newsEditById),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriEditId});
}, function (data, status) {
console.log(status);
});
}
};
//Add News
$scope.createNews = function(newsAdd) {
if(confirm("Add?")) {
$http({
method: 'POST',
url: 'http://localhost:8081/api/HR/'+ $stateParams.employeeId+'/catalogies/' + $stateParams.myCatagoriAddId+'/news',
data: angular.toJson(newsAdd),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriAddId});
}, function (data, status) {
console.log(status);
});
}
};
});
\ No newline at end of file
angular.module("myApp").controller('homeController', function ($scope,$http, $state,News, $window,$stateParams,Catagories,LatestNews) {
$scope.catagories = Catagories.query();
$scope.currentPage = 1
,$scope.numPerPage = 6
,$scope.maxSize = 5;
$scope.catagoriDetail = Catagories.get({}, {myCatagoriesId: $stateParams.catagoriId}).$promise.then(
function (value) {
$scope.todos = value.news;
$scope.catagori = value;
$scope.numPages = function () {
return Math.ceil($scope.todos.length / $scope.numPerPage);
};
console.log( $scope.todos.length);
$scope.$watch('currentPage + numPerPage', function () {
var begin = (($scope.currentPage - 1) * $scope.numPerPage)
, end = begin + $scope.numPerPage;
$scope.myNews = $scope.todos.slice(begin, end);
});
},
function (error) {
console.log()
}
);
$scope.newsById = News.get({}, {myNewsId: $stateParams.Id1});
$scope.show = function(id){
$scope.newestNews = LatestNews.get({}, {CatagoriesId: id});
};
$scope.catagoriById = Catagories.get({}, {myCatagoriesId: $stateParams.myCatagoriId});
//Delete News
$scope.deleteNews = function(newsId) {
if (confirm("Delete?")) {
$http({
method: 'DELETE',
url: 'http://localhost:8080/api/HR/news/' + newsId,
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("delete OK");
$state.reload();
}, function (data, status) {
$state.reload();
});
}
};
//Edit news
$scope.newsEditById = News.get({}, {myNewsId: $stateParams.myNewsEditId});
$scope.editNews = function(newsEditById) {
if(confirm("Update?")) {
$http({
method: 'PUT',
url: 'http://localhost:8080/api/HR/news/' + newsEditById.id,
data: angular.toJson(newsEditById),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriEditId});
}, function (data, status) {
console.log(status);
});
}
};
//Add News
$scope.createNews = function(newsAdd) {
if(confirm("Add?")) {
$http({
method: 'POST',
url: 'http://localhost:8080/api/HR/'+ $stateParams.employeeId+'/catalogies/' + $stateParams.myCatagoriAddId+'/news',
data: angular.toJson(newsAdd),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriAddId});
}, function (data, status) {
console.log(status);
});
}
};
});
\ No newline at end of file
...@@ -12,25 +12,25 @@ ...@@ -12,25 +12,25 @@
<tr> <tr>
<div ng-if="catagoriById.name == 'Office'"> <div ng-if="catagoriById.name == 'Office'">
<a href="#/management/catagori/4" style="float:left"><< Back </a> <a href="#/management/catagori/5" style="float:left"><< Back </a>
</div> </div>
<div ng-if="catagoriById.name == 'Outdoor Activiy'"> <div ng-if="catagoriById.name == 'Outdoor Activity'">
<a href="#/management/catagori/1" style="float:left"><< Back </a> <a href="#/management/catagori/1" style="float:left"><< Back </a>
</div> </div>
<div ng-if="catagoriById.name == 'Projects'"> <div ng-if="catagoriById.name == 'Projects'">
<a href="#/management/catagori/2" style="float:left"><< Back</a> <a href="#/management/catagori/2" style="float:left"><< Back</a>
</div> </div>
<div ng-if="catagoriById.name == 'Recruitments'"> <div ng-if="catagoriById.name == 'Recruitments'">
<a href="#/management/catagori/3" style="float:left"><< Back </a> <a href="#/management/catagori/4" style="float:left"><< Back </a>
</div> </div>
<div ng-if="catagoriById.name == 'Office'"> <div ng-if="catagoriById.name == 'Office'">
<a href="#/management/catagori/2" style="float:right">Next >> </a> <a href="#/management/catagori/2" style="float:right">Next >> </a>
</div> </div>
<div ng-if="catagoriById.name == 'Outdoor Activiy'"> <div ng-if="catagoriById.name == 'Outdoor Activity'">
<a href="#/management/catagori/3" style="float:right">Next >></a> <a href="#/management/catagori/4" style="float:right">Next >></a>
</div> </div>
<div ng-if="catagoriById.name == 'Projects'"> <div ng-if="catagoriById.name == 'Projects'">
<a href="#/management/catagori/4" style="float:right">Next >></a> <a href="#/management/catagori/5" style="float:right">Next >></a>
</div> </div>
<div ng-if="catagoriById.name == 'Recruitments'"> <div ng-if="catagoriById.name == 'Recruitments'">
<a href="#/management/catagori/1" style="float:right">Next >></a> <a href="#/management/catagori/1" style="float:right">Next >></a>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment