diff --git a/extensions/mistral/static/mistral/js/obsolete/controllers.js b/extensions/mistral/static/mistral/js/obsolete/controllers.js deleted file mode 100644 index 8a6c95b..0000000 --- a/extensions/mistral/static/mistral/js/obsolete/controllers.js +++ /dev/null @@ -1,391 +0,0 @@ -/** - * Created by tsufiev on 12/29/14. - */ - -(function() { - - function isObject(obj) { - return Object.prototype.toString.call(obj) === '[object Object]' - } - - function isArray(obj) { - return Object.prototype.toString.call(obj) === '[object Array]' - } - - angular.module('hz') - - .controller('workbookCtrl', function($scope, workbook, $filter) { - $scope.workbook = workbook; - - $scope.defaults = { - 'actions': { - name: 'Action1', - base: 'nova.create_server', - baseInput: { - flavorId: { - title: 'Flavor Id', - type: 'string' - }, - imageId: { - title: 'Image Id', - type: 'string' - } - }, - input: [], - output: [] - } - }; - $scope.data = { - actions: [{ - id: 'action1', - name: 'Action1', - base: 'nova.create_server', - baseInput: { - flavorId: { - title: 'Flavor Id', - type: 'string' - }, - imageId: { - title: 'Image Id', - type: 'string' - } - }, - input: [''], - output: [{ - id: 'varlist1', - type: 'string', - value: '' - }, { - id: 'varlist2', - type: 'dictionary', - value: { - key1: '', - key2: '' - } - }, { - id: 'varlist3', - type: 'list', - value: ['', ''] - }] - }], - workflows: [{ - id: 'workflow1', - name: 'Workflow1', - base: '', // FIXME - input: [''], - output: [{ - id: 'varlist1', - type: 'string', - value: '' - }], - taskDefaults: { - onError: { - type: 'list', - value: ['', ''] - }, - onSuccess: { - type: 'list', - value: [''] - }, - onComplete: { - type: 'list', - value: ['', ''] - } - } - }] - }; - - $scope.schema = { - name: { - type: 'string', - index: 0, - panelIndex: 0, - row: 0 - }, - description: { - type: 'text', - index: 1, - panelIndex: 0, - row: 0 - }, - actions: { - index: 2, - type: 'panel', - multiple: true, - value: { - name: { - type: 'string', - row: 0, - index: 0 - }, - base: { - type: 'string', - row: 0, - index: 1 - }, - baseInput: { - type: 'frozendict', - title: 'Base Input', - index: 2 - }, - input: { - type: 'list', - index: 3 - }, - output: { - type: 'varlist', - index: 4 - } - } - }, - workflows: { - index: 3, - type: 'panel', - multiple: true, - value: { - name: { - type: 'string', - index: 0, - row: 0 - }, - base: { - type: 'string', - index: 1, - row: 0 - }, - input: { - type: 'list', - index: 2 - }, - output: { - type: 'varlist', - index: 3 - }, - taskDefaults: { - type: 'group', - title: 'Task defaults', - additive: false, - index: 4, - value: { - onError: { - type: 'yaqllist', - title: 'On error', - index: 0 - }, - onSuccess: { - type: 'yaqllist', - title: 'On success', - index: 1 - }, - onComplete: { - type: 'yaqllist', - title: 'On complete', - index: 2 - } - } - }, - tasks: { - type: 'group', - index: 5, - value: { - task: { - type: 'group', - additive: false, - multiple: true, - index: 0, - value: { - name: { - type: 'string', - index: 0, - row: 0 - }, - type: { - type: 'string', - index: 1, - row: 0 - }, - action: { - type: 'string', - index: 2, - row: 1 - }, - input: { - type: 'dictionary', - index: 3 - }, - publish: { - type: 'dictionary', - index: 4 - }, - onError: { - type: 'yaqllist', - title: 'On error', - index: 5 - }, - onSuccess: { - type: 'yaqllist', - title: 'On success', - index: 6 - }, - onComplete: { - type: 'yaqllist', - title: 'On complete', - index: 7 - }, - policies: { - type: 'group', - additive: false, - index: 8, - value: { - waitBefore: { - type: 'string', - title: 'Wait before', - index: 0, - row: 0 - }, - waitAfter: { - type: 'string', - title: 'Wait after', - index: 1, - row: 0 - }, - timeout: { - type: 'string', - index: 2, - row: 1 - }, - retryCount: { - type: 'string', - title: 'Retry count', - index: 3, - row: 2 - }, - retryDelay: { - type: 'string', - title: 'Retry delay', - index: 4, - row: 2 - }, - retryBreakOn: { - type: 'string', - title: 'Retry break on', - index: 5, - row: 3 - } - } - } - } - } - } - } - } - } - }; - - - - $scope.makeTitle = function(str) { - if ( !str ) { - return ''; - } - var firstLetter = str.substr(0, 1).toUpperCase(); - return firstLetter + str.substr(1); - }; - - $scope.getKeys = function(obj) { - return Object.keys(obj); - }; - - $scope.isAtomic = function(type) { - return ['string', 'text', 'number'].indexOf(type) > -1; - }; - - $scope.remove = function(parent, item) { - if ( angular.isString(parent) ) { - parent = $scope.data[parent]; - } - var index = parent.indexOf(item); - parent.splice(index, 1); - return parent.length; - }; - - $scope.removeKey = function(parent, key) { - if ( angular.isString(parent) ) { - parent = $scope.data[parent]; - } - if ( !angular.isObject(parent) ) { - return; - } - delete parent[key]; - return $scope.getKeys(parent).length; - }; - - $scope.addAutoKey = function(parent) { - if ( angular.isString(parent) ) { - parent = $scope.data[parent]; - } - if ( !angular.isObject(parent) ) { - return; - } - var maxNumber = $scope.getKeys(parent).map(function(key) { - var match = /[Kk]ey(\d+)/.exec(key); - if ( match ) { - return +match[1]; - } else { - return null; - } - }).filter(function(value) { - return value; - }).reduce(function(prevValue, curValue) { - return prevValue > curValue ? prevValue : curValue; - }, 0), - newKey = 'key' + (maxNumber+1); - parent[newKey] = ''; - }; - - $scope.add = function(parent, value) { - var defaultValue, key; - if ( angular.isString(parent) ) { - key = parent; - defaultValue = angular.copy($scope.defaults[key]); - parent = $scope.data[key]; - defaultValue.id = key + parent.length; - } - parent.push(value || defaultValue); - } - - }) - - .controller('actionCtrl', function($scope) { - var actionBase = null, - baseTypes = { - 'nova.create_server': { - flavorId: { - title: 'Flavor Id', - type: 'string' - }, - imageId: { - title: 'Image Id', - type: 'string' - } - } - }; - - }) - - .controller('dictionaryCtrl', function($scope) { - if ( !isObject($scope.subItem.value) ) { - $scope.subItem.value = {'Key1': ''}; - } - }) - - .controller('listCtrl', function($scope) { - if ( !isArray($scope.subItem.value) ) { - $scope.subItem.value = ['']; - } - }) - - .controller('workflowsCtrl', function() { - - }); -})(); \ No newline at end of file diff --git a/extensions/mistral/static/mistral/js/obsolete/schema-alt.js b/extensions/mistral/static/mistral/js/obsolete/schema-alt.js deleted file mode 100644 index aff2f63..0000000 --- a/extensions/mistral/static/mistral/js/obsolete/schema-alt.js +++ /dev/null @@ -1,213 +0,0 @@ - -/* Copyright (c) 2014 Mirantis, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - */ - -(function() { - angular.module('hz') - - .factory('workbook', function() { - var types = { - Mistral: {}, - base: {}, - OpenStack: { - // TODO: obtain list of predefined OpenStack actions from Mistral server-side - // for now a stubbed list of predefined actions suffices - actions: ['createInstance', 'terminateInstance'] - }, - getOpenStackActions: function() { - return this.OpenStack.actions.slice(); - } - }; - - //types.base.AcceptsMixin = Barricade.Blueprint.create(function (acceptsList) { - // acceptsList = acceptsList || []; - // - // this.getLabels = function() { - // return acceptsList.map(function(item) { - // return item.label; - // }) - // }; - // - // this.getValue = function(label) { - // for ( var i = 0; i < acceptsList.length; i++ ) { - // if ( acceptsList[i].label === label ) { - // return acceptsList[i].value; - // } - // } - // return null; - // } - //}); - -//types.Mistral.Task = Barricade.create({ -// '@class': types.Mistral.dictionary, -// -// 'name': {'@type': String}, -// 'input': { -// '@type': Array, -// '*': { -// '@class': Barricade.Primitive.extend({ -// 'name': 'Parameter' -// }, { -// '@type': String -// }) -// } -// }, -// 'publish': { -// '@type': String, -// '@required': false -// }, -// 'policies': { -// '@class': types.Mistral.Policy, -// '@required': false -// } -//}); -// -//types.Mistral.Tasks = Barricade.MutableObject.extend({ -// create: function(json, parameters) { -// var self = Barricade.MutableObject.create.call(this); -// -// function getParentWorkflowType() { -// var container = self._container, -// workflow; -// while ( container ) { -// if ( container.instanceof(types.Mistral.Workflow) ) { -// workflow = container; -// break; -// } -// container = container._container; -// } -// return workflow && workflow.get('type').get(); -// } -// -// var directSpecificData = { -// 'on-complete': { -// '@type': String, -// '@required': false -// }, -// 'on-success': { -// '@type': String, -// '@required': false -// }, -// 'on-error': { -// '@type': String, -// '@required': false -// } -// }, -// reverseSpecificData = { -// 'requires': { -// '@type': Array, -// '*': { -// '@class': Barricade.Primitive.extend({ -// 'name': 'Action' -// }, { -// '@type': String, -// '@enum': function() { -// var container = this._container, -// workflow, task; -// while ( container ) { -// if ( container.instanceof(types.Mistral.Task) ) { -// task = container; -// } -// if ( container.instanceof(types.Mistral.Workflow) ) { -// workflow = container; -// break; -// } -// container = container._container; -// } -// if ( workflow && task ) { -// return workflow.get('tasks').toArray().filter(function(taskItem) { -// return !(taskItem === task) && taskItem.get('name').get(); -// }).map(function(taskItem) { -// return taskItem.get('name').get(); -// }); -// } else { -// return []; -// } -// } -// }) -// } -// } -// }; -// -// types.base.AcceptsMixin.call(self, [ -// { -// label: 'Action-based', -// value: function() { -// var workflowType = getParentWorkflowType(); -// if ( workflowType === 'direct' ) { -// return types.Mistral.ActionTask.extend({}, directSpecificData); -// } else if ( workflowType === 'reverse' ) { -// return types.Mistral.ActionTask.extend({}, reverseSpecificData); -// } else { -// return types.Mistral.ActionTask; -// } -// } -// }, { -// label: 'Workflow-based', -// value: function() { -// var workflowType = getParentWorkflowType(); -// if ( workflowType === 'direct' ) { -// return types.Mistral.WorkflowTask.extend({}, directSpecificData); -// } else if ( workflowType === 'reverse' ) { -// return types.Mistral.WorkflowTask.extend({}, reverseSpecificData); -// } else { -// return types.Mistral.WorkflowTask; -// } -// } -// } -// ]); -// return self; -// } -//}, { -// '@type': Object, -// '?': {'@class': types.Mistral.Task} -//}); -// -//types.Mistral.WorkflowTask = types.Mistral.Task.extend({}, -// { -// 'workflow': { -// '@type': String, -// '@enum': function() { -// var workflows = workbook.get('workflows').toArray(); -// return workflows.map(function(workflowItem) { -// return workflowItem.get('name').get(); -// }).filter(function (name) { -// return name; -// }); -// } -// } -// }); -// -//types.Mistral.ActionTask = types.Mistral.Task.extend({}, -// { -// 'action': { -// '@type': String, -// '@enum': function() { -// var predefinedActions = types.getOpenStackActions(), -// actions = workbook.get('actions').toArray(); -// return predefinedActions.concat(actions.map(function(actionItem) { -// return actionItem.get('name').get(); -// }).filter(function(name) { -// return name; } -// )); -// } -// } -// }); - - - return types.Mistral.Workbook.create(); - }) -})(); - diff --git a/extensions/mistral/static/mistral/js/obsolete/schema.js b/extensions/mistral/static/mistral/js/obsolete/schema.js deleted file mode 100644 index 27f8718..0000000 --- a/extensions/mistral/static/mistral/js/obsolete/schema.js +++ /dev/null @@ -1,342 +0,0 @@ - -/* Copyright (c) 2014 Mirantis, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. - */ - -var types = { - Mistral: {}, - base: {}, - OpenStack: { - // TODO: obtain list of predefined OpenStack actions from Mistral server-side - // for now a stubbed list of predefined actions suffices - actions: ['createInstance', 'terminateInstance'] - }, - getOpenStackActions: function() { - return this.OpenStack.actions.slice(); - } -}; - -types.base.AcceptsMixin = Barricade.Blueprint.create(function (acceptsList) { - acceptsList = acceptsList || []; - - this.getLabels = function() { - return acceptsList.map(function(item) { - return item.label; - }) - }; - - this.getValue = function(label) { - for ( var i = 0; i < acceptsList.length; i++ ) { - if ( acceptsList[i].label === label ) { - return acceptsList[i].value; - } - } - return null; - } -}); - -types.Mistral.Action = Barricade.create({ - '@type': Object, - '@meta': {'groups': ['panel2']}, - - 'name': {'@type': String}, - 'base': { - '@type': String, - '@enum': function() { - var predefinedActions = types.getOpenStackActions(), - actions = workbook.get('actions'), - currentItemIndex = actions.length() - 1; - actions.each(function(index, actionItem) { - var name = actionItem.get('name'); - if ( index < currentItemIndex && !name.isEmpty() ) { - predefinedActions = predefinedActions.concat(name.get()) - } - }); - return predefinedActions; - }, - '@default': types.getOpenStackActions()[0] - }, - 'base-input': { - '@type': Object, - '@required': false, - '?': {'@type': String} - } -}); - -types.Mistral.Policy = Barricade.create({ - '@type': Object, - - 'wait-before': { - '@type': Number, - '@required': false - }, - 'wait-after': { - '@type': Number, - '@required': false - }, - 'retry': { - '@type': Object, - '@required': false, - 'count': {'@type': Number}, - 'delay': {'@type': Number}, - 'break-on': { - '@type': String, - '@required': false - } - }, - 'timeout': { - '@type': Number, - '@required': false - } -}); - -types.Mistral.Task = Barricade.create({ - '@type': Object, - - 'name': {'@type': String}, - 'input': { - '@type': Array, - '*': { - '@class': Barricade.Primitive.extend({ - 'name': 'Parameter' - }, { - '@type': String - }) - } - }, - 'publish': { - '@type': String, - '@required': false - }, - 'policies': { - '@class': types.Mistral.Policy, - '@required': false - } -}); - -types.Mistral.Tasks = Barricade.MutableObject.extend({ - create: function(json, parameters) { - var self = Barricade.MutableObject.create.call(this); - - function getParentWorkflowType() { - var container = self._container, - workflow; - while ( container ) { - if ( container.instanceof(types.Mistral.Workflow) ) { - workflow = container; - break; - } - container = container._container; - } - return workflow && workflow.get('type').get(); - } - - var directSpecificData = { - 'on-complete': { - '@type': String, - '@required': false - }, - 'on-success': { - '@type': String, - '@required': false - }, - 'on-error': { - '@type': String, - '@required': false - } - }, - reverseSpecificData = { - 'requires': { - '@type': Array, - '*': { - '@class': Barricade.Primitive.extend({ - 'name': 'Action' - }, { - '@type': String, - '@enum': function() { - var container = this._container, - workflow, task; - while ( container ) { - if ( container.instanceof(types.Mistral.Task) ) { - task = container; - } - if ( container.instanceof(types.Mistral.Workflow) ) { - workflow = container; - break; - } - container = container._container; - } - if ( workflow && task ) { - return workflow.get('tasks').toArray().filter(function(taskItem) { - return !(taskItem === task) && taskItem.get('name').get(); - }).map(function(taskItem) { - return taskItem.get('name').get(); - }); - } else { - return []; - } - } - }) - } - } - }; - - types.base.AcceptsMixin.call(self, [ - { - label: 'Action-based', - value: function() { - var workflowType = getParentWorkflowType(); - if ( workflowType === 'direct' ) { - return types.Mistral.ActionTask.extend({}, directSpecificData); - } else if ( workflowType === 'reverse' ) { - return types.Mistral.ActionTask.extend({}, reverseSpecificData); - } else { - return types.Mistral.ActionTask; - } - } - }, { - label: 'Workflow-based', - value: function() { - var workflowType = getParentWorkflowType(); - if ( workflowType === 'direct' ) { - return types.Mistral.WorkflowTask.extend({}, directSpecificData); - } else if ( workflowType === 'reverse' ) { - return types.Mistral.WorkflowTask.extend({}, reverseSpecificData); - } else { - return types.Mistral.WorkflowTask; - } - } - } - ]); - return self; - } -}, { - '@type': Object, - '?': {'@class': types.Mistral.Task} -}); - -types.Mistral.WorkflowTask = types.Mistral.Task.extend({}, - { - 'workflow': { - '@type': String, - '@enum': function() { - var workflows = workbook.get('workflows').toArray(); - return workflows.map(function(workflowItem) { - return workflowItem.get('name').get(); - }).filter(function (name) { - return name; - }); - } - } - }); - -types.Mistral.ActionTask = types.Mistral.Task.extend({}, - { - 'action': { - '@type': String, - '@enum': function() { - var predefinedActions = types.getOpenStackActions(), - actions = workbook.get('actions').toArray(); - return predefinedActions.concat(actions.map(function(actionItem) { - return actionItem.get('name').get(); - }).filter(function(name) { - return name; } - )); - } - } - }); - -types.Mistral.Workflow = Barricade.create({ - '@type': Object, - '@meta': {'groups': 'panel3'}, - - 'name': {'@type': String}, - 'type': { - '@type': String, - '@enum': ['reverse', 'direct'], - '@default': 'direct' - }, - 'input': { - '@type': Array, - '@required': false, - '*': { - '@class': Barricade.Primitive.extend({ - 'name': 'Primitive' - }, { - '@type': String - }) - } - }, - 'output': { - '@type': String, - '@required': false - }, - 'task-defaults': { - '@type': Object, - '@required': false, - 'on-error': {'@type': String}, - 'on-success': {'@type': String}, - 'on-complete': {'@type': String}, - 'policies': {'@class': types.Mistral.Policy} - }, - 'tasks': { - '@class': types.Mistral.Tasks - } - -}); - -types.Mistral.Workbook = Barricade.create({ - '@type': Object, - - 'version': { - '@type': Number, - '@enum': function() { return [2]; }, - '@meta': { - 'index': 2, - 'panelIndex': 0, - 'row': 1 - }, - '@default': 2 - }, - 'name': { - '@type': String, - '@meta': { - 'index': 0, - 'panelIndex': 0, - 'row': 0 - } - }, - 'description': { - '@type': String, - '@meta': { - 'index': 1, - 'panelIndex': 0, - 'row': 0 - }, - '@required': false - }, - 'actions': { - '@type': Object, - '@required': false, - '?': { - '@class': types.Mistral.Action - } - }, - 'workflows': { - '@type': Object, - '?': { - '@class': types.Mistral.Workflow - } - } -}); diff --git a/extensions/mistral/static/mistral/js/obsolete/services.js b/extensions/mistral/static/mistral/js/obsolete/services.js deleted file mode 100644 index eaab9e1..0000000 --- a/extensions/mistral/static/mistral/js/obsolete/services.js +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Created by tsufiev on 12/29/14. - */ - -(function() { - angular.module('hz') - - .factory('defaultSetter', function($parse) { - return function(attrs, attrName, defaultValue) { - if ( attrs[attrName] === undefined ) { - attrs[attrName] = defaultValue; - } else { - attrs[attrName] = $parse(attrs[attrName])(); - } - } - }) - - .run(function($http, $templateCache) { - var fields = ['dictionary', 'frozendict', 'list', 'string', - 'varlist', 'text', 'group', 'yaqllist', 'number' - ]; - fields.forEach(function(field) { - var base = '/static/mistral/js/templates-templates/fields/'; - $http.get(base + field + '.html').success(function(templateContent) { - $templateCache.put(field, templateContent); - }); - }) - }) - - .filter('prepareSchema', function($filter) { - var toArray = $filter('toArray'), - orderBy = $filter('orderBy'); - function schemaToArray(schema) { - return angular.isArray(schema) ? schema : orderBy( - toArray(schema, true), 'index').map(function(item) { - item.name = item.$key; - if ( item.type === 'panel' ) { - item.panelIndex = item.index; - } - if ( item.type === 'panel' || item.type === 'group' ) { - item.value = schemaToArray(item.value); - } - return item; - }); - } - return schemaToArray; - }) - - .filter('normalizePanels', function() { - return function(collection) { - return collection.map(function(panelSpec) { - if ( panelSpec[0].type === 'panel' ) { - var data = panelSpec[0]; - panelSpec.length = data.value.length; - for ( var i = 0; i < panelSpec.length; i++ ) { - panelSpec[i] = data.value[i]; - } - panelSpec.multiple = data.multiple; - panelSpec.name = data.name; - } - return panelSpec; - }); - } - }) - - .filter('getPanels', function($filter) { - var orderBy = $filter('orderBy'), - groupBy = $filter('groupBy'), - toArray = $filter('toArray'); - return function(container) { - var seq = groupBy(container, 'getMeta().panelIndex'); - console.log('seq', seq); - var seq1 = toArray(seq, true); - console.log('seq1', seq1); - var seq2 = orderBy(seq1, '$key'); - console.log('seq2', seq2); -// var seq = orderBy( -// toArray(, true), -// '$key'); - return seq2; - } - }) - - - function sign(x) { - if ( x > 0 ) { - return 1; - } else { - return x < 0 ? -1 : 0; - } - } - - function comparePanelIndices(item1, item2) { - var index1 = item1.getMeta().panelIndex, - index2 = item2.getMeta().panelIndex; - - if ( index1 === undefined || index2 === undefined ) { - return -1; - } else { - return sign(index1-index2); - } - - } - - - -})(); \ No newline at end of file diff --git a/extensions/mistral/static/mistral/js/obsolete/workbook.js b/extensions/mistral/static/mistral/js/obsolete/workbook.js deleted file mode 100644 index 69c79c2..0000000 --- a/extensions/mistral/static/mistral/js/obsolete/workbook.js +++ /dev/null @@ -1,331 +0,0 @@ -/* Copyright (c) 2014 Mirantis, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); you may - not use this file except in compliance with the License. You may obtain - a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - License for the specific language governing permissions and limitations - under the License. -*/ - -var workbook; - -$(function() { - var __counter = 0; - var current_workbook_id; - - function getNextCounter() { - __counter++; - return __counter; - } - - function drawBaseNode($label, item, type, converter) { - var $item = $('
'), - $input = $(''); - converter = converter || function(x) { return x;}; - $input.val(item.get()); - $input.change(function() { - item.set(converter($input.val())) - }); - $item.append($label); - $item.append($input.attr('type', type)); - return $item; - } - - function drawSelectElement(labels, values, selected) { - var $input = $(''), - $addAction = $('