Created
February 19, 2015 14:31
-
-
Save javrasya/a780815d7b7eb53673c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="action-wizard" xmlns="http://www.w3.org/1999/html"> | |
<div class="hero"> | |
<div class="container"> | |
<h3>{{ 'esefcontent_add_header'|translate: {model:modelName} }}</h3> | |
</div> | |
</div> | |
<div class="panel container"> | |
<div class="panel-body"> | |
<form name="actionForm" ng-submit="saveAction(true)"> | |
<div class="eventState"> | |
<div class="form-group"> | |
<label for="evetState">{{ 'cep_event_state' | translate }}</label> | |
<select class="form-control" id="eventState" ng-model="eventState.id" ng-options="eState.id as eState.name for eState in eStates"></select> | |
</div> | |
</div> | |
<div class="action" ng-if="eventState.state"> | |
<div class="form-group"> | |
<label class="checkbox-inline" ng-repeat="(key, val) in actionTypes"> | |
<input type="checkbox" ng-model="selectedActions[val.action]" | |
ng-required="!someSelected(selectedActions)"> {{val.name}} | |
</label> | |
</div> | |
<div class="form-group" ng-if="selectedActions.emailAction"> | |
<label>{{ 'cep_action_name'|translate }}</label> | |
<input type="text" class="form-control" id="name" placeholder="Aksiyon ismi giriniz" ng-model="emailAction.description"> | |
<label class="checkbox-inline"> | |
<input type="checkbox" ng-model="emailAction.regional_notification">{{'cep_regional_notification'|translate}} | |
</label> | |
<div class="clear-fix"></div> | |
<label>{{ 'cep_email_action_contacts'|translate }}</label> | |
<ui-select multiple required theme="bootstrap" name="contacts" ng-model="emailAction.contacts"> | |
<ui-select-match ng-placeholder='form.placeholder'>{{$item.email}}</ui-select-match> | |
<ui-select-choices repeat="contact.id as contact in contacts | filter : {email : $select.search}"> | |
{{contact.email}} | |
</ui-select-choices> | |
</ui-select> | |
</div> | |
<div class="form-group" ng-if="selectedActions.scriptAction"> | |
<label>{{ 'cep_action_name'|translate }}</label> | |
<input type="text" class="form-control" id="name" placeholder="Aksiyon tanımı giriniz" ng-model="scriptAction.description"> | |
<label>{{ 'cep_sensu_check'|translate }}</label> | |
<select class="form-control" id="check" ng-model="scriptAction.check" ng-options="sensuCheck.name as sensuCheck.name for sensuCheck in sensuChecks"></select> | |
<label class="checkbox-inline"> | |
<input type="checkbox" ng-model="sensuEmailAction.regional_notification">{{'cep_regional_notification'|translate}} | |
</label> | |
<div class="clear-fix"></div> | |
<label>{{ 'cep_email_action_contacts'|translate }}</label> | |
<ui-select multiple required theme="bootstrap" name="sensu_contacts" ng-model="sensuEmailAction.contacts"> | |
<ui-select-match ng-placeholder='form.placeholder'>{{$item.email}}</ui-select-match> | |
<ui-select-choices repeat="contact.id as contact in contacts | filter : {email : $select.search}"> | |
{{contact.email}} | |
</ui-select-choices> | |
</ui-select> | |
</div> | |
<div class="form-group" ng-if="isNotificationAction"> | |
</div> | |
</div> | |
<div class="pull-right"> | |
<button type="button" class="btn btn-default" ng-click="goToList()" translate>cancel</button> | |
<input type="submit" class="btn btn-primary" value="{{ 'save'|translate }}"/> | |
</div> | |
</form> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular.module('lolWebapp') | |
.controller('ActionAddCtrl', | |
function ($scope, $location, $routeParams, $log, cepApi) { | |
var model = 'Action'; | |
$scope.listUrl = 'cep/eventState/list'; | |
$scope.isEmailAction = false; | |
$scope.isScriptAction = false; | |
$scope.isNotificationAction = false; | |
$scope.selectedActions = {}; | |
$scope.actionTypes = [ | |
{'name': 'Email Action', 'id': '1', 'action': 'emailAction'}, | |
{'name': 'Script Action', 'id': '2', 'action': 'scriptAction'}, | |
{'name': 'Notification Action', 'id': '3', 'action': 'notificationAction'}, | |
]; | |
$scope.modelName = model; | |
$scope.emailAction = { | |
contacts: [] | |
}; | |
$scope.scriptAction = {}; | |
$scope.sensuEmailAction = { | |
contacts: [] | |
}; | |
$scope.action = {}; | |
cepApi.eventstate() | |
.get({id: $routeParams.id}, function (result) { | |
$scope.selectedEventState = result; | |
$scope.eventState = $scope.selectedEventState; | |
}); | |
cepApi.eventstate() | |
.get(function (result) { | |
$scope.eStates = result.results; | |
}); | |
cepApi.contact() | |
.get(function (result) { | |
$scope.contacts = result.results; | |
}); | |
cepApi.sensuChecks() | |
.query(function (result) { | |
console.log(result); | |
$scope.sensuChecks = result; | |
}); | |
$scope.someSelected = function (object) { | |
return Object.keys(object).some(function (key) { | |
return object[key]; | |
}); | |
}; | |
$scope.saveAction = function (valid) { | |
if (valid) { | |
if ($scope.selectedActions.emailAction) { | |
$scope.emailAction.event_state = $scope.eventState.id; | |
cepApi.emailaction() | |
.save($scope.emailAction, function (result) { | |
$log.debug('Result', result); | |
}, function () { | |
alert("Field is required") | |
}); | |
} | |
if ($scope.selectedActions.scriptAction) { | |
if (valid) { | |
$scope.scriptAction.event_state = $scope.eventState.id; | |
$scope.scriptAction.email_action = $scope.sensuEmailAction; | |
console.log($scope.sensu_email_action); | |
cepApi.scriptaction() | |
.save($scope.scriptAction, function (result) { | |
$log.debug('Result', result); | |
$scope.goToList(); | |
}, | |
function () { | |
alert("Error"); | |
} | |
) | |
} | |
} | |
$scope.goToList(); | |
} | |
else { | |
alert("Not valid"); | |
} | |
}; | |
$scope.goToList = function () { | |
$location.path($scope.listUrl); | |
}; | |
} | |
) | |
; | |
}) | |
(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular.module('lolWebapp') | |
.factory('cepApi', ['$resource', 'lolConfig', | |
function ($resource, lolConfig) { | |
var apiUrl = '/api'; | |
return { | |
eventstate: function () { | |
return $resource(apiUrl + '/EventState/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
contact: function () { | |
return $resource(apiUrl + '/Contact/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
region: function () { | |
return $resource(apiUrl + '/Region/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
city: function () { | |
return $resource(apiUrl + '/City/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
emailaction: function () { | |
return $resource(apiUrl + '/EmailAction/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
scriptaction: function () { | |
return $resource(apiUrl + '/SensuCheckAction/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
action: function () { | |
return $resource(apiUrl + '/Action/:id?', {id: '@_id'}, { | |
update: { | |
method: 'PUT' // this method issues a PUT request | |
} | |
} | |
); | |
}, | |
sensuChecks: function () { | |
return $resource(lolConfig.sensuServerUrl + lolConfig.sensuCheckListPath, { | |
query: { | |
method: 'GET', | |
isArray: true | |
} | |
}); | |
} | |
}; | |
} | |
]); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment