update alarm ui and fix bug

This commit is contained in:
denz
2016-04-26 17:00:44 +09:00
parent ccebbeab80
commit de1a27751f
13 changed files with 518 additions and 423 deletions
@@ -9,8 +9,7 @@
* @class
*/
pinpointApp.constant('AlarmUtilServiceConfig', {
"hideClass": "hide-me",
"hasNotEditClass": "has-not-edit"
"hideClass": "hide-me"
});
pinpointApp.service( "AlarmUtilService", [ "AlarmUtilServiceConfig", "AlarmAjaxService", "globalConfig", function ( $config, $ajaxService, globalConfig ) {
@@ -23,15 +22,6 @@
arguments[i].addClass( $config.hideClass );
}
};
// this.showLoading = function( $elLoading, isEdit ) {
// $elLoading[ isEdit ? "removeClass" : "addClass" ]( $config.hasNotEditClass );
// $elLoading.removeClass( $config.hideClass );
// };
this.showAlert = function( $elAlert, message ) {
$elAlert.find(".message").html( message ).end().removeClass( $config.hideClass ).animate({
height: 300
}, 500, function() {});
};
this.sendCRUD = function( funcName, data, successCallback, failCallback ) {
if ( ( angular.isUndefined( data ) || data === "" ) ) {
data = {
@@ -46,66 +36,6 @@
successCallback( resultData );
}
});
/*
switch( funcName ) {
case "getGroupMemberListInGroup":
successCallback([{
memberId: 1,
department: "Paas",
name: "정민우"
},{
memberId: 2,
department: "Paas",
name: "정현길"
}]);
break;
case "removeMemberInGroup":
successCallback();
break;
case "getUserGroupList":
successCallback([{
number: 1,
id: "pinpoint-monitor-group"
}, {
number: 2,
id: "pinpoint-dev-group"
}]);
break;
case "getPinpointUserList":
successCallback([{
userId: 1,
department: "PaaS",
name: "김성관"
},{
userId: 2,
department: "PaaS",
name: "문성호"
},{
userId: 3,
department: "PaaS",
name: "송효종"
},{
userId: 4,
department: "PaaS",
name: "정민우"
}]);
break;
case "createUserGroup":
successCallback({
id: data.id,
number: parseInt( Math.random() * 10000 )
});
break;
case "updateUserGroup":
successCallback();
break;
case "removeUserGroup":
successCallback();
break;
default:
break;
}
*/
};
this.setTotal = function( $elTotal, n ) {
$elTotal.html( "(" + n + ")");
@@ -113,7 +43,7 @@
this.hasDuplicateItem = function( list, func ) {
var len = list.length;
var has = false;
for( var i = 0 ; i < list.length ; i++ ) {
for( var i = 0 ; i < len ; i++ ) {
if ( func( list[i] ) ) {
has = true;
break;
@@ -131,5 +61,8 @@
this.extractID = function( $el ) {
return $el.prop("id").split("_")[1];
};
this.getNode = function( $event, tagName ) {
return $( $event.toElement || $event.target ).parents( tagName );
};
}]);
})(jQuery);
@@ -31,9 +31,6 @@
function cancelPreviousWork() {
RemoveGroupMember.cancelAction( alarmUtilService, $workingNode );
}
function getNode( $event ) {
return $( $event.toElement || $event.target ).parents("li");
}
function showAlert( oServerError ) {
$elAlert.find( ".message" ).html( oServerError.errorMessage );
alarmUtilService.hide( $elLoading );
@@ -42,6 +39,7 @@
function initData() {
oGroupMemberList = [];
scope.groupMemberList = [];
alarmUtilService.setTotal( $elTotal, oGroupMemberList.length );
}
function hasUser( userID ) {
return $( "#" + scope.prefix + userID ).length > 0;
@@ -66,10 +64,10 @@
// remove process
scope.onRemoveGroupMember = function( $event ) {
if ( $workingNode !== null && isSameNode( getNode( $event ) ) === false ) {
if ( $workingNode !== null && isSameNode( alarmUtilService.getNode( $event, "li" ) ) === false ) {
cancelPreviousWork();
}
$workingNode = getNode( $event );
$workingNode = alarmUtilService.getNode( $event, "li" );
RemoveGroupMember.onAction( alarmUtilService, $workingNode );
};
scope.onApplyRemoveGroupMember = function() {
@@ -96,7 +94,15 @@
// sort
scope.onSortGroupMember = function() {
console.log( "sort group member ");
if ( currentUserGroupId === "" ) return;
var oSortedGroupMemberList = [];
var len = oGroupMemberList.length - 1;
for( var j = 0, i = len ; i >= 0 ; j++, i-- ) {
oSortedGroupMemberList[j] = oGroupMemberList[i];
}
oGroupMemberList = oSortedGroupMemberList;
scope.groupMemberList = oGroupMemberList;
};
// other
@@ -23,14 +23,22 @@
var $elTotal = $element.find(".total");
var $elLoading = $element.find(".some-loading");
var $elAlert = $element.find(".some-alert");
var $elSearch = $element.find(".some-list-search input");
var $workingNode = null;
var aEditNode = $element.find(".new-group").toArray().map(function( el ) {
return $(el);
});
var bIsLoaded = false;
var bIsCreate = true; // update
var bIsRemoving = false;
var oPinpointUserList = [];
var oGroupMemberList = [];
scope.pinpointUserList = [];
scope.isAllowedCreate = globalConfig.editUserInfo;
scope.bIsAllowedCreate = globalConfig.editUserInfo;
function cancelPreviousWork() {
AddPinpointUser.cancelAction( hideEditArea );
RemovePinpointUser.cancelAction( alarmUtilService, $workingNode );
}
function showAlert( oServerError ) {
$elAlert.find( ".message" ).html( oServerError.errorMessage );
alarmUtilService.hide( $elLoading );
@@ -47,9 +55,6 @@
alarmUtilService.hide( $elLoading );
}, showAlert );
}
function getNode( $event ) {
return $( $event.toElement || $event.target ).parents("li");
}
function getTotal() {
return oGroupMemberList.length + "/" + oPinpointUserList.length;
}
@@ -60,206 +65,183 @@
}
}
}
function showAddArea() {
var $ul = $elWrapper.find("ul");
var len = aEditNode.length - 1;
for( var i = len ; i >= 0 ; i-- ) {
$ul.prepend( aEditNode[i] );
}
aEditNode[0].find("input").attr("disabled", "");
alarmUtilService.hide( aEditNode[len].find( CONSTS.DIV_EDIT ) );
alarmUtilService.show( aEditNode[len].find( CONSTS.DIV_ADD ) );
$.each( aEditNode, function( index, $el ) {
alarmUtilService.show( $el );
});
aEditNode[0].focus();
}
function showEditArea( oPinpointUser ) {
var len = aEditNode.length - 1;
for( var i = len ; i >= 0 ; i-- ) {
$workingNode.after( aEditNode[i] );
}
aEditNode[0].find("input").val( oPinpointUser.userId );
aEditNode[1].find("input").val( oPinpointUser.name );
aEditNode[2].find("input").val( oPinpointUser.department );
aEditNode[3].find("input").val( oPinpointUser.phoneNumber );
aEditNode[4].find("input").val( oPinpointUser.email );
aEditNode[0].find("input").attr("disabled", "disabled");
/*
var $elUL = $element.find(".some-list-content ul");
$elUL.on("click", function( $event ) {
var $target = $( $event.toElement || $event.target );
var tagName = $target.get(0).tagName.toLowerCase();
var $li = $target.parents("li");
alarmUtilService.hide( aEditNode[len].find( CONSTS.DIV_ADD ) );
alarmUtilService.show( aEditNode[len].find( CONSTS.DIV_EDIT ) );
$.each( aEditNode, function( index, $el ) {
alarmUtilService.show( $el );
});
aEditNode[0].find("input").focus();
}
function hideEditArea() {
$.each( aEditNode, function( index, $el ) {
alarmUtilService.hide( $el );
$el.find("input").val("");
});
}
function getNewPinpointUser() {
var userId = $.trim( aEditNode[0].find("input").val() );
var userName = $.trim( aEditNode[1].find("input").val() );
var userDepartment = $.trim( aEditNode[2].find("input").val() );
var userPhone = $.trim( aEditNode[3].find("input").val() );
var userEmail = $.trim( aEditNode[4].find("input").val() );
if ( tagName == "button" ) {
if ( $target.hasClass("confirm-cancel") ) {
removeCancel( $li );
} else if ( $target.hasClass("confirm-cancel") ) {
removeConfirm( $li );
} else if ( $target.hasClass("move") ) {
moveUser( $li );
} else if ( $target.hasClass("edit-user") ) {
scope.onUpdate( $event );
}
} else if ( tagName == "span" ) {
if ( $target.hasClass("remove") ) {
if ( isRemoving === true ) return;
isRemoving = true;
$li.addClass("remove").find("span.remove").hide().end().find("button.move").addClass("disabled").end().append($removeTemplate);
} else if ( $target.hasClass("contents") ) {
} else if( $target.hasClass("glyphicon-edit") ) {
scope.onUpdate( $event );
} else if ( $target.hasClass("glyphicon-remove") ) {
removeCancel( $li );
} else if ( $target.hasClass("glyphicon-ok") ) {
removeConfirm( $li );
} else if ( $target.hasClass("glyphicon-chevron-left") ) {
moveUser( $li );
}
}
});
var oPinpointUser = {
"userId": userId,
"name": userName,
"department": userDepartment,
"phoneNumber": userPhone,
"email": userEmail
};
return oPinpointUser;
}
function validateEmail( email ) {
var reg = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
return reg.test(email);
}
function validatePhone( phone ) {
var reg = /^\d+$/;
return reg.test(phone);
}
function isSameNode( $current ) {
return alarmUtilService.extractID( $workingNode ) === alarmUtilService.extractID( $current );
}
function searchPinpointUser( userId ) {
for( var i = 0 ; i < oPinpointUserList.length ; i++ ) {
if ( oPinpointUserList[i].userId === userId ) {
return oPinpointUserList[i];
}
}
return null;
}
// add
scope.onAddPinpointUser = function() {
if ( AddPinpointUser.isOn() ) {
return;
}
cancelPreviousWork();
AddPinpointUser.onAction( function() {
showAddArea();
});
};
scope.onCancelAddPinpointUser = function() {
AddPinpointUser.cancelAction( function() {
hideEditArea();
});
};
scope.onApplyAddPinpointUser = function() {
applyAddPinpointUser();
};
function applyAddPinpointUser() {
AddPinpointUser.applyAction( alarmUtilService, getNewPinpointUser(), $elLoading, function( oNewPinpointUser ) {
analyticsService.send( analyticsService.CONST.MAIN, analyticsService.CONST.CLK_ALARM_CREATE_PINPOINT_USER );
oPinpointUserList.push( oNewPinpointUser );
scope.pinpointUserList = oPinpointUserList;
hideEditArea();
alarmUtilService.setTotal( $elTotal, oPinpointUserList.length );
}, showAlert );
}
// remove
scope.onRemovePinpointUser = function( $event ) {
var $node = alarmUtilService.getNode( $event, "li" );
if ( $workingNode !== null && isSameNode( $node ) === false ) {
cancelPreviousWork( $node );
}
$workingNode = $node;
RemovePinpointUser.onAction( alarmUtilService, $workingNode );
};
scope.onCancelRemovePinpointUser = function() {
RemovePinpointUser.cancelAction( alarmUtilService, $workingNode );
};
scope.onApplyRemovePinpointUser = function() {
RemovePinpointUser.applyAction( alarmUtilService, $workingNode, $elLoading, function( userId ) {
for( var i = 0 ; i < oPinpointUserList.length ; i++ ) {
if ( oPinpointUserList[i].userId == userId ) {
oPinpointUserList.splice(i, 1);
break;
}
}
scope.pinpointUserList = oPinpointUserList;
alarmUtilService.setTotal( $elTotal, oPinpointUserList.length );
alarmBroadcastService.sendUserRemoved( userId );
}, showAlert );
};
// update
scope.onUpdatePinpointUser = function( $event ) {
cancelPreviousWork();
$workingNode = alarmUtilService.getNode( $event, "li" );
UpdatePinpointUser.onAction( alarmUtilService, $workingNode, function( userId ) {
showEditArea( searchPinpointUser( userId ) );
});
};
scope.onCancelUpdatePinpointUser = function() {
UpdatePinpointUser.cancelAction( alarmUtilService, $workingNode, hideEditArea );
};
scope.onApplyUpdatePinpointUser = function() {
UpdatePinpointUser.applyAction( alarmUtilService, getNewPinpointUser(), $workingNode, $elLoading, function( oPinpointUser ) {
function reset() {
scope.onCancelEdit();
alarmUtilService.unsetFilterBackground( $elWrapper );
$elSearchInput.val("");
}
function moveUser( $el ) {
alarmUtilService.showLoading( $elLoading, false );
alarmBroadcastService.sendUserAdd( searchUser( alarmUtilService.extractID( $el ) ) );
}
function removeConfirm( $el ) {
alarmUtilService.showLoading( $elLoading, false );
removeUser( alarmUtilService.extractID( $el ) );
}
function removeCancel( $el ) {
$el
.find("span.right").remove().end()
.find("span.remove").show().end()
.find("button.move").removeClass("disabled").end()
.removeClass("remove");
isRemoving = false;
}
function createUser( userId, userName, userDepartment, userPhone, userEmail ) {
var oNewUser = {
"userId": userId,
"name": userName,
"department": userDepartment,
"phoneNumber": userPhone,
"email": userEmail
};
alarmUtilService.sendCRUD( "createPinpointUser", oNewUser, function( resultData ) {
alarmUtilService.hide( $elLoading, $elEdit );
$elSearchType.val( "userName" );
$elSearchInput.val( userName );
scope.onSearch();
}, function(errorData) {}, $elAlert );
}
function updateUser( userId, userName, userDepartment, userPhone, userEmail ) {
var oUpdateUser = {
"userId": userId,
"name": userName,
"department": userDepartment,
"phoneNumber": userPhone,
"email": userEmail
};
alarmUtilService.sendCRUD( "updatePinpointUser", oUpdateUser, function( resultData ) {
for( var i = 0 ; i < pinpointUserList.length ; i++ ) {
if ( pinpointUserList[i].userId == userId ) {
pinpointUserList[i].name = userName;
pinpointUserList[i].department = userDepartment;
pinpointUserList[i].phoneNumber = userPhone;
pinpointUserList[i].email = userEmail;
}
}
alarmUtilService.hide( $elLoading, $elEdit );
alarmBroadcastService.sendUserUpdated( oUpdateUser );
}, function( errorData ) {}, $elAlert );
}
function removeUser( userId ) {
alarmUtilService.sendCRUD( "removePinpointUser", { "userId": userId }, function( resultData ) {
scope.$apply(function() {
for( var i = 0 ; i < pinpointUserList.length ; i++ ) {
if ( pinpointUserList[i].userId == userId ) {
pinpointUserList.splice(i, 1);
break;
}
}
});
alarmUtilService.setTotal( $elTotal, pinpointUserList.length );
alarmUtilService.hide( $elLoading );
isRemoving = false;
alarmBroadcastService.sendUserRemoved( userId );
}, function( errorData ) {}, $elAlert );
}
function validateEmail( email ) {
var reg = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
return reg.test(email);
}
function validatePhone( phone ) {
var reg = /^\d+$/;
return reg.test(phone);
}
for( var i = 0 ; i < oPinpointUserList.length ; i++ ) {
if ( oPinpointUserList[i].userId == oPinpointUser.userId ) {
oPinpointUserList[i].name = oPinpointUser.name;
oPinpointUserList[i].department = oPinpointUser.department;
oPinpointUserList[i].phoneNumber = oPinpointUser.phone;
oPinpointUserList[i].email = oPinpointUser.email;
break;
}
}
scope.pinpointUserList = oPinpointUserList;
alarmBroadcastService.sendUserUpdated( oPinpointUser );
}, showAlert );
};
scope.onSearchKeydown = function( $event ) {
if ( $event.keyCode == 13 ) { // Enter
scope.onSearch();
} else if ( $event.keyCode == 27 ) { // ESC
$event.stopPropagation();
}
};
scope.onSearch = function() {
cancelPreviousWork();
var query = $.trim( $elSearch.val() );
scope.onCreate = function() {
if ( isRemoving === true ) return;
isCreate = true;
$elEditGuide.html( "Create new pinpoint user" );
$elEditInputUserID.prop("disabled", "");
$elEditInputUserID.val("");
$elEditInputName.val("");
$elEditInputDepartment.val("");
$elEditInputPhone.val("");
$elEditInputEmail.val("");
alarmUtilService.show( $elEdit );
$elEditInputUserID.focus();
};
scope.onUpdate = function($event) {
if ( isRemoving === true ) return;
isCreate = false;
var $el = $( $event.toElement || $event.target ).parents("li");
var oUser = searchUser( alarmUtilService.extractID( $el ) );
$elEditGuide.html( "Update pinpoint user data." );
$elEditInputUserID.prop("disabled", "disabled");
$elEditInputUserID.val( oUser.userId );
$elEditInputName.val( oUser.name );
$elEditInputDepartment.val( oUser.department );
$elEditInputPhone.val( oUser.phoneNumber );
$elEditInputEmail.val( oUser.email );
alarmUtilService.show( $elEdit );
$elEditInputName.focus().select();
};
scope.onInputEdit = function($event) {
if ( $event.keyCode == 13 ) { // Enter
scope.onApplyEdit();
} else if ( $event.keyCode == 27 ) { // ESC
scope.onCancelEdit();
$event.stopPropagation();
}
};
scope.onCancelEdit = function() {
alarmUtilService.hide( $elEdit );
};
scope.onApplyEdit = function() {
var userId = $.trim( $elEditInputUserID.val() );
var userName = $.trim( $elEditInputName.val() );
var userDepartment = $.trim( $elEditInputDepartment.val() );
var userPhone = $.trim( $elEditInputPhone.val() );
var userEmail = $.trim( $elEditInputEmail.val() );
if ( userId === "" || userName === "" ) {
alarmUtilService.showLoading( $elLoading, true );
alarmUtilService.showAlert( $elAlert, "You must input user id and user name.");
return;
}
alarmUtilService.showLoading( $elLoading, true );
if ( alarmUtilService.hasDuplicateItem( pinpointUserList, function( pinpointUser ) {
return pinpointUser.userId == userId;
}) && isCreate === true) {
alarmUtilService.showAlert( $elAlert, "Exist a same user id in the lists." );
return;
}
if ( validatePhone( userPhone ) === false ) {
alarmUtilService.showAlert( $elAlert, "You can only input numbers." );
return;
}
if ( validateEmail( userEmail ) === false ) {
alarmUtilService.showAlert( $elAlert, "Invalid email format." );
return;
}
if ( isCreate ) {
analyticsService.send( analyticsService.CONST.MAIN, analyticsService.CONST.CLK_ALARM_CREATE_PINPOINT_USER );
createUser( userId, userName, userDepartment, userPhone, userEmail );
} else {
updateUser( userId, userName, userDepartment, userPhone, userEmail );
}
};
*/
if ( query.length < 3 ) {
$elSearch.focus();
return;
}
alarmUtilService.show( $elLoading );
analyticsService.send( analyticsService.CONST.MAIN, analyticsService.CONST.CLK_ALARM_FILTER_PINPOINT_USER );
loadData({ "userName": query });
// { "department" :query }
};
scope.checkUser = function( $event ) {
alarmUtilService.show( $elLoading );
var $node = getNode( $event );
var $node = alarmUtilService.getNode( $event, "li" );
var userId = alarmUtilService.extractID( $node );
if ( $node.find("input").get(0).checked ) {
alarmBroadcastService.sendUserAdd( getUser( userId ) );
@@ -281,6 +263,7 @@
scope.$apply(function() {
scope.pinpointUserList = oPinpointUserList;
});
alarmUtilService.setTotal( $elTotal, getTotal() );
});
scope.$on("alarmPinpointUser.configuration.groupLoaded", function( event, list ) {
$elWrapper.removeClass( "_disable-check" );
@@ -295,6 +278,7 @@
}
});
scope.pinpointUserList = oPinpointUserList;
alarmUtilService.setTotal( $elTotal, getTotal() );
});
scope.$on("alarmPinpointUser.configuration.selectNone", function() {
$elWrapper.addClass( "_disable-check" );
@@ -303,22 +287,165 @@
});
oGroupMemberList = [];
scope.pinpointUserList = oPinpointUserList;
alarmUtilService.setTotal( $elTotal, getTotal() );
});
scope.$on("alarmPinpointUser.configuration.addUserCallback", function( event, bSuccess ) {
if ( bSuccess === false ) {
scope.$on("alarmPinpointUser.configuration.addUserCallback", function( event, list ) {
if ( list.length > oGroupMemberList.length ) {
//success
} else {
//fail
}
oGroupMemberList = list;
alarmUtilService.setTotal( $elTotal, getTotal() );
alarmUtilService.hide( $elLoading );
});
scope.onCloseAlert = function() {
alarmUtilService.closeAlert( $elAlert, $elLoading );
};
scope.$on("alarmPinpointUser.configuration.load", function( event, department ) {
cancelPreviousWork();
if ( bIsLoaded === false ) {
loadData( angular.isUndefined( department ) ? {} : { "department": department } );
loadData( { "department": "OxygenTF" } );
// loadData( angular.isUndefined( department ) ? {} : { "department": department } );
}
});
}
};
}]);
var CONSTS = {
INPUT_USERID_AND_NAME: "Input user id and name",
INPUT_PHONE_OR_EMAIL: "Input phone number or email",
YOU_CAN_ONLY_INPUT_NUMBERS: "You can only input numbers",
INVALID_EMAIL_FORMAT: "Invalid email format.",
DIV_NORMAL: "div._normal",
DIV_REMOVE: "div._remove",
DIV_ADD: "div._add",
DIV_EDIT: "div._edit"
};
var AddPinpointUser = {
_bIng: false,
isOn: function() {
return this._bIng;
},
onAction: function( cb ) {
this._bIng = true;
cb();
},
cancelAction: function( cbCancel ) {
if ( this._bIng === true ) {
cbCancel();
this._bIng = false;
}
},
applyAction: function( alarmUtilService, oNewPinpointUser, $elLoading, cbSuccess, cbFail ) {
var self = this;
alarmUtilService.show( $elLoading );
if ( oNewPinpointUser.userId === "" || oNewPinpointUser.name === "" ) {
cbFail({ errorMessage: CONSTS.INPUT_USERID_AND_NAME });
return;
}
if ( oNewPinpointUser.phoneNumber === "" && oNewPinpointUser.email === "" ) {
cbFail({ errorMessage: CONSTS.INPUT_PHONE_OR_EMAIL });
return;
}
if ( oNewPinpointUser.phoneNumber !== "" && validatePhone( oNewPinpointUser.phoneNumber ) ) {
cbFail({ errorMessage: CONSTS.YOU_CAN_ONLY_INPUT_NUMBERS });
return;
}
if ( oNewPinpointUser.email !== "" && validateEmail( oNewPinpointUser.email ) ) {
cbFail({ errorMessage: CONSTS.INVALID_EMAIL_FORMAT });
return;
}
alarmUtilService.sendCRUD( "createPinpointUser", oNewPinpointUser, function( oServerData ) {
oNewPinpointUser.number = oServerData.number;
cbSuccess( oNewPinpointUser );
self.cancelAction( function() {} );
alarmUtilService.hide( $elLoading );
}, function( oServerError ) {
cbFail( oServerError );
});
}
};
var RemovePinpointUser = {
_bIng: false,
isOn: function () {
return this._bIng;
},
onAction: function ( alarmUtilService, $node ) {
this._bIng = true;
$node.addClass("remove");
alarmUtilService.hide( $node.find( CONSTS.DIV_NORMAL ) );
alarmUtilService.show( $node.find( CONSTS.DIV_REMOVE ) );
},
cancelAction: function ( alarmUtilService, $node ) {
if ( this._bIng === true ) {
$node.removeClass("remove");
alarmUtilService.hide($node.find( CONSTS.DIV_REMOVE ));
alarmUtilService.show($node.find( CONSTS.DIV_NORMAL ));
this._bIng = false;
}
},
applyAction: function (alarmUtilService, $node, $elLoading, cbSuccess, cbFail) {
var self = this;
var userId = alarmUtilService.extractID( $node );
alarmUtilService.sendCRUD( "removePinpointUser", { "userId": userId }, function( oServerData ) {
cbSuccess( userId );
self.cancel( alarmUtilService, $node );
alarmUtilService.hide( $elLoading );
}, function( oServerError ) {
cbFail( oServerError );
});
}
};
var UpdatePinpointUser = {
_bIng: false,
isOn: function () {
return this._bIng;
},
onAction: function ( alarmUtilService, $node, cb ) {
this._bIng = true;
alarmUtilService.hide( $node );
cb( alarmUtilService.extractID( $node ) );
},
cancelAction: function( alarmUtilService, $node, cbCancel ) {
if ( this._bIng === true ) {
cbCancel();
alarmUtilService.show( $node );
this._bIng = false;
}
},
applyAction: function (alarmUtilService, oPinpointUser, $node, $elLoading, cbSuccess, cbFail) {
var self = this;
alarmUtilService.show($elLoading);
if ( oPinpointUser.name === "" ) {
cbFail({ errorMessage: CONSTS.INPUT_USERID_AND_NAME });
return;
}
if ( oPinpointUser.phoneNumber === "" && oPinpointUser.email === "" ) {
cbFail({ errorMessage: CONSTS.INPUT_PHONE_OR_EMAIL });
return;
}
if ( oPinpointUser.phoneNumber !== "" && validatePhone( oPinpointUser.phoneNumber ) ) {
cbFail({ errorMessage: CONSTS.YOU_CAN_ONLY_INPUT_NUMBERS });
return;
}
if ( oPinpointUser.email !== "" && validateEmail( oPinpointUser.email ) ) {
cbFail({ errorMessage: CONSTS.INVALID_EMAIL_FORMAT });
return;
}
alarmUtilService.sendCRUD( "updatePinpointUser", oPinpointUser, function( oServerData ) {
self.cancelAction( alarmUtilService, $node, function () {});
cbSuccess( oPinpointUser );
alarmUtilService.hide($elLoading);
}, function( oServerError ) {
cbFail( oServerError );
} );
}
}
})(jQuery);
@@ -32,8 +32,8 @@
scope.ruleSets = [];
function cancelPreviousWork() {
AddAlarm.cancelAction( alarmUtilService, aEditNodes );
RemoveAlarm.cancelAction( alarmUtilService, $workingNode );
AddAlarm.cancelAction( hideEditArea );
RemoveAlarm.cancelAction( alarmUtilService, $workingNode, hideEditArea );
UpdateAlarm.cancelAction( alarmUtilService, $workingNode, aEditNodes );
}
function isSameNode( $current ) {
@@ -109,6 +109,7 @@
}).on("change", function (e) {});
}
function showAddArea() {
$elWrapper.find("tbody").prepend( aEditNodes[1] ).prepend( aEditNodes[0] );
alarmUtilService.hide( aEditNodes[0].find( CONSTS.DIV_EDIT ) );
alarmUtilService.show( aEditNodes[0].find( CONSTS.DIV_ADD ) );
$.each( aEditNodes, function( index, $el ) {
@@ -168,9 +169,6 @@
}
return oRule;
}
function getNode( $event ) {
return $( $event.toElement || $event.target ).parents("tr");
}
function searchRule( ruleId ) {
for( var i = 0 ; i < oRuleList.length ; i++ ) {
if ( oRuleList[i].ruleId == ruleId ) {
@@ -192,9 +190,8 @@
}
cancelPreviousWork();
AddAlarm.onAction( function() {
$elWrapper.find("tbody").prepend( aEditNodes[1] ).prepend( aEditNodes[0] );
showAddArea();
} );
});
};
scope.onApplyAddAlarm = function() {
AddAlarm.applyAction( alarmUtilService, getNewRule(), $elLoading, function( application, rule ) {
@@ -210,12 +207,10 @@
}, showAlert );
};
scope.onCancelAddAlarm = function() {
AddAlarm.cancelAction( function() {
hideEditArea();
});
AddAlarm.cancelAction( hideEditArea );
};
scope.onRemoveAlarm = function( $event ) {
var $node = getNode( $event );
var $node = alarmUtilService.getNode( $event, "tr" );
if ( $workingNode !== null && isSameNode( $node ) === false ) {
cancelPreviousWork( $node );
}
@@ -239,16 +234,14 @@
};
scope.onUpdateAlarm = function( $event ) {
cancelPreviousWork();
$workingNode = getNode( $event );
$workingNode = alarmUtilService.getNode( $event, "tr" );
UpdateAlarm.onAction( alarmUtilService, $workingNode, function( ruleId ) {
$workingNode.after( aEditNodes[1] ).after( aEditNodes[0] );
showEditArea( searchRule( ruleId ) );
});
};
scope.onCancelUpdateAlarm = function() {
UpdateAlarm.cancelAction( alarmUtilService, $workingNode, function() {
hideEditArea();
});
UpdateAlarm.cancelAction( alarmUtilService, $workingNode, hideEditArea );
};
scope.onApplyUpdateAlarm = function() {
UpdateAlarm.applyAction( alarmUtilService, getNewRule( alarmUtilService.extractID( $workingNode ) ), $workingNode, $elLoading, function( ruleId, application, rule ) {
@@ -350,11 +343,13 @@
_bIng: false,
onAction: function( alarmUtilService, $node ) {
this._bIng = true;
$node.addClass("remove");
alarmUtilService.hide( $node.find( CONSTS.DIV_NORMAL ) );
alarmUtilService.show( $node.find( CONSTS.DIV_REMOVE ) );
},
cancelAction: function( alarmUtilService, $node ) {
if ( this._bIng === true ) {
$node.removeClass("remove");
alarmUtilService.hide($node.find( CONSTS.DIV_REMOVE ));
alarmUtilService.show($node.find( CONSTS.DIV_NORMAL ));
this._bIng = false;
@@ -43,11 +43,14 @@
function loadData( sParam ) {
alarmUtilService.show( $elLoading );
alarmUtilService.sendCRUD( "getUserGroupList", sParam, function( aServerData ) {
bIsLoaded = true;
oUserGroupList = scope.userGroupList = aServerData;
alarmUtilService.setTotal( $elTotal, oUserGroupList.length );
alarmBroadcastService.sendSelectionEmpty();
if ( bIsLoaded === false ) {
alarmBroadcastService.sendLoadPinpointUser();
}
bIsLoaded = true;
alarmUtilService.hide( $elLoading );
alarmBroadcastService.sendLoadPinpointUser();
}, showAlert );
}
function selectGroup( $el ) {
@@ -71,15 +74,12 @@
UpdateUserGroup.cancelAction( alarmUtilService, $workingNode );
RemoveUserGroup.cancelAction( alarmUtilService, $workingNode );
}
function getNode( $event ) {
return $( $event.toElement || $event.target ).parents("li");
}
function showAlert( oServerError ) {
$elAlert.find( ".message" ).html( oServerError.errorMessage );
alarmUtilService.hide( $elLoading );
alarmUtilService.show( $elAlert );
}
// search
scope.onSearch = function() {
alarmUtilService.show( $elLoading );
cancelPreviousWork();
@@ -90,7 +90,7 @@
return;
}
analyticsService.send( analyticsService.CONST.MAIN, analyticsService.CONST.CLK_ALARM_FILTER_USER_GROUP );
loadData( query );
loadData( { "userGroupId": query } );
};
// add process
@@ -120,7 +120,7 @@
// remove process
scope.onRemoveUserGroup = function( $event ) {
var $node = getNode( $event );
var $node = alarmUtilService.getNode( $event, "li" );
if ( $workingNode !== null && isSameNode( $node ) === false ) {
cancelPreviousWork( $node );
}
@@ -148,7 +148,7 @@
// update process
scope.onUpdateUserGroup = function( $event ) {
cancelPreviousWork();
$workingNode = getNode( $event );
$workingNode = alarmUtilService.getNode( $event, "li" );
UpdateUserGroup.onAction( alarmUtilService, $workingNode );
};
scope.onCancelUpdateUserGroup = function() {
@@ -158,9 +158,9 @@
applyUpdateUserGroup();
};
function applyUpdateUserGroup() {
UpdateUserGroup.applyAction( alarmUtilService, $workingNode, $elLoading, function( groupName ) {
UpdateUserGroup.applyAction( alarmUtilService, $workingNode, $elLoading, function( groupNumber, groupName ) {
return alarmUtilService.hasDuplicateItem( oUserGroupList, function( userGroup ) {
return userGroup.id == groupName;
return ( ( userGroup.number != groupNumber ) && userGroup.id == groupName ) || ( userGroup.number == groupNumber && userGroup.id == groupName );
});
}, function( groupNumber, groupName ) {
analyticsService.send( analyticsService.CONST.MAIN, analyticsService.CONST.CLK_ALARM_CREATE_USER_GROUP );
@@ -174,6 +174,14 @@
}
// key down
scope.onSearchKeydown = function( $event ) {
if ( $event.keyCode == 13 ) { // Enter
scope.onSearch();
} else if ( $event.keyCode == 27 ) { // ESC
$elSearchInput.val("");
$event.stopPropagation();
}
};
scope.onAddUserGroupKeydown = function( $event ) {
if ( $event.keyCode == 13 ) { // Enter
applyAddUserGroup();
@@ -203,8 +211,8 @@
}
]);
var CONSTS = {
MIN_GROUPNAME_LENGTH : 4,
ENTER_AT_LEAST: "Enter at least 4 letters to search",
MIN_GROUPNAME_LENGTH : 3,
ENTER_AT_LEAST: "Enter at least 3 letters to search",
EXIST_A_SAME: "Exist a same group name",
NEW_GROUP: "New Group",
DIV_NORMAL: "div._normal",
@@ -226,7 +234,7 @@
if ( this._bIng === true ) {
this._bIng = false;
alarmUtilService.hide( $newNode );
$newNode.find( "input" ).attr( "placeholder", CONSTS.NEW_GROUP ).val( "" );
$newNode.removeClass( "blink-blink" ).find( "input" ).attr( "placeholder", CONSTS.NEW_GROUP ).val( "" );
}
},
applyAction: function( alarmUtilService, $newNode, $elLoading, cbSuccess, cbFail ) {
@@ -234,7 +242,7 @@
var groupId = $newNode.find("input").val();
if ( groupId.length < CONSTS.MIN_GROUPNAME_LENGTH ) {
alarmUtilService.hide( $elLoading );
$newNode.find( "input" ).attr( "placeholder", CONSTS.ENTER_AT_LEAST ).val( "" ).focus();
$newNode.addClass( "blink-blink" ).find( "input" ).attr( "placeholder", CONSTS.ENTER_AT_LEAST ).val( "" ).focus();
return;
}
alarmUtilService.sendCRUD( "createUserGroup", { "id": groupId }, function( oServerData ) {
@@ -251,11 +259,13 @@
_bIng: false,
onAction: function( alarmUtilService, $node ) {
this._bIng = true;
$node.addClass("remove");
alarmUtilService.hide( $node.find( CONSTS.DIV_NORMAL ) );
alarmUtilService.show( $node.find( CONSTS.DIV_REMOVE ) );
},
cancelAction: function( alarmUtilService, $node ) {
if ( this._bIng === true ) {
$node.removeClass("remove");
alarmUtilService.hide($node.find( CONSTS.DIV_REMOVE ));
alarmUtilService.show($node.find( CONSTS.DIV_NORMAL ));
this._bIng = false;
@@ -278,6 +288,7 @@
_bIng: false,
onAction: function( alarmUtilService, $node ) {
this._bIng = true;
$node.addClass("edit");
alarmUtilService.hide( $node.find( CONSTS.DIV_NORMAL ) );
alarmUtilService.show( $node.find( CONSTS.DIV_EDIT ) );
alarmUtilService.hide( $node.find(".contents") );
@@ -286,6 +297,7 @@
},
cancelAction: function( alarmUtilService, $node ) {
if ( this._bIng === true ) {
$node.removeClass("edit blink-blink");
$node.find("input").hide();
alarmUtilService.hide($node.find( CONSTS.DIV_EDIT ));
alarmUtilService.show($node.find(".contents"));
@@ -299,13 +311,15 @@
var groupNumber = alarmUtilService.extractID( $node );
var groupName = $node.find("input").val();
if ( groupName === "" ) {
if ( groupName === "" || groupName.length < CONST.MIN_GROUPNAME_LENGTH ) {
alarmUtilService.hide( $elLoading );
$node.addClass("blink-blink");
$node.find("input").attr("placeholder", CONSTS.ENTER_AT_LEAST).val("").focus();
return;
}
if ( cbHasDuplicate( groupName ) ) {
if ( cbHasDuplicate( groupNumber, groupName ) ) {
alarmUtilService.hide( $elLoading );
$node.addClass("blink-blink");
$node.find("input").attr("placeholder", CONSTS.EXIST_A_SAME).val("").focus();
return;
}
@@ -1,37 +1,63 @@
<div class="some-list" style="width:300px;height:459px;margin-left: 15px;">
<div class="some-list-header" style="background-color:#9A9A9A;color:#FFF;">
<span class="title">Pinpoint User <span class="total"></span></span>
<span class="glyphicon glyphicon-sort right" style="cursor:pointer" ng-click="onSortGroupMember()"></span>
<span ng-show="isAllowedCreated">+Add</span>
<span ng-show="bIsAllowedCreated" class="right" style="text-decoration: underline;cursor:pointer" ng-click="onAddPinpointUser()">+ Add</span>
</div>
<div class="some-list-search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter at least 2 letters to search" ng-keydown="onSearchKeydown($event)"/>
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="onSearch()">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</button>
</span>
</div>
</div>
<div class="some-list-content" style="color:#9A9A9A;">
<div class="wrapper _disable-check"><ul>
<div class="wrapper _disable-check" style="height:375px;"><ul>
<li class="new-group hide-me">
<input type="text" class="form-control" style="height:25px" placeholder="User Id" ng-keydown="onAdd($event)"/>
</li>
<li class="new-group hide-me">
<input type="text" class="form-control" style="height:25px" placeholder="Name" ng-keydown="onAdd($event)"/>
</li>
<li class="new-group hide-me">
<input type="text" class="form-control" style="height:25px" placeholder="Department" ng-keydown="onAdd($event)"/>
</li>
<li class="new-group hide-me">
<input type="text" class="form-control" style="height:25px" placeholder="Phone" ng-keydown="onAdd($event)"/>
</li>
<li class="new-group hide-me">
<input type="text" class="form-control" style="height:25px" placeholder="Email" ng-keydown="onAdd($event)"/>
<div style="float:right" class="_add hide-me">
<span class="glyphicon glyphicon-remove remove" aria-hidden="true" ng-click="onCancelAddPinpointUser()"></span>
<span class="glyphicon glyphicon-ok edit" aria-hidden="true" ng-click="onApplyAddPinpointUser()"></span>
</div>
<div style="float:right" class="_edit hide-me">
<span class="glyphicon glyphicon-remove remove" aria-hidden="true" ng-click="onCancelUpdatePinpointUser()"></span>
<span class="glyphicon glyphicon-ok edit-confirm" aria-hidden="true" ng-click="onApplyUpdatePinpointUser()"></span>
</div>
</li>
<li ng-repeat="pinpointUser in pinpointUserList" id="{{prefix + pinpointUser.userId}}">
<span class="contents">{{"("+pinpointUser.department + ")" + pinpointUser.name}}</span>
<span class="contents" style="margin-left:6px">{{"("+pinpointUser.department + ")" + pinpointUser.name}}</span>
<input type="checkbox" ng-click="checkUser($event)" ng-model="pinpointUser.has"/>
<div style="float:right" class="_normal" ng-show="bIsAllowedCreated">
<span class="glyphicon glyphicon-remove remove" aria-hidden="true" ng-click="onRemovePinpointUser($event)"></span>
<span class="glyphicon glyphicon-pencil edit" aria-hidden="true" ng-click="onUpdatePinpointUser($event)"></span>
</div>
<div style="float:right" class="_remove hide-me" ng-show="bIsAllowedCreated">
<span class="glyphicon glyphicon-remove remove remove-confirm" aria-hidden="true" ng-click="onApplyRemovePinpointUser()"></span>
<span class="glyphicon glyphicon-arrow-left remove-cancel" aria-hidden="true" ng-click="onCancelRemovePinpointUser()"></span>
</div>
</li>
</ul></div>
</div>
<div class="some-loading hide-me">
<div class="some-loading hide-me" style="height:375px">
<div class="timer-loader"></div>
</div>
<div class="some-alert hide-me">
<div class="some-alert hide-me" style="height:375px">
<span class="message"></span>
<span class="close-alert" style="color:#FFF;" ng-click="onCloseAlert()">X</span>
</div>
<!--div class="some-edit-content pinpoint hide-me" style="width:300px;">
<div class="title-message">Create new pinpoint user</div>
<div class="edit-wrapper">
<div><span class="title">User ID</span><input type="text" placeholder="user id" name="userID"/></div>
<div><span class="title">Name</span><input type="text" placeholder="name" name="name"/></div>
<div><span class="title">Department</span><input type="text" placeholder="your department" name="department"/></div>
<div><span class="title">Phone</span><input type="text" placeholder="only number" name="phone"/></div>
<div><span class="title">Email</span><input type="text" placeholder="your@email.com" name="email"/></div>
<div style="padding-top:10px;clear:both">
<button class="btn btn-warning left" style="margin-left:4px" ng-click="onCancelEdit()"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
<button class="btn btn-warning right" style="margin-right:4px" ng-click="onApplyEdit()"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>
</div>
</div>
</div-->
</div>
@@ -1,15 +1,7 @@
<div class="some-list some-table" style="width:615px;height:459px">
<div class="some-list-header" style="background-color:#9A9A9A;color:#FFF;">
<span class="title">Alarm Rules<span class="total"></span></span>
<div class="input-group" style="float:right;width:300px;margin-top:-7px">
<input type="text" class="form-control" placeholder="3 or more letters, an App or a Rule" ng-keydown="onSearchKeydown()"/>
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="onSearch()">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</button>
</span>
</div>
<span class="right" style="text-decoration: underline;cursor:pointer;margin-right:10px;" ng-click="onAddAlarm()">+ Add</span>
<span class="right" style="text-decoration: underline;cursor:pointer;margin-right:6px;" ng-click="onAddAlarm()">+ Add</span>
</div>
<div class="some-list-content">
<div class="wrapper">
@@ -5,7 +5,7 @@
</div>
<div class="some-list-search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter at least 4 letters to search" ng-keydown="onSearchKeydown()"/>
<input type="text" class="form-control" placeholder="Enter at least 3 letters to search" ng-keydown="onSearchKeydown($event)"/>
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="onSearch()">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
@@ -17,13 +17,13 @@
<div class="wrapper"><ul>
<li class="new-group hide-me">
<span class="contents"></span>
<input type="text" placeholder="New Group" ng-keydown="onAddUserGroupKeydown($event)"/>
<input type="text" placeholder="New Group" style="height:22px" ng-keydown="onAddUserGroupKeydown($event)"/>
<span class="glyphicon glyphicon-remove remove" aria-hidden="true" ng-click="onCancelAddUserGroup()"></span>
<span class="glyphicon glyphicon-pencil edit" aria-hidden="true" ng-click="onApplyAddUserGroup()"></span>
<span class="glyphicon glyphicon-ok edit" aria-hidden="true" ng-click="onApplyAddUserGroup()"></span>
</li>
<li ng-repeat="userGroup in userGroupList" id="{{prefix + userGroup.number}}">
<span class="contents">{{userGroup.id}}</span>
<input type="text" ng-keydown="onUpdateuserGroupKeydown($event)"/>
<input type="text" style="height:22px" ng-keydown="onUpdateuserGroupKeydown($event)"/>
<div style="float:right" class="_normal">
<span class="glyphicon glyphicon-remove remove" aria-hidden="true" ng-click="onRemoveUserGroup($event)"></span>
<span class="glyphicon glyphicon-pencil edit" aria-hidden="true" ng-click="onUpdateUserGroup($event)"></span>
@@ -18,7 +18,7 @@
pinpointApp.controller('ConfigurationCtrl', [ '$scope','$element', 'ConfigurationConfig', 'AnalyticsService',
function ($scope, $element, $constant, analyticsService) {
$scope.selectMember = false;
$scope.selectMember = true;
$scope.currentTab = $constant.menu.GENERAL;
// define isGeneral(), isAlram()... func.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+36 -35
View File
@@ -49,14 +49,6 @@
width: 100%;
height: 100%;
}
/*
#pinpoint-configuration .some-list .btn{
border-radius: 0px;
font-size: 16px;
padding-top: 3px;
padding-bottom: 3px;
}
*/
#pinpoint-configuration .some-list-header {
height: 41px;
padding: 10px 10px 0px 10px;
@@ -71,13 +63,6 @@
padding: 3px 4px 0px 4px;
border-bottom: 1px solid #E2E2E2;
vertical-align: middle;
}
#pinpoint-configuration .some-list-search input {
border: 1px solid #46BCFD;
}
#pinpoint-configuration .some-list-header .title {
}
#pinpoint-configuration .left {
float: left;
@@ -95,9 +80,9 @@
height: 416px;
overflow-y: auto;
}
#pinpoint-configuration .some-list-content ul {
list-style-type: none;
#pinpoint-configuration .some-list-content ul {
padding:0px 0px 4px 0px;
list-style-type: none;
}
#pinpoint-configuration .some-list-content li {
cursor: pointer;
@@ -108,17 +93,23 @@
#pinpoint-configuration .some-list-content li input[type=text] {
width: 220px;
color: #000;
display: inline-block;
display: none;
}
#pinpoint-configuration .some-list-content li input[type=checkbox] {
float: right;
float: left;
margin-top: 4px;
line-height: 12px;
margin-right: 10px;
padding-left: 4px;
padding-right: 4px;
}
#pinpoint-configuration .some-list-content li.remove {
background-color: #FEF4F4;
}
#pinpoint-configuration .some-list-content li.edit {
background-color: #F3FBFF;
}
#pinpoint-configuration .some-list-content li.remove span.contents {
color: #EF4B55;
}
#pinpoint-configuration .some-list-content li.selected {
background-color: #46BCFD;
@@ -178,14 +169,8 @@
#pinpoint-configuration .some-list-content li.new-group input {
width: 210px;
color: #000;
border: 0px solid #FFF;
display: inline-block;
background-color: #F3FBFF;
}
#pinpoint-configuration .some-list-content li.remove:hover {
background-color: #EFABAB;
color: #000;
border: 1px solid #CCC;
}
#pinpoint-configuration .some-list-content .wrapper .empty-list {
text-align: center;
@@ -285,13 +270,20 @@
cursor: pointer;
background-color: #FAFAFA;
}
#pinpoint-configuration .some-table .some-list-content tr:hover,
#pinpoint-configuration .some-list-content tr:hover span.remove,
#pinpoint-configuration .some-list-content tr:hover span.remove-cancel,
#pinpoint-configuration .some-list-content tr:hover span.edit,
#pinpoint-configuration .some-list-content tr:hover span.edit-confirm {
#pinpoint-configuration .some-list-content tbody tr:hover,
#pinpoint-configuration .some-list-content tbody tr:hover span.remove,
#pinpoint-configuration .some-list-content tbody tr:hover span.remove-cancel,
#pinpoint-configuration .some-list-content tbody tr:hover span.edit,
#pinpoint-configuration .some-list-content tbody tr:hover span.edit-confirm {
color: #000;
}
#pinpoint-configuration .some-list-content tr.remove {
background-color: #FEF4F4;
}
#pinpoint-configuration .some-list-content tr.remove td {
background-color: #FEF4F4;
color: #EF4B55;
}
#pinpoint-configuration .some-list-content tr span.remove-confirm {
color: #F00 !important;
}
@@ -472,5 +464,14 @@
font-size: 14px;
text-align: left;
padding-bottom: 4px;
}
.blink-blink {
animation: back-blink 1s;
animation-iteration-count: infinite;
}
@keyframes back-blink {
0% {background-color: #F3FBFF;}
50% {background-color: #F00;}
100% {background-color: #FF0 }
}