more updates to ui crud

This commit is contained in:
John Mitchell 2016-09-07 15:27:11 -04:00
parent 1f586091e2
commit ab3588fd93
14 changed files with 180 additions and 55 deletions

View File

@ -13,7 +13,7 @@
export function JobsListController ($rootScope, $log, $scope, $compile, $stateParams,
ClearScope, LoadSchedulesScope,
LoadJobsScope, AllJobsList, ScheduledJobsList, GetChoices, GetBasePath, Wait) {
LoadJobsScope, AllJobsList, ScheduledJobsList, GetChoices, GetBasePath, Wait, $state) {
ClearScope();
@ -61,6 +61,11 @@ export function JobsListController ($rootScope, $log, $scope, $compile, $statePa
}
}
jobs_scope = $scope.$new(true);
jobs_scope.viewJob = function (id) {
$state.transitionTo('jobDetail', {id: id});
};
jobs_scope.showJobType = true;
LoadJobsScope({
parent_scope: $scope,
@ -153,4 +158,4 @@ export function JobsListController ($rootScope, $log, $scope, $compile, $statePa
JobsListController.$inject = ['$rootScope', '$log', '$scope', '$compile', '$stateParams',
'ClearScope', 'LoadSchedulesScope', 'LoadJobsScope',
'AllJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait'];
'AllJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'Wait', '$state'];

View File

@ -17,6 +17,7 @@ export default
LookUpInit, OrganizationList, inventory_script,
$scope, $state
) {
var generator = GenerateForm,
id = inventory_script.id,
form = inventoryScriptsFormObject,
@ -24,13 +25,15 @@ export default
url = GetBasePath('inventory_scripts');
$scope.canEdit = false;
$scope.canEditInvScripts = false;
Rest.setUrl(GetBasePath('inventory_scripts') + id);
Rest.options()
.success(function(data) {
if (data.actions.PUT) {
$scope.canEdit = true;
$scope.canEditInvScripts = true;
} else {
$scope.canEditInvScripts = false;
}
});

View File

@ -25,14 +25,14 @@ export default function() {
addRequired: true,
editRequired: true,
capitalize: false,
ngDisabled: '!canEdit'
ngDisabled: '!canEditInvScripts'
},
description: {
label: 'Description',
type: 'text',
addRequired: false,
editRequired: false,
ngDisabled: '!canEdit'
ngDisabled: '!canEditInvScripts'
},
organization: {
label: 'Organization',
@ -44,7 +44,7 @@ export default function() {
sourceModel: 'organization',
sourceField: 'name',
ngClick: 'lookUpOrganization()',
ngDisabled: '!canEdit'
ngDisabled: '!canEditInvScripts'
},
script: {
label: 'Custom Script',
@ -54,7 +54,7 @@ export default function() {
addRequired: true,
editRequired: true,
awDropFile: true,
ngDisabled: '!canEdit',
ngDisabled: '!canEditInvScripts',
rows: 10,
awPopOver: "<p>Drag and drop your custom inventory script file here or create one in the field to import your custom inventory. " +
"<br><br> Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python</p>",
@ -67,16 +67,16 @@ export default function() {
buttons: { //for now always generates <button> tags
cancel: {
ngClick: 'formCancel()',
ngShow: 'canEdit'
ngShow: 'canEditInvScripts'
},
close: {
ngClick: 'formCancel()',
ngShow: '!canEdit'
ngShow: '!canEditInvScripts'
},
save: {
ngClick: 'formSave()', //$scope.function to call on click, optional
ngDisabled: 'custom_inventory_form.$pristine || custom_inventory_form.$invalid || !canEdit', //Disable when $pristine or $invalid, optional
ngShow: 'canEdit'
ngShow: 'canEditInvScripts'
}
}
};

View File

@ -94,7 +94,12 @@ export default
fieldActions: {
columnClass: 'col-lg-2 col-md-2 col-sm-3 col-xs-4',
"view": {
mode: "all",
ngClick: "viewJob(all_job.id)",
awToolTip: "View the job",
dataPlacement: "top"
},
submit: {
icon: 'icon-rocket',
mode: 'all',

View File

@ -78,13 +78,22 @@ export default
mode: "all",
ngClick: "editSchedule(schedule)",
awToolTip: "Edit the schedule",
dataPlacement: "top"
dataPlacement: "top",
ngShow: 'schedule.summary_fields.user_capabilities.edit'
},
"view": {
mode: "all",
ngClick: "editSchedule(schedule)",
awToolTip: "View the schedule",
dataPlacement: "top",
ngShow: '!schedule.summary_fields.user_capabilities.edit'
},
"delete": {
mode: 'all',
ngClick: 'deleteSchedule(schedule.id)',
awToolTip: 'Delete the schedule',
dataPlacement: 'top'
dataPlacement: 'top',
ngShow: 'schedule.summary_fields.user_capabilities.delete'
}
}
});

View File

@ -69,7 +69,8 @@ export default
ngClick: 'addSchedule()',
awToolTip: 'Add a new schedule',
actionClass: 'btn List-buttonSubmit',
buttonContent: '&#43; ADD'
buttonContent: '&#43; ADD',
ngShow: 'canAdd'
}
},
@ -82,6 +83,13 @@ export default
dataPlacement: 'top',
ngShow: 'schedule.summary_fields.user_capabilities.edit'
},
view: {
label: 'View',
ngClick: "editSchedule(schedule.id)",
awToolTip: 'View schedule',
dataPlacement: 'top',
ngShow: '!schedule.summary_fields.user_capabilities.edit'
},
"delete": {
label: 'Delete',
ngClick: "deleteSchedule(schedule.id)",

View File

@ -17,6 +17,7 @@
<div class="MgmtCards-actionItems">
<button class="MgmtCards-actionItem List-actionButton"
ng-click='chooseRunJob(card.id, card.name)'
ng-show='current_user.is_superuser'
data-placement="top" aw-tool-tip="Launch Management Job" data-original-title="" title="">
<i class="MgmtCards-actionItemIcon icon-launch"></i>
</button>
@ -27,6 +28,7 @@
</button>
<button class="MgmtCards-actionItem List-actionButton"
ng-click='goToNotifications(card, card.id)'
ng-show='current_user.is_superuser'
data-placement="top" aw-tool-tip="Configure Notifications" data-original-title="" title="" ng-class="{'List-editButton--selected': activeCard === card.id && cardAction === 'notifications'}">
<i class="MgmtCards-actionItemIcon fa fa-bell-o"></i>
</button>

View File

@ -9,14 +9,23 @@ export default
'NotificationsFormObject', 'ProcessErrors', 'GetBasePath', 'Empty',
'GenerateForm', 'SearchInit' , 'PaginateInit', 'LookUpInit',
'OrganizationList', '$scope', '$state', 'CreateSelect2', 'GetChoices',
'NotificationsTypeChange', 'ParseTypeChange',
'NotificationsTypeChange', 'ParseTypeChange', 'Alert',
function(
$rootScope, pagination, $compile, SchedulerInit, Rest, Wait,
NotificationsFormObject, ProcessErrors, GetBasePath, Empty,
GenerateForm, SearchInit, PaginateInit, LookUpInit,
OrganizationList, $scope, $state, CreateSelect2, GetChoices,
NotificationsTypeChange, ParseTypeChange
NotificationsTypeChange, ParseTypeChange, Alert
) {
Rest.setUrl(GetBasePath('projects'));
Rest.options()
.success(function(data) {
if (!data.actions.POST) {
$state.go("^");
Alert('Permission Error', 'You do not have permission to add a notification template.', 'alert-info');
}
});
var generator = GenerateForm,
form = NotificationsFormObject,
url = GetBasePath('notification_templates');

View File

@ -25,6 +25,16 @@ export default
master = {},
url = GetBasePath('notification_templates');
$scope.canEdit = false;
Rest.setUrl(GetBasePath('notification_templates') + id);
Rest.options()
.success(function(data) {
if (data.actions.PUT) {
$scope.canEdit = true;
}
});
$scope.notification_template = notification_template;
generator.inject(form, {
mode: 'edit' ,

View File

@ -24,6 +24,18 @@ export default
scope: scope
});
scope.canAdd = false;
scope.canEdit = false;
Rest.setUrl(GetBasePath('notification_templates'));
Rest.options()
.success(function(data) {
if (data.actions.POST) {
scope.canAdd = true;
scope.canEdit = true;;
}
});
scope.removePostRefresh = scope.$on('PostRefresh', function () {
Wait('stop');
if (scope.notification_templates) {

View File

@ -27,13 +27,15 @@ export default function() {
type: 'text',
addRequired: true,
editRequired: true,
capitalize: false
capitalize: false,
ngDisabled: '!canEdit'
},
description: {
label: 'Description',
type: 'text',
addRequired: false,
editRequired: false
editRequired: false,
ngDisabled: '!canEdit'
},
organization: {
label: 'Organization',
@ -44,7 +46,8 @@ export default function() {
awRequiredWhen: {
reqExpression: "organizationrequired",
init: "true"
}
},
ngDisabled: '!canEdit'
},
notification_type: {
label: 'Type',
@ -54,13 +57,15 @@ export default function() {
class: 'NotificationsForm-typeSelect',
ngOptions: 'type.label for type in notification_type_options track by type.value',
ngChange: 'typeChange()',
hasSubForm: true
hasSubForm: true,
ngDisabled: '!canEdit'
},
username: {
label: 'Username',
type: 'text',
ngShow: "notification_type.value == 'email' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
host: {
@ -71,7 +76,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'email' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
sender: {
label: 'Sender Email',
@ -81,7 +87,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'email' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
recipients: {
label: 'Recipient List',
@ -97,7 +104,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'email' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
password: {
labelBind: 'passwordLabel',
@ -108,7 +116,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'email' || notification_type.value == 'irc' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
port: {
labelBind: 'portLabel',
@ -122,7 +131,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'email' || notification_type.value == 'irc'",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
channels: {
label: 'Destination Channels',
@ -138,7 +148,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'slack'",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
rooms: {
label: 'Destination Channels',
@ -154,7 +165,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'hipchat'",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
token: {
labelBind: 'tokenLabel',
@ -165,7 +177,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'slack' || notification_type.value == 'pagerduty' || notification_type.value == 'hipchat'",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
account_token: {
label: 'Account Token',
@ -176,7 +189,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'twilio' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
from_number: {
label: 'Source Phone Number',
@ -188,7 +202,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'twilio' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
to_numbers: {
label: 'Destination SMS Number',
@ -204,7 +219,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'twilio' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
account_sid: {
label: 'Account SID',
@ -214,7 +230,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'twilio' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
subdomain: {
label: 'Pagerduty subdomain',
@ -224,7 +241,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'pagerduty' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
service_key: {
label: 'API Service/Integration Key',
@ -234,7 +252,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'pagerduty' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
client_name: {
label: 'Client Identifier',
@ -244,7 +263,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'pagerduty' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
message_from: {
label: 'Label to be shown with notification',
@ -254,7 +274,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'hipchat' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
api_url: {
label: 'API URL',
@ -265,7 +286,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'hipchat' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
color: {
label: 'Notification Color',
@ -277,13 +299,15 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'hipchat' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
notify: {
label: 'Notify Channel',
type: 'checkbox',
ngShow: "notification_type.value == 'hipchat' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
url: {
label: 'Target URL',
@ -293,7 +317,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'webhook' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
headers: {
label: 'HTTP Headers',
@ -313,7 +338,8 @@ export default function() {
'</pre></p>',
dataPlacement: 'right',
ngShow: "notification_type.value == 'webhook' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
server: {
label: 'IRC Server Address',
@ -323,7 +349,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'irc' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
nickname: {
label: 'IRC Nick',
@ -333,7 +360,8 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'irc' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
targets: {
label: 'Destination Channels or Users',
@ -349,13 +377,15 @@ export default function() {
init: "false"
},
ngShow: "notification_type.value == 'irc' ",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
use_ssl: {
label: 'SSL Connection',
type: 'checkbox',
ngShow: "notification_type.value == 'irc'",
subForm: 'typeSubForm'
subForm: 'typeSubForm',
ngDisabled: '!canEdit'
},
checkbox_group: {
label: 'Options',
@ -367,13 +397,15 @@ export default function() {
label: 'Use TLS',
type: 'checkbox',
ngShow: "notification_type.value == 'email' ",
labelClass: 'checkbox-options stack-inline'
labelClass: 'checkbox-options stack-inline',
ngDisabled: '!canEdit'
}, {
name: 'use_ssl',
label: 'Use SSL',
type: 'checkbox',
ngShow: "notification_type.value == 'email'",
labelClass: 'checkbox-options stack-inline'
labelClass: 'checkbox-options stack-inline',
ngDisabled: '!canEdit'
}]
}
},
@ -381,9 +413,15 @@ export default function() {
buttons: { //for now always generates <button> tags
cancel: {
ngClick: 'formCancel()',
ngShow: 'canEdit'
},
close: {
ngClick: 'formCancel()',
ngShow: '!canEdit'
},
save: {
ngClick: 'formSave()', //$scope.function to call on click, optional
ngClick: 'formSave()',
ngShow: 'canEdit', //$scope.function to call on click, optional
ngDisabled: true //Disable when $pristine or $invalid, optional
}
}

View File

@ -49,7 +49,8 @@ export default function(){
ngClick: 'addNotification()',
awToolTip: 'Create a new custom inventory',
actionClass: 'btn List-buttonSubmit',
buttonContent: '&#43; ADD'
buttonContent: '&#43; ADD',
ngShow: 'canAdd'
}
},
@ -62,7 +63,8 @@ export default function(){
label: 'Edit',
"class": 'btn-sm',
awToolTip: 'Test notification',
dataPlacement: 'top'
dataPlacement: 'top',
ngShow: 'notification_template.summary_fields.user_capabilities.edit'
},
edit: {
ngClick: "editNotification(notification_template.id)",
@ -70,7 +72,16 @@ export default function(){
label: 'Edit',
"class": 'btn-sm',
awToolTip: 'Edit notification',
dataPlacement: 'top'
dataPlacement: 'top',
ngShow: 'notification_template.summary_fields.user_capabilities.edit'
},
view: {
ngClick: "editNotification(notification_template.id)",
label: 'View',
"class": 'btn-sm',
awToolTip: 'View notification',
dataPlacement: 'top',
ngShow: '!notification_template.summary_fields.user_capabilities.edit'
},
"delete": {
ngClick: "deleteNotification(notification_template.id, notification_template.name)",
@ -78,7 +89,8 @@ export default function(){
label: 'Delete',
"class": 'btn-sm',
awToolTip: 'Delete notification',
dataPlacement: 'top'
dataPlacement: 'top',
ngShow: 'notification_template.summary_fields.user_capabilities.delete'
}
}
};

View File

@ -48,6 +48,19 @@ export default [
}
$scope.removeParentLoaded = $scope.$on('ParentLoaded', function() {
url += "schedules/";
$scope.canAdd = false;
$scope.canEdit = false;
Rest.setUrl(url);
Rest.options()
.success(function(data) {
if (data.actions.POST) {
$scope.canAdd = true;
$scope.canEdit = true;
}
});
schedList.well = true;
// include name of item in listTitle

View File

@ -9,7 +9,6 @@ export default ['$compile', '$filter', '$state', '$stateParams', 'AddSchedule',
'Rest', 'ParamPass',
function($compile, $filter, $state, $stateParams, AddSchedule, Wait, $scope,
$rootScope, CreateSelect2, ParseTypeChange, GetBasePath, Rest, ParamPass) {
$scope.processSchedulerEndDt = function(){
// set the schedulerEndDt to be equal to schedulerStartDt + 1 day @ midnight
var dt = new Date($scope.schedulerUTCTime);