{"action":"created","comment":{"url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/comments/75223177","id":75223177,"diff_hunk":"@@ -0,0 +1,166 @@\n+/**\n+ * (c) Copyright 2016 Hewlett-Packard Development Company, L.P.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License. You may obtain\n+ * a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+(function() {\n+  'use strict';\n+\n+  angular\n+    .module('bsn.bsndashboard.networktemplateassignment.actions')\n+    .factory('bsn.bsndashboard.networktemplateassignemnt.actions.apply.service', applyService);\n+\n+  applyService.$inject = [\n+    'bsn.bsndashboard.networktemplateassignment.resourceType',\n+    'horizon.app.core.openstack-service-api.bsnneutron',\n+    'horizon.framework.widgets.toast.service',\n+    '$modal',\n+    'horizon.framework.util.actions.action-result.service',\n+    '$rootScope'\n+  ];\n+\n+  /**\n+   * @ngDoc factory\n+   * @name horizon.app.core.images.actions.applyService\n+   * @Description A service to open the user wizard.\n+   */\n+  function applyService(\n+    resourceType,\n+    bsnneutron,\n+    toast,\n+    $modal,\n+    actionResultService,\n+    $rootScope\n+  ) {\n+    var message = {\n+      success: gettext('Template application in progress.')\n+    };\n+\n+    var service = {\n+      perform: perform,\n+      allowed: allowed\n+    };\n+\n+    return service;\n+\n+    //////////////\n+    function allowed() {\n+      var promise = new Promise(function (resolve) {\n+        resolve(true);\n+      });\n+\n+      return promise;\n+    }\n+    \n+    var stack_create_response = {};\n+    var template = {};\n+    var parameters = {};\n+\n+    function perform() {\n+\n+      return bsnneutron.networktemplateassignment_list()\n+        .then(function (result) {\n+          if (result.data.items) {\n+            // there is already a template applied, cannot apply another\n+            var localSpec = {\n+              backdrop: 'static',\n+              templateUrl: '/static/networktemplateassignment/actions/apply/denyModal.html'\n+            }\n+            $modal.open(localSpec).result;\n+            return;\n+          }\n+          else {\n+            // there is not template yet, we can apply one\n+            return apply();\n+          }\n+        })\n+    }\n+\n+    /**\n+     * To apply a network template, we open the selection modal (modal.open). Once the user has selected a network\n+     * template to apply, we get the fields required for the network template (validateTemplte). Once the input fields\n+     * are returned, we can open the second modal to fill in the arguments (applyTemplate). Then, we can create the\n+     * assignment (createNetTemplateAssign), create the heat stack (createHeatStack), and update the assignment\n+     * (updateNetTemplateAssign). When this is done, we return with onApplyTemplate. The controller is then responsible\n+     * for querying Heat for the status of the heat stack creation, and then update the table.\n+     */\n+\n+    function apply() {\n+      var localSpec = {\n+        backdrop: 'static',\n+        controller: 'SelectNetTemplateController as ctrl',\n+        templateUrl: '/static/networktemplateassignment/actions/apply/selectModal.html'\n+      };\n+\n+      return $modal.open(localSpec).result\n+        .then(validateTemplate)\n+        .then(applyTemplate)\n+        .then(createNetTemplateAssign)\n+        .then(createHeatStack)\n+        .then(updateNetTemplateAssign)\n+        .then(onApplyTemplate);\n+    }\n+\n+    function validateTemplate(selectResult) {\n+      var result = JSON.parse(selectResult.template);\n+      template = result;\n+      return bsnneutron.template_validate(result);\n+    }\n+\n+    function applyTemplate(validateResult) {\n+      $rootScope.properties = validateResult.data;\n+      var localSpec = {\n+        backdrop: 'static',\n+        controller: 'SelectNetTemplateController as ctrl',\n+        templateUrl: '/static/networktemplateassignment/actions/apply/applyModal.html',\n+        scope: $rootScope\n+      };\n+      return $modal.open(localSpec).result\n+    }\n+\n+    function createNetTemplateAssign(params){\n+      parameters = params;\n+\n+      var assignment = {\n+        template_id: template.id,\n+        stack_id: 'PENDING'\n+      };\n+      return bsnneutron.networktemplateassignment_create(assignment);","path":"horizon_bsn/bsndashboard/static/networktemplateassignment/actions/apply/apply.action.service.js","position":139,"original_position":139,"commit_id":"fa17fb03ce6638f7ff85272c28179762659d8f73","original_commit_id":"fa17fb03ce6638f7ff85272c28179762659d8f73","user":{"login":"mmxiong","id":10491334,"avatar_url":"https://avatars.githubusercontent.com/u/10491334?v=3","gravatar_id":"","url":"https://api.github.com/users/mmxiong","html_url":"https://github.com/mmxiong","followers_url":"https://api.github.com/users/mmxiong/followers","following_url":"https://api.github.com/users/mmxiong/following{/other_user}","gists_url":"https://api.github.com/users/mmxiong/gists{/gist_id}","starred_url":"https://api.github.com/users/mmxiong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmxiong/subscriptions","organizations_url":"https://api.github.com/users/mmxiong/orgs","repos_url":"https://api.github.com/users/mmxiong/repos","events_url":"https://api.github.com/users/mmxiong/events{/privacy}","received_events_url":"https://api.github.com/users/mmxiong/received_events","type":"User","site_admin":false},"body":"Errors are logged immediately when an API call fails. Each API call in neutron.service.js has a .error clause that will toast in the case of failure.","created_at":"2016-08-17T23:00:15Z","updated_at":"2016-08-17T23:00:15Z","html_url":"https://github.com/bigswitch/horizon-bsn/pull/60#discussion_r75223177","pull_request_url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/comments/75223177"},"html":{"href":"https://github.com/bigswitch/horizon-bsn/pull/60#discussion_r75223177"},"pull_request":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60","id":81381110,"html_url":"https://github.com/bigswitch/horizon-bsn/pull/60","diff_url":"https://github.com/bigswitch/horizon-bsn/pull/60.diff","patch_url":"https://github.com/bigswitch/horizon-bsn/pull/60.patch","issue_url":"https://api.github.com/repos/bigswitch/horizon-bsn/issues/60","number":60,"state":"open","locked":false,"title":"upgrade horizon dashboard to angularjs base","user":{"login":"mmxiong","id":10491334,"avatar_url":"https://avatars.githubusercontent.com/u/10491334?v=3","gravatar_id":"","url":"https://api.github.com/users/mmxiong","html_url":"https://github.com/mmxiong","followers_url":"https://api.github.com/users/mmxiong/followers","following_url":"https://api.github.com/users/mmxiong/following{/other_user}","gists_url":"https://api.github.com/users/mmxiong/gists{/gist_id}","starred_url":"https://api.github.com/users/mmxiong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmxiong/subscriptions","organizations_url":"https://api.github.com/users/mmxiong/orgs","repos_url":"https://api.github.com/users/mmxiong/repos","events_url":"https://api.github.com/users/mmxiong/events{/privacy}","received_events_url":"https://api.github.com/users/mmxiong/received_events","type":"User","site_admin":false},"body":"Reviewer: @wolverineav \r\nCC: @xinwu \r\n\r\nFinished plugin","created_at":"2016-08-15T21:45:41Z","updated_at":"2016-08-17T23:00:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a49e26327d9ce9985690631c37e657491d111ab","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60/commits","review_comments_url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60/comments","review_comment_url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bigswitch/horizon-bsn/issues/60/comments","statuses_url":"https://api.github.com/repos/bigswitch/horizon-bsn/statuses/fa17fb03ce6638f7ff85272c28179762659d8f73","head":{"label":"mmxiong:bsndev","ref":"bsndev","sha":"fa17fb03ce6638f7ff85272c28179762659d8f73","user":{"login":"mmxiong","id":10491334,"avatar_url":"https://avatars.githubusercontent.com/u/10491334?v=3","gravatar_id":"","url":"https://api.github.com/users/mmxiong","html_url":"https://github.com/mmxiong","followers_url":"https://api.github.com/users/mmxiong/followers","following_url":"https://api.github.com/users/mmxiong/following{/other_user}","gists_url":"https://api.github.com/users/mmxiong/gists{/gist_id}","starred_url":"https://api.github.com/users/mmxiong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmxiong/subscriptions","organizations_url":"https://api.github.com/users/mmxiong/orgs","repos_url":"https://api.github.com/users/mmxiong/repos","events_url":"https://api.github.com/users/mmxiong/events{/privacy}","received_events_url":"https://api.github.com/users/mmxiong/received_events","type":"User","site_admin":false},"repo":{"id":65766887,"name":"horizon-bsn","full_name":"mmxiong/horizon-bsn","owner":{"login":"mmxiong","id":10491334,"avatar_url":"https://avatars.githubusercontent.com/u/10491334?v=3","gravatar_id":"","url":"https://api.github.com/users/mmxiong","html_url":"https://github.com/mmxiong","followers_url":"https://api.github.com/users/mmxiong/followers","following_url":"https://api.github.com/users/mmxiong/following{/other_user}","gists_url":"https://api.github.com/users/mmxiong/gists{/gist_id}","starred_url":"https://api.github.com/users/mmxiong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmxiong/subscriptions","organizations_url":"https://api.github.com/users/mmxiong/orgs","repos_url":"https://api.github.com/users/mmxiong/repos","events_url":"https://api.github.com/users/mmxiong/events{/privacy}","received_events_url":"https://api.github.com/users/mmxiong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mmxiong/horizon-bsn","description":"Big Switch Networks Extension for the Openstack Dashboard (Horizon)","fork":true,"url":"https://api.github.com/repos/mmxiong/horizon-bsn","forks_url":"https://api.github.com/repos/mmxiong/horizon-bsn/forks","keys_url":"https://api.github.com/repos/mmxiong/horizon-bsn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mmxiong/horizon-bsn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mmxiong/horizon-bsn/teams","hooks_url":"https://api.github.com/repos/mmxiong/horizon-bsn/hooks","issue_events_url":"https://api.github.com/repos/mmxiong/horizon-bsn/issues/events{/number}","events_url":"https://api.github.com/repos/mmxiong/horizon-bsn/events","assignees_url":"https://api.github.com/repos/mmxiong/horizon-bsn/assignees{/user}","branches_url":"https://api.github.com/repos/mmxiong/horizon-bsn/branches{/branch}","tags_url":"https://api.github.com/repos/mmxiong/horizon-bsn/tags","blobs_url":"https://api.github.com/repos/mmxiong/horizon-bsn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mmxiong/horizon-bsn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mmxiong/horizon-bsn/git/refs{/sha}","trees_url":"https://api.github.com/repos/mmxiong/horizon-bsn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mmxiong/horizon-bsn/statuses/{sha}","languages_url":"https://api.github.com/repos/mmxiong/horizon-bsn/languages","stargazers_url":"https://api.github.com/repos/mmxiong/horizon-bsn/stargazers","contributors_url":"https://api.github.com/repos/mmxiong/horizon-bsn/contributors","subscribers_url":"https://api.github.com/repos/mmxiong/horizon-bsn/subscribers","subscription_url":"https://api.github.com/repos/mmxiong/horizon-bsn/subscription","commits_url":"https://api.github.com/repos/mmxiong/horizon-bsn/commits{/sha}","git_commits_url":"https://api.github.com/repos/mmxiong/horizon-bsn/git/commits{/sha}","comments_url":"https://api.github.com/repos/mmxiong/horizon-bsn/comments{/number}","issue_comment_url":"https://api.github.com/repos/mmxiong/horizon-bsn/issues/comments{/number}","contents_url":"https://api.github.com/repos/mmxiong/horizon-bsn/contents/{+path}","compare_url":"https://api.github.com/repos/mmxiong/horizon-bsn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mmxiong/horizon-bsn/merges","archive_url":"https://api.github.com/repos/mmxiong/horizon-bsn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mmxiong/horizon-bsn/downloads","issues_url":"https://api.github.com/repos/mmxiong/horizon-bsn/issues{/number}","pulls_url":"https://api.github.com/repos/mmxiong/horizon-bsn/pulls{/number}","milestones_url":"https://api.github.com/repos/mmxiong/horizon-bsn/milestones{/number}","notifications_url":"https://api.github.com/repos/mmxiong/horizon-bsn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mmxiong/horizon-bsn/labels{/name}","releases_url":"https://api.github.com/repos/mmxiong/horizon-bsn/releases{/id}","deployments_url":"https://api.github.com/repos/mmxiong/horizon-bsn/deployments","created_at":"2016-08-15T21:41:45Z","updated_at":"2016-08-15T21:46:41Z","pushed_at":"2016-08-15T23:40:58Z","git_url":"git://github.com/mmxiong/horizon-bsn.git","ssh_url":"git@github.com:mmxiong/horizon-bsn.git","clone_url":"https://github.com/mmxiong/horizon-bsn.git","svn_url":"https://github.com/mmxiong/horizon-bsn","homepage":null,"size":449,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bigswitch:master","ref":"master","sha":"3cc843f3a7809c2f5e8b98be4c98084cfb9221c9","user":{"login":"bigswitch","id":286009,"avatar_url":"https://avatars.githubusercontent.com/u/286009?v=3","gravatar_id":"","url":"https://api.github.com/users/bigswitch","html_url":"https://github.com/bigswitch","followers_url":"https://api.github.com/users/bigswitch/followers","following_url":"https://api.github.com/users/bigswitch/following{/other_user}","gists_url":"https://api.github.com/users/bigswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/bigswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigswitch/subscriptions","organizations_url":"https://api.github.com/users/bigswitch/orgs","repos_url":"https://api.github.com/users/bigswitch/repos","events_url":"https://api.github.com/users/bigswitch/events{/privacy}","received_events_url":"https://api.github.com/users/bigswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":52573594,"name":"horizon-bsn","full_name":"bigswitch/horizon-bsn","owner":{"login":"bigswitch","id":286009,"avatar_url":"https://avatars.githubusercontent.com/u/286009?v=3","gravatar_id":"","url":"https://api.github.com/users/bigswitch","html_url":"https://github.com/bigswitch","followers_url":"https://api.github.com/users/bigswitch/followers","following_url":"https://api.github.com/users/bigswitch/following{/other_user}","gists_url":"https://api.github.com/users/bigswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/bigswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigswitch/subscriptions","organizations_url":"https://api.github.com/users/bigswitch/orgs","repos_url":"https://api.github.com/users/bigswitch/repos","events_url":"https://api.github.com/users/bigswitch/events{/privacy}","received_events_url":"https://api.github.com/users/bigswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bigswitch/horizon-bsn","description":"Big Switch Networks Extension for the Openstack Dashboard (Horizon)","fork":false,"url":"https://api.github.com/repos/bigswitch/horizon-bsn","forks_url":"https://api.github.com/repos/bigswitch/horizon-bsn/forks","keys_url":"https://api.github.com/repos/bigswitch/horizon-bsn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bigswitch/horizon-bsn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bigswitch/horizon-bsn/teams","hooks_url":"https://api.github.com/repos/bigswitch/horizon-bsn/hooks","issue_events_url":"https://api.github.com/repos/bigswitch/horizon-bsn/issues/events{/number}","events_url":"https://api.github.com/repos/bigswitch/horizon-bsn/events","assignees_url":"https://api.github.com/repos/bigswitch/horizon-bsn/assignees{/user}","branches_url":"https://api.github.com/repos/bigswitch/horizon-bsn/branches{/branch}","tags_url":"https://api.github.com/repos/bigswitch/horizon-bsn/tags","blobs_url":"https://api.github.com/repos/bigswitch/horizon-bsn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bigswitch/horizon-bsn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bigswitch/horizon-bsn/git/refs{/sha}","trees_url":"https://api.github.com/repos/bigswitch/horizon-bsn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bigswitch/horizon-bsn/statuses/{sha}","languages_url":"https://api.github.com/repos/bigswitch/horizon-bsn/languages","stargazers_url":"https://api.github.com/repos/bigswitch/horizon-bsn/stargazers","contributors_url":"https://api.github.com/repos/bigswitch/horizon-bsn/contributors","subscribers_url":"https://api.github.com/repos/bigswitch/horizon-bsn/subscribers","subscription_url":"https://api.github.com/repos/bigswitch/horizon-bsn/subscription","commits_url":"https://api.github.com/repos/bigswitch/horizon-bsn/commits{/sha}","git_commits_url":"https://api.github.com/repos/bigswitch/horizon-bsn/git/commits{/sha}","comments_url":"https://api.github.com/repos/bigswitch/horizon-bsn/comments{/number}","issue_comment_url":"https://api.github.com/repos/bigswitch/horizon-bsn/issues/comments{/number}","contents_url":"https://api.github.com/repos/bigswitch/horizon-bsn/contents/{+path}","compare_url":"https://api.github.com/repos/bigswitch/horizon-bsn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bigswitch/horizon-bsn/merges","archive_url":"https://api.github.com/repos/bigswitch/horizon-bsn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bigswitch/horizon-bsn/downloads","issues_url":"https://api.github.com/repos/bigswitch/horizon-bsn/issues{/number}","pulls_url":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls{/number}","milestones_url":"https://api.github.com/repos/bigswitch/horizon-bsn/milestones{/number}","notifications_url":"https://api.github.com/repos/bigswitch/horizon-bsn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bigswitch/horizon-bsn/labels{/name}","releases_url":"https://api.github.com/repos/bigswitch/horizon-bsn/releases{/id}","deployments_url":"https://api.github.com/repos/bigswitch/horizon-bsn/deployments","created_at":"2016-02-26T02:47:09Z","updated_at":"2016-08-01T19:09:22Z","pushed_at":"2016-08-15T23:40:58Z","git_url":"git://github.com/bigswitch/horizon-bsn.git","ssh_url":"git@github.com:bigswitch/horizon-bsn.git","clone_url":"https://github.com/bigswitch/horizon-bsn.git","svn_url":"https://github.com/bigswitch/horizon-bsn","homepage":null,"size":378,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60"},"html":{"href":"https://github.com/bigswitch/horizon-bsn/pull/60"},"issue":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/issues/60"},"comments":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/bigswitch/horizon-bsn/statuses/fa17fb03ce6638f7ff85272c28179762659d8f73"}}}}
{"actor":{"display_login":"mmxiong"}}