How to use getBasePath method in Karma

Best JavaScript code snippet using karma

stateDefinitions.factory.js

Source:stateDefinitions.factory.js Github

copy

Full Screen

1/**2 * @ngdoc interface3 * @name stateDefinitions4 * @description An API for generating a standard set of state definitions5 * generateTree - builds a full list/form tree6 * generateListNode - builds a single list node e.g. {name: 'projects', ...}7 * generateFormNode - builds a form node definition e.g. {name: 'projects.add', ...}8 * generateFormListDefinitions - builds form list definitions attached to a form node e.g. {name: 'projects.edit.permissions', ...}9 * generateLookupNodes - Attaches to a form node. Builds an abstract '*.lookup' node with field-specific 'lookup.*' children e.g. {name: 'projects.add.lookup.organizations', ...}10 */11export default ['$injector', '$stateExtender', '$log', 'i18n',12function($injector, $stateExtender, $log, i18n) {13 return {14 /**15 * @ngdoc method16 * @name stateDefinitions.generateTree17 * @description intended for consumption by $stateProvider.state.lazyLoad in a placeholder node18 * @param {object} params19 {20 parent: 'stateName', // the name of the top-most node of this tree21 modes: ['add', 'edit'], // form modes to include in this state tree22 list: 'InjectableListDefinition',23 form: 'InjectableFormDefinition',24 controllers: {25 list: 'Injectable' || Object,26 add: 'Injectable' || Object,27 edit: 'Injectable' || Object,28 }29 * @returns {object} Promise which resolves to an object.state containing array of all state definitions in this tree30 * e.g. {state: [{...}, {...}, ...]}31 */32 generateTree: function(params) {33 let form, list, formStates, listState,34 states = [];35 //return defer.promise;36 return new Promise((resolve) => {37 // returns array of the following states:38 // resource.add, resource.edit39 // resource.add.lookup, resource.add.lookup.* => [field in form.fields if field.type == 'lookup']40 // resource.edit.lookup, resource.edit.lookup.* => [field in form.fields if field.type == 'lookup']41 // resource.edit.* => [relationship in form.related]42 if (params.list) {43 list = $injector.get(params.list);44 listState = this.generateListNode(list, params);45 states.push(listState);46 }47 if (params.form) {48 // handle inconsistent typing of form definitions49 // can be either an object or fn50 form = $injector.get(params.form);51 form = typeof(form) === 'function' ? form() : form;52 formStates = _.map(params.modes, (mode) => this.generateFormNode(mode, form, params));53 states = states.concat(_.flatten(formStates));54 }55 $log.debug('*** Generated State Tree', states);56 resolve({ states: states });57 });58 },59 /**60 * @ngdoc method61 * @name stateDefinitions.generateListNode62 * @description builds single list node63 * @params {object} list - list definition/configuration object64 * @params {object} params65 * @returns {object} a list state definition66 */67 generateListNode: function(list, params) {68 let state,69 url = params.urls && params.urls.list ? params.urls.list : (params.url ? params.url : `/${list.name}`);70 // allows passed-in params to specify a custom templateUrl71 // otherwise, use html returned by generateList.build() to fulfill templateProvider fn72 function generateTemplateBlock() {73 if (params.templates && params.templates.list) {74 return params.templates.list;75 } else {76 return function(ListDefinition, generateList) {77 let html = generateList.build({78 list: ListDefinition,79 mode: 'edit'80 });81 html = generateList.wrapPanel(html);82 // generateList.formView() inserts a ui-view="form" inside the list view's hierarchy83 html = generateList.insertFormView() + html;84 if(params.generateSchedulerView){85 html = generateList.insertSchedulerView() + html;86 }87 return html;88 };89 }90 }91 let views = params.views ? params.views : {92 '@': {93 // resolves to a variable property name:94 // 'templateUrl' OR 'templateProvider'95 [params.templates && params.templates.list ? 'templateUrl' : 'templateProvider']: generateTemplateBlock(),96 controller: params.controllers.list,97 }98 };99 state = $stateExtender.buildDefinition({100 searchPrefix: list.iterator,101 name: params.parent,102 url: url,103 data: params.data,104 ncyBreadcrumb: {105 label: list.title106 },107 resolve: {108 Dataset: [params.list, 'QuerySet', '$stateParams', 'GetBasePath',109 function(list, qs, $stateParams, GetBasePath) {110 let path = GetBasePath(list.basePath) || GetBasePath(list.name);111 return qs.search(path, $stateParams[`${list.iterator}_search`]);112 }113 ],114 ListDefinition: () => list115 },116 views: views117 });118 // allow passed-in params to override default resolve block119 if (params.resolve && params.resolve.list) {120 state.resolve = _.merge(state.resolve, params.resolve.list);121 }122 // allow passed-in params to override default ncyBreadcrumb property123 if (params.ncyBreadcrumb) {124 state.ncyBreadcrumb = params.ncyBreadcrumb;125 }126 if (list.search) {127 state.params[`${list.iterator}_search`].value = _.merge(state.params[`${list.iterator}_search`].value, list.search);128 }129 return state;130 },131 /**132 * @ngdoc method133 * @name stateDefinitions.generateFormNode134 * @description builds a node of form states, e.g. resource.edit.** or resource.add.**135 * @param {string} mode - 'add' || 'edit' - the form mode of this node136 * @param {object} form - form definition/configuration object137 * @returns {array} Array of state definitions required by form mode [{...}, {...}, ...]138 */139 generateFormNode: function(mode, form, params) {140 let formNode,141 states = [],142 url;143 switch (mode) {144 case 'add':145 url = params.urls && params.urls.add ? params.urls.add : (params.url ? params.url : '/add');146 // breadcrumbName necessary for resources that are more than one word like147 // job templates. form.name can't have spaces in it or it busts form gen148 formNode = $stateExtender.buildDefinition({149 name: params.name || `${params.parent}.add`,150 url: url,151 ncyBreadcrumb: {152 [params.parent ? 'parent' : null]: `${params.parent}`,153 label: i18n.sprintf(i18n._("CREATE %s"), i18n._(`${form.breadcrumbName || form.name.toUpperCase()}`))154 },155 views: {156 'form': {157 templateProvider: function(FormDefinition, GenerateForm) {158 let form = typeof(FormDefinition) === 'function' ?159 FormDefinition() : FormDefinition;160 return GenerateForm.buildHTML(form, {161 mode: 'add',162 related: false163 });164 },165 controller: params.controllers.add166 }167 },168 resolve: {169 'FormDefinition': [params.form, function(definition) {170 return definition;171 }]172 }173 });174 if (params.resolve && params.resolve.add) {175 formNode.resolve = _.merge(formNode.resolve, params.resolve.add);176 }177 break;178 case 'edit':179 url = params.urls && params.urls.edit ? params.urls.edit : (params.url ? params.url : `/:${form.name}_id`);180 let breadcrumbLabel = params.breadcrumbs && params.breadcrumbs.edit ? params.breadcrumbs.edit : '{{parentObject.name || name}}';181 let formNodeState = {182 name: params.name || `${params.parent}.edit`,183 url: url,184 ncyBreadcrumb: {185 [params.parent ? 'parent' : null]: `${params.parent}`,186 label: breadcrumbLabel187 },188 views: {189 'form': {190 templateProvider: function(FormDefinition, GenerateForm) {191 let form = typeof(FormDefinition) === 'function' ?192 FormDefinition() : FormDefinition;193 return GenerateForm.buildHTML(form, {194 mode: 'edit'195 });196 },197 controller: params.controllers.edit198 }199 },200 resolve: {201 FormDefinition: [params.form, function(definition) {202 return definition;203 }],204 resourceData: ['FormDefinition', 'Rest', '$stateParams', 'GetBasePath', '$q', 'ProcessErrors',205 function(FormDefinition, Rest, $stateParams, GetBasePath, $q, ProcessErrors) {206 let form, path;207 let deferred = $q.defer();208 form = typeof(FormDefinition) === 'function' ?209 FormDefinition() : FormDefinition;210 if (GetBasePath(form.basePath) === undefined && GetBasePath(form.stateTree) === undefined ){211 throw { name: 'NotImplementedError', message: `${form.name} form definition is missing basePath or stateTree property.` };212 }213 else{214 path = (GetBasePath(form.basePath) || GetBasePath(form.stateTree) || form.basePath) + $stateParams[`${form.name}_id`];215 }216 Rest.setUrl(path);217 Rest.get()218 .then((response) => deferred.resolve(response))219 .catch(({ data, status }) => {220 ProcessErrors(null, data, status, null,221 {222 hdr: i18n._('Error!'),223 msg: i18n._('Unable to get resource: ') + status224 }225 );226 deferred.reject();227 });228 return deferred.promise;229 }230 ]231 },232 };233 if (params.data && params.data.activityStreamTarget) {234 formNodeState.data = {};235 formNodeState.data.activityStreamId = params.data.activityStreamId ? params.data.activityStreamId : params.data.activityStreamTarget + '_id';236 formNodeState.data.activityStreamTarget = params.data.activityStreamTarget;237 }238 formNode = $stateExtender.buildDefinition(formNodeState);239 if (params.resolve && params.resolve.edit) {240 formNode.resolve = _.merge(formNode.resolve, params.resolve.edit);241 }242 break;243 }244 states.push(formNode);245 states = states.concat(this.generateLookupNodes(form, formNode)).concat(this.generateFormListDefinitions(form, formNode, params));246 return states;247 },248 /**249 * @ngdoc method250 * @name stateDefinitions.generateFormListDefinitions251 * @description builds state definitions for a form's related lists, like notifications/permissions252 * @param {object} form - form definition/configuration object253 * @params {object} formStateDefinition - the parent form node254 * @returns {array} Array of state definitions [{...}, {...}, ...]255 */256 generateFormListDefinitions: function(form, formStateDefinition, params) {257 function buildRbacUserTeamDirective(){258 let states = [];259 states.push($stateExtender.buildDefinition({260 name: `${formStateDefinition.name}.permissions.add`,261 squashSearchUrl: true,262 url: '/add-permissions',263 params: {264 project_search: {265 value: {order_by: 'name', page_size: '5', role_level: 'admin_role'},266 dynamic: true267 },268 job_template_search: {269 value: {order_by: 'name', page_size: '5', role_level: 'admin_role'},270 dynamic: true271 },272 workflow_template_search: {273 value: {order_by: 'name', page_size: '5', role_level: 'admin_role'},274 dynamic: true275 },276 inventory_search: {277 value: {order_by: 'name', page_size: '5', role_level: 'admin_role'},278 dynamic: true279 },280 credential_search: {281 value: {order_by: 'name', page_size: '5', role_level: 'admin_role'},282 dynamic: true283 },284 organization_search: {285 value: {order_by: 'name', page_size: '5', role_level: 'admin_role'},286 dynamic: true287 }288 },289 ncyBreadcrumb:{290 skip:true291 },292 views: {293 [`modal@${formStateDefinition.name}`]: {294 template: `<add-rbac-user-team resolve="$resolve" title="` + i18n._('Add Permissions') + `"></add-rbac-user-team>`295 }296 },297 resolve: {298 jobTemplatesDataset: ['QuerySet', '$stateParams', 'GetBasePath',299 function(qs, $stateParams, GetBasePath) {300 let path = GetBasePath('job_templates');301 return qs.search(path, $stateParams.job_template_search);302 }303 ],304 workflowTemplatesDataset: ['QuerySet', '$stateParams', 'GetBasePath',305 function(qs, $stateParams, GetBasePath) {306 let path = GetBasePath('workflow_job_templates');307 return qs.search(path, $stateParams.workflow_template_search);308 }309 ],310 projectsDataset: ['ProjectList', 'QuerySet', '$stateParams', 'GetBasePath',311 function(list, qs, $stateParams, GetBasePath) {312 let path = GetBasePath(list.basePath) || GetBasePath(list.name);313 return qs.search(path, $stateParams[`${list.iterator}_search`]);314 }315 ],316 inventoriesDataset: ['InventoryList', 'QuerySet', '$stateParams', 'GetBasePath',317 function(list, qs, $stateParams, GetBasePath) {318 let path = GetBasePath(list.basePath) || GetBasePath(list.name);319 return qs.search(path, $stateParams[`${list.iterator}_search`]);320 }321 ],322 credentialsDataset: ['CredentialList', 'QuerySet', '$stateParams', 'GetBasePath', 'resourceData', 'Rest', '$q',323 function(list, qs, $stateParams, GetBasePath, resourceData, Rest, $q) {324 let path = GetBasePath(list.basePath) || GetBasePath(list.name);325 if(resourceData.data.type === "team") {326 $stateParams[`${list.iterator}_search`].organization = resourceData.data.organization;327 }328 if(resourceData.data.type === "user") {329 let resolve = $q.defer();330 let getMoreOrgs = function(data, arr) {331 Rest.setUrl(data.next);332 Rest.get()333 .then(function (resData) {334 if (data.next) {335 getMoreOrgs(resData.data, arr.concat(resData.data.results));336 } else {337 resolve.resolve(arr.concat(resData.data.results));338 }339 });340 };341 Rest.setUrl(GetBasePath('users') + `${resourceData.data.id}/organizations?page_size=200`);342 Rest.get()343 .then(function(resData) {344 if (resData.data.next) {345 getMoreOrgs(resData.data, resData.data.results);346 } else {347 resolve.resolve(resData.data.results);348 }349 });350 return resolve.promise.then(function (organizations) {351 if(organizations && organizations.length > 0) {352 let orgIds = _.map(organizations, function(organization){353 return organization.id;354 });355 $stateParams[`${list.iterator}_search`].or__organization = 'null';356 $stateParams[`${list.iterator}_search`].or__organization__in = orgIds.join();357 }358 else {359 $stateParams[`${list.iterator}_search`].organization = 'null';360 }361 return qs.search(path, $stateParams[`${list.iterator}_search`]);362 });363 }364 else {365 return qs.search(path, $stateParams[`${list.iterator}_search`]);366 }367 }368 ],369 organizationsDataset: ['OrganizationList', 'QuerySet', '$stateParams', 'GetBasePath',370 function(list, qs, $stateParams, GetBasePath) {371 let path = GetBasePath(list.basePath) || GetBasePath(list.name);372 return qs.search(path, $stateParams[`${list.iterator}_search`]);373 }374 ],375 },376 onExit: function($state) {377 if ($state.transition) {378 $('#add-permissions-modal').modal('hide');379 $('.modal-backdrop').remove();380 $('body').removeClass('modal-open');381 }382 },383 }));384 return states;385 }386 function buildRbacResourceDirective() {387 let states = [];388 states.push($stateExtender.buildDefinition({389 name: `${formStateDefinition.name}.permissions.add`,390 squashSearchUrl: true,391 url: '/add-permissions',392 params: {393 user_search: {394 value: { order_by: 'username', page_size: '5', is_superuser: false },395 dynamic: true,396 },397 team_search: {398 value: { order_by: 'name', page_size: '5' },399 dynamic: true400 }401 },402 views: {403 [`modal@${formStateDefinition.name}`]: {404 template: `<add-rbac-resource users-dataset="$resolve.usersDataset" teams-dataset="$resolve.teamsDataset" selected="allSelected" resource-data="$resolve.resourceData" title="` + i18n._('Add Users') + ' / ' + i18n._('Teams') + `"></add-rbac-resource>`405 }406 },407 ncyBreadcrumb:{408 skip:true409 },410 resolve: {411 usersDataset: ['addPermissionsUsersList', 'QuerySet', '$stateParams', 'GetBasePath',412 function(list, qs, $stateParams, GetBasePath) {413 let path = GetBasePath(list.basePath) || GetBasePath(list.name);414 return qs.search(path, $stateParams.user_search);415 }416 ],417 teamsDataset: ['addPermissionsTeamsList', 'QuerySet', '$stateParams', 'GetBasePath',418 function(list, qs, $stateParams, GetBasePath) {419 let path = GetBasePath(list.basePath) || GetBasePath(list.name);420 return qs.search(path, $stateParams.team_search);421 }422 ]423 },424 onExit: function($state) {425 if ($state.transition) {426 $('#add-permissions-modal').modal('hide');427 $('.modal-backdrop').remove();428 $('body').removeClass('modal-open');429 }430 },431 }));432 return states;433 }434 function buildNotificationState(field) {435 let state,436 list = field.include ? $injector.get(field.include) : field,437 breadcrumbLabel = (field.iterator.replace('_', ' ') + 's').toUpperCase();438 state = $stateExtender.buildDefinition({439 searchPrefix: `${list.iterator}`,440 name: `${formStateDefinition.name}.${list.iterator}s`,441 url: `/${list.iterator}s`,442 ncyBreadcrumb: {443 parent: `${formStateDefinition.name}`,444 label: `${breadcrumbLabel}`445 },446 params: {447 [list.iterator + '_search']: {448 value: { order_by: field.order_by ? field.order_by : 'name' }449 }450 },451 views: {452 'related': {453 templateProvider: function(FormDefinition, GenerateForm, $stateParams, SourcesFormDefinition) {454 var form, html;455 if($stateParams && $stateParams.inventory_source_id){456 form = SourcesFormDefinition;457 }458 else {459 form = typeof(FormDefinition) === 'function' ?460 FormDefinition() : FormDefinition;461 }462 html = GenerateForm.buildCollection({463 mode: 'edit',464 related: `${list.iterator}s`,465 form: form466 });467 return html;468 },469 controller: ['$scope', 'ListDefinition', 'Dataset', 'ToggleNotification', 'NotificationsListInit', 'GetBasePath', '$stateParams',470 function($scope, list, Dataset, ToggleNotification, NotificationsListInit, GetBasePath, $stateParams) {471 var url , params = $stateParams, id;472 if(params.hasOwnProperty('project_id')){473 id = params.project_id;474 url = GetBasePath('projects');475 }476 if(params.hasOwnProperty('job_template_id')){477 id = params.job_template_id;478 url = GetBasePath('job_templates');479 }480 if(params.hasOwnProperty('workflow_job_template_id')){481 id = params.workflow_job_template_id;482 url = GetBasePath('workflow_job_templates');483 }484 if(params.hasOwnProperty('inventory_source_id')){485 id = params.inventory_source_id;486 url = GetBasePath('inventory_sources');487 }488 if(params.hasOwnProperty('organization_id')){489 id = params.organization_id;490 url = GetBasePath('organizations');491 }492 function init() {493 $scope.list = list;494 $scope[`${list.iterator}_dataset`] = Dataset.data;495 $scope[list.name] = $scope[`${list.iterator}_dataset`].results;496 NotificationsListInit({497 scope: $scope,498 url: url,499 id: id500 });501 $scope.$watch(`${list.iterator}_dataset`, function() {502 // The list data has changed and we need to update which notifications are on/off503 $scope.$emit('relatednotifications');504 });505 }506 $scope.toggleNotification = function(event, notifier_id, column) {507 var notifier = this.notification;508 try {509 $(event.target).tooltip('hide');510 }511 catch(e) {512 // ignore513 }514 ToggleNotification({515 scope: $scope,516 url: url + id,517 notifier: notifier,518 column: column,519 callback: 'NotificationRefresh'520 });521 };522 init();523 }524 ]525 }526 },527 resolve: {528 ListDefinition: () => {529 return list;530 },531 Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope',532 (list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => {533 // allow related list definitions to use interpolated $rootScope / $stateParams in basePath field534 let path, interpolator;535 if (GetBasePath(list.basePath)) {536 path = GetBasePath(list.basePath);537 } else {538 interpolator = $interpolate(list.basePath);539 path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams });540 }541 return qs.search(path, $stateParams[`${list.iterator}_search`]);542 }543 ]544 }545 });546 return state;547 }548 function buildRbacUserDirective() {549 let states = [];550 states.push($stateExtender.buildDefinition({551 name: `${formStateDefinition.name}.users.add`,552 url: '/add-user',553 searchPrefix: 'add_user',554 params: {555 add_user_search: {556 value: { order_by: 'username', page_size: '5' },557 dynamic: true558 }559 },560 views: {561 [`modal@${formStateDefinition.name}`]: {562 template: `<add-rbac-resource default-params="$resolve.defaultParams" users-dataset="$resolve.usersDataset" selected="allSelected" resource-data="$resolve.resourceData" without-team-permissions="true" title="` + i18n._('Add Users') + `" only-member-role="true" query-prefix="add_user"></add-rbac-resource>`563 }564 },565 ncyBreadcrumb:{566 skip:true567 },568 resolve: {569 roleToExclude: ['$stateParams', 'Rest', 'GetBasePath', 'i18n', function($stateParams, Rest, GetBasePath, i18n) {570 const basePath = ($stateParams.team_id) ? GetBasePath('teams') + `${$stateParams.team_id}/object_roles` :571 GetBasePath('organizations') + `${$stateParams.organization_id}/object_roles`;572 Rest.setUrl(basePath);573 return Rest.get().then(({data}) => {574 return data.results575 .filter(({name}) => name === i18n._('Member'))576 .map(({id}) => id)[0];577 });578 }],579 usersDataset: ['addPermissionsUsersList', 'QuerySet', '$stateParams', 'GetBasePath', 'roleToExclude',580 function(list, qs, $stateParams, GetBasePath, roleToExclude) {581 let path = GetBasePath(list.basePath) || GetBasePath(list.name);582 if (roleToExclude) {583 $stateParams.add_user_search.not__roles = roleToExclude;584 }585 return qs.search(path, $stateParams.add_user_search);586 }587 ],588 defaultParams: ['$stateParams', 'usersDataset', function($stateParams) {589 return $stateParams.add_user_search;590 }]591 },592 onExit: function($state) {593 if ($state.transition) {594 $('#add-permissions-modal').modal('hide');595 $('.modal-backdrop').remove();596 $('body').removeClass('modal-open');597 }598 },599 }));600 return states;601 }602 function buildListNodes(field) {603 let states = [];604 if(!field.skipGenerator) {605 if(field.iterator === 'notification'){606 states.push(buildNotificationState(field));607 states = _.flatten(states);608 }609 else{610 states.push(buildListDefinition(field));611 if (field.iterator === 'permission' && field.actions && field.actions.add) {612 if (form.name === 'user' || form.name === 'team'){613 states.push(buildRbacUserTeamDirective());614 }615 else {616 states.push(buildRbacResourceDirective());617 }618 }619 else if (field.iterator === 'user' && field.actions && field.actions.add) {620 if(form.name === 'team' || form.name === 'organization') {621 states.push(buildRbacUserDirective());622 }623 }624 }625 }626 states = _.flatten(states);627 return states;628 }629 function buildListDefinition(field) {630 let state,631 list = field.include ? $injector.get(field.include) : field,632 // Added this line specifically for Completed Jobs but should be OK633 // for all the rest of the related tabs634 breadcrumbLabel = (field.iterator.replace('_', ' ') + 's').toUpperCase(),635 stateConfig = {636 searchPrefix: `${list.iterator}`,637 name: `${formStateDefinition.name}.${list.iterator}s`,638 url: `/${list.iterator}s`,639 ncyBreadcrumb: {640 parent: `${formStateDefinition.name}`,641 label: `${breadcrumbLabel}`642 },643 params: {644 [list.iterator + '_search']: {645 value: { order_by: field.order_by ? field.order_by : 'name' }646 },647 },648 views: {649 'related': {650 templateProvider: function(FormDefinition, GenerateForm) {651 let html = GenerateForm.buildCollection({652 mode: 'edit',653 related: `${list.iterator}s`,654 form: typeof(FormDefinition) === 'function' ?655 FormDefinition() : FormDefinition656 });657 return html;658 }659 }660 },661 resolve: {662 ListDefinition: () => {663 return list;664 },665 Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope',666 (list, qs, $stateParams, GetBasePath, $interpolate, $rootScope) => {667 // allow related list definitions to use interpolated $rootScope / $stateParams in basePath field668 let path, interpolator;669 if (GetBasePath(list.basePath)) {670 path = GetBasePath(list.basePath);671 } else {672 interpolator = $interpolate(list.basePath);673 path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams });674 }675 return qs.search(path, $stateParams[`${list.iterator}_search`]);676 }677 ]678 }679 };680 if(params.controllers && params.controllers.related && params.controllers.related[field.name]) {681 stateConfig.views.related.controller = params.controllers.related[field.name];682 }683 else if(field.name === 'permissions') {684 stateConfig.views.related.controller = 'PermissionsList';685 }686 else {687 // Generic controller688 stateConfig.views.related.controller = ['$scope', 'ListDefinition', 'Dataset',689 function($scope, list, Dataset) {690 $scope.list = list;691 $scope[`${list.iterator}_dataset`] = Dataset.data;692 $scope[`${list.iterator}s`] = $scope[`${list.iterator}_dataset`].results;693 }694 ];695 }696 state = $stateExtender.buildDefinition(stateConfig);697 // appy any default search parameters in form definition698 if (field.search) {699 state.params[`${field.iterator}_search`].value = _.merge(state.params[`${field.iterator}_search`].value, field.search);700 }701 return state;702 }703 return _(form.related).map(buildListNodes).flatten().value();704 },705 /**706 * @ngdoc method707 * @name stateDefinitions.generateLookupNode708 * @description builds a node of child states for each lookup field in a form709 * @param {object} form - form definition/configuration object710 * @params {object} formStateDefinition - the parent form node711 * @returns {array} Array of state definitions [{...}, {...}, ...]712 */713 generateLookupNodes: function(form, formStateDefinition) {714 function buildFieldDefinition(field) {715 // Some lookup modals require some additional default params,716 // namely organization and inventory_script, and insights717 // credentials. If these params718 // aren't set as default params out of the gate, then smart719 // search will think they need to be set as search tags.720 var params;721 if(field.sourceModel === "organization"){722 if (form.name === "notification_template") {723 // Users with admin_role role level should also have724 // notification_admin_role so this should handle regular admin725 // users as well as notification admin users726 params = {727 page_size: '5',728 role_level: 'notification_admin_role'729 };730 } else {731 params = {732 page_size: '5',733 role_level: 'admin_role'734 };735 }736 }737 else if(field.sourceModel === "inventory_script"){738 params = {739 page_size: '5',740 role_level: 'admin_role',741 organization: null742 };743 }744 else if(field.sourceModel === "insights_credential"){745 params = {746 page_size: '5',747 role_level: 'admin_role',748 credential_type: null749 };750 }751 else if(field.sourceModel === 'host') {752 params = {753 page_size: '5'754 };755 }756 else {757 params = {758 page_size: '5',759 role_level: 'use_role'760 };761 }762 let state = $stateExtender.buildDefinition({763 searchPrefix: field.sourceModel,764 //squashSearchUrl: true, @issue enable765 name: `${formStateDefinition.name}.${field.sourceModel}`,766 url: `/${field.sourceModel}?selected`,767 // a lookup field's basePath takes precedence over generic list definition's basePath, if supplied768 data: {769 basePath: field.basePath || null,770 formChildState: true771 },772 params: {773 [field.sourceModel + '_search']: {774 value: params775 }776 },777 ncyBreadcrumb: {778 skip: true779 },780 views: {781 'modal': {782 templateProvider: function(ListDefinition, generateList) {783 const listConfig = {784 mode: 'lookup',785 list: ListDefinition,786 input_type: 'radio'787 };788 if (field.lookupMessage) {789 listConfig.lookupMessage = field.lookupMessage;790 }791 let list_html = generateList.build(listConfig);792 return `<lookup-modal>${list_html}</lookup-modal>`;793 }794 }795 },796 resolve: {797 ListDefinition: [field.list, function(list) {798 let listClone = _.cloneDeep(list);799 listClone.iterator = field.sourceModel;800 return listClone;801 }],802 OrganizationId: ['ListDefinition', 'InventoriesService', '$stateParams', '$rootScope',803 function(list, InventoriesService, $stateParams, $rootScope){804 if(list.iterator === 'inventory_script'){805 if($rootScope.$$childTail &&806 $rootScope.$$childTail.$resolve &&807 $rootScope.$$childTail.$resolve.hasOwnProperty('inventoryData')){808 return $rootScope.$$childTail.$resolve.inventoryData.summary_fields.organization.id;809 }810 else {811 return InventoriesService.getInventory($stateParams.inventory_id).then(res => res.data.summary_fields.organization.id);812 }813 }814 else {815 return;816 }817 }],818 InsightsCredTypePK: ['ListDefinition', 'Rest', 'GetBasePath', 'ProcessErrors',819 function(list, Rest, GetBasePath,ProcessErrors) {820 if(list.iterator === 'insights_credential'){821 Rest.setUrl(GetBasePath('credential_types') + '?name=Insights');822 return Rest.get()823 .then(({data}) => {824 return data.results[0].id;825 })826 .catch(({data, status}) => {827 ProcessErrors(null, data, status, null, {828 hdr: 'Error!',829 msg: 'Failed to get credential type data: ' + status830 });831 });832 }833 }],834 Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope', '$state', 'OrganizationId', 'InsightsCredTypePK',835 (list, qs, $stateParams, GetBasePath, $interpolate, $rootScope, $state, OrganizationId, InsightsCredTypePK) => {836 // allow lookup field definitions to use interpolated $stateParams / $rootScope in basePath field837 // the basePath on a form's lookup field will take precedence over the general model list's basepath838 let path, interpolator;839 if ($state.transition._targetState._definition.data && GetBasePath($state.transition._targetState._definition.data.basePath)) {840 path = GetBasePath($state.transition._targetState._definition.data.basePath);841 } else if ($state.transition._targetState._definition.data && $state.transition._targetState._definition.data.basePath) {842 interpolator = $interpolate($state.transition._targetState._definition.data.basePath);843 path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams });844 } else if (GetBasePath(list.basePath)) {845 path = GetBasePath(list.basePath);846 } else {847 interpolator = $interpolate(list.basePath);848 path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams });849 }850 // Need to change the role_level here b/c organizations and inventory scripts851 // don't have a "use_role", only "admin_role" and "read_role"852 if(list.iterator === "organization"){853 if ($state.current.name.includes('inventories')) {854 $stateParams[`${list.iterator}_search`].role_level = "inventory_admin_role";855 } else if ($state.current.name.includes('projects')) {856 $stateParams[`${list.iterator}_search`].role_level = "project_admin_role";857 } else if ($state.current.name.includes('templates.addWorkflowJobTemplate') || $state.current.name.includes('templates.editWorkflowJobTemplate')) {858 $stateParams[`${list.iterator}_search`].role_level = "workflow_admin_role";859 }860 }861 if(list.iterator === "inventory_script"){862 $stateParams[`${list.iterator}_search`].role_level = "admin_role";863 $stateParams[`${list.iterator}_search`].organization = OrganizationId;864 }865 if(list.iterator === "insights_credential"){866 $stateParams[`${list.iterator}_search`].role_level = "admin_role";867 $stateParams[`${list.iterator}_search`].credential_type = InsightsCredTypePK.toString() ;868 }869 if(list.iterator === 'credential') {870 if($state.current.name.includes('projects.edit') || $state.current.name.includes('projects.add')) {871 state.params[`${list.iterator}_search`].value = _.merge(state.params[`${list.iterator}_search`].value, $stateParams[`${list.iterator}_search`]);872 }873 }874 return qs.search(path, $stateParams[`${list.iterator}_search`]);875 }876 ]877 },878 onExit: function($state) {879 if ($state.transition) {880 $('#form-modal').modal('hide');881 $('.modal-backdrop').remove();882 $('body').removeClass('modal-open');883 }884 },885 });886 if (field.search) {887 state.params[`${field.sourceModel}_search`].value = _.merge(state.params[`${field.sourceModel}_search`].value, field.search);888 }889 return state;890 }891 return _(form.fields).filter({ type: 'lookup' }).map(buildFieldDefinition).value();892 }893 };...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1/*************************************************2 * Copyright (c) 2015 Ansible, Inc.3 *4 * All Rights Reserved5 *************************************************/6import listController from './schedulerList.controller';7import addController from './schedulerAdd.controller';8import editController from './schedulerEdit.controller';9import {templateUrl} from '../shared/template-url/template-url.factory';10import schedulerDatePicker from './schedulerDatePicker.directive';11import { N_ } from '../i18n';12import AddSchedule from './factories/add-schedule.factory';13import DeleteSchedule from './factories/delete-schedule.factory';14import EditSchedule from './factories/edit-schedule.factory';15import RRuleToAPI from './factories/r-rule-to-api.factory';16import SchedulePost from './factories/schedule-post.factory';17import ToggleSchedule from './factories/toggle-schedule.factory';18import SchedulesList from './schedules.list';19import ScheduledJobsList from './scheduled-jobs.list';20export default21 angular.module('scheduler', [])22 .controller('schedulerListController', listController)23 .controller('schedulerAddController', addController)24 .controller('schedulerEditController', editController)25 .factory('AddSchedule', AddSchedule)26 .factory('DeleteSchedule', DeleteSchedule)27 .factory('EditSchedule', EditSchedule)28 .factory('RRuleToAPI', RRuleToAPI)29 .factory('SchedulePost', SchedulePost)30 .factory('ToggleSchedule', ToggleSchedule)31 .factory('SchedulesList', SchedulesList)32 .factory('ScheduledJobsList', ScheduledJobsList)33 .directive('schedulerDatePicker', schedulerDatePicker)34 .run(['$stateExtender', function($stateExtender) {35 // Inventory sync schedule states registered in: awx/ui/client/src/inventories/manage/groups/main.js36 // Scheduled jobs states registered in awx/uiclient/src/job-detail/main.js37 // job templates38 $stateExtender.addState({39 searchPrefix: 'schedule',40 name: 'jobTemplateSchedules',41 route: '/templates/job_template/:id/schedules',42 data: {43 activityStream: true,44 activityStreamTarget: 'job_template',45 activityStreamId: 'id'46 },47 ncyBreadcrumb: {48 parent: 'templates.editJobTemplate({job_template_id: parentObject.id})',49 label: N_('SCHEDULES')50 },51 resolve: {52 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',53 function(list, qs, $stateParams, GetBasePath) {54 let path = `${GetBasePath('job_templates')}${$stateParams.id}/schedules`;55 return qs.search(path, $stateParams[`${list.iterator}_search`]);56 }57 ],58 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){59 let path = `${GetBasePath('job_templates')}${$stateParams.id}`;60 Rest.setUrl(path);61 return Rest.get(path).then((res) => res.data);62 }],63 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',64 function(Rest, GetBasePath, $stateParams, $q) {65 Rest.setUrl(GetBasePath('unified_jobs'));66 var val = $q.defer();67 Rest.options()68 .then(function(data) {69 val.resolve(data.data);70 }, function(data) {71 val.reject(data);72 });73 return val.promise;74 }],75 ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',76 (SchedulesList, GetBasePath, $stateParams) => {77 let list = _.cloneDeep(SchedulesList);78 list.basePath = GetBasePath('job_templates') + $stateParams.id + '/schedules/';79 return list;80 }81 ]82 },83 views: {84 '@': {85 templateProvider: function(ScheduleList, generateList, ParentObject, $filter){86 // include name of parent resource in listTitle87 ScheduleList.listTitle = `${$filter('sanitize')(ParentObject.name)}<div class='List-titleLockup'></div>` + N_('SCHEDULES');88 let html = generateList.build({89 list: ScheduleList,90 mode: 'edit'91 });92 html = generateList.wrapPanel(html);93 return generateList.insertFormView() + html;94 },95 controller: 'schedulerListController'96 }97 }98 });99 $stateExtender.addState({100 name: 'jobTemplateSchedules.add',101 route: '/add',102 views: {103 'form': {104 controller: 'schedulerAddController',105 templateUrl: templateUrl("scheduler/schedulerForm"),106 }107 },108 ncyBreadcrumb: {109 parent: 'jobTemplateSchedules',110 label: N_('CREATE SCHEDULE')111 }112 });113 $stateExtender.addState({114 name: 'jobTemplateSchedules.edit',115 route: '/:schedule_id',116 views: {117 'form': {118 controller: 'schedulerEditController',119 templateUrl: templateUrl("scheduler/schedulerForm"),120 }121 },122 ncyBreadcrumb: {123 parent: 'jobTemplateSchedules',124 label: '{{schedule_obj.name}}'125 }126 });127 // workflows128 $stateExtender.addState({129 searchPrefix: 'schedule',130 name: 'workflowJobTemplateSchedules',131 route: '/templates/workflow_job_template/:id/schedules',132 templateUrl: templateUrl("scheduler/scheduler"),133 controller: 'schedulerController',134 data: {135 activityStream: true,136 activityStreamTarget: 'job_template',137 activityStreamId: 'id'138 },139 ncyBreadcrumb: {140 parent: 'templates.editWorkflowJobTemplate({workflow_job_template_id: parentObject.id})',141 label: N_('SCHEDULES')142 },143 resolve: {144 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',145 function(list, qs, $stateParams, GetBasePath) {146 let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}/schedules`;147 return qs.search(path, $stateParams[`${list.iterator}_search`]);148 }149 ],150 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){151 let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`;152 Rest.setUrl(path);153 return Rest.get(path).then((res) => res.data);154 }],155 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',156 function(Rest, GetBasePath, $stateParams, $q) {157 Rest.setUrl(GetBasePath('unified_jobs'));158 var val = $q.defer();159 Rest.options()160 .then(function(data) {161 val.resolve(data.data);162 }, function(data) {163 val.reject(data);164 });165 return val.promise;166 }],167 ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',168 (SchedulesList, GetBasePath, $stateParams) => {169 let list = _.cloneDeep(SchedulesList);170 list.basePath = GetBasePath('workflow_job_templates') + $stateParams.id + '/schedules/';171 return list;172 }173 ]174 },175 views: {176 '@': {177 templateProvider: function(ScheduleList, generateList, ParentObject, $filter){178 // include name of parent resource in listTitle179 ScheduleList.listTitle = `${$filter('sanitize')(ParentObject.name)}<div class='List-titleLockup'></div>` + N_('SCHEDULES');180 let html = generateList.build({181 list: ScheduleList,182 mode: 'edit'183 });184 html = generateList.wrapPanel(html);185 return generateList.insertFormView() + html;186 },187 controller: 'schedulerListController'188 }189 }190 });191 $stateExtender.addState({192 name: 'workflowJobTemplateSchedules.add',193 route: '/add',194 views: {195 'form': {196 controller: 'schedulerAddController',197 templateUrl: templateUrl("scheduler/schedulerForm"),198 }199 },200 ncyBreadcrumb: {201 parent: 'workflowJobTemplateSchedules',202 label: N_('CREATE SCHEDULE')203 }204 });205 $stateExtender.addState({206 name: 'workflowJobTemplateSchedules.edit',207 route: '/:schedule_id',208 views: {209 'form': {210 controller: 'schedulerEditController',211 templateUrl: templateUrl("scheduler/schedulerForm"),212 }213 },214 ncyBreadcrumb: {215 parent: 'workflowJobTemplateSchedules',216 label: '{{schedule_obj.name}}'217 }218 });219 // projects220 $stateExtender.addState({221 searchPrefix: 'schedule',222 name: 'projectSchedules',223 route: '/projects/:id/schedules',224 data: {225 activityStream: true,226 activityStreamTarget: 'project',227 activityStreamId: 'id'228 },229 ncyBreadcrumb: {230 parent: 'projects.edit({project_id: parentObject.id})',231 label: N_('SCHEDULES')232 },233 resolve: {234 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',235 function(list, qs, $stateParams, GetBasePath) {236 let path = `${GetBasePath('projects')}${$stateParams.id}/schedules`;237 return qs.search(path, $stateParams[`${list.iterator}_search`]);238 }239 ],240 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){241 let path = `${GetBasePath('projects')}${$stateParams.id}`;242 Rest.setUrl(path);243 return Rest.get(path).then((res) => res.data);244 }],245 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',246 function(Rest, GetBasePath, $stateParams, $q) {247 Rest.setUrl(GetBasePath('unified_jobs'));248 var val = $q.defer();249 Rest.options()250 .then(function(data) {251 val.resolve(data.data);252 }, function(data) {253 val.reject(data);254 });255 return val.promise;256 }],257 ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',258 (SchedulesList, GetBasePath, $stateParams) => {259 let list = _.cloneDeep(SchedulesList);260 list.basePath = GetBasePath('projects') + $stateParams.id + '/schedules/';261 return list;262 }263 ]264 },265 views: {266 '@': {267 templateProvider: function(ScheduleList, generateList, ParentObject, $filter){268 // include name of parent resource in listTitle269 ScheduleList.listTitle = `${$filter('sanitize')(ParentObject.name)}<div class='List-titleLockup'></div>` + N_('SCHEDULES');270 let html = generateList.build({271 list: ScheduleList,272 mode: 'edit'273 });274 html = generateList.wrapPanel(html);275 return generateList.insertFormView() + html;276 },277 controller: 'schedulerListController'278 }279 }280 });281 $stateExtender.addState({282 name: 'projectSchedules.add',283 route: '/add',284 ncyBreadcrumb: {285 label: N_('CREATE SCHEDULE')286 },287 views: {288 'form': {289 controller: 'schedulerAddController',290 templateUrl: templateUrl("scheduler/schedulerForm"),291 }292 }293 });294 $stateExtender.addState({295 name: 'projectSchedules.edit',296 route: '/:schedule_id',297 ncyBreadcrumb: {298 label: '{{schedule_obj.name}}'299 },300 views: {301 'form': {302 controller: 'schedulerEditController',303 templateUrl: templateUrl("scheduler/schedulerForm"),304 }305 }306 });307 // upcoming scheduled jobs308 $stateExtender.addState({309 searchPrefix: 'schedule',310 name: 'jobs.schedules',311 route: '/schedules',312 params: {313 schedule_search: {314 value: {315 next_run__isnull: 'false',316 order_by: 'unified_job_template__polymorphic_ctype__model'317 },318 dynamic: true319 }320 },321 data: {322 activityStream: false,323 },324 ncyBreadcrumb: {325 parent: 'jobs',326 label: N_('SCHEDULED')327 },328 resolve: {329 ScheduleList: ['ScheduledJobsList', function(list){330 return list;331 }],332 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',333 function(list, qs, $stateParams, GetBasePath) {334 let path = GetBasePath('schedules');335 return qs.search(path, $stateParams[`${list.iterator}_search`]);336 }337 ],338 ParentObject: ['GetBasePath', (GetBasePath) =>{return {endpoint:GetBasePath('schedules')}; }],339 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',340 function(Rest, GetBasePath, $stateParams, $q) {341 Rest.setUrl(GetBasePath('unified_jobs'));342 var val = $q.defer();343 Rest.options()344 .then(function(data) {345 val.resolve(data.data);346 }, function(data) {347 val.reject(data);348 });349 return val.promise;350 }]351 },352 views: {353 'list@jobs': {354 templateProvider: function(ScheduleList, generateList){355 let html = generateList.build({356 list: ScheduleList,357 mode: 'edit',358 title: false359 });360 return html;361 },362 controller: 'schedulerListController'363 }364 }365 });...

Full Screen

Full Screen

schedules.route.js

Source:schedules.route.js Github

copy

Full Screen

1import { N_ } from '../i18n';2import {templateUrl} from '../shared/template-url/template-url.factory';3import editScheduleResolve from './editSchedule.resolve';4const jobTemplatesSchedulesListRoute = {5 searchPrefix: 'schedule',6 name: 'templates.editJobTemplate.schedules',7 route: '/schedules',8 data: {9 activityStream: true,10 activityStreamTarget: 'job_template',11 },12 ncyBreadcrumb: {13 label: N_('SCHEDULES')14 },15 resolve: {16 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',17 function(list, qs, $stateParams, GetBasePath) {18 let path = `${GetBasePath('job_templates')}${$stateParams.job_template_id}/schedules`;19 return qs.search(path, $stateParams[`${list.iterator}_search`]);20 }21 ],22 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){23 let path = `${GetBasePath('job_templates')}${$stateParams.job_template_id}`;24 Rest.setUrl(path);25 return Rest.get(path).then(response => response.data);26 }],27 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$q',28 function(Rest, GetBasePath, $q) {29 Rest.setUrl(GetBasePath('unified_jobs'));30 var val = $q.defer();31 Rest.options()32 .then(function(data) {33 val.resolve(data.data);34 }, function(data) {35 val.reject(data);36 });37 return val.promise;38 }],39 ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',40 (SchedulesList, GetBasePath, $stateParams) => {41 let list = _.cloneDeep(SchedulesList);42 list.basePath = GetBasePath('job_templates') + $stateParams.job_template_id + '/schedules/';43 return list;44 }45 ]46 },47 views: {48 related: {49 templateProvider: function(ScheduleList, generateList){50 ScheduleList.title = false;51 let html = generateList.build({52 list: ScheduleList,53 mode: 'edit'54 });55 return html;56 },57 controller: 'schedulerListController'58 }59 }60};61const jobTemplatesSchedulesAddRoute = {62 name: 'templates.editJobTemplate.schedules.add',63 route: '/add',64 views: {65 'scheduler@templates': {66 controller: 'schedulerAddController',67 templateUrl: templateUrl("scheduler/schedulerForm"),68 }69 },70 ncyBreadcrumb: {71 label: N_('CREATE SCHEDULE')72 }73};74const jobTemplatesSchedulesEditRoute = {75 name: 'templates.editJobTemplate.schedules.edit',76 route: '/:schedule_id',77 views: {78 'scheduler@templates': {79 controller: 'schedulerEditController',80 templateUrl: templateUrl("scheduler/schedulerForm"),81 }82 },83 ncyBreadcrumb: {84 label: "{{breadcrumb.schedule_name}}"85 },86 resolve: editScheduleResolve()87};88// workflows89const workflowSchedulesRoute = {90 searchPrefix: 'schedule',91 name: 'templates.editWorkflowJobTemplate.schedules',92 route: '/schedules',93 data: {94 activityStream: true,95 activityStreamTarget: 'workflow_job_template',96 },97 ncyBreadcrumb: {98 label: N_('SCHEDULES')99 },100 resolve: {101 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',102 function(list, qs, $stateParams, GetBasePath) {103 let path = `${GetBasePath('workflow_job_templates')}${$stateParams.workflow_job_template_id}/schedules`;104 return qs.search(path, $stateParams[`${list.iterator}_search`]);105 }106 ],107 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){108 let path = `${GetBasePath('workflow_job_templates')}${$stateParams.workflow_job_template_id}`;109 Rest.setUrl(path);110 return Rest.get(path).then(response => response.data);111 }],112 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',113 function(Rest, GetBasePath, $stateParams, $q) {114 Rest.setUrl(GetBasePath('unified_jobs'));115 var val = $q.defer();116 Rest.options()117 .then(function(data) {118 val.resolve(data.data);119 }, function(data) {120 val.reject(data);121 });122 return val.promise;123 }],124 ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',125 (SchedulesList, GetBasePath, $stateParams) => {126 let list = _.cloneDeep(SchedulesList);127 list.basePath = GetBasePath('workflow_job_templates') + $stateParams.workflow_job_template_id + '/schedules/';128 return list;129 }130 ]131 },132 views: {133 related: {134 templateProvider: function(ScheduleList, generateList){135 ScheduleList.title = false;136 let html = generateList.build({137 list: ScheduleList,138 mode: 'edit'139 });140 return html;141 },142 controller: 'schedulerListController'143 }144 }145};146const workflowSchedulesAddRoute = {147 name: 'templates.editWorkflowJobTemplate.schedules.add',148 route: '/add',149 views: {150 'scheduler@templates': {151 controller: 'schedulerAddController',152 templateUrl: templateUrl("scheduler/schedulerForm"),153 }154 },155 ncyBreadcrumb: {156 label: N_('CREATE SCHEDULE')157 }158};159const workflowSchedulesEditRoute = {160 name: 'templates.editWorkflowJobTemplate.schedules.edit',161 route: '/:schedule_id',162 views: {163 'scheduler@templates': {164 controller: 'schedulerEditController',165 templateUrl: templateUrl("scheduler/schedulerForm"),166 }167 },168 ncyBreadcrumb: {169 label: '{{breadcrumb.schedule_name}}'170 },171 resolve: editScheduleResolve()172};173const projectsSchedulesListRoute = {174 searchPrefix: 'schedule',175 name: 'projects.edit.schedules',176 route: '/schedules',177 data: {178 activityStream: true,179 activityStreamTarget: 'project',180 },181 ncyBreadcrumb: {182 label: N_('SCHEDULES')183 },184 resolve: {185 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',186 function(list, qs, $stateParams, GetBasePath) {187 let path = `${GetBasePath('projects')}${$stateParams.project_id}/schedules`;188 return qs.search(path, $stateParams[`${list.iterator}_search`]);189 }190 ],191 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){192 let path = `${GetBasePath('projects')}${$stateParams.project_id}`;193 Rest.setUrl(path);194 return Rest.get(path).then(response => response.data);195 }],196 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',197 function(Rest, GetBasePath, $stateParams, $q) {198 Rest.setUrl(GetBasePath('unified_jobs'));199 var val = $q.defer();200 Rest.options()201 .then(function(data) {202 val.resolve(data.data);203 }, function(data) {204 val.reject(data);205 });206 return val.promise;207 }],208 ScheduleList: ['SchedulesList', 'GetBasePath', '$stateParams',209 (SchedulesList, GetBasePath, $stateParams) => {210 let list = _.cloneDeep(SchedulesList);211 list.basePath = GetBasePath('projects') + $stateParams.project_id + '/schedules/';212 return list;213 }214 ]215 },216 views: {217 related: {218 templateProvider: function(ScheduleList, generateList){219 ScheduleList.title = false;220 let html = generateList.build({221 list: ScheduleList,222 mode: 'edit'223 });224 return html;225 },226 controller: 'schedulerListController'227 }228 }229};230const projectsSchedulesAddRoute = {231 name: 'projects.edit.schedules.add',232 route: '/add',233 ncyBreadcrumb: {234 label: N_('CREATE SCHEDULE')235 },236 views: {237 'scheduler@projects': {238 controller: 'schedulerAddController',239 templateUrl: templateUrl("scheduler/schedulerForm"),240 }241 }242};243const projectsSchedulesEditRoute = {244 name: 'projects.edit.schedules.edit',245 route: '/:schedule_id',246 ncyBreadcrumb: {247 label: "{{breadcrumb.schedule_name}}"248 },249 views: {250 'scheduler@projects': {251 controller: 'schedulerEditController',252 templateUrl: templateUrl("scheduler/schedulerForm"),253 }254 },255 resolve: editScheduleResolve()256};257const jobsSchedulesRoute = {258 searchPrefix: 'schedule',259 name: 'schedules',260 route: '/schedules',261 params: {262 schedule_search: {263 value: {264 next_run__isnull: 'false',265 order_by: 'unified_job_template__polymorphic_ctype__model'266 },267 dynamic: true268 }269 },270 data: {271 activityStream: false,272 },273 ncyBreadcrumb: {274 label: N_('SCHEDULES')275 },276 resolve: {277 ScheduleList: ['ScheduledJobsList', function(list){278 return list;279 }],280 Dataset: ['ScheduleList', 'QuerySet', '$stateParams', 'GetBasePath',281 function(list, qs, $stateParams, GetBasePath) {282 let path = GetBasePath('schedules');283 return qs.search(path, $stateParams[`${list.iterator}_search`]);284 }285 ],286 ParentObject: ['GetBasePath', (GetBasePath) =>{return {endpoint:GetBasePath('schedules')}; }],287 UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',288 function(Rest, GetBasePath, $stateParams, $q) {289 Rest.setUrl(GetBasePath('unified_jobs'));290 var val = $q.defer();291 Rest.options()292 .then(function(data) {293 val.resolve(data.data);294 }, function(data) {295 val.reject(data);296 });297 return val.promise;298 }]299 },300 views: {301 '@': {302 templateProvider: function(ScheduleList, generateList){303 304 let html = generateList.build({305 list: ScheduleList,306 mode: 'edit'307 });308 html = generateList.wrapPanel(html);309 let formPlaceholder = generateList.insertFormView();310 html = formPlaceholder + html;311 return html;312 },313 controller: 'schedulerListController'314 }315 }316};317// the /#/jobs/schedules/:schedule_id state needs to know about the type of318// resource is being scheduled.319const parentResolve = {320 ParentObject: ['$stateParams', 'Rest', 'GetBasePath', 'scheduleResolve',321 function($stateParams, Rest, GetBasePath, scheduleResolve){322 let path = scheduleResolve.related.unified_job_template;323 Rest.setUrl(path);324 return Rest.get(path).then(response => response.data);325 }326 ]327};328const jobsSchedulesEditRoute = {329 name: 'schedules.edit',330 route: '/:schedule_id',331 ncyBreadcrumb: {332 parent: 'schedules',333 label: "{{breadcrumb.schedule_name}}"334 },335 views: {336 'form':{337 templateProvider: function(ParentObject, $http){338 let path;339 if(ParentObject.type === 'system_job_template'){340 path = templateUrl('management-jobs/scheduler/schedulerForm');341 }342 else {343 path = templateUrl('scheduler/schedulerForm');344 }345 return $http.get(path).then(response => response.data);346 },347 controllerProvider: function(ParentObject){348 if (ParentObject.type === 'system_job_template') {349 return 'managementJobEditController';350 }351 else {352 return 'schedulerEditController';353 }354 }355 }356 },357 resolve: _.merge(editScheduleResolve(), parentResolve)358};359export {360 jobTemplatesSchedulesListRoute,361 jobTemplatesSchedulesAddRoute,362 jobTemplatesSchedulesEditRoute,363 workflowSchedulesRoute,364 workflowSchedulesAddRoute,365 workflowSchedulesEditRoute,366 projectsSchedulesListRoute,367 projectsSchedulesAddRoute,368 projectsSchedulesEditRoute,369 jobsSchedulesRoute,370 jobsSchedulesEditRoute...

Full Screen

Full Screen

organizations-linkout.route.js

Source:organizations-linkout.route.js Github

copy

Full Screen

1/*************************************************2 * Copyright (c) 2016 Ansible, Inc.3 *4 * All Rights Reserved5 *************************************************/6import OrganizationsJobTemplatesRoute from '~features/templates/routes/organizationsTemplatesList.route';7import OrganizationsAdmins from './controllers/organizations-admins.controller';8import OrganizationsInventories from './controllers/organizations-inventories.controller';9import OrganizationsProjects from './controllers/organizations-projects.controller';10import OrganizationsTeams from './controllers/organizations-teams.controller';11import OrganizationsUsers from './controllers/organizations-users.controller';12import { N_ } from '../../i18n';13let lists = [{14 name: 'organizations.users',15 url: '/:organization_id/users',16 searchPrefix: 'user',17 views: {18 'form': {19 controller: OrganizationsUsers,20 templateProvider: function(OrgUserList, generateList) {21 let html = generateList.build({22 list: OrgUserList,23 mode: 'edit',24 cancelButton: true25 });26 return generateList.wrapPanel(html);27 },28 }29 },30 params: {31 user_search: {32 value: {33 order_by: 'username'34 },35 dynamic: true36 }37 },38 ncyBreadcrumb: {39 parent: "organizations.edit",40 label: N_("USERS")41 },42 data: {43 activityStream: true,44 activityStreamTarget: 'organization'45 },46 resolve: {47 features: ['FeaturesService', function(FeaturesService) {48 return FeaturesService.get();49 }],50 OrgUsersDataset: ['OrgUserList', 'QuerySet', '$stateParams', 'GetBasePath',51 function(list, qs, $stateParams, GetBasePath) {52 let path = GetBasePath(list.basePath) || list.basePath;53 return qs.search(path, $stateParams.org_user_search);54 }55 ],56 OrgUserList: ['UserList', 'GetBasePath', '$stateParams', 'i18n', function(UserList, GetBasePath, $stateParams, i18n) {57 let list = _.cloneDeep(UserList);58 delete list.actions.add;59 list.basePath = `${GetBasePath('organizations')}${$stateParams.organization_id}/users`;60 list.searchRowActions = {61 add: {62 awToolTip: i18n._('Add existing user to organization'),63 actionClass: 'at-Button--add',64 actionId: 'button-add',65 ngClick: 'addUsers()'66 }67 };68 return list;69 }]70 }71}, {72 name: 'organizations.teams',73 url: '/:organization_id/teams',74 searchPrefix: 'team',75 views: {76 'form': {77 controller: OrganizationsTeams,78 templateProvider: function(OrgTeamList, generateList) {79 let html = generateList.build({80 list: OrgTeamList,81 mode: 'edit',82 cancelButton: true83 });84 return generateList.wrapPanel(html);85 },86 },87 },88 data: {89 activityStream: true,90 activityStreamTarget: 'organization'91 },92 ncyBreadcrumb: {93 parent: "organizations.edit",94 label: N_("TEAMS")95 },96 resolve: {97 features: ['FeaturesService', function(FeaturesService) {98 return FeaturesService.get();99 }],100 OrgTeamList: ['TeamList', 'GetBasePath', '$stateParams', 'i18n', function(TeamList, GetBasePath, $stateParams, i18n) {101 let list = _.cloneDeep(TeamList);102 delete list.actions.add;103 // @issue Why is the delete action unavailable in this view?104 delete list.fieldActions.delete;105 list.listTitle = i18n._('Teams') + ` | {{ name }}`;106 list.basePath = `${GetBasePath('organizations')}${$stateParams.organization_id}/teams`;107 list.emptyListText = `${i18n._('This list is populated by teams added from the')}&nbsp;<a ui-sref='teams.add'>${N_('Teams')}</a>&nbsp;${N_('section')}`;108 return list;109 }],110 OrgTeamsDataset: ['OrgTeamList', 'QuerySet', '$stateParams', 'GetBasePath',111 function(list, qs, $stateParams, GetBasePath) {112 let path = GetBasePath(list.basePath) || list.basePath;113 return qs.search(path, $stateParams.team_search);114 }115 ]116 }117}, {118 name: 'organizations.inventories',119 url: '/:organization_id/inventories',120 searchPrefix: 'inventory',121 views: {122 'form': {123 controller: OrganizationsInventories,124 templateProvider: function(OrgInventoryList, generateList) {125 let html = generateList.build({126 list: OrgInventoryList,127 mode: 'edit',128 cancelButton: true129 });130 return generateList.wrapPanel(html);131 },132 },133 },134 data: {135 activityStream: true,136 activityStreamTarget: 'organization'137 },138 ncyBreadcrumb: {139 parent: "organizations.edit",140 label: N_("INVENTORIES")141 },142 resolve: {143 features: ['FeaturesService', function(FeaturesService) {144 return FeaturesService.get();145 }],146 OrgInventoryList: ['InventoryList', 'GetBasePath', '$stateParams', 'i18n', function(InventoryList, GetBasePath, $stateParams, i18n) {147 let list = _.cloneDeep(InventoryList);148 delete list.actions.add;149 // @issue Why is the delete action unavailable in this view?150 delete list.fieldActions.delete;151 list.title = true;152 list.listTitle = i18n._('Inventories') + ` | {{ name }}`;153 list.basePath = `${GetBasePath('organizations')}${$stateParams.organization_id}/inventories`;154 list.emptyListText = `${i18n._("This list is populated by inventories added from the")}&nbsp;<a ui-sref='inventories.add'>${N_("Inventories")}</a>&nbsp;${N_("section")}`;155 return list;156 }],157 OrgInventoryDataset: ['OrgInventoryList', 'QuerySet', '$stateParams', 'GetBasePath',158 function(list, qs, $stateParams, GetBasePath) {159 let path = GetBasePath(list.basePath) || list.basePath;160 return qs.search(path, $stateParams.inventory_search);161 }162 ]163 }164}, {165 name: 'organizations.projects',166 url: '/:organization_id/projects',167 searchPrefix: 'project',168 views: {169 'form': {170 controller: OrganizationsProjects,171 templateProvider: function(OrgProjectList, generateList) {172 let html = generateList.build({173 list: OrgProjectList,174 mode: 'edit',175 cancelButton: true176 });177 return generateList.wrapPanel(html);178 },179 },180 },181 data: {182 activityStream: true,183 activityStreamTarget: 'organization',184 socket: {185 "groups": {186 "jobs": ["status_changed"]187 }188 },189 },190 ncyBreadcrumb: {191 parent: "organizations.edit",192 label: N_("PROJECTS")193 },194 resolve: {195 features: ['FeaturesService', function(FeaturesService) {196 return FeaturesService.get();197 }],198 OrgProjectList: ['ProjectList', 'GetBasePath', '$stateParams', 'i18n', function(ProjectList, GetBasePath, $stateParams, i18n) {199 let list = _.cloneDeep(ProjectList);200 delete list.actions;201 // @issue Why is the delete action unavailable in this view?202 delete list.fieldActions.delete;203 list.listTitle = i18n._('Projects') + ` | {{ name }}`;204 list.basePath = `${GetBasePath('organizations')}${$stateParams.organization_id}/projects`;205 list.emptyListText = `${i18n._("This list is populated by projects added from the")}&nbsp;<a ui-sref='projects.add'>${N_("Projects")}</a>&nbsp;${N_("section")}`;206 return list;207 }],208 OrgProjectDataset: ['OrgProjectList', 'QuerySet', '$stateParams', 'GetBasePath',209 function(list, qs, $stateParams, GetBasePath) {210 let path = GetBasePath(list.basePath) || list.basePath;211 return qs.search(path, $stateParams.project_search);212 }213 ]214 }215}, {216 name: 'organizations.admins',217 url: '/:organization_id/admins',218 searchPrefix: 'user',219 params: {220 user_search: {221 value: {222 order_by: 'username'223 },224 dynamic: true225 },226 add_user_search: {227 value: {228 order_by: 'username',229 page_size: '5',230 },231 dynamic: true,232 squash: true233 }234 },235 views: {236 'form': {237 controller: OrganizationsAdmins,238 templateProvider: function(OrgAdminList, generateList) {239 let html = generateList.build({240 list: OrgAdminList,241 mode: 'edit',242 cancelButton: true243 });244 return generateList.wrapPanel(html);245 },246 }247 },248 data: {249 activityStream: true,250 activityStreamTarget: 'organization'251 },252 ncyBreadcrumb: {253 parent: "organizations.edit",254 label: N_("ADMINS")255 },256 resolve: {257 features: ['FeaturesService', function(FeaturesService) {258 return FeaturesService.get();259 }],260 OrgAdminsDataset: ['OrgAdminList', 'QuerySet', '$stateParams', 'GetBasePath',261 function(list, qs, $stateParams, GetBasePath) {262 let path = GetBasePath(list.basePath) || list.basePath;263 return qs.search(path, $stateParams[`user_search`]);264 }265 ],266 OrgAdminList: ['UserList', 'GetBasePath', '$stateParams', 'i18n', function(UserList, GetBasePath, $stateParams, i18n) {267 let list = _.cloneDeep(UserList);268 delete list.actions.add;269 list.basePath = `${GetBasePath('organizations')}${$stateParams.organization_id}/admins`;270 list.searchRowActions = {271 add: {272 awToolTip: i18n._('Add existing user to organization as administrator'),273 actionClass: 'at-Button--add',274 ngClick: 'addUsers()'275 }276 };277 list.listTitle = i18n._('Admins') + ` | {{ name }}`;278 return list;279 }]280 }281}];282lists.push(OrganizationsJobTemplatesRoute);...

Full Screen

Full Screen

templates.service.js

Source:templates.service.js Github

copy

Full Screen

1/*************************************************2 * Copyright (c) 2015 Ansible, Inc.3 *4 * All Rights Reserved5 *************************************************/6export default ['Rest', 'GetBasePath', '$q', 'NextPage', function(Rest, GetBasePath, $q, NextPage){7 return {8 deleteJobTemplate: function(id){9 var url = GetBasePath('job_templates');10 url = url + id;11 Rest.setUrl(url);12 return Rest.destroy();13 },14 deleteWorkflowJobTemplate: function(id) {15 var url = GetBasePath('workflow_job_templates');16 url = url + id;17 Rest.setUrl(url);18 return Rest.destroy();19 },20 createJobTemplate: function(data){21 var url = GetBasePath('job_templates');22 Rest.setUrl(url);23 return Rest.post(data);24 },25 createWorkflowJobTemplate: function(data) {26 var url = GetBasePath('workflow_job_templates');27 Rest.setUrl(url);28 return Rest.post(data);29 },30 getAllLabelOptions: function() {31 Rest.setUrl(GetBasePath('labels') + '?page_size=200');32 return Rest.get()33 .then(function(res) {34 if (res.data.next) {35 return NextPage({36 url: res.data.next,37 arrayOfValues: res.data.results38 }).then(function(labels) {39 return labels;40 }).catch(function(response){41 return $q.reject( response );42 });43 }44 else {45 return $q.resolve( res.data.results );46 }47 }).catch(function(response){48 return $q.reject( response );49 });50 },51 getAllJobTemplateLabels: function(id) {52 Rest.setUrl(GetBasePath('job_templates') + id + "/labels?page_size=20");53 return Rest.get()54 .then(function(res) {55 if (res.data.next) {56 return NextPage({57 url: res.data.next,58 arrayOfValues: res.data.results59 }).then(function(labels) {60 return labels;61 }).catch(function(response){62 return $q.reject( response );63 });64 }65 else {66 return $q.resolve( res.data.results );67 }68 }).catch(function(response){69 return $q.reject( response );70 });71 },72 getAllWorkflowJobTemplateLabels: function(id) {73 Rest.setUrl(GetBasePath('workflow_job_templates') + id + "/labels?page_size=200");74 return Rest.get()75 .then(function(res) {76 if (res.data.next) {77 return NextPage({78 url: res.data.next,79 arrayOfValues: res.data.results80 }).then(function(labels) {81 return labels;82 }).catch(function(response){83 return $q.reject( response );84 });85 }86 else {87 return $q.resolve( res.data.results );88 }89 }).catch(function(response){90 return $q.reject( response );91 });92 },93 getJobTemplate: function(id) {94 var url = GetBasePath('job_templates');95 url = url + id;96 Rest.setUrl(url);97 return Rest.get();98 },99 addWorkflowNode: function(params) {100 // params.url101 // params.data102 Rest.setUrl(params.url);103 return Rest.post(params.data);104 },105 editWorkflowNode: function(params) {106 // params.id107 // params.data108 var url = GetBasePath('workflow_job_template_nodes') + params.id;109 Rest.setUrl(url);110 return Rest.put(params.data);111 },112 getJobTemplateLaunchInfo: function(id) {113 var url = GetBasePath('job_templates');114 url = url + id + '/launch';115 Rest.setUrl(url);116 return Rest.get();117 },118 getWorkflowJobTemplateNodes: function(id, page) {119 var url = GetBasePath('workflow_job_templates');120 url = url + id + '/workflow_nodes?page_size=200';121 if(page) {122 url += '/&page=' + page;123 }124 Rest.setUrl(url);125 return Rest.get();126 },127 updateWorkflowJobTemplate: function(params) {128 // params.id129 // params.data130 var url = GetBasePath('workflow_job_templates');131 url = url + params.id;132 Rest.setUrl(url);133 return Rest.patch(params.data);134 },135 getWorkflowJobTemplate: function(id) {136 var url = GetBasePath('workflow_job_templates');137 url = url + id;138 Rest.setUrl(url);139 return Rest.get();140 },141 deleteWorkflowJobTemplateNode: function(id) {142 var url = GetBasePath('workflow_job_template_nodes') + id;143 Rest.setUrl(url);144 return Rest.destroy();145 },146 disassociateWorkflowNode: function(params) {147 //params.parentId148 //params.nodeId149 //params.edge150 var url = GetBasePath('workflow_job_template_nodes') + params.parentId;151 if(params.edge === 'success') {152 url = url + '/success_nodes';153 }154 else if(params.edge === 'failure') {155 url = url + '/failure_nodes';156 }157 else if(params.edge === 'always') {158 url = url + '/always_nodes';159 }160 Rest.setUrl(url);161 return Rest.post({162 "id": params.nodeId,163 "disassociate": true164 });165 },166 associateWorkflowNode: function(params) {167 //params.parentId168 //params.nodeId169 //params.edge170 var url = GetBasePath('workflow_job_template_nodes') + params.parentId;171 if(params.edge === 'success') {172 url = url + '/success_nodes';173 }174 else if(params.edge === 'failure') {175 url = url + '/failure_nodes';176 }177 else if(params.edge === 'always') {178 url = url + '/always_nodes';179 }180 Rest.setUrl(url);181 return Rest.post({182 id: params.nodeId183 });184 },185 getUnifiedJobTemplate: function(id) {186 var url = GetBasePath('unified_job_templates');187 url = url + "?id=" + id;188 Rest.setUrl(url);189 return Rest.get();190 },191 getCredential: function(id) {192 var url = GetBasePath('credentials');193 url = url + id;194 Rest.setUrl(url);195 return Rest.get();196 },197 getInventory: function(id) {198 var url = GetBasePath('inventory');199 url = url + id;200 Rest.setUrl(url);201 return Rest.get();202 },203 getWorkflowCopy: function(id) {204 let url = GetBasePath('workflow_job_templates');205 url = url + id + '/copy';206 Rest.setUrl(url);207 return Rest.get();208 },209 copyWorkflow: function(id) {210 let url = GetBasePath('workflow_job_templates');211 url = url + id + '/copy';212 Rest.setUrl(url);213 return Rest.post();214 },215 getWorkflowJobTemplateOptions: function() {216 var deferred = $q.defer();217 let url = GetBasePath('workflow_job_templates');218 Rest.setUrl(url);219 Rest.options()220 .then(({data}) => {221 deferred.resolve(data);222 }).catch(({msg, code}) => {223 deferred.reject(msg, code);224 });225 return deferred.promise;226 },227 getJobTemplateOptions: function() {228 var deferred = $q.defer();229 let url = GetBasePath('job_templates');230 Rest.setUrl(url);231 Rest.options()232 .then(({data}) => {233 deferred.resolve(data);234 }).catch(({msg, code}) => {235 deferred.reject(msg, code);236 });237 return deferred.promise;238 },239 postWorkflowNodeCredential: function(params) {240 // params.id241 // params.data242 var url = GetBasePath('workflow_job_template_nodes') + params.id + '/credentials';243 Rest.setUrl(url);244 return Rest.post(params.data);245 }246 };...

Full Screen

Full Screen

angular.js

Source:angular.js Github

copy

Full Screen

...18 */19gulp.task('js', function () {20 return gulp.src([21 helper.getBaseRoot() + '/roa-constants/constants/roag_exports.js',22 helper.getBasePath() + '/js/lib/coherent.js',23 helper.getBasePath() + '/js/lib/base64.js',24 helper.getBasePath() + '/js/static/translations.js',25 helper.getBasePath() + '/js/lib/jquery.min.js',26 helper.getBasePath() + '/js/lib/jquery-ui.js',27 // helper.getBasePath() + '/js/lib/sql.js' //DONT include this file, because SQL.js is already minified, and in minified state it crashes and can't open DB again, thats why we add it normal,28 helper.getBasePath() + '/js/lib/resizeSensor.js',29 helper.getBasePath() + '/js/lib/elementQueries.js',30 helper.getBasePath() + '/js/lib/angular.min.js',31 helper.getBasePath() + '/js/lib/angular-sanitize.min.js',32 helper.getBasePath() + '/js/lib/ng-slider.min.js',33 helper.getBasePath() + '/js/lib/angular-ui-router.js',34 helper.getBasePath() + '/js/lib/angular-translate.js',35 helper.getBasePath() + '/js/lib/angular-dragdrop.min.js',36 helper.getBasePath() + '/js/lib/angularUI-bootstrap.js',37 helper.getBasePath() + '/js/config/routeProvider.js',38 helper.getBasePath() + '/js/config/translationProvider.js',39 helper.getBasePath() + '/js/config/httpProvider.js',40 helper.getBasePath() + '/js/factories/factories.js',41 helper.getBasePath() + '/js/directives/controls/buttonIcon.js',42 helper.getBasePath() + '/js/directives/controls/buttonText.js',43 helper.getBasePath() + '/js/directives/controls/checkbox.js',44 helper.getBasePath() + '/js/directives/controls/dropDown.js',45 helper.getBasePath() + '/js/directives/controls/roaSrc.js',46 helper.getBasePath() + '/js/directives/controls/roaBackgroundImage.js',47 helper.getBasePath() + '/js/directives/controls/qbSlider.js',48 helper.getBasePath() + '/js/directives/controls/radio.js',49 helper.getBasePath() + '/js/directives/controls/registerKey.js',50 helper.getBasePath() + '/js/directives/controls/textbox.js',51 helper.getBasePath() + '/js/directives/controls/chatTab.js',52 helper.getBasePath() + '/js/directives/controls/chatTabCtrl.js',53 helper.getBasePath() + '/js/directives/controls/storage.js',54 helper.getBasePath() + '/js/directives/controls/item.js',55 helper.getBasePath() + '/js/directives/directives.js',56 helper.getBasePath() + '/js/controller/bodyController.js',57 helper.getBasePath() + '/js/controller/settingsController.js',58 helper.getBasePath() + '/js/controller/escController.js',59 helper.getBasePath() + '/js/controller/helpController.js',60 helper.getBasePath() + '/js/controller/temporaryController.js',61 helper.getBasePath() + '/js/controller/logController.js',62 helper.getBasePath() + '/js/controller/informationController.js',63 helper.getBasePath() + '/js/controller/state/login/loginController.js',64 helper.getBasePath() + '/js/controller/state/game/topbar/topbar.js',65 helper.getBasePath() + '/js/controller/state/game/chat/chatController.js',66 helper.getBasePath() + '/js/controller/state/game/charCreation/charCreationController.js',67 helper.getBasePath() + '/js/controller/state/game/charSelection/charSelectionController.js',68 helper.getBasePath() + '/js/controller/state/game/taskbar/taskbarController.js',69 helper.getBasePath() + '/js/controller/state/game/storage/storageController.js',70 helper.getBasePath() + '/js/controller/state/game/overlay/overlayController.js',71 helper.getBasePath() + '/js/controller/state/game/minigames/gathering/mining/gatheringMiningController.js',72 helper.getBasePath() + '/js/services/logService.js',73 helper.getBasePath() + '/js/services/uiDB.js',74 helper.getBasePath() + '/js/services/helperService.js',75 helper.getBasePath() + '/js/services/uiService.js',76 helper.getBasePath() + '/js/services/uiCommunicate.js',77 helper.getBasePath() + '/js/services/uiSocket.js',78 helper.getBasePath() + '/js/services/uiAudio.js',79 helper.getBasePath() + '/js/services/uiUser.js',80 helper.getBasePath() + '/js/models/uiCommunicateModel.js',81 helper.getBasePath() + '/js/models/uiCommunicateSocketModel.js',82 helper.getBasePath() + '/js/data/uiCommunicateData.js',83 helper.getBasePath() + '/js/data/uiCommunicateSocketData.js',84 helper.getBasePath() + '/js/data/uiControllerData.js',85 helper.getBasePath() + '/js/data/uiChannelData.js',86 helper.getBasePath() + '/js/data/uiBroadcastData.js',87 helper.getBasePath() + '/js-build/templates.js',88 helper.getBasePath() + '/js-build/app_for_minification.js',89 helper.getBasePath() + '/js/factory.js',90 helper.getBasePath() + '/js/controllers.js',91 helper.getBasePath() + '/js/services.js',92 helper.getBasePath() + '/js/models.js',93 ])94 .pipe(concat({path: 'app.min.js', stat: {mode: 0666}}))95 .pipe(uglify({compress: {hoist_funs: false}}))96 .pipe(insert.prepend(helper.copyright(argv.VERSION)))97 .pipe(gulp.dest(helper.getDeployPath() + '/js'));98});99/**100 * Compile the angular templates101 */102gulp.task('templates', function () {103 return gulp.src(helper.getBasePath() + '/templates/**/*.html')104 .pipe(minifyHtml({empty: true, quotes: true}))105 .pipe(ngTemplate({106 moduleName: 'templates',107 standalone: true,108 filePath: 'templates.js',109 prefix: argv.URL + '/templates/',110 })).pipe(gulp.dest(helper.getBasePath() + '/js-build')); // output file: 'dist/js/templates.js'111});112/**113 * Prepare angular config114 */115gulp.task('prepare-angular-config', function () {116 var normalApp;117 if (argv.BRANCH !== "master") {118 //Empty it because development119 normalApp = gulp.src([120 helper.getBasePath() + '/js/app.js'121 ]).pipe(replace(/'{{ADD_MODULES}}'/g, ""))122 .pipe(rename('app.js'))123 .pipe(gulp.dest(helper.getBasePath() + '/js-build')); // output file: 'dist/js/templates.js'124 }125 else {126 //Add the templates module127 normalApp = gulp.src([128 helper.getBasePath() + '/js/app.js'129 ]).pipe(replace(/'{{ADD_MODULES}}'/g, "'templates'"))130 .pipe(rename('app.js'))131 .pipe(gulp.dest(helper.getBasePath() + '/js-build')); // output file: 'dist/js/templates.js'132 }133 //We need to compile always one with "compiled_app.js" for minification that stage system also can work with the templates134 var compiledApp = gulp.src([135 helper.getBasePath() + '/js/app.js'136 ]).pipe(replace(/'{{ADD_MODULES}}'/g, "'templates'"))137 .pipe(rename('app_for_minification.js'))138 .pipe(gulp.dest(helper.getBasePath() + '/js-build')); // output file: 'dist/js/templates.js'139 return merge(normalApp,compiledApp);140});...

Full Screen

Full Screen

insights.route.js

Source:insights.route.js Github

copy

Full Screen

1import {templateUrl} from '../../../shared/template-url/template-url.factory';2import { N_ } from '../../../i18n';3export default {4 url: '/insights',5 ncyBreadcrumb: {6 label: N_("INSIGHTS")7 },8 views: {9 'related': {10 controller: 'InsightsController',11 templateUrl: templateUrl('inventories-hosts/inventories/insights/insights')12 }13 },14 resolve: {15 InsightsData: ['Rest', '$stateParams', 'GetBasePath', 'ProcessErrors',16 (Rest, $stateParams, GetBasePath, ProcessErrors) => {17 var path = `${GetBasePath('hosts')}${$stateParams.host_id}/insights`;18 Rest.setUrl(path);19 return Rest.get()20 .then(function(data) {21 return (data.data.insights_content);22 }).catch(function(response) {23 ProcessErrors(null, response.data, response.status, null, {24 hdr: 'Error!',25 msg: 'Failed to get insights info. GET returned status: ' +26 response.status27 });28 });29 }30 ],31 InventoryData: ['Rest', '$stateParams', 'GetBasePath', 'ProcessErrors', 'resourceData',32 (Rest, $stateParams, GetBasePath, ProcessErrors, resourceData) => {33 if(resourceData.data.type === "host"){34 var path = `${GetBasePath('inventory')}${resourceData.data.inventory}`;35 Rest.setUrl(path);36 return Rest.get()37 .then(function(data) {38 return (data.data);39 }).catch(function(response) {40 ProcessErrors(null, response.data, response.status, null, {41 hdr: 'Error!',42 msg: 'Failed to get insights info. GET returned status: ' +43 response.status44 });45 });46 }47 else if(resourceData.data.type === 'inventory'){48 return resourceData.data;49 }50 }51 ],52 checkProjectPermission: ['InventoryData', '$stateParams', 'Rest', 'GetBasePath',53 function(InventoryData, $stateParams, Rest, GetBasePath){54 if(_.has(InventoryData, 'summary_fields.insights_credential')){55 let credential_id = InventoryData.summary_fields.insights_credential.id,56 path = `${GetBasePath('projects')}?credential__id=${credential_id}&role_level=use_role`;57 Rest.setUrl(path);58 return Rest.get().then(({data}) => {59 if (data.results.length > 0){60 return true;61 }62 else {63 return false;64 }65 }).catch(() => {66 return false;67 });68 }69 else {70 return false;71 }72 }],73 checkInventoryPermission: ['InventoryData', '$stateParams', 'Rest', 'GetBasePath',74 function(InventoryData, $stateParams, Rest, GetBasePath){75 if(_.has(InventoryData, 'summary_fields.insights_credential')){76 let path = `${GetBasePath('inventory')}${InventoryData.id}/?role_level=use_role`;77 Rest.setUrl(path);78 return Rest.get().then(() => {79 return true;80 }).catch(() => {81 return false;82 });83 }84 else {85 return false;86 }87 }],88 CanRemediate: ['checkProjectPermission', 'checkInventoryPermission',89 function(checkProjectPermission, checkInventoryPermission){90 // the user can remediate an insights91 // inv if the user has "use" permission on92 // an insights project and the inventory93 // being edited:94 return checkProjectPermission === true && checkInventoryPermission === true;95 }]96 }...

Full Screen

Full Screen

inventories.service.js

Source:inventories.service.js Github

copy

Full Screen

1/*************************************************2 * Copyright (c) 2016 Ansible, Inc.3 *4 * All Rights Reserved5 *************************************************/6 export default7 ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait',8 function($rootScope, Rest, GetBasePath, ProcessErrors, Wait){9 return {10 // cute abstractions via fn.bind()11 url: function(){12 return '';13 },14 error: function(data, status) {15 ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',16 msg: 'Call to ' + this.url + '. GET returned: ' + status });17 },18 success: function(data){19 return data;20 },21 // data getters22 getInventory: function(id){23 Wait('start');24 this.url = GetBasePath('inventory') + id;25 Rest.setUrl(this.url);26 return Rest.get()27 .then(this.success.bind(this))28 .catch(this.error.bind(this))29 .finally(Wait('stop'));30 },31 getBreadcrumbs: function(groups){32 Wait('start');33 this.url = GetBasePath('groups') + '?' + _.map(groups, function(item){34 return '&or__id=' + item;35 }).join('');36 Rest.setUrl(this.url);37 return Rest.get()38 .then(this.success.bind(this))39 .catch(this.error.bind(this))40 .finally(Wait('stop'));41 },42 rootHostsUrl: function(id){43 var url = GetBasePath('inventory') + id + '/hosts';44 return url;45 },46 childHostsUrl: function(id){47 var url = GetBasePath('groups') + id + '/all_hosts';48 return url;49 },50 childGroupsUrl: function(id){51 var url = GetBasePath('groups') + id + '/children';52 return url;53 },54 groupsUrl: function(id){55 var url = GetBasePath('inventory') + id+ '/groups';56 return url;57 },58 inventorySourcesOptions: function(inventoryId) {59 this.url = GetBasePath('inventory') + inventoryId + '/inventory_sources';60 Rest.setUrl(this.url);61 return Rest.options()62 .then(this.success.bind(this))63 .catch(this.error.bind(this));64 },65 updateInventorySourcesGet: function(inventoryId) {66 this.url = GetBasePath('inventory') + inventoryId + '/update_inventory_sources';67 Rest.setUrl(this.url);68 return Rest.get()69 .then(this.success.bind(this))70 .catch(this.error.bind(this));71 },72 getHost: function(inventoryId, hostId) {73 this.url = GetBasePath('inventory') + inventoryId + '/hosts?id=' + hostId;74 Rest.setUrl(this.url);75 return Rest.get()76 .then(this.success.bind(this))77 .catch(this.error.bind(this));78 }79 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var basePath = window.__karma__.basePath;2var basePath = window.__karma__.basePath;3var basePath = window.__karma__.basePath;4var basePath = window.__karma__.basePath;5var basePath = window.__karma__.basePath;6var basePath = window.__karma__.basePath;7var basePath = window.__karma__.basePath;8var basePath = window.__karma__.basePath;9var basePath = window.__karma__.basePath;10var basePath = window.__karma__.basePath;11var basePath = window.__karma__.basePath;12var basePath = window.__karma__.basePath;13var basePath = window.__karma__.basePath;14var basePath = window.__karma__.basePath;15var basePath = window.__karma__.basePath;16var basePath = window.__karma__.basePath;17var basePath = window.__karma__.basePath;18var basePath = window.__karma__.basePath;19var basePath = window.__karma__.basePath;20var basePath = window.__karma__.basePath;21var basePath = window.__karma__.basePath;22var basePath = window.__karma__.basePath;

Full Screen

Using AI Code Generation

copy

Full Screen

1var server = new KarmaServer({2}, function(exitCode) {3 console.log('Karma has exited with ' + exitCode);4 process.exit(exitCode);5});6server.on('browser_register', function(browser) {7 console.log('New browser has registered:', browser.name);8});9server.on('browser_complete', function(browser) {10 console.log('Browser has completed:', browser.name);11});12server.on('run_complete', function(browsers, results) {13 console.log('Run complete');14});15server.start();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Karma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful