Skip to content

Commit

Permalink
[Add] Admin user page and admin project page of certain user
Browse files Browse the repository at this point in the history
Add and edit admin page to search information about certain user.
  • Loading branch information
Minjae77 committed Jun 6, 2018
1 parent 3dd84fb commit 4924873
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 301 deletions.
115 changes: 19 additions & 96 deletions src/app/admin/account/admin.users.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,106 +14,29 @@
limit: 7,
page: 1
};
// 더미 데이터베이스
vm.datas =
[
{
p_name: 'AngularJs',
td_name: 'AngularJs 독서',
u_name: '이창원',
startdate: '5/21',
duedate: '6/11',
done: true,
},
{
p_name: 'AngularJs',
td_name: 'AngularJs 공부하기',
u_name: '김윤지',
startdate: '5/23',
duedate: '6/14',
done: true,
},
{
p_name: 'AngularJs',
td_name: 'AngularJs 게시판 만들기',
u_name: '조건희',
startdate: '5/28',
duedate: '6/2',
done: false,
},
{
p_name: 'project A',
td_name: 'REST DOCUMENT 작성하기',
u_name: '고현수',
startdate: '5/29',
duedate: '6/12',
done: false,
},
{
p_name: 'project A',
td_name: 'DB 스키마 만들기',
u_name: '김병남',
startdate: '5/21',
duedate: '6/11',
done: true,
},
{
p_name: 'project B',
td_name: '레이아웃 작업하기',
u_name: '류민재',
startdate: '5/21',
duedate: '6/11',
done: true,
},
{
p_name: 'project B',
td_name: 'Config 파일 작성',
u_name: '오영환',
startdate: '5/21',
duedate: '6/11',
done: false,
},
];

vm.delete = (pid) => {
const cf = window.confirm('삭제하시겠습니까?');
if (cf) {
vm.pid = pid;
$http.delete('/{vm.session.uid}/project/{pid}');
alert('게시글이 삭제되었습니다.');
vm.location.reload();
}
};


// 사용자 구분
/* $http.get('/session').then(successCallback, errorCallback);
function successCallback(response){
//vm.$log.log(response);
if(response.data.auth===10) vm.state = "admin";
else if(response.data.auth<10 && response.data.auth >= 0) vm.state = "user";
$http.get('/rest/session').then((result) => {
if (result.data.auth === 1) { vm.user = 'admin'; } else if (result.data.auth === 0 && result.data.auth > 1) { vm.user = 'user'; }
});

$http.get('/rest/session').then(successCallback, errorCallback);
function successCallback(response) {
if (response.data.auth === 1) vm.state = 'admin';
else if (response.data.auth === 0 && response.data.auth > 1) vm.state = 'user';
}

function errorCallback(error) {
vm.$log.log(error, 'can not get data.');
vm.log(error, 'can not get data.');
}

// 글 목록 가져오기
$http.get('/main/1/main_post').then(function(response) {
for(var i=0; i<response.data.length; i++) {
response.data[i].updatedAt = response.data[i].updatedAt.split("T")[0];
$http.get('/rest/admin/users').then((res) => {
vm.users = res.data;
});
vm.delete = (uid) => {
const cf = window.confirm('삭제하시겠습니까?');
if (cf) {
$http.delete(`/rest/admin/user/${uid}`);
alert('해당 유저가 삭제되었습니다.');
}
vm.datas = response.data;
}); */

function remainingTodos() {
const count = vm.datas.reduce((accumulator, currentValue) => {
if (currentValue.done === false) return accumulator + 1;
return accumulator;
}, 0);

return count;
}

vm.remainingTodos = remainingTodos();
};
}
}());
63 changes: 34 additions & 29 deletions src/app/admin/account/admin.users.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<div ng-controller="AdminUsersController as adminusers">
<h2 style="font-size: 23pt; color: #ffc000">TO DO LIST</h2>
<h2 style="font-size: 23pt; color: #ffffff"> TOTAL REQUESTS: <strong>{{adminusers.datas.length}}</strong>
<div ng-controller="AdminUsersController as adminUsers">
<md-card>
<h2 style="font-size: 23pt;">&nbsp;Total Users: <strong>{{adminUsers.users.length}}</strong>
<br>
REMAINED REQUESTS: <strong>{{adminusers.remainingTodos}}</strong>
</h2>

<md-card ng-cloak>

</h2>
</md-card>
<md-card ng-cloak>
<md-card>
<md-input-container md-no-float class="md-block">
<ng-md-icon icon="search" style="margin-left:5px"></ng-md-icon>
Expand All @@ -16,36 +14,43 @@ <h2 style="font-size: 23pt; color: #ffffff"> TOTAL REQUESTS: <strong>{{adminuser

<md-table-container>
<table md-table class="table_notice">
<thead md-head md-order="adminusers.query.order">
<thead md-head md-order="adminUsers.query.order">
<tr md-row>
<th md-column md-numeric md-order-by="p_id"><span class="title_size">완료 여부</span></th>
<th md-column md-numeric md-order-by="p_id"><span class="title_size">Project</span></th>
<th md-column md-order-by="td_id"><span class="title_size">Todo</span></th>
<th md-column md-order-by="name"><span class="title_size">작성자</span></th>
<th md-column md-numeric><span class="title_size">작성일</span></th>
<th md-column md-order-by="duedate"><span class="title_size">마감일</span></th>
<th md-column md-numeric md-order-by="uid" colspan="2"><span class="title_size">ID</span></th>
<th md-column md-numeric md-order-by="name"><span class="title_size">User Name</span></th>
<th md-column md-numeric md-order-by="auth"><span class="title_size">Role</span></th>
</tr>
</thead>
<tbody md-bodylayout="row">
<tr md-row
ng-repeat="data in adminusers.datas | filter: filter.search | orderBy: noticecon.query.order | limitTo: adminusers.query.limit : (adminusers.query.page -1) * adminusers.query.limit">
<td md-cell class="breakall"><input type="checkbox" ng-model="data.done" checked="checked">
ng-repeat="user in adminUsers.users | filter: filter.search | orderBy: adminUsers.query.order | limitTo: adminUsers.query.limit : (adminUsers.query.page -1) * adminUsers.query.limit">

<td md-cell class="breakall" colspan="2">{{user.uid}}</td>
<td md-cell class="breakall">{{user.name}}</td>
<td md-cell class="breakall">
<div ng-switch="{{user.auth}}">
<div ng-switch-when="0">
Developer
</div>
</div>
<div ng-switch="{{user.auth}}">
<div ng-switch-when="1">
Admin
</div>
</div>
<div ng-switch="{{user.auth}}">
<div ng-switch-when="2">
Project Manager
</div>
</div>
</td>
<td md-cell class="breakall">{{data.p_name}}</td>
<td md-cell class="breakall">{{data.td_name}}</td>
<td md-cell class="breakall">{{data.u_name}}</td>
<td md-cell class="breakall">{{data.startdate}}</td>
<td md-cell>{{data.duedate}}</td>
<td md-cell><md-button class="md-primary" a ui-sref="modify({ modify_id: data.id })">수정</md-button>
<md-button class="md-accent" ng-click="adminusers.delete(data.id)">삭제</md-button>
<td md-cell><md-button class="md-primary" a ui-sref="adminUserModify({ modify_id: user.uid })">View</md-button>
<md-button class="md-accent" ng-click="adminUsers.delete(user.uid)">Delete</md-button>
</td>
</tr>
</tbody>
</table>

</md-table-container>
<md-table-pagination md-limit="adminusers.query.limit" md-page="adminusers.query.page"
md-total="{{adminusers.datas.length}}" md-page-select
md-boundary-links></md-table-pagination>
</md-card>
<md-table-pagination md-limit="adminUsers.query.limit" md-page="adminUsers.query.page" md-total="{{adminUsers.datas.length}}" md-page-select md-boundary-links></md-table-pagination>
</md-card>
</div>
55 changes: 55 additions & 0 deletions src/app/admin/account/admin.users.modify.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(function () {
angular
.module('pms')
.controller('AdminUsersModifyController', AdminUsersModifyController);

// admin/users 컨트롤러
function AdminUsersModifyController($log, $http, $window, $sessionStorage, $location, $stateParams) {
const vm = this;

vm.log = $log.log;
vm.stateParams = $stateParams;
vm.session = $sessionStorage.getObject('session');
vm.query = {
order: 'pid',
limit: 7,
page: 1
};
$http.get('/rest/session').then((result) => {
if (result.data.auth === 1) { vm.user = 'admin'; } else if (result.data.auth === 0 && result.data.auth > 1) { vm.user = 'user'; }
});

$http.get('/rest/session').then(successCallback, errorCallback);
function successCallback(response) {
if (response.data.auth === 1) vm.state = 'admin';
else if (response.data.auth === 0 && response.data.auth > 1) vm.state = 'user';
}

function errorCallback(error) {
vm.log(error, 'can not get data.');
}
vm.initModify = () => {
if (vm.stateParams.modify_id != null) {
// 유저 데이터 불러오기
$http.get(`/rest/admin/user/${vm.stateParams.modify_id}`).then((response) => {
if (response.data.error) {
alert('글이 존재하지 않습니다.');
}
vm.user = response.data.user;
vm.proj = response.data.project;
});
}
};
// 유저 수정
vm.modify = () => {
$http.put(`/rest/admin/user/${vm.stateParams.modify_id}`, {
uid: vm.user.uid,
name: vm.user.name,
auth: vm.user.auth,
email: vm.user.email,
ph: vm.user.ph
});
$location.path('/admin/users');
};
}
}());
64 changes: 64 additions & 0 deletions src/app/admin/account/admin.users.modify.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<div ng-controller="AdminUsersModifyController as adminModify">
<div ng-init="adminModify.initModify()">
<form ng-submit="adminModify.modify()">
<md-card>
<div>
<h3 style="text-align: center">User</h3>
<hr class="title_line">
<h2>Id</h2>
<input type="text" class="" ng-model="adminModify.user.uid" value="{{adminModify.user.uid}}">
<hr>
</div>
<div>
<h2>Name</h2>
<input type="text" class="" ng-model="adminModify.user.name" value="{{adminModify.user.name}}">
<hr>
</div>
<div>
<h2>auth</h2>
<input type="text" class="" ng-model="adminModify.user.auth" value="{{adminModify.user.auth}}">
<hr>
</div>
<div>
<h2>Email</h2>
<input type="text" class="" ng-model="adminModify.user.email" value="{{adminModify.user.email}}">
<hr>
</div>
<div>
<h2>Phone</h2>
<input type="text" class="" ng-model="adminModify.user.ph" value="{{adminModify.user.ph}}">
<hr>
</div>
</md-card>
<md-card>
<div>
<h3 style="text-align: center">Project</h3>
<hr class="title_line">
<md-table-container>
<table md-table class="table_notice">
<thead md-head md-order="adminUsers.query.order">
<tr md-row>
<th md-column md-numeric md-order-by="uid" colspan="2"><span class="table_title">ID</span></th>
<th md-column md-numeric md-order-by="name"><span class="table_title">Project Name</span></th>
</tr>
</thead>
<tbody md-bodylayout="row">
<tr md-row
ng-repeat="proj in adminModify.proj | orderBy: adminModify.query.order | limitTo: adminModify.query.limit : (adminModify.query.page -1) * adminModify.query.limit">

<td md-cell class="breakall" colspan="2">{{proj.pid}}</td>
<td md-cell class="breakall">{{proj.project.name}}</td>
<td md-cell><md-button class="md-primary" a ui-sref="adminModify({ modify_id: user.uid })">View</md-button>
</td>
</tr>
</tbody>
</table>
</md-table-container>
</div>
</md-card>
<md-card>
<md-button type="submit" class="md-raised"><i class="fa fa-edit">Edit</i></md-button>
</md-card>
</form>
</div>
</div>
Loading

0 comments on commit 4924873

Please sign in to comment.