Best JavaScript code snippet using protractor
index.js
Source:index.js
1'use strict';2Object.defineProperty(exports, '__esModule', { value: true });3function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }4var angular = _interopDefault(require('angular'));5var core = require('@angular/core');6var _static = require('@angular/upgrade/static');7var common = require('@angular/common');8var common$1 = require('@msx/common');9var forms = require('@msx/forms');10var templateManagement = require('@msx/template-management');11var _ = _interopDefault(require('lodash'));12var rxjs = require('rxjs');13/*! *****************************************************************************14Copyright (c) Microsoft Corporation. All rights reserved.15Licensed under the Apache License, Version 2.0 (the "License"); you may not use16this file except in compliance with the License. You may obtain a copy of the17License at http://www.apache.org/licenses/LICENSE-2.01819THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY20KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED21WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,22MERCHANTABLITY OR NON-INFRINGEMENT.2324See the Apache Version 2.0 License for specific language governing permissions25and limitations under the License.26***************************************************************************** */2728function __decorate(decorators, target, key, desc) {29 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;30 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);31 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;32 return c > 3 && r && Object.defineProperty(target, key, r), r;33}3435function __param(paramIndex, decorator) {36 return function (target, key) { decorator(target, key, paramIndex); }37}3839function __metadata(metadataKey, metadataValue) {40 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);41}4243function __awaiter(thisArg, _arguments, P, generator) {44 return new (P || (P = Promise))(function (resolve, reject) {45 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }46 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }47 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }48 step((generator = generator.apply(thisArg, _arguments || [])).next());49 });50}5152function __generator(thisArg, body) {53 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;54 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;55 function verb(n) { return function (v) { return step([n, v]); }; }56 function step(op) {57 if (f) throw new TypeError("Generator is already executing.");58 while (_) try {59 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;60 if (y = 0, t) op = [op[0] & 2, t.value];61 switch (op[0]) {62 case 0: case 1: t = op; break;63 case 4: _.label++; return { value: op[1], done: false };64 case 5: _.label++; y = op[1]; op = [0]; continue;65 case 7: op = _.ops.pop(); _.trys.pop(); continue;66 default:67 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }68 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }69 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }70 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }71 if (t[2]) _.ops.pop();72 _.trys.pop(); continue;73 }74 op = body.call(thisArg, _);75 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }76 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };77 }78}7980function __spreadArrays() {81 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;82 for (var r = Array(s), k = 0, i = 0; i < il; i++)83 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)84 r[k] = a[j];85 return r;86}87var template = "<div class=\"msx-add-device-info\"><div class=\"msx-add-device-info__deviceDetails\" *ngIf=\"!isLoading\"><div class=\"msx-add-device-info__deviceDetails__name\"><msx-input-box type=\"text\" name=\"deviceName\" [msxModel]=\"deviceName\" [msxRequired]=\"true\" (msxModelChange)=\"onValueChange($event, 'deviceName')\" placeholder=\"cisco.common.workflow.add.device.deviceInfo.device.name.placeholder\" label=\"cisco.common.workflow.add.device.deviceInfo.device.name.label\" inputErrorMessage=\"cisco.common.workflow.add.device.deviceInfo.device.name.errorMessage\"></msx-input-box></div><div class=\"msx-add-device-info__deviceDetails__model\"><msx-multi-select-combo-dropdown [items]=\"deviceModelsList\" appendTo=\"body\" [msxModel]=\"deviceModel\" [msxRequired]=\"true\" (msxModelChange)=\"onValueChange($event, 'deviceModel')\" label=\"cisco.common.workflow.add.device.deviceInfo.device.model.label\" placeholder=\"cisco.common.workflow.add.device.deviceInfo.device.model.placeholder\" [singleSelect]=\"true\" [showClearSelection]=\"false\"></msx-multi-select-combo-dropdown></div><div class=\"msx-add-device-info__deviceDetails__serial\"><msx-input-box type=\"text\" name=\"deviceSerial\" [msxModel]=\"deviceSerial\" (msxModelChange)=\"onValueChange($event, 'deviceSerial')\" placeholder=\"cisco.common.workflow.add.device.deviceInfo.device.serial.placeholder\" label=\"cisco.common.workflow.add.device.deviceInfo.device.serial.label\"></msx-input-box></div></div></div>\n";88var AddDeviceInfoComponent = (function () {89 function AddDeviceInfoComponent(devicesService, _step) {90 this.devicesService = devicesService;91 this._step = _step;92 this.deviceName = '';93 this.deviceSerial = '';94 this.deviceModelsList = [];95 }96 AddDeviceInfoComponent.prototype.ngOnInit = function () {97 var _this = this;98 this.deviceModelsList = [];99 this.devicesService.getDeviceModelsByType().then(function (data) {100 var items = [];101 data.forEach(function (val) {102 items.push({103 label: val.name,104 value: val.name105 });106 });107 _this.deviceModelsList = _this.rangeWildcardReplacement(items);108 });109 };110 AddDeviceInfoComponent.prototype.rangeWildcardReplacement = function (items) {111 var updatedItems = [];112 items.forEach(function (modelItem) {113 updatedItems.push({114 label: modelItem.label.replaceAll('[0-9]', '*').replaceAll('(', '').replaceAll(')', ''),115 value: modelItem.value116 });117 });118 return updatedItems;119 };120 AddDeviceInfoComponent.prototype.onValueChange = function (value, type) {121 var _this = this;122 setTimeout(function () {123 if (type === 'deviceName') {124 _this.deviceName = value;125 }126 else if (type === 'deviceModel') {127 _this.deviceModel = value;128 }129 else if (type === 'deviceSerial') {130 _this.deviceSerial = value;131 }132 if (_this.deviceName && !_.isEmpty(_this.deviceModel)) {133 var deviceData = {134 managed: false,135 model: _this.deviceModel[0].value,136 name: _this.deviceName,137 onboardType: "none",138 serialKey: _this.deviceSerial,139 tags: {},140 tenantId: _this.componentData.tenantId,141 type: "ANY"142 };143 _this.componentData.deviceInfo = deviceData;144 _this._step.completed = true;145 }146 else {147 _this._step.completed = false;148 }149 });150 };151 __decorate([152 core.Input(),153 __metadata("design:type", Object)154 ], AddDeviceInfoComponent.prototype, "componentData", void 0);155 AddDeviceInfoComponent = __decorate([156 core.Component({157 selector: 'msx-add-device-info',158 providers: [159 new common$1.AngularJSProvider('msx.devicesService')160 ],161 template: template162 }),163 __param(0, core.Inject('msx.devicesService')),164 __param(1, core.Inject(common$1.WizardStepComponent)),165 __metadata("design:paramtypes", [Object, Object])166 ], AddDeviceInfoComponent);167 return AddDeviceInfoComponent;168}());169var template$1 = "<div class=\"msx-add-device-review\"><div *ngIf=\"componentData.deviceInfo\" class=\"msx-add-device-review__details\">\n <div *ngIf=\"componentData.deviceInfo.name\">\n <label role=\"label\" class=\"sk-font-metadata-medium\" msxResourceString=\"cisco.common.workflow.add.device.deviceReview.device.name.label\"></label>\n <span class=\"msx-add-device-review__details_name sk-font-standard-text\" msxResourceString=\"{{componentData.deviceInfo.name}}\"></span>\n </div>\n <div *ngIf=\"componentData.deviceInfo.model\">\n <label role=\"label\" class=\"sk-font-metadata-medium\" msxResourceString=\"cisco.common.workflow.add.device.deviceReview.device.model.label\"></label>\n <span class=\"msx-add-device-review__details_model sk-font-standard-text\" msxResourceString=\"{{componentData.deviceInfo.model}}\"></span>\n </div>\n <div *ngIf=\"componentData.deviceInfo.serialKey\">\n <label role=\"label\" class=\"sk-font-metadata-medium\" msxResourceString=\"cisco.common.workflow.add.device.deviceReview.device.serial.label\"></label>\n <span class=\"msx-add-device-review__details_serial sk-font-standard-text\" msxResourceString=\"{{componentData.deviceInfo.serialKey}}\"></span>\n </div>\n </div><div class=\"msx-add-device-review__details__button-bar button-bar center-buttons\">\n <button class=\"button button--medium button--secondary\" (click)=\"back()\" msxResourceString=\"cisco.common.button.back\"></button>\n <button *ngIf=\"componentData.deviceInfo\" class=\"button button--medium button--cta\" (click)=\"addDevice()\" msxResourceString=\"cisco.common.button.submission\"></button>\n </div></div>\n";170var AddDeviceReviewComponent = (function () {171 function AddDeviceReviewComponent(devicesService, loggerService, _wizardStepper) {172 this.devicesService = devicesService;173 this.loggerService = loggerService;174 this._wizardStepper = _wizardStepper;175 }176 AddDeviceReviewComponent.prototype.back = function () {177 this._wizardStepper.previous();178 };179 AddDeviceReviewComponent.prototype.addDevice = function () {180 var _this = this;181 var device = this.componentData.deviceInfo;182 this.componentData.deviceName = device.name;183 if (device && device.name) {184 this.devicesService.addDevice(device.tenantId, this.componentData.selectedService.serviceInstanceId, this.componentData.selectedService.type, device.serialKey, device.model, device.deviceType || '', device.deviceSubtype || '', device.name, null, device.version || '', 'none', false).then(function (resp) {185 if (resp && resp.data && resp.data.responseObject) {186 _this.componentData.deviceId = resp.data.responseObject.id;187 _this._wizardStepper.next();188 }189 }, function (err) {190 _this.loggerService.warn("addDevice Error:", err);191 _this.componentData.failureMessage = err.data.message;192 _this._wizardStepper.next();193 });194 }195 };196 __decorate([197 core.Input(),198 __metadata("design:type", Object)199 ], AddDeviceReviewComponent.prototype, "componentData", void 0);200 AddDeviceReviewComponent = __decorate([201 core.Component({202 selector: 'msx-add-device-review',203 providers: [204 new common$1.AngularJSProvider('msx.devicesService'),205 new common$1.AngularJSProvider('msx.loggerService')206 ],207 template: template$1208 }),209 __param(0, core.Inject('msx.devicesService')),210 __param(1, core.Inject('msx.loggerService')),211 __param(2, core.Inject(common$1.WizardComponent)),212 __metadata("design:paramtypes", [Object, Object, Object])213 ], AddDeviceReviewComponent);214 return AddDeviceReviewComponent;215}());216var template$2 = "<div class=\"msx-add-device-service\"><msx-busy-indicator *ngIf=\"isLoading\" [radius]=\"3.2\" class=\"vms-busy-center\"></msx-busy-indicator><div *ngIf=\"!isLoading\"><div class=\"msx-add-device-service__services\" *ngIf=\"componentData.tenantServices && componentData.tenantServices.length\"><ng-container *ngFor=\"let tile of componentData.tenantServices\"><div class=\"msx-add-device-service__services__service msx-add-device-service__services__service-for-{{tile.type}}\" [ngClass]=\"{'msx-add-device-service__services__service__disabled': componentData.preSelectedService || tile.doesNotSupportGlobalAddDevice}\" (click)=\"onServiceChange(tile)\"><div class=\"msx-add-device-service__services__service__icon-wrapper\" [ngClass]=\"{'msx-add-device-service__services__service__icon-wrapper__disabled': componentData.preSelectedService}\"><msx-image-loader [ngClass]=\"{'msx-add-device-service__services__service__not_supported': tile.doesNotSupportGlobalAddDevice}\" *ngIf=\"tile.icon != null\" url=\"{{tile.icon}}\"></msx-image-loader><div *ngIf=\"tile.type === selectedServiceType || tile.type === componentData.preSelectedService\" class=\"msx-add-device-service__services__service__icon-badge vms_fi_alert6015-16\" [ngClass]=\"{'sk-color-white': tile.type === selectedServiceType, 'sk-background-primary-1': tile.type === selectedServiceType }\"></div></div><div class=\"msx-add-device-service__services__service__title sk-font-standard-text\" [ngClass]=\"{'msx-add-device-service__services__service__not_supported': tile.doesNotSupportGlobalAddDevice}\" msxResourceString=\"{{tile.title}}\">\n\t\t\t\t\t</div><div class=\"msx-add-device-service__services__service__link sk-font-standard-link\" tabindex=\"{{ componentData.preSelectedService ? -1 : 0 }}\" role=\"link\" *ngIf=\"!tile.doesNotSupportGlobalAddDevice\" [ngClass]=\"{'sk-font-metadata-medium': componentData.preSelectedService, 'msx-add-device-service__services__service__link__disabled': componentData.preSelectedService}\" msxResourceString=\"{{getLinkTitle(tile)}}\"></div><div class=\"msx-add-device-service__services__service__not_supported sk-font-metadata-medium\" *ngIf=\"tile.doesNotSupportGlobalAddDevice\" msxResourceString=\"{{getDisabledMessage(tile)}}\"></div>\n\t\t\t\t</div></ng-container></div></div></div>";217var AddDeviceServiceComponent = (function () {218 function AddDeviceServiceComponent(translateService, servicesService) {219 this.translateService = translateService;220 this.servicesService = servicesService;221 this.selectedServiceType = '';222 }223 AddDeviceServiceComponent.prototype.ngOnInit = function () {224 var _this = this;225 this.stepChange.subscribe(function (step) {226 if (step === 'addDeviceService' && _this.componentData && _this.componentData.preSelectedService) {227 _this.selectedServiceType = _this.componentData.preSelectedService;228 }229 });230 };231 AddDeviceServiceComponent.prototype.onServiceChange = function (service) {232 if (service.doesNotSupportGlobalAddDevice) {233 return;234 }235 if (this.componentData && this.componentData.preSelectedService) {236 this.selectedServiceType = this.componentData.preSelectedService;237 }238 else if (this.componentData && (service === null || service === void 0 ? void 0 : service.type) !== this.selectedServiceType) {239 this.selectedServiceType = service.type;240 this.componentData.serviceSelected(service);241 }242 else {243 this.selectedServiceType = null;244 this.componentData.serviceSelected(null);245 }246 };247 AddDeviceServiceComponent.prototype.getLinkTitle = function (service) {248 if (service && service.type && this.componentData.preSelectedService && this.componentData.preSelectedService === service.type) {249 return "cisco.common.button.selected";250 }251 else if (this.componentData.preSelectedService && this.componentData.preSelectedService !== service.type) {252 return "cisco.common.button.disabled";253 }254 else if ((service === null || service === void 0 ? void 0 : service.type) === this.selectedServiceType) {255 return "cisco.common.button.unselect";256 }257 return "cisco.common.button.select";258 };259 AddDeviceServiceComponent.prototype.getDisabledMessage = function (service) {260 var msg = "cisco.global.actions.add.device.disabled.for.label";261 return this.translateService(msg, { serviceName: this.servicesService.getTranslatedServiceName(service.type) });262 };263 __decorate([264 core.Input(),265 __metadata("design:type", Object)266 ], AddDeviceServiceComponent.prototype, "componentData", void 0);267 __decorate([268 core.Input(),269 __metadata("design:type", rxjs.Subject)270 ], AddDeviceServiceComponent.prototype, "stepChange", void 0);271 AddDeviceServiceComponent = __decorate([272 core.Component({273 selector: 'msx-add-device-service',274 providers: [275 new common$1.AngularJSProvider('msx.translateService'),276 new common$1.AngularJSProvider('msx.servicesService')277 ],278 template: template$2279 }),280 __param(0, core.Inject('msx.translateService')),281 __param(1, core.Inject('msx.servicesService')),282 __metadata("design:paramtypes", [Object, Object])283 ], AddDeviceServiceComponent);284 return AddDeviceServiceComponent;285}());286var template$3 = "<div class=\"msx-add-device\"><msx-wizard #wizard (wizardClosed)=\"closeWizard()\" (wizardStepChange)=\"handleStepChange($event)\"><ng-container *ngFor=\"let step of jsonStepMetadata\"><msx-wizard-step [title]=\"step.title\" [description]=\"step.description\" [key]=\"step.key\" [status]=\"step.status\" [skipToStepKey]=\"step.skipToStepKey\" [introductionTitle]=\"step.introductionTitle\" [introductionDescription]=\"step.introductionDescription\" [introductionIcon]=\"step.introductionIcon\" [introductionLargeImage]=\"step.introductionLargeImage\" [introductionStartButtonLabel]=\"step.introductionStartButtonLabel\" [introductionSkipButtonLabel]=\"step.introductionSkipButtonLabel\" [introductionStepLabel]=\"step.introductionStepLabel\" [showIntroductionStep]=\"step.showIntroductionStep\" [allowSkippingIntroductionStep]=\"step.allowSkippingIntroductionStep\" [isChanged]=\"step.isChanged\" [hideTitle]=\"step.hideTitle\" [hideButtonBar]=\"step.hideButtonBar\" [disableButtons]=\"step.disableButtons\" [showBusyDir]=\"step.showBusyDir\" [optional]=\"step.optional\" [completed]=\"step.completed\" (stepEnterHandler)=\"step.stepEnterHandler()\" [systemStepTitle]=\"step.systemStepTitle\" [systemStepLoadingCaption]=\"step.systemStepLoadingCaption\" [systemStepIconClasses]=\"step.systemStepIconClasses\" [systemStepButtons]=\"step.systemStepButtons\" [showFinalStep]=\"step.showFinalStep\"><dynamic-wizard-step *ngIf=\"step.component\" [(component)]=\"step.component\" [(module)]=\"step.module\" [(componentData)]=\"step.componentData\" [(stepChange)]=\"stepChange\" (nextSteps)=\"addNextSteps($event, step.key)\"></dynamic-wizard-step></msx-wizard-step></ng-container></msx-wizard></div>\n";287var AddDeviceComponent = (function () {288 function AddDeviceComponent(servicesService, serviceCatalogService, sitesService, translateService, deviceDetailsRegistry, twgaRegistry, msxInfo, $state) {289 var _this = this;290 this.servicesService = servicesService;291 this.serviceCatalogService = serviceCatalogService;292 this.sitesService = sitesService;293 this.translateService = translateService;294 this.deviceDetailsRegistry = deviceDetailsRegistry;295 this.twgaRegistry = twgaRegistry;296 this.msxInfo = msxInfo;297 this.$state = $state;298 this.globalAddCheck = false;299 this.close = new core.EventEmitter();300 this.jsonStepMetadata = [];301 this.serviceSteps = [];302 this.serviceActions = [];303 this.stepChange = new rxjs.Subject();304 this.lastInsertedSteps = [];305 this.deviceStepsData = {306 tenantServices: [],307 preSelectedService: this.serviceType,308 selectedService: {},309 serviceSelected: function (data) { return _this.getServiceSteps(data); },310 deviceInfo: {},311 closeWizard: function () { return _this.closeWizard(); }312 };313 this.initialSteps = [{314 optional: true,315 key: "addDeviceIntroduction",316 introductionTitle: "cisco.common.workflow.add.device.introduction.title",317 introductionDescription: "cisco.common.workflow.add.device.introduction.description",318 introductionIcon: "vms_fi_settings3027-48",319 introductionStepLabel: "addDeviceIntroduction",320 showIntroductionStep: true,321 allowSkippingIntroductionStep: true,322 hideButtonBar: true323 }, {324 title: "cisco.common.workflow.add.device.serviceselection.title",325 description: "cisco.common.workflow.add.device.serviceselection.description",326 optional: false,327 key: "addDeviceService",328 completed: false,329 component: AddDeviceServiceComponent,330 componentData: this.deviceStepsData331 }];332 this.defaultFlowSteps = [{333 title: "cisco.common.workflow.add.device.deviceInfo.title",334 description: "cisco.common.workflow.add.device.deviceInfo.description",335 optional: false,336 key: "platformAddDeviceInfo",337 completed: false,338 component: AddDeviceInfoComponent,339 componentData: this.deviceStepsData340 }, {341 title: "cisco.common.workflow.add.device.deviceReview.title",342 description: "cisco.common.workflow.add.device.deviceReview.description",343 optional: true,344 hideButtonBar: true,345 key: "platformAddDeviceReview",346 completed: false,347 component: AddDeviceReviewComponent,348 componentData: this.deviceStepsData349 }];350 this.finalStep = [{351 title: 'cisco.common.workflow.add.device.final.busy.caption',352 optional: true,353 hideButtonBar: true,354 key: 'addDeviceFinal',355 completed: false,356 stepEnterHandler: function () { return _this.getFinalStepInfo(); },357 hideTitle: true,358 systemStepLoadingCaption: "cisco.common.workflow.add.device.final.busy.caption",359 systemStepTitle: '',360 description: '',361 systemStepIconClasses: '',362 systemStepButtons: [],363 showFinalStep: true364 }];365 this.originalSpStepsComponentData = null;366 }367 AddDeviceComponent.prototype.ngOnInit = function () {368 var tenant = JSON.parse(window.localStorage.getItem('ngStorage-tenantItem') || '{}');369 this._tenantId = this.tenantId ? this.tenantId : tenant.tenantId;370 this.deviceStepsData.preSelectedService = this.serviceType;371 if (this.serviceType) {372 this.initialSteps[1].description = 'cisco.common.workflow.add.device.serviceselection.selected';373 }374 this.jsonStepMetadata = this.initialSteps;375 this.addStepEnter();376 this.getServices();377 };378 AddDeviceComponent.prototype.closeWizard = function () {379 this.close.emit();380 };381 AddDeviceComponent.prototype.handleStepChange = function (step) {382 this.stepChange.next(step.key);383 };384 AddDeviceComponent.prototype.getServices = function () {385 var _this = this;386 var serviceTiles = [];387 var filter = [{388 name: "tenantId",389 value: [this._tenantId]390 }];391 var getCtx = function (ctx) {392 return ctx;393 };394 var self = getCtx(this);395 this.servicesService.getServices('', 0, 100, filter).then(function (data) {396 if (data.entities && data.entities.length) {397 data.entities.forEach(function (service) {398 var title = _this.servicesService.getTranslatedServiceName(service.serviceDefAttribute.type);399 _this.serviceCatalogService.getService(service.serviceDefAttribute.id).then(function (serviceData) {400 var tile = {401 serviceInstanceId: service.serviceInstanceId,402 subscriptionId: service.subscriptionId,403 type: service.serviceDefAttribute.type || "unknown",404 title: _this.translateService(title),405 icon: serviceData.image,406 doesNotSupportGlobalAddDevice: false407 };408 if (self.globalAddCheck) {409 var actions = _this.twgaRegistry.getGlobalActionsSupport(tile.type);410 if (!actions.addDevice) {411 tile.doesNotSupportGlobalAddDevice = true;412 }413 }414 serviceTiles.push(tile);415 serviceTiles.sort(function (a, b) {416 var aLabel = (a.title || "").toLowerCase();417 var bLabel = (b.title || "").toLowerCase();418 if (aLabel < bLabel) {419 return -1;420 }421 else if (aLabel > bLabel) {422 return 1;423 }424 return 0;425 });426 if (_this.serviceType && _this.serviceType === tile.type && !tile.doesNotSupportGlobalAddDevice) {427 _this.getServiceSteps(tile);428 }429 });430 });431 _this.deviceStepsData.tenantServices = serviceTiles;432 }433 });434 };435 AddDeviceComponent.prototype.addStepEnter = function () {436 _.forEach(this.jsonStepMetadata, function (step) {437 if (!step.stepEnterHandler) {438 step.stepEnterHandler = function () { };439 }440 });441 };442 AddDeviceComponent.prototype.getServiceSteps = function (service) {443 if (service && service.type) {444 this.deviceStepsData.selectedService = service;445 var steps = this.deviceDetailsRegistry.getAddDeviceSteps(service.type) || [];446 if (steps.length) {447 this.jsonStepMetadata = __spreadArrays(this.initialSteps, steps, this.finalStep);448 }449 else {450 this.jsonStepMetadata = __spreadArrays(this.initialSteps, this.defaultFlowSteps, this.finalStep);451 }452 this.originalSpStepsComponentData = _.cloneDeep(this.jsonStepMetadata[2].componentData);453 this.jsonStepMetadata[2].componentData.tenantId = this._tenantId;454 this.jsonStepMetadata[2].componentData.selectedService = this.deviceStepsData.selectedService;455 this.addStepEnter();456 }457 else {458 this.deviceStepsData.selectedService = {};459 this.jsonStepMetadata = __spreadArrays(this.initialSteps);460 }461 this.jsonStepMetadata[1].completed = !!(service && service.type);462 };463 AddDeviceComponent.prototype.processFinalStepFailure = function (stepIndex, description, deviceId) {464 var _this = this;465 this.jsonStepMetadata[stepIndex].status = 'major';466 this.jsonStepMetadata[stepIndex].systemStepIconClasses = 'sk-background-status-major vms_fi_alert6001-48';467 this.jsonStepMetadata[stepIndex].systemStepTitle = 'cisco.common.workflow.add.device.final.failure.title';468 this.jsonStepMetadata[stepIndex].description = description;469 if (this.siteId) {470 this.jsonStepMetadata[stepIndex].systemStepButtons.push({471 label: "cisco.common.workflow.add.device.final.button.viewdevice.label",472 buttonClass: 'button--primary',473 handler: function () {474 _this.$state.go("app.tenant_deviceDetails", { obj: { id: deviceId } });475 }476 });477 }478 this.jsonStepMetadata[stepIndex].systemStepButtons = [{ label: "cisco.common.button.close" }];479 this.jsonStepMetadata[stepIndex].completed = true;480 };481 AddDeviceComponent.prototype.processFinalStepSuccess = function (stepIndex, description, deviceId, deviceName) {482 var _this = this;483 this.jsonStepMetadata[stepIndex].systemStepIconClasses = 'sk-background-status-normal vms_fi_alert6015-48';484 this.jsonStepMetadata[stepIndex].systemStepTitle = 'cisco.common.workflow.add.device.final.success.title';485 this.jsonStepMetadata[stepIndex].description = description;486 this.serviceActions = this.deviceDetailsRegistry.getAddDeviceActions(this.deviceStepsData.selectedService.type) || [];487 var assignSiteAction;488 var addAnotherDeviceAction;489 if (this.completeActions && this.completeActions.length) {490 var assignToSiteDefaultAction = _.find(this.completeActions, ['commonType', 'ASSIGN_TO_SITE']);491 if (assignToSiteDefaultAction) {492 assignSiteAction = assignToSiteDefaultAction;493 if (!assignSiteAction.label) {494 assignSiteAction.label = this.translateService("cisco.common.workflow.add.device.final.button.addsite.label");495 }496 if (!assignSiteAction.buttonClass) {497 assignSiteAction.buttonClass = 'button--primary';498 }499 }500 var addAnotherDeviceDefaultAction = _.find(this.completeActions, ['commonType', 'ADD_ANOTHER']);501 if (addAnotherDeviceDefaultAction) {502 addAnotherDeviceAction = addAnotherDeviceDefaultAction;503 if (!addAnotherDeviceAction.label) {504 addAnotherDeviceAction.label = this.translateService("cisco.common.workflow.add.device.final.button.adddevice.label");505 }506 }507 }508 if (this.serviceActions && this.serviceActions.length) {509 var assignSiteSpAction = _.find(this.serviceActions, ['commonType', 'ASSIGN_TO_SITE']);510 if (assignSiteSpAction) {511 assignSiteAction = assignSiteSpAction;512 }513 var addAnotherDeviceSpAction = _.find(this.serviceActions, ['commonType', 'ADD_ANOTHER']);514 if (addAnotherDeviceSpAction) {515 addAnotherDeviceAction = addAnotherDeviceSpAction;516 }517 }518 if (this.siteId) {519 this.jsonStepMetadata[stepIndex].systemStepButtons.push({520 label: "cisco.common.workflow.assigndevice.final.button.viewsite",521 buttonClass: 'button--primary',522 handler: function () {523 _this.$state.go("app.tenant_siteDetails", { obj: { siteId: _this.siteId } });524 }525 });526 }527 else if (assignSiteAction) {528 if (assignSiteAction.handler) {529 var data_1 = {530 deviceInstanceId: deviceId,531 deviceName: deviceName,532 serviceType: this.deviceStepsData.selectedService.type,533 tenantId: this._tenantId534 };535 var action = {536 label: assignSiteAction.label,537 buttonClass: assignSiteAction.buttonClass,538 hide: assignSiteAction.hide,539 commonType: assignSiteAction.commonType,540 handler: (function () { return assignSiteAction.handler(data_1); })541 };542 this.jsonStepMetadata[stepIndex].systemStepButtons.push(action);543 }544 else {545 this.jsonStepMetadata[stepIndex].systemStepButtons.push(assignSiteAction);546 }547 }548 if (addAnotherDeviceAction) {549 if (addAnotherDeviceAction.handler && this.siteId && this.siteName) {550 var data_2 = {551 deviceInstanceId: deviceId,552 deviceName: deviceName,553 serviceType: this.deviceStepsData.selectedService.type,554 tenantId: this._tenantId,555 siteId: this.siteId,556 siteName: this.siteName557 };558 var action = {559 label: addAnotherDeviceAction.label,560 buttonClass: addAnotherDeviceAction.buttonClass,561 hide: addAnotherDeviceAction.hide,562 commonType: addAnotherDeviceAction.commonType,563 handler: (function () { return addAnotherDeviceAction.handler(data_2); })564 };565 this.jsonStepMetadata[stepIndex].systemStepButtons.push(action);566 }567 else {568 this.jsonStepMetadata[stepIndex].systemStepButtons.push(addAnotherDeviceAction);569 }570 }571 this.jsonStepMetadata[stepIndex].systemStepButtons.push({ label: "cisco.common.button.close" });572 this.jsonStepMetadata[stepIndex].completed = true;573 };574 AddDeviceComponent.prototype.getFinalStepInfo = function () {575 var _this = this;576 var lastStepIndex = this.jsonStepMetadata.length - 1;577 var previousStepIndex = lastStepIndex - 1;578 var previousStepData = this.jsonStepMetadata[previousStepIndex].componentData;579 var deviceName = previousStepData && previousStepData.deviceName ? previousStepData.deviceName : null;580 var deviceId = previousStepData && previousStepData.deviceId ? previousStepData.deviceId : null;581 var siteName = this.siteName ? this.siteName : null;582 if (deviceId) {583 if (this.siteId && siteName) {584 this.sitesService.addDevice(this.siteId, deviceId).then(function (resp) {585 if (resp && resp.data && resp.data.responseObject) {586 var description = _this.translateService("cisco.common.workflow.assigndevice.final.success.description", { deviceName: deviceName, siteName: siteName });587 _this.processFinalStepSuccess(lastStepIndex, description, deviceId, deviceName);588 }589 }, function (err) {590 var failureMessage = err.data && err.data.message ? err.data.message : null;591 var description = _this.translateService("cisco.common.workflow.add.device.final.assignment.failure.description", { deviceName: deviceName, siteName: siteName }) + " " + failureMessage;592 _this.processFinalStepFailure(lastStepIndex, description, deviceId);593 });594 }595 else {596 var description = this.translateService("cisco.common.workflow.add.device.final.success.caption", { deviceName: deviceName });597 this.processFinalStepSuccess(lastStepIndex, description, deviceId, deviceName);598 }599 }600 else {601 var failureMessage = previousStepData.failureMessage ? previousStepData.failureMessage : "";602 var description = this.translateService("cisco.common.workflow.add.device.final.failure.caption", { deviceName: deviceName }) + " " + failureMessage;603 this.processFinalStepFailure(lastStepIndex, description, null);604 }605 };606 AddDeviceComponent.prototype.addNextSteps = function (steps, key) {607 var _a;608 if (key && steps && steps.length) {609 if (key === this.stepKeyofLastInsertedSteps) {610 this.jsonStepMetadata = _.differenceBy(this.jsonStepMetadata, this.lastInsertedSteps, 'key');611 }612 var currentStepIndex = _.findIndex(this.jsonStepMetadata, ['key', key]);613 (_a = this.jsonStepMetadata).splice.apply(_a, __spreadArrays([currentStepIndex + 1, 0], steps));614 this.stepKeyofLastInsertedSteps = key;615 this.lastInsertedSteps = steps;616 this.addStepEnter();617 }618 };619 AddDeviceComponent.prototype.ngOnDestroy = function () {620 var _this = this;621 if (this.originalSpStepsComponentData) {622 this.jsonStepMetadata.forEach(function (step, index) {623 if (step.componentData && index !== 0 && index !== 1 && index !== _this.jsonStepMetadata.length - 1) {624 step.componentData = _this.originalSpStepsComponentData;625 }626 });627 }628 };629 AddDeviceComponent.ng1DirectiveName = 'msxAddDevice';630 __decorate([631 core.Input(),632 __metadata("design:type", String)633 ], AddDeviceComponent.prototype, "tenantId", void 0);634 __decorate([635 core.Input(),636 __metadata("design:type", String)637 ], AddDeviceComponent.prototype, "serviceType", void 0);638 __decorate([639 core.Input(),640 __metadata("design:type", String)641 ], AddDeviceComponent.prototype, "siteId", void 0);642 __decorate([643 core.Input(),644 __metadata("design:type", String)645 ], AddDeviceComponent.prototype, "siteName", void 0);646 __decorate([647 core.Input(),648 __metadata("design:type", Object)649 ], AddDeviceComponent.prototype, "completeActions", void 0);650 __decorate([651 core.Input(),652 __metadata("design:type", Boolean)653 ], AddDeviceComponent.prototype, "globalAddCheck", void 0);654 __decorate([655 core.Output(),656 __metadata("design:type", Object)657 ], AddDeviceComponent.prototype, "close", void 0);658 __decorate([659 core.ViewChild('wizard', { static: false }),660 __metadata("design:type", common$1.WizardComponent)661 ], AddDeviceComponent.prototype, "wizard", void 0);662 AddDeviceComponent = __decorate([663 core.Component({664 selector: 'msx-add-device',665 providers: [666 new common$1.AngularJSProvider('msx.servicesService'),667 new common$1.AngularJSProvider('msx.serviceCatalogService'),668 new common$1.AngularJSProvider('msx.sitesService'),669 new common$1.AngularJSProvider('msx.translateService'),670 new common$1.AngularJSProvider('msx.platform.deviceDetailsRegistry'),671 new common$1.AngularJSProvider('msx.platform.tenantWorkspaceGlobalActionsRegistry'),672 new common$1.AngularJSProvider('msx.platform.msxInfo')673 ],674 template: template$3675 }),676 __param(0, core.Inject('msx.servicesService')),677 __param(1, core.Inject('msx.serviceCatalogService')),678 __param(2, core.Inject('msx.sitesService')),679 __param(3, core.Inject('msx.translateService')),680 __param(4, core.Inject('msx.platform.deviceDetailsRegistry')),681 __param(5, core.Inject('msx.platform.tenantWorkspaceGlobalActionsRegistry')),682 __param(6, core.Inject('msx.platform.msxInfo')),683 __param(7, core.Inject('$state')),684 __metadata("design:paramtypes", [Object, Object, Object, Object, Object, Object, Object, Object])685 ], AddDeviceComponent);686 return AddDeviceComponent;687}());688var template$4 = "<div class=\"msx-assign-device\"><msx-wizard #wizard class=\"wizard-style assign-device-wizard\" (wizardClosed)=\"closeWizard()\"><msx-wizard-step key=\"assignToSite_introduction\" introductionTitle=\"cisco.common.workflow.assigndevice.introduction.title\" introductionDescription=\"{{introStepDescription}}\" introductionIcon=\"vms_fi_settings3036-48\" introductionStepLabel=\"assignToSiteIntroduction\" [showIntroductionStep]=\"true\" [allowSkippingIntroductionStep]=\"true\" [optional]=\"true\" [hideButtonBar]=\"true\"></msx-wizard-step><msx-wizard-step key=\"assignToSite_selection\" title=\"cisco.common.workflow.assigndevice.siteselection.title\" description=\"cisco.common.workflow.assigndevice.siteselection.description\" [completed]=\"siteSelectionCompleted\"><msx-assign-device-selection [tenantId]=\"_tenantId\" [serviceType]=\"serviceType\" (selectedSite)=\"selectedSite($event)\"></msx-assign-device-selection></msx-wizard-step><msx-wizard-step key=\"assignToSite_final\" title=\"cisco.common.workflow.assigndevice.final.title\" [hideTitle]=\"true\" (stepEnterHandler)=\"handleAssignDevice()\" [hideButtonBar]=\"true\" [status]=\"assignmentStatus\" [completed]=\"isAssignCompleted\" [optional]=\"true\" [showFinalStep]=\"true\" systemStepLoadingCaption=\"cisco.common.workflow.assigndevice.final.busy.caption\" systemStepTitle=\"{{finalStepTitle}}\" description=\"{{finalStepDescription}}\" systemStepIconClasses=\"{{finalStepIcons}}\" [systemStepButtons]=\"finalStepButtons\"></msx-wizard-step></msx-wizard></div>\n";689var AssignDeviceComponent = (function () {690 function AssignDeviceComponent(sitesService, loggerService, translateService, $state) {691 this.sitesService = sitesService;692 this.loggerService = loggerService;693 this.translateService = translateService;694 this.$state = $state;695 this.close = new core.EventEmitter();696 this.serviceActions = [];697 this.siteSelectionCompleted = false;698 this.isAssignCompleted = false;699 this.finalStepButtons = [];700 }701 AssignDeviceComponent.prototype.ngOnInit = function () {702 this.introStepDescription = this.translateService("cisco.common.workflow.assigndevice.introduction.description", { deviceName: this.deviceName });703 var tenant = JSON.parse(window.localStorage.getItem('ngStorage-tenantItem') || '{}');704 this._tenantId = this.tenantId ? this.tenantId : tenant.tenantId;705 };706 AssignDeviceComponent.prototype.selectedSite = function (data) {707 this.siteSelectionCompleted = !!(data && data.id);708 this.siteData = data;709 };710 AssignDeviceComponent.prototype.closeWizard = function () {711 this.close.emit();712 };713 AssignDeviceComponent.prototype.handleAssignDevice = function () {714 var _this = this;715 if (this.siteData && this.siteData.id && this.deviceInstanceId) {716 var siteName_1 = this.siteData.name;717 this.sitesService.addDevice(this.siteData.id, this.deviceInstanceId).then(function (resp) {718 if (resp && resp.data && resp.data.responseObject) {719 _this.isAssignCompleted = true;720 _this.finalStepIcons = 'sk-background-status-normal vms_fi_alert6015-48';721 _this.finalStepTitle = _this.translateService("cisco.common.workflow.assigndevice.final.success.title");722 _this.finalStepDescription = _this.translateService("cisco.common.workflow.assigndevice.final.success.description", { deviceName: _this.deviceName, siteName: siteName_1 });723 _this.finalStepButtons = [{724 label: "cisco.common.button.close"725 }, {726 label: "cisco.common.workflow.assigndevice.final.button.viewsite",727 buttonClass: 'button--primary',728 handler: function () {729 _this.$state.go("app.tenant_siteDetails", { obj: { siteId: resp.data.responseObject.id } });730 }731 }];732 }733 }, function (err) {734 var failureMessage = err.data && err.data.message ? err.data.message : null;735 _this.isAssignCompleted = true;736 _this.assignmentStatus = 'major';737 _this.finalStepIcons = 'sk-background-status-major vms_fi_alert6001-48';738 _this.finalStepTitle = _this.translateService("cisco.common.workflow.assigndevice.final.failure.title");739 _this.finalStepDescription = _this.translateService("cisco.common.workflow.assigndevice.final.failure.description", { deviceName: _this.deviceName, siteName: siteName_1 }) + " " + failureMessage;740 _this.finalStepButtons = [{741 label: "cisco.common.button.close"742 }];743 _this.loggerService.warn("Error Assigning Device To Site:", err);744 });745 }746 };747 AssignDeviceComponent.ng1DirectiveName = 'msxAssignDevice';748 __decorate([749 core.Input(),750 __metadata("design:type", String)751 ], AssignDeviceComponent.prototype, "tenantId", void 0);752 __decorate([753 core.Input(),754 __metadata("design:type", String)755 ], AssignDeviceComponent.prototype, "serviceType", void 0);756 __decorate([757 core.Input(),758 __metadata("design:type", String)759 ], AssignDeviceComponent.prototype, "deviceInstanceId", void 0);760 __decorate([761 core.Input(),762 __metadata("design:type", String)763 ], AssignDeviceComponent.prototype, "deviceName", void 0);764 __decorate([765 core.Input(),766 __metadata("design:type", Object)767 ], AssignDeviceComponent.prototype, "completeActions", void 0);768 __decorate([769 core.Output(),770 __metadata("design:type", Object)771 ], AssignDeviceComponent.prototype, "close", void 0);772 __decorate([773 core.ViewChild('wizard', { static: false }),774 __metadata("design:type", common$1.WizardComponent)775 ], AssignDeviceComponent.prototype, "wizard", void 0);776 AssignDeviceComponent = __decorate([777 core.Component({778 selector: 'msx-assign-device',779 providers: [780 new common$1.AngularJSProvider('msx.sitesService'),781 new common$1.AngularJSProvider('msx.loggerService'),782 new common$1.AngularJSProvider('msx.translateService')783 ],784 template: template$4785 }),786 __param(0, core.Inject('msx.sitesService')),787 __param(1, core.Inject('msx.loggerService')),788 __param(2, core.Inject('msx.translateService')),789 __param(3, core.Inject('$state')),790 __metadata("design:paramtypes", [Object, Object, Object, Object])791 ], AssignDeviceComponent);792 return AssignDeviceComponent;793}());794var template$5 = "<div class=\"msx-assign-device-site-selection\">\n\t<msx-site-selector class=\"msx-assign-device-site-selection__site-dropdown\" label=\"cisco.common.workflow.assigndevice.siteselection.site.label\" showLabel=\"true\" includeImage=\"true\" mappedOnly=\"true\" [tenantId]=\"tenantId\" (onSiteSelect)=\"onSiteSelect($event)\" appendTo=\"body\"></msx-site-selector>\n\t<msx-site-info-tile *ngIf=\"showSite\" [image]=\"selectedSiteData.image\" [mainTitle]=\"selectedSiteData.name\" [subTitle]=\"selectedSiteData.address.formattedAddress || selectedSiteData.address.name\" [notes]=\"selectedSiteData.address.address2\" [description]=\"selectedSiteData.description\" class=\"msx-assign-device-site-selection__site-info\"></msx-site-info-tile>\n</div>";795var AssignDeviceSelectionComponent = (function () {796 function AssignDeviceSelectionComponent() {797 this.selectedSite = new core.EventEmitter();798 this.selectedSiteData = {};799 this.showSite = false;800 }801 AssignDeviceSelectionComponent.prototype.onSiteSelect = function (selection) {802 if (selection.site) {803 this.selectedSiteData = selection.site;804 this.showSite = true;805 }806 else {807 this.selectedSiteData = {};808 this.showSite = false;809 }810 this.selectedSite.emit(this.selectedSiteData);811 };812 __decorate([813 core.Input(),814 __metadata("design:type", String)815 ], AssignDeviceSelectionComponent.prototype, "tenantId", void 0);816 __decorate([817 core.Input(),818 __metadata("design:type", String)819 ], AssignDeviceSelectionComponent.prototype, "serviceType", void 0);820 __decorate([821 core.Output(),822 __metadata("design:type", core.EventEmitter)823 ], AssignDeviceSelectionComponent.prototype, "selectedSite", void 0);824 AssignDeviceSelectionComponent = __decorate([825 core.Component({826 selector: 'msx-assign-device-selection',827 template: template$5828 })829 ], AssignDeviceSelectionComponent);830 return AssignDeviceSelectionComponent;831}());832var ADD_DEVICE_DIRECTIVES = [833 AddDeviceComponent,834 AddDeviceServiceComponent,835 AddDeviceInfoComponent,836 AddDeviceReviewComponent,837 AssignDeviceComponent,838 AssignDeviceSelectionComponent839];840var DevicesModule = (function () {841 function DevicesModule() {842 }843 DevicesModule = __decorate([844 core.NgModule({845 providers: [846 new common$1.AngularJSProvider('$state'),847 new common$1.AngularJSProvider('msx.servicesService'),848 new common$1.AngularJSProvider('msx.serviceCatalogService'),849 new common$1.AngularJSProvider('msx.translateService'),850 new common$1.AngularJSProvider('msx.loggerService'),851 new common$1.AngularJSProvider('skI18nService'),852 new common$1.AngularJSProvider('rbacService'),853 new common$1.AngularJSProvider('$stateParams')854 ],855 imports: [common$1.MsxCommonModule, common.CommonModule, forms.MsxFormsModule, templateManagement.TemplateManagementModule],856 declarations: [ADD_DEVICE_DIRECTIVES],857 exports: [ADD_DEVICE_DIRECTIVES],858 entryComponents: [ADD_DEVICE_DIRECTIVES]859 })860 ], DevicesModule);861 return DevicesModule;862}());863function getRootInjector() {864 var msx = window["msx"];865 return msx.rootInjector.getRootInjector();866}867var downgradedDevices = _static.downgradeModule(function () {868 return __awaiter(this, void 0, void 0, function () {869 var rootInjector, factory;870 return __generator(this, function (_a) {871 switch (_a.label) {872 case 0: return [4, getRootInjector()];873 case 1:874 rootInjector = _a.sent();875 return [4, rootInjector.get(core.Compiler).compileModuleAsync(DevicesModule)];876 case 2:877 factory = _a.sent();878 return [2, factory.create(rootInjector)];879 }880 });881 });882});883var msxAddDeviceFactory = _static.downgradeComponent({884 component: AddDeviceComponent,885 downgradedModule: downgradedDevices886});887var msxAssignDeviceFactory = _static.downgradeComponent({888 component: AssignDeviceComponent,889 downgradedModule: downgradedDevices890});891var msxDevices = angular.module('msx.devices', [892 'ui.router',893 downgradedDevices894])895 .directive(AddDeviceComponent.ng1DirectiveName, msxAddDeviceFactory)896 .directive(AssignDeviceComponent.ng1DirectiveName, msxAssignDeviceFactory);897exports.DevicesModule = DevicesModule;...
ng1-sandbox.directive.js
Source:ng1-sandbox.directive.js
...3 'use strict';4 angular5 .module('ynfsworkshop')6 .directive('sidenavNg1', sidenavNg1Directive);7 function sidenavNg1Directive() {8 return {9 controller: SideNavController,10 controllerAs: 'sn',11 templateUrl: 'app/ng1-sandbox/layout/sidenavNg1.html'12 };13 }14 function SideNavController($mdSidenav) {15 this.sidenavNg1 = 'sidenavNg1';16 }...
Using AI Code Generation
1var ng1Directive = require('protractor-angular-1-directive');2ng1Directive(browser);3var ng1Directive = require('protractor-angular-1-directive');4ng1Directive(browser);5var ng1Directive = require('protractor-angular-1-directive');6ng1Directive(browser);7var ng1Directive = require('protractor-angular-1-directive');8ng1Directive(browser);9var ng1Directive = require('protractor-angular-1-directive');10ng1Directive(browser);11var ng1Directive = require('protractor-angular-1-directive');12ng1Directive(browser);13var ng1Directive = require('protractor-angular-1-directive');14ng1Directive(browser);15var ng1Directive = require('protractor-angular-1-directive');16ng1Directive(browser);17var ng1Directive = require('protractor-angular-1-directive');18ng1Directive(browser);19var ng1Directive = require('protractor-angular-1-directive');20ng1Directive(browser);21var ng1Directive = require('protractor-angular-1-directive');22ng1Directive(browser);23var ng1Directive = require('protractor-angular-1-directive');24ng1Directive(browser);25var ng1Directive = require('protractor-angular-1-directive');26ng1Directive(browser);
Using AI Code Generation
1const ng1Page = require('protractor').ProtractorNg1Page;2const ng1Directive = ng1Page.ng1Directive;3describe('ng1Directive', function() {4 it('should return a promise that resolves to the element', function() {5 let directive = ng1Directive('myDirective');6 expect(directive.getText()).toEqual('Hello, world!');7 });8});9const ng1Page = require('protractor').ProtractorNg1Page;10const ng1Directive = ng1Page.ng1Directive;11describe('ng1Directive', function() {12 it('should return a promise that resolves to the element', function() {13 let directive = ng1Directive('myDirective');14 expect(directive.evaluate('myDirectiveVar')).toEqual('Hello, world!');15 });16});17const ng1Page = require('protractor').ProtractorNg1Page;18const ng1Directive = ng1Page.ng1Directive;19describe('ng1Directive', function() {20 it('should return a promise that resolves to the element', function() {21 let directive = ng1Directive('myDirective');22 expect(directive.evaluateAsync('myDirectiveVar')).toEqual('Hello, world!');23 });24});25const ng1Page = require('protractor').ProtractorNg1Page;26const ng1Directive = ng1Page.ng1Directive;27describe('ng1Directive', function() {28 it('should return a promise that resolves to the element', function() {29 let directive = ng1Directive('myDirective');30 expect(directive.scope()).toEqual('Hello, world!');31 });32});
Using AI Code Generation
1describe('Test', function() {2 it('should display the correct title', function() {3 var ng1Directive = element(by.css('ng1-directive'));4 expect(ng1Directive.getText()).toEqual('Hello from Angular 1!');5 });6});7angular.module('app', [])8 .component('ng1Directive', {9 });10import { BrowserModule } from '@angular/platform-browser';11import { NgModule } from '@angular/core';12import { UpgradeModule } from '@angular/upgrade/static';13import { AppComponent } from './app.component';14@NgModule({15 imports: [16})17export class AppModule { }18import { Component, OnInit, AfterViewInit } from '@angular/core';19import { UpgradeModule } from '@angular/upgrade/static';20@Component({21})22export class AppComponent implements OnInit, AfterViewInit {23 title = 'app';24 constructor(private upgrade: UpgradeModule) { }25 ngOnInit() {26 this.upgrade.bootstrap(document.body, ['app']);27 }28 ngAfterViewInit() {29 this.upgrade.$injector.get('$compile')(document.body)(this.upgrade.$rootScope);30 }31}32ng1-directive {33 display: block;34 background-color: #00f;35 color: #fff;36 padding: 10px;37}
Protractor is developed by Google Developers to test Angular and AngularJS code. Today, it is used to test non-Angular applications as well. It performs a real-world user-like test against your application in a real browser. It comes under an end-to-end testing framework. As of now, Selenium Protractor has proved to be a popular framework for end-to-end automation for AngularJS.
Let’s talk about what it does:
Protractor is a JavaScript framework, end-to-end test automation framework for Angular and AngularJS applications.
Protractor Selenium provides new locator methods that actually make it easier to find elements in the DOM.
Two files are required to execute Protractor Selenium tests for end-to-end automation: Specs & Config. Go through the link above to understand in a better way.
To carry out extensive, automated cross browser testing, you can't imagine installing thousands of the available browsers on your own workstation. The only way to increase browser usage is through remote execution on the cloud. To execute your automation test scripts across a variety of platforms and browser versions, LambdaTest offers more than 3000 browsers.
We recommend Selenium for end-to-end automation for AngularJS because both are maintained and owned by Google, and they build JavaScript test automation framework to handle AngularJS components in a way that better matches how developers use it.
For scripting, selenium locators are essential since if they're off, your automation scripts won't run. Therefore, in any testing framework, these Selenium locators are the foundation of your Selenium test automation efforts.
To make sure that your Selenium automation tests function as intended, debugging can be an effective option. Check the blog to know more.
If you are not familiar with writing Selenium test automation on Protractor, here is a blog for you to get you understand in depth.
Selenium tests are asynchronous and there are various reasons for a timeout to occur in a Protractor test. Find out how to handle timeouts in this Protractor tutorial.
In this Protractor tutorial, learn how to handle frames or iframes in Selenium with Protractor for automated browser testing.
Handle alerts and popups in Protractor more efficiently. It can be confusing. Here's a simple guide to understand how to handle alerts and popups in Selenium.
Get 100 minutes of automation test minutes FREE!!