Moved ZoomDirective to gui2-fw-lib (from gui2-topo-lib)
Change-Id: Idc8bfefea7c84d6611242a9562d84ca6cc53a7b3
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.css b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.css
new file mode 100644
index 0000000..c8acf1b
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.css
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/*
+ ONOS GUI -- Name Input Component (layout) -- CSS file
+ */
+#name-input-dialog {
+ top: 140px;
+ padding: 12px;
+}
+
+#name-input-dialog h3 {
+ display: inline-block;
+ font-weight: bold;
+ font-size: 18pt;
+}
+
+#name-input-dialog p {
+ font-size: 12pt;
+}
+
+#name-input-dialog p.strong {
+ font-weight: bold;
+ padding: 8px;
+ text-align: center;
+}
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.html b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.html
new file mode 100644
index 0000000..e505780
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.html
@@ -0,0 +1,22 @@
+<!--
+~ Copyright 2019-present Open Networking Foundation
+~
+~ 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.
+-->
+<div id="name-input-dialog" class="floatpanel dialog" [@niDlgState]="title!==''">
+ <h3>{{ title }}</h3><br>
+ <input #newName type="text" pattern="[a-zA-Z0-9\-:_]{3}" [placeholder]="placeholder" name="nameinput" [minLength]="minLen" [maxLength]="maxLen" width="40" required>
+ <p *ngIf="warning" class="warning strong">{{ warning }}</p>
+ <div tabindex="10" class="dialog-button" (click)="choice(true, newName.value)">OK</div>
+ <div tabindex="11" class="dialog-button" (click)="choice(false, '')">Cancel</div>
+</div>
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.spec.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.spec.ts
new file mode 100644
index 0000000..63ec2cb
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.spec.ts
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+import {async, ComponentFixture, TestBed} from '@angular/core/testing';
+
+import {NameInputComponent} from './name-input.component';
+import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
+
+describe('NameInputComponent', () => {
+ let component: NameInputComponent;
+ let fixture: ComponentFixture<NameInputComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [BrowserAnimationsModule],
+ declarations: [NameInputComponent]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NameInputComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.ts b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.ts
new file mode 100644
index 0000000..9d7116e
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.component.ts
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
+import {animate, state, style, transition, trigger} from '@angular/animations';
+
+export interface NameInputResult {
+ chosen: boolean;
+ name: string;
+}
+
+@Component({
+ selector: 'onos-name-input',
+ templateUrl: './name-input.component.html',
+ styleUrls: [
+ './name-input.component.css',
+ './name-input.theme.css',
+ '../../layer/dialog.css',
+ '../../layer/dialog.theme.css',
+ '../../widget/panel.css',
+ '../../widget/panel-theme.css'
+ ],
+ animations: [
+ trigger('niDlgState', [
+ state('true', style({
+ transform: 'translateX(-100%)',
+ opacity: '100'
+ })),
+ state('false', style({
+ transform: 'translateX(0%)',
+ opacity: '0'
+ })),
+ transition('0 => 1', animate('100ms ease-in')),
+ transition('1 => 0', animate('100ms ease-out'))
+ ])
+ ]
+})
+export class NameInputComponent implements OnInit {
+ @Input() warning: string;
+ @Input() title: string = '';
+ @Input() pattern;
+ @Input() minLen = 4;
+ @Input() maxLen = 40;
+ @Input() placeholder = 'name';
+ @Output() chosen: EventEmitter<NameInputResult> = new EventEmitter();
+
+ constructor() {
+ }
+
+ ngOnInit() {
+ }
+
+ /**
+ * When OK or Cancel is pressed, send an event to parent with choice
+ */
+ choice(chosen: boolean, newName: string): void {
+ if (chosen && (newName === undefined || newName === '')) {
+ return;
+ }
+ this.chosen.emit(<NameInputResult>{
+ chosen: chosen,
+ name: newName
+ });
+ }
+}
diff --git a/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.theme.css b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.theme.css
new file mode 100644
index 0000000..bb88fb2
--- /dev/null
+++ b/web/gui2-fw-lib/projects/gui2-fw-lib/src/lib/util/name-input/name-input.theme.css
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/*
+ ONOS GUI -- name-input-dialog Component (theme) -- CSS file
+ */
+/* temporarily removed .light */
+#name-input-dialog p.strong {
+ color: white;
+ background-color: #ce5b58;
+}
+
+#name-input-dialog.floatpanel.dialog {
+ background-color: #ffffff;
+}
+
+#name-input-dialog p.strong {
+ color: white;
+ background-color: #ce5b58;
+}