Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master c4c18c55e -> e2e89e12a


adds clone profile to TPv2 and adds a few missing change log statements


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/5d7926b6
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/5d7926b6
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/5d7926b6

Branch: refs/heads/master
Commit: 5d7926b6167c860a99dd43016b1ad8802c70bcfc
Parents: c4c18c5
Author: Jeremy Mitchell <mitchell...@gmail.com>
Authored: Tue Aug 8 08:35:33 2017 -0600
Committer: Dan Kirkwood <dang...@gmail.com>
Committed: Thu Aug 10 22:03:25 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Parameter.pm            | 17 +++++++--
 traffic_ops/app/lib/API/Profile.pm              |  9 ++---
 traffic_portal/app/src/app.js                   |  1 +
 .../app/src/common/api/ProfileService.js        | 16 +++++++--
 .../dialog/input/DialogInputController.js       | 37 ++++++++++++++++++++
 .../modules/dialog/input/dialog.input.tpl.html  | 33 +++++++++++++++++
 .../src/common/modules/dialog/input/index.js    | 21 +++++++++++
 .../dialog/select/dialog.select.tpl.html        |  2 +-
 .../form/profile/FormProfileController.js       | 26 +++++++++++---
 .../modules/form/profile/form.profile.tpl.html  |  2 +-
 .../private/admin/parameters/new/index.js       |  4 ++-
 11 files changed, 152 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_ops/app/lib/API/Parameter.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Parameter.pm 
b/traffic_ops/app/lib/API/Parameter.pm
index 9766189..9910bff 100644
--- a/traffic_ops/app/lib/API/Parameter.pm
+++ b/traffic_ops/app/lib/API/Parameter.pm
@@ -290,8 +290,12 @@ sub create {
             })
     }
     $self->db->txn_commit();
+
+    my $msg = scalar(@new_parameters) . " parameters created";
+    &log( $self, $msg, "APICHANGE" );
+
     my $response  = \@new_parameters;
-    return $self->success($response, "Create ". scalar(@new_parameters) . " 
parameters successfully.");
+    return $self->success($response, $msg);
 }
 
 sub update {
@@ -332,6 +336,9 @@ sub update {
         }
     );
 
+    my $msg = "Parameter [ $name ] updated";
+    &log( $self, $msg, "APICHANGE" );
+
     my $response;
     $response->{id}     = $find->id;
     $response->{name}   = $find->name;
@@ -339,7 +346,7 @@ sub update {
     $response->{value}  = $find->value;
     $response->{secure} = $find->secure;
 
-    return $self->success($response, "Parameter was successfully edited.");
+    return $self->success($response, $msg);
 }
 
 sub delete {
@@ -366,7 +373,11 @@ sub delete {
     }
  
     $find->delete();
-    return $self->success_message("Parameter was successfully deleted.");
+
+    my $msg = "Parameter [ " . $find->name . " ] deleted";
+    &log( $self, $msg, "APICHANGE" );
+
+    return $self->success_message($msg);
 }
 
 sub validate {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_ops/app/lib/API/Profile.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Profile.pm 
b/traffic_ops/app/lib/API/Profile.pm
index bef7e13..730c470 100644
--- a/traffic_ops/app/lib/API/Profile.pm
+++ b/traffic_ops/app/lib/API/Profile.pm
@@ -228,7 +228,7 @@ sub copy {
        my $self = shift;
 
        if ( !&is_oper($self) ) {
-               return $self->alert( { Error => " - You must be an admin or 
oper to perform this operation!" } );
+               return $self->forbidden();
        }
 
        my $name                   = $self->param('profile_name');
@@ -251,7 +251,7 @@ sub copy {
                return $self->alert("profile_copy_from $profile_copy_from_name 
doesn't exist.");
        }
        my $profile_copy_from_id = $row1->id;
-       my $description          = $row1->description;
+       my $description          = "";
 
        my $cdn = $row1->cdn;
        my $type = $row1->type;
@@ -280,8 +280,9 @@ sub copy {
                        $insert->insert();
                }
        }
+       my $msg = "Created new profile [ $name ] from existing profile [ 
$profile_copy_from_name ]";
 
-       &log( $self, "Created profile from copy with id: " . $new_id . " and 
name: " . $name, "APICHANGE" );
+       &log( $self, $msg, "APICHANGE" );
 
        my $response;
        $response->{id}              = $new_id;
@@ -289,7 +290,7 @@ sub copy {
        $response->{description}     = $description;
        $response->{profileCopyFrom} = $profile_copy_from_name;
        $response->{idCopyFrom}      = $profile_copy_from_id;
-       return $self->success($response);
+       return $self->success($response, $msg);
 }
 
 sub update {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/app.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/app.js b/traffic_portal/app/src/app.js
index 017231f..08de89e 100644
--- a/traffic_portal/app/src/app.js
+++ b/traffic_portal/app/src/app.js
@@ -171,6 +171,7 @@ var trafficPortal = angular.module('trafficPortal', [
         // common modules
         require('./common/modules/dialog/confirm').name,
         require('./common/modules/dialog/delete').name,
+        require('./common/modules/dialog/input').name,
         require('./common/modules/dialog/reset').name,
         require('./common/modules/dialog/select').name,
         require('./common/modules/dialog/select/status').name,

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/api/ProfileService.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/api/ProfileService.js 
b/traffic_portal/app/src/common/api/ProfileService.js
index d7c9df9..3a91477 100644
--- a/traffic_portal/app/src/common/api/ProfileService.js
+++ b/traffic_portal/app/src/common/api/ProfileService.js
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-var ProfileService = function(Restangular, locationUtils, messageModel) {
+var ProfileService = function(Restangular, $http, locationUtils, messageModel, 
ENV) {
 
     this.getProfiles = function(queryParams) {
         return Restangular.all('profiles').getList(queryParams);
@@ -72,8 +72,20 @@ var ProfileService = function(Restangular, locationUtils, 
messageModel) {
         return Restangular.one('parameters', 
paramId).getList('unassigned_profiles');
     };
 
+    this.cloneProfile = function(sourceName, cloneName) {
+        return $http.post(ENV.api['root'] + "profiles/name/" + cloneName + 
"/copy/" + sourceName)
+            .then(
+                function(result) {
+                    messageModel.setMessages(result.data.alerts, true);
+                    locationUtils.navigateToPath('/admin/profiles/' + 
result.data.response.id);
+                },
+                function(fault) {
+                    messageModel.setMessages(fault.data.alerts, false);
+                }
+            );
+    };
 
 };
 
-ProfileService.$inject = ['Restangular', 'locationUtils', 'messageModel'];
+ProfileService.$inject = ['Restangular', '$http', 'locationUtils', 
'messageModel', 'ENV'];
 module.exports = ProfileService;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/modules/dialog/input/DialogInputController.js
----------------------------------------------------------------------
diff --git 
a/traffic_portal/app/src/common/modules/dialog/input/DialogInputController.js 
b/traffic_portal/app/src/common/modules/dialog/input/DialogInputController.js
new file mode 100644
index 0000000..b6a3ed9
--- /dev/null
+++ 
b/traffic_portal/app/src/common/modules/dialog/input/DialogInputController.js
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 DialogInputController = function(params, $scope, $uibModalInstance) {
+
+       $scope.params = params;
+
+       $scope.inputValue = null;
+
+       $scope.select = function() {
+               $uibModalInstance.close($scope.inputValue);
+       };
+
+       $scope.cancel = function () {
+               $uibModalInstance.dismiss('cancel');
+       };
+
+};
+
+DialogInputController.$inject = ['params', '$scope', '$uibModalInstance'];
+module.exports = DialogInputController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/modules/dialog/input/dialog.input.tpl.html
----------------------------------------------------------------------
diff --git 
a/traffic_portal/app/src/common/modules/dialog/input/dialog.input.tpl.html 
b/traffic_portal/app/src/common/modules/dialog/input/dialog.input.tpl.html
new file mode 100644
index 0000000..35b5346
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/dialog/input/dialog.input.tpl.html
@@ -0,0 +1,33 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<div class="modal-header">
+    <button type="button" class="close" ng-click="cancel()"><span 
aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+    <h4 class="modal-title">{{::params.title}}</h4>
+</div>
+<div class="modal-body">
+    <p ng-bind-html="params.message"></p>
+    <form name="inputForm" novalidate>
+        <input type="text" class="form-control" ng-model="inputValue" 
ng-maxlength="256">
+    </form>
+</div>
+<div class="modal-footer">
+    <button class="btn btn-link" ng-click="cancel()">Cancel</button>
+    <button class="btn btn-primary" ng-disabled="inputForm.$invalid" 
ng-click="select()">Submit</button>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/modules/dialog/input/index.js
----------------------------------------------------------------------
diff --git a/traffic_portal/app/src/common/modules/dialog/input/index.js 
b/traffic_portal/app/src/common/modules/dialog/input/index.js
new file mode 100644
index 0000000..2912a50
--- /dev/null
+++ b/traffic_portal/app/src/common/modules/dialog/input/index.js
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+module.exports = angular.module('trafficPortal.dialog.input', [])
+       .controller('DialogInputController', 
require('./DialogInputController'));

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/modules/dialog/select/dialog.select.tpl.html
----------------------------------------------------------------------
diff --git 
a/traffic_portal/app/src/common/modules/dialog/select/dialog.select.tpl.html 
b/traffic_portal/app/src/common/modules/dialog/select/dialog.select.tpl.html
index 568935d..4bf84ea 100644
--- a/traffic_portal/app/src/common/modules/dialog/select/dialog.select.tpl.html
+++ b/traffic_portal/app/src/common/modules/dialog/select/dialog.select.tpl.html
@@ -22,7 +22,7 @@ under the License.
     <h4 class="modal-title">{{::params.title}}</h4>
 </div>
 <div class="modal-body">
-    <p>{{::params.message}}</p>
+    <p ng-bind-html="params.message"></p>
     <form name="selectForm" novalidate>
         <select id="cdn" name="cdn" class="form-control" 
ng-model="selectedItemId" ng-options="item.id as item.name for item in 
collection" required>
             <option value="">Select...</option>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/modules/form/profile/FormProfileController.js
----------------------------------------------------------------------
diff --git 
a/traffic_portal/app/src/common/modules/form/profile/FormProfileController.js 
b/traffic_portal/app/src/common/modules/form/profile/FormProfileController.js
index 1523ee0..74af772 100644
--- 
a/traffic_portal/app/src/common/modules/form/profile/FormProfileController.js
+++ 
b/traffic_portal/app/src/common/modules/form/profile/FormProfileController.js
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-var FormProfileController = function(profile, $scope, $location, formUtils, 
locationUtils, cdnService) {
+var FormProfileController = function(profile, $scope, $location, $uibModal, 
formUtils, locationUtils, cdnService, profileService) {
 
     var getCDNs = function() {
         cdnService.getCDNs(true)
@@ -58,11 +58,29 @@ var FormProfileController = function(profile, $scope, 
$location, formUtils, loca
     };
 
     $scope.cloneProfile = function() {
-        alert('not hooked up yet: cloneProfile');
+        var params = {
+            title: 'Clone Profile',
+            message: "Your are about to clone the " + profile.name + " 
profile. Your clone will have the same attributes and parameter assignments as 
the " + profile.name + " profile.<br><br>Please enter a name for your cloned 
profile."
+        };
+        var modalInstance = $uibModal.open({
+            templateUrl: 'common/modules/dialog/input/dialog.input.tpl.html',
+            controller: 'DialogInputController',
+            size: 'md',
+            resolve: {
+                params: function () {
+                    return params;
+                }
+            }
+        });
+        modalInstance.result.then(function(clonedProfileName) {
+            profileService.cloneProfile(profile.name, clonedProfileName);
+        }, function () {
+            // do nothing
+        });
     };
 
     $scope.exportProfile = function() {
-        alert('not hooked up yet: exportProfile');
+        // todo: implement export profile
     };
 
     $scope.navigateToPath = locationUtils.navigateToPath;
@@ -78,5 +96,5 @@ var FormProfileController = function(profile, $scope, 
$location, formUtils, loca
 
 };
 
-FormProfileController.$inject = ['profile', '$scope', '$location', 
'formUtils', 'locationUtils', 'cdnService'];
+FormProfileController.$inject = ['profile', '$scope', '$location', 
'$uibModal', 'formUtils', 'locationUtils', 'cdnService', 'profileService'];
 module.exports = FormProfileController;

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/common/modules/form/profile/form.profile.tpl.html
----------------------------------------------------------------------
diff --git 
a/traffic_portal/app/src/common/modules/form/profile/form.profile.tpl.html 
b/traffic_portal/app/src/common/modules/form/profile/form.profile.tpl.html
index e88ff0d..265d994 100644
--- a/traffic_portal/app/src/common/modules/form/profile/form.profile.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/profile/form.profile.tpl.html
@@ -36,7 +36,7 @@ under the License.
                     <li role="menuitem"><a ng-click="viewServers()" 
ng-if="profile.type != 'DS_PROFILE'">View Servers</a></li>
                     <li class="divider"></li>
                     <li role="menuitem"><a ng-click="cloneProfile()">Clone 
Profile</a></li>
-                    <li role="menuitem"><a ng-click="exportProfile()">Export 
Profile</a></li>
+                    <!--<li role="menuitem"><a 
ng-click="exportProfile()">Export Profile</a></li>-->
                 </ul>
             </div>
         </div>

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5d7926b6/traffic_portal/app/src/modules/private/admin/parameters/new/index.js
----------------------------------------------------------------------
diff --git 
a/traffic_portal/app/src/modules/private/admin/parameters/new/index.js 
b/traffic_portal/app/src/modules/private/admin/parameters/new/index.js
index 4f46616..3a50eca 100644
--- a/traffic_portal/app/src/modules/private/admin/parameters/new/index.js
+++ b/traffic_portal/app/src/modules/private/admin/parameters/new/index.js
@@ -28,7 +28,9 @@ module.exports = 
angular.module('trafficPortal.private.admin.parameters.new', []
                         controller: 'FormNewParameterController',
                         resolve: {
                             parameter: function() {
-                                return {};
+                                return {
+                                    secure: false
+                                };
                             }
                         }
                     }

Reply via email to