webpackJsonp([35],{

/***/ 1495:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModuleConfigPageModule", function() { return ModuleConfigPageModule; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_ionic_angular__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__module_config__ = __webpack_require__(1793);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__modules_dynamic_form_dynamic_form_module__ = __webpack_require__(1013);
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




var ModuleConfigPageModule = /** @class */ (function () {
    function ModuleConfigPageModule() {
    }
    ModuleConfigPageModule = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["NgModule"])({
            declarations: [
                __WEBPACK_IMPORTED_MODULE_2__module_config__["a" /* ModuleConfigPage */],
            ],
            imports: [
                __WEBPACK_IMPORTED_MODULE_3__modules_dynamic_form_dynamic_form_module__["a" /* DynamicFormModule */],
                __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["j" /* IonicPageModule */].forChild(__WEBPACK_IMPORTED_MODULE_2__module_config__["a" /* ModuleConfigPage */]),
            ],
        })
    ], ModuleConfigPageModule);
    return ModuleConfigPageModule;
}());

//# sourceMappingURL=module-config.module.js.map

/***/ }),

/***/ 1793:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export AppSettings */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ModuleConfigPage; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_ionic_angular__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__modules_dynamic_form_containers_dynamic_form_dynamic_form_component__ = __webpack_require__(1012);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__angular_forms__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_ngx_logger__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ncinga_sp_nsp_app_core_dist_cache_settings__ = __webpack_require__(40);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__providers_activation_service_activation_service__ = __webpack_require__(112);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ionic_native_screen_orientation__ = __webpack_require__(378);
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};








/**
 * Generated class for the ModuleConfigPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */
var AppSettings = /** @class */ (function () {
    function AppSettings(obj) {
        this.id = obj && obj.id;
        this.app_type = obj && obj.app_type;
        this.app_name = obj && obj.app_name;
        this.configs = obj && obj.configs;
    }
    return AppSettings;
}());

var ModuleConfigPage = /** @class */ (function () {
    function ModuleConfigPage(navCtrl, navParams, logger, orientation, platform, settings, actSvc) {
        this.navCtrl = navCtrl;
        this.navParams = navParams;
        this.logger = logger;
        this.orientation = orientation;
        this.platform = platform;
        this.settings = settings;
        this.actSvc = actSvc;
        this.APP_CONTEXT = 'bctx';
        this.APP_SBJ_FILTERS = 'subject_display_keys';
        this.landscape = true;
        this.config = [];
        this.preSettingsByApp = [];
        this.optionsMap = {};
        this.validity = [];
        this.initModel();
    }
    ModuleConfigPage.prototype.ionViewDidLoad = function () {
        this.initForm();
        // this.actSvc.removeActivation();
    };
    ModuleConfigPage.prototype.initModel = function () {
        var _this = this;
        var args = this.navParams.get('options');
        this.tenant = this.navParams.get('tenant');
        this.subject_key = this.navParams.get('subject_key');
        if (args && args.length) {
            var presettingargs_1 = [];
            args.forEach(function (arg) {
                arg.settings.forEach(function (inp) {
                    /*
                     * TODO:define presettings options
                     * */
                    presettingargs_1.push({
                        validation: [__WEBPACK_IMPORTED_MODULE_3__angular_forms__["Validators"].required],
                        name: inp.arg_id,
                        type: inp.arg_type,
                        data_type: inp.data_type,
                        label: inp.name,
                        multiple: inp.multiple,
                        placeholder: inp.name,
                        s_name: inp.s_name,
                        s_value: inp.s_value
                    });
                });
                presettingargs_1.push({
                    label: 'Save',
                    name: 'submit',
                    type: 'button'
                });
                _this.preSettingsByApp.push(new AppSettings({
                    id: arg.app_id,
                    app_name: arg.app_name,
                    app_type: arg.product_type,
                    configs: presettingargs_1
                }));
                presettingargs_1 = [];
            });
            this.loadTestData(this.preSettingsByApp);
        }
    };
    ModuleConfigPage.prototype.loadTestData = function (configs) {
        var _this = this;
        var dataToRequest = [];
        this.preSettingsByApp.forEach(function (appsetting) {
            appsetting.configs.forEach(function (item) {
                if (item.type === 'select' || item.type === 'filterselect') {
                    dataToRequest.push(item.data_type);
                }
            });
        });
        if (dataToRequest.length > 0) {
            this.actSvc.getPreSettingsData(this.tenant, this.subject_key, dataToRequest).subscribe(function (res) {
                // this.config = configs;
                _this.preSettingsByApp.forEach(function (appsetting) {
                    appsetting.configs.forEach(function (item) {
                        if (item.type === 'select' || item.type === 'filterselect') {
                            var options = res.result.filter(function (entry) {
                                if (entry.hasOwnProperty(item.data_type) && entry.app_type === appsetting.app_type) {
                                    return true;
                                }
                            });
                            if (options.length > 0) {
                                var dataoptions = _this._changeintoSelectData(options[0][item.data_type], item);
                                item.options = dataoptions;
                                // keep for later processing when save into locakstorage
                                _this.optionsMap[appsetting.app_type + '_' + item.name] = dataoptions;
                            }
                        }
                        if (item.type === 'filterselect') {
                            var found = res.result.find(function (data) { return data['app_type'] === appsetting.app_type; });
                            item.filters = (found[_this.APP_SBJ_FILTERS]) ? found[_this.APP_SBJ_FILTERS].slice() : [];
                        }
                    });
                });
            });
        }
    };
    ModuleConfigPage.prototype._changeintoSelectData = function (arr, conf) {
        var data = [];
        try {
            arr.forEach(function (item) {
                data.push({
                    name: item[conf['s_name']],
                    id: item[conf['s_value']],
                    label: item['filter_key'],
                    hsk: item['hsk'],
                    gatev: item['gatev'],
                    gatek: item['gatek'],
                    oss_sub: item['oss_sub'],
                    dis_name: item['dis_name']
                });
            });
        }
        catch (e) {
            return data;
        }
        return data;
    };
    ModuleConfigPage.prototype.initForm = function () {
        this.forms.forEach(function (form) {
            var previousValid = form.valid;
            form.changes.subscribe(function () {
                if (form.valid !== previousValid) {
                    previousValid = form.valid;
                    form.setDisabled('submit', !previousValid);
                }
                // this._checkFormValid();
            });
            form.setDisabled('submit', true);
        });
    };
    ModuleConfigPage.prototype.isValidAll = function () {
        return this.validity.every(function (cv) {
            return cv;
        });
    };
    /*
     * save module config values here
     * */
    ModuleConfigPage.prototype.submit = function (value, appType, settings) {
        var _this = this;
        if (value) {
            value['tenant'] = this.tenant;
            value['subject_key'] = this.subject_key;
        }
        this.freezeOrientation();
        value = this.postProcessValues(value, settings);
        settings.extra = true;
        this.actSvc.getFinalizedAppData(this.tenant, this.subject_key, appType, this.APP_CONTEXT).subscribe(function (res) {
            settings.extra = true;
            if (res.result) {
                _this.logger.log(appType, 'configuration success');
                settings.extra = false;
                var out = res.result.filter(function (item) { return item.app_type === appType; }).map(function (opt) {
                    return opt[_this.APP_CONTEXT][0];
                    /* return {
                     'plan_name': 'production_plan',
                     'window': [
                     -3,
                     3
                     ]
                     };*/
                });
                value[_this.APP_CONTEXT] = out[0];
                _this.settings.setValue('app_data_' + appType, value);
                _this.validity.push(true);
                if (_this.preSettingsByApp.length === 1) {
                    _this.go();
                }
                // this.actSvc.resetTokens();
                // this.navCtrl.setRoot('LoginPage', {}, {animate: true, direction: 'forward'});
            }
            else {
                _this.logger.error('please setup bctx data for the product type' + appType);
            }
        }, function (err) {
            _this.logger.error(appType, err);
            settings.extra = false;
        });
    };
    ModuleConfigPage.prototype.postProcessValues = function (value, settings) {
        var _this = this;
        var _loop_1 = function (key) {
            if (this_1.optionsMap.hasOwnProperty(settings.app_type + '_' + key)) {
                var selectedOpts_1 = [];
                value[key].forEach(function (selected) {
                    var subjectId = selected.split('@');
                    _this.optionsMap[settings.app_type + '_' + key].filter(function (item) {
                        if (subjectId[1]) {
                            if (subjectId[0] === item.id && subjectId[1] === item.hsk) {
                                var found = selectedOpts_1.find(function (opt) { return opt.id === item.id; });
                                if (!found) {
                                    selectedOpts_1.push(item);
                                }
                                return true;
                            }
                        }
                        else {
                            if (subjectId[0] === item.id) {
                                var found = selectedOpts_1.find(function (opt) { return opt.id === item.id; });
                                if (!found) {
                                    selectedOpts_1.push(item);
                                }
                                return true;
                            }
                        }
                    });
                });
                value[key] = selectedOpts_1;
            }
        };
        var this_1 = this;
        /*
         * prepare subjects list and save
         * */
        for (var key in value) {
            _loop_1(key);
        }
        return value;
    };
    ModuleConfigPage.prototype.freezeOrientation = function () {
        if (this.platform.is('cordova')) {
            try {
                var mode = (this.landscape) ? this.orientation.ORIENTATIONS.LANDSCAPE : this.orientation.ORIENTATIONS.PORTRAIT;
                this.settings.setValue('orientation', mode);
                this.orientation.lock(mode);
            }
            catch (e) {
                this.logger.debug(e);
            }
        }
    };
    ModuleConfigPage.prototype.go = function () {
        this.navCtrl.setRoot('LoginPage', {}, { animate: true, direction: 'forward' });
    };
    __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["ViewChildren"])(__WEBPACK_IMPORTED_MODULE_2__modules_dynamic_form_containers_dynamic_form_dynamic_form_component__["a" /* DynamicFormComponent */]),
        __metadata("design:type", __WEBPACK_IMPORTED_MODULE_0__angular_core__["QueryList"])
    ], ModuleConfigPage.prototype, "forms", void 0);
    ModuleConfigPage = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'page-module-config',template:/*ion-inline-start:"/disk1/jenkins/workspace/ncinga_spark_installation_apk/src/pages/module-config/module-config.html"*/'<!--\n  Generated template for the ModuleConfigPage page.\n\n  See http://ionicframework.com/docs/components/#navigation for more info on\n  Ionic pages and navigation.\n-->\n<ion-header>\n\n  <ion-navbar no-border-bottom color="ocean">\n    <ion-title>Module Configurations</ion-title>\n  </ion-navbar>\n\n</ion-header>\n\n\n<ion-content padding class="module-config">\n    <ion-grid no-padding class="form-wrapper">\n        <ion-row class="border-btm">\n            <ion-col>\n                <h4 class="input-heading">App Pre settings<small>({{subject_key}})</small></h4>\n                <p>Please fill followings to complete installation</p>\n            </ion-col>\n        </ion-row>\n        <ion-row>\n            <ion-item class="orientation-item">\n                <ion-label>Orientation <span *ngIf="landscape" class="orientation-lbl">Landscape</span>\n                    <span class="orientation-lbl" *ngIf="!landscape">Portrait</span></ion-label>\n                <ion-toggle color="secondary" mode="ios" [(ngModel)]="landscape"></ion-toggle>\n            </ion-item>\n        </ion-row>\n        <ion-row>\n            <ion-col col-12 *ngFor="let app of preSettingsByApp">\n                <h4>{{app.app_name}} <small>({{app.app_type}})</small></h4>\n                <dynamic-form\n                        [config]="app.configs"\n                        #form="dynamicForm"\n                        (submit)="submit($event, app.app_type, app)">\n                </dynamic-form>\n                <p [hidden]="!app.extra">Completing app setting up ...<ion-spinner name="ios-small"></ion-spinner></p>\n            </ion-col>\n        </ion-row>\n        <ion-row>\n            <ion-col align-items-end class="btn-container">\n\n            </ion-col>\n        </ion-row>\n    </ion-grid>\n</ion-content>\n\n<ion-footer>\n    <ion-buttons end>\n        <button color="calm" [disabled]="validity.length != preSettingsByApp.length" ion-button (click)="go()">Complete</button>\n    </ion-buttons>\n</ion-footer>\n'/*ion-inline-end:"/disk1/jenkins/workspace/ncinga_spark_installation_apk/src/pages/module-config/module-config.html"*/,
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1_ionic_angular__["o" /* NavController */], __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["p" /* NavParams */],
            __WEBPACK_IMPORTED_MODULE_4_ngx_logger__["b" /* NGXLogger */],
            __WEBPACK_IMPORTED_MODULE_7__ionic_native_screen_orientation__["a" /* ScreenOrientation */],
            __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["r" /* Platform */],
            __WEBPACK_IMPORTED_MODULE_5__ncinga_sp_nsp_app_core_dist_cache_settings__["a" /* Settings */], __WEBPACK_IMPORTED_MODULE_6__providers_activation_service_activation_service__["a" /* ActivationService */]])
    ], ModuleConfigPage);
    return ModuleConfigPage;
}());

//# sourceMappingURL=module-config.js.map

/***/ })

});
//# sourceMappingURL=35.js.map