You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:33:10 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5934: TP: Adds ability to view/create/delete a cdn lock

ocket8888 commented on a change in pull request #5934:
URL: https://github.com/apache/trafficcontrol/pull/5934#discussion_r650205133



##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/dialog.select.lock.tpl.html
##########
@@ -0,0 +1,69 @@
+<!--
+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">Create CDN Lock</h4>
+</div>
+<div class="modal-body">
+    <form name="lockForm" novalidate>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.cdn), 'has-feedback': hasError(lockForm.cdn)}">
+                    <label class="control-label" for="cdn">CDN *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.cdn, 'required')">Required</small>
+                    </label>
+                    <select id="cdn" name="cdn" class="form-control" ng-model="lock.cdn" ng-options="cdn.name as cdn.name for cdn in cdns" required>
+                        <option value="">Select...</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.message), 'has-feedback': hasError(lockForm.message)}">
+                    <label class="control-label" for="message">Message *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.message, 'maxlength')">Too Long</small>
+                    </label>
+                    <input id="message" name="message" type="text" class="form-control" ng-model="lock.message" ng-maxlength="256" required autofocus>
+                    <span ng-show="hasError(lockForm.message)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+                <div class="col-sm-12 col-md-12">
+                    <div class="form-group">
+                        <p>Type *</p>

Review comment:
       I think this should properly be a `legend` child of a `fieldset` element for proper labeling with assistive technologies.

##########
File path: traffic_portal/app/src/common/modules/locks/locks.tpl.html
##########
@@ -0,0 +1,23 @@
+<!--
+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 id="locksContainer">
+    <div class="alert alert-dark" ng-repeat="l in locks">
+        <button type="button" class="close" title="Unlock {{l.cdn}}" aria-hidden="true" ng-click="confirmUnlock(l)"><i class="fa fa-unlock"></i></button>

Review comment:
       this shouldn't have `aria-hidden`, that makes it invisible to users using assistive technologies.

##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/dialog.select.lock.tpl.html
##########
@@ -0,0 +1,69 @@
+<!--
+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">Create CDN Lock</h4>
+</div>
+<div class="modal-body">
+    <form name="lockForm" novalidate>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.cdn), 'has-feedback': hasError(lockForm.cdn)}">
+                    <label class="control-label" for="cdn">CDN *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.cdn, 'required')">Required</small>
+                    </label>
+                    <select id="cdn" name="cdn" class="form-control" ng-model="lock.cdn" ng-options="cdn.name as cdn.name for cdn in cdns" required>
+                        <option value="">Select...</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.message), 'has-feedback': hasError(lockForm.message)}">
+                    <label class="control-label" for="message">Message *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.message, 'maxlength')">Too Long</small>
+                    </label>
+                    <input id="message" name="message" type="text" class="form-control" ng-model="lock.message" ng-maxlength="256" required autofocus>
+                    <span ng-show="hasError(lockForm.message)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+                <div class="col-sm-12 col-md-12">
+                    <div class="form-group">
+                        <p>Type *</p>
+                        <input id="soft" type="radio" data-ng-model="lock.soft" data-ng-value="true">
+                        <label class="has-tooltip" for="soft">&nbsp;Soft<div class="helptooltip">
+                            <div class="helptext">A soft lock will prevent others from queueing server updates or snapshotting the locked CDN.</div>
+                        </div>
+                        </label><br>
+                        <input id="hard" type="radio" data-ng-model="lock.soft" data-ng-value="false">
+                        <label class="has-tooltip" for="soft">&nbsp;Hard<div class="helptooltip">
+                            <div class="helptext">A hard lock will prevent others from queueing server updates or snapshotting the locked CDN. It will also block others from making changes that would change the state of the locked CDN.</div>
+                        </div>
+                        </label>
+                    </div>
+            </div>
+        </div>
+    </form>
+</div>
+<div class="modal-footer">
+    <button class="btn action-btn" ng-click="cancel()">Cancel</button>
+    <button class="btn btn-link" ng-disabled="lockForm.$invalid" ng-click="select()">Submit</button>

Review comment:
       `button`s that don't submit containing `form`s should be `button[type=button]`s, as the implicit default is `button[type=submit]`.

##########
File path: traffic_portal/app/src/common/modules/locks/locks.tpl.html
##########
@@ -0,0 +1,23 @@
+<!--
+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 id="locksContainer">
+    <div class="alert alert-dark" ng-repeat="l in locks">
+        <button type="button" class="close" title="Unlock {{l.cdn}}" aria-hidden="true" ng-click="confirmUnlock(l)"><i class="fa fa-unlock"></i></button>
+        <div ng-bind-html="l.cdn + ' is ' + ((l.soft) ? 'soft' : 'hard') + ' locked by ' + l.userName + ' (' + l.message + ')' | linky:'_blank'"></div>

Review comment:
       Why use `ng-bind-html` instead of just a regular template?

##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/DialogSelectLockController.js
##########
@@ -0,0 +1,46 @@
+/*
+ * 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 DialogSelectLockController = function(cdns, $scope, $uibModalInstance) {
+
+	$scope.cdns = cdns.filter(
+		function (cdn) {
+			// you cannot apply a lock to the 'ALL' cdn
+			return cdn.name != 'ALL';

Review comment:
       comparisons should use `!==`/`===`

##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/dialog.select.lock.tpl.html
##########
@@ -0,0 +1,69 @@
+<!--
+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">Create CDN Lock</h4>
+</div>
+<div class="modal-body">
+    <form name="lockForm" novalidate>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.cdn), 'has-feedback': hasError(lockForm.cdn)}">
+                    <label class="control-label" for="cdn">CDN *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.cdn, 'required')">Required</small>
+                    </label>
+                    <select id="cdn" name="cdn" class="form-control" ng-model="lock.cdn" ng-options="cdn.name as cdn.name for cdn in cdns" required>
+                        <option value="">Select...</option>

Review comment:
       `Select...` is not a valid CDN name, should be `hidden` and `disabled` (and then also `selected` so that it actually shows up by default)

##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/dialog.select.lock.tpl.html
##########
@@ -0,0 +1,69 @@
+<!--
+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">Create CDN Lock</h4>
+</div>
+<div class="modal-body">
+    <form name="lockForm" novalidate>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.cdn), 'has-feedback': hasError(lockForm.cdn)}">
+                    <label class="control-label" for="cdn">CDN *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.cdn, 'required')">Required</small>
+                    </label>
+                    <select id="cdn" name="cdn" class="form-control" ng-model="lock.cdn" ng-options="cdn.name as cdn.name for cdn in cdns" required>
+                        <option value="">Select...</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.message), 'has-feedback': hasError(lockForm.message)}">
+                    <label class="control-label" for="message">Message *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.message, 'maxlength')">Too Long</small>
+                    </label>
+                    <input id="message" name="message" type="text" class="form-control" ng-model="lock.message" ng-maxlength="256" required autofocus>
+                    <span ng-show="hasError(lockForm.message)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+                <div class="col-sm-12 col-md-12">
+                    <div class="form-group">
+                        <p>Type *</p>
+                        <input id="soft" type="radio" data-ng-model="lock.soft" data-ng-value="true">
+                        <label class="has-tooltip" for="soft">&nbsp;Soft<div class="helptooltip">
+                            <div class="helptext">A soft lock will prevent others from queueing server updates or snapshotting the locked CDN.</div>
+                        </div>
+                        </label><br>
+                        <input id="hard" type="radio" data-ng-model="lock.soft" data-ng-value="false">

Review comment:
       Does this work with the `data-` prefixes? At the least it's unnecessary. Also, in order to make the browser recognize these as mutually exclusive options, they should have the same `name` attribute. Finally, these should have the `required` attribute to make it clear that a selection must be made (it's best to put it on both, IMO, for clarity, but when they have the same `name` only one _needs_ to have it for it to work strictly speaking)

##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/dialog.select.lock.tpl.html
##########
@@ -0,0 +1,69 @@
+<!--
+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">Create CDN Lock</h4>
+</div>
+<div class="modal-body">
+    <form name="lockForm" novalidate>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.cdn), 'has-feedback': hasError(lockForm.cdn)}">
+                    <label class="control-label" for="cdn">CDN *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.cdn, 'required')">Required</small>
+                    </label>
+                    <select id="cdn" name="cdn" class="form-control" ng-model="lock.cdn" ng-options="cdn.name as cdn.name for cdn in cdns" required>
+                        <option value="">Select...</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.message), 'has-feedback': hasError(lockForm.message)}">
+                    <label class="control-label" for="message">Message *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.message, 'maxlength')">Too Long</small>
+                    </label>
+                    <input id="message" name="message" type="text" class="form-control" ng-model="lock.message" ng-maxlength="256" required autofocus>
+                    <span ng-show="hasError(lockForm.message)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+                <div class="col-sm-12 col-md-12">
+                    <div class="form-group">
+                        <p>Type *</p>
+                        <input id="soft" type="radio" data-ng-model="lock.soft" data-ng-value="true">
+                        <label class="has-tooltip" for="soft">&nbsp;Soft<div class="helptooltip">
+                            <div class="helptext">A soft lock will prevent others from queueing server updates or snapshotting the locked CDN.</div>
+                        </div>
+                        </label><br>
+                        <input id="hard" type="radio" data-ng-model="lock.soft" data-ng-value="false">
+                        <label class="has-tooltip" for="soft">&nbsp;Hard<div class="helptooltip">
+                            <div class="helptext">A hard lock will prevent others from queueing server updates or snapshotting the locked CDN. It will also block others from making changes that would change the state of the locked CDN.</div>
+                        </div>
+                        </label>
+                    </div>
+            </div>
+        </div>
+    </form>
+</div>
+<div class="modal-footer">

Review comment:
       nit but there's a native [`<footer>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer) - although we don't do a lot of sectioning so it won't really do much to use it here.

##########
File path: traffic_portal/app/src/common/modules/dialog/select/lock/dialog.select.lock.tpl.html
##########
@@ -0,0 +1,69 @@
+<!--
+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">Create CDN Lock</h4>
+</div>
+<div class="modal-body">
+    <form name="lockForm" novalidate>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.cdn), 'has-feedback': hasError(lockForm.cdn)}">
+                    <label class="control-label" for="cdn">CDN *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.cdn, 'required')">Required</small>
+                    </label>
+                    <select id="cdn" name="cdn" class="form-control" ng-model="lock.cdn" ng-options="cdn.name as cdn.name for cdn in cdns" required>
+                        <option value="">Select...</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-sm-12 col-md-12">
+                <div class="form-group" ng-class="{'has-error': hasError(lockForm.message), 'has-feedback': hasError(lockForm.message)}">
+                    <label class="control-label" for="message">Message *
+                        <small class="input-error" ng-show="hasPropertyError(lockForm.message, 'maxlength')">Too Long</small>
+                    </label>
+                    <input id="message" name="message" type="text" class="form-control" ng-model="lock.message" ng-maxlength="256" required autofocus>
+                    <span ng-show="hasError(lockForm.message)" class="form-control-feedback"><i class="fa fa-times"></i></span>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+                <div class="col-sm-12 col-md-12">
+                    <div class="form-group">
+                        <p>Type *</p>
+                        <input id="soft" type="radio" data-ng-model="lock.soft" data-ng-value="true">
+                        <label class="has-tooltip" for="soft">&nbsp;Soft<div class="helptooltip">
+                            <div class="helptext">A soft lock will prevent others from queueing server updates or snapshotting the locked CDN.</div>
+                        </div>
+                        </label><br>
+                        <input id="hard" type="radio" data-ng-model="lock.soft" data-ng-value="false">
+                        <label class="has-tooltip" for="soft">&nbsp;Hard<div class="helptooltip">

Review comment:
       spacing should be achieved with CSS - this makes the input labeled as literally "&nbsp;Hard" instead of just "Hard".




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org