webpackJsonp([22],{

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

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SettingViewModule", function() { return SettingViewModule; });
/* 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__setting_view__ = __webpack_require__(1854);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__ncinga_sp_nsp_app_core_dist__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_components_module__ = __webpack_require__(991);
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;
};
/**
 * Created by dilshan on 7/5/18.
 */





var SettingViewModule = /** @class */ (function () {
    function SettingViewModule() {
    }
    SettingViewModule = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["NgModule"])({
            declarations: [
                __WEBPACK_IMPORTED_MODULE_2__setting_view__["a" /* SettingView */]
            ],
            imports: [
                __WEBPACK_IMPORTED_MODULE_3__ncinga_sp_nsp_app_core_dist__["j" /* CoreModule */],
                __WEBPACK_IMPORTED_MODULE_4__components_components_module__["a" /* ComponentsModule */],
                __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["j" /* IonicPageModule */].forChild(__WEBPACK_IMPORTED_MODULE_2__setting_view__["a" /* SettingView */])
            ]
        })
    ], SettingViewModule);
    return SettingViewModule;
}());

//# sourceMappingURL=setting-view.module.js.map

/***/ }),

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

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SettingView; });
/* 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_ngx_logger__ = __webpack_require__(4);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__setting_template__ = __webpack_require__(1855);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__ncinga_sp_nsp_app_core_dist_providers_business_context__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__ncinga_sp_nsp_app_core_dist__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__providers_masterdata_service_masterdata_service__ = __webpack_require__(207);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__providers_application_cache_service_app_cache_service__ = __webpack_require__(148);
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);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [0, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
/**
 * Created by dilshan on 7/5/18.
 */








var SettingView = /** @class */ (function () {
    function SettingView(logger, appMsDtCntrl, bsCtx, navparams, imagePro, appCacheSrv, appCtx) {
        this.logger = logger;
        this.appMsDtCntrl = appMsDtCntrl;
        this.bsCtx = bsCtx;
        this.navparams = navparams;
        this.imagePro = imagePro;
        this.appCacheSrv = appCacheSrv;
        this.appCtx = appCtx;
        this.sync_components = [];
        this.pagetitle = 'App sync';
        this.check = false;
        this.close = false;
        this.bubble = false;
        this.sync_components = [];
        this.setupViewModel();
    }
    SettingView.prototype.setupViewModel = function () {
        this.view_config = this.navparams.get('conf');
        if (this.view_config) {
            this.sync_components = this.view_config['component_descriptor'];
        }
        this.sync_components.forEach(function (data) {
            data['check'] = false;
            data['close'] = false;
            data['bubble'] = false;
        });
    };
    /*
     sync with backend call
     */
    SettingView.prototype.syncClick = function (param, index, tp) {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            var selectSyncBtn, data, e_1;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        selectSyncBtn = this.sync_components[index];
                        _a.label = 1;
                    case 1:
                        _a.trys.push([1, 5, , 6]);
                        this.bubble = true;
                        this.logger.trace('sync parameter', param);
                        data = null;
                        if (!(tp === 'ms_data')) return [3 /*break*/, 3];
                        return [4 /*yield*/, this.appMsDtCntrl.appSyncronization(param)];
                    case 2:
                        data = _a.sent();
                        this.logger.trace('data ?????', data);
                        return [3 /*break*/, 4];
                    case 3:
                        if (tp === 'file') {
                            this.imagePro.resetCache();
                            this.imagePro.loadImages(true);
                        }
                        else if (tp === 'ctx') {
                            data = this.bsCtx.reloadContextData();
                            this.logger.trace('bsns Cntxt listenForStateChanges');
                        }
                        _a.label = 4;
                    case 4:
                        if (data) {
                            this.check = true;
                            this.bubble = false;
                            this.close = false;
                        }
                        else {
                            this.check = false;
                            this.close = true;
                            this.bubble = false;
                        }
                        selectSyncBtn['check'] = this.check;
                        selectSyncBtn['close'] = this.close;
                        selectSyncBtn['bubble'] = this.bubble;
                        if (tp === 'shift_sync') {
                            this.appCtx.loadShiftList().then(function (res) {
                                if (res) {
                                    _this.check = true;
                                    _this.bubble = false;
                                    _this.close = false;
                                }
                                else {
                                    _this.check = false;
                                    _this.close = true;
                                    _this.bubble = false;
                                }
                                selectSyncBtn['check'] = _this.check;
                                selectSyncBtn['close'] = _this.close;
                                selectSyncBtn['bubble'] = _this.bubble;
                            });
                        }
                        return [3 /*break*/, 6];
                    case 5:
                        e_1 = _a.sent();
                        selectSyncBtn['check'] = false;
                        selectSyncBtn['close'] = true;
                        selectSyncBtn['bubble'] = false;
                        this.logger.error(e_1);
                        return [3 /*break*/, 6];
                    case 6: return [2 /*return*/];
                }
            });
        });
    };
    /*
     sync all sync btn at once
     */
    SettingView.prototype.syncAll = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            var res, temp_sync_comp;
            return __generator(this, function (_a) {
                this.logger.trace('App sync all');
                res = null;
                temp_sync_comp = [];
                this.sync_components.forEach(function (data, index) {
                    _this.bubble = true;
                    var selectSyncBtn = _this.sync_components[index];
                    if (data.type === 'ctx') {
                        _this.bsCtx.reloadContextData().then(function (response) {
                            if (response) {
                                _this.appMsDtCntrl.appSyncAllData().then(function (comb) {
                                    temp_sync_comp.forEach(function (dt, index) {
                                        if (dt.type === 'file') {
                                            _this.imagePro.resetCache();
                                            _this.imagePro.loadImages(true);
                                            _this.logger.trace('file downloaded');
                                            _this.check = false;
                                            _this.close = true;
                                            _this.bubble = false;
                                        }
                                        else {
                                            var selectSyncBtn_1 = temp_sync_comp[index];
                                            if (comb) {
                                                _this.check = true;
                                                _this.bubble = false;
                                                _this.close = false;
                                            }
                                            else {
                                                _this.check = false;
                                                _this.close = true;
                                                _this.bubble = false;
                                            }
                                            _this.logger.trace('change selectSyncBtn', selectSyncBtn_1);
                                            selectSyncBtn_1['check'] = _this.check;
                                            selectSyncBtn_1['close'] = _this.close;
                                            selectSyncBtn_1['bubble'] = _this.bubble;
                                        }
                                    });
                                });
                                _this.check = true;
                                _this.bubble = false;
                                _this.close = false;
                                selectSyncBtn['check'] = _this.check;
                                selectSyncBtn['close'] = _this.close;
                                selectSyncBtn['bubble'] = _this.bubble;
                                // this.appMsDtCntrl.cacheSaveInSync();
                                _this.appMsDtCntrl.appSyncAllData();
                            }
                            else {
                                _this.check = false;
                                _this.close = true;
                                _this.bubble = false;
                            }
                            selectSyncBtn['check'] = _this.check;
                            selectSyncBtn['close'] = _this.close;
                            selectSyncBtn['bubble'] = _this.bubble;
                            _this.logger.trace('bsns Cntxt listenForStateChanges');
                        });
                    }
                    else if (data.type === 'shift_sync') {
                        _this.appCtx.loadShiftList().then(function (res) {
                            if (res) {
                                _this.check = true;
                                _this.bubble = false;
                                _this.close = false;
                            }
                            else {
                                _this.check = false;
                                _this.close = true;
                                _this.bubble = false;
                            }
                            selectSyncBtn['check'] = _this.check;
                            selectSyncBtn['close'] = _this.close;
                            selectSyncBtn['bubble'] = _this.bubble;
                        });
                    }
                    else {
                        temp_sync_comp.push(data);
                        if (data.type !== 'file') {
                            _this.check = false;
                            _this.bubble = true;
                            _this.close = false;
                        }
                        else {
                            _this.bubble = false;
                        }
                        selectSyncBtn['check'] = _this.check;
                        selectSyncBtn['close'] = _this.close;
                        selectSyncBtn['bubble'] = _this.bubble;
                    }
                });
                return [2 /*return*/];
            });
        });
    };
    /*
     app status get
     */
    SettingView.prototype.appStatusSync = function () {
        var _this = this;
        this.loading = true;
        this.appCacheSrv.restoreAppData().then(function (res) {
            _this.loading = false;
            _this.logger.debug('APP_CACHE', 'restore successful');
        }, function (err) {
            _this.loading = false;
        });
    };
    SettingView = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_1_ionic_angular__["i" /* IonicPage */])(),
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({
            selector: 'setting-view',
            template: __WEBPACK_IMPORTED_MODULE_3__setting_template__["a" /* SETTTING_TEMPLATE_HTML */]
        }),
        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2_ngx_logger__["b" /* NGXLogger */],
            __WEBPACK_IMPORTED_MODULE_6__providers_masterdata_service_masterdata_service__["a" /* AppMasterDataCntrl */],
            __WEBPACK_IMPORTED_MODULE_4__ncinga_sp_nsp_app_core_dist_providers_business_context__["a" /* BusinessContext */],
            __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["p" /* NavParams */],
            __WEBPACK_IMPORTED_MODULE_5__ncinga_sp_nsp_app_core_dist__["l" /* ImagesProvider */],
            __WEBPACK_IMPORTED_MODULE_7__providers_application_cache_service_app_cache_service__["a" /* AppCacheService */],
            __WEBPACK_IMPORTED_MODULE_5__ncinga_sp_nsp_app_core_dist__["d" /* ApplicationContext */]])
    ], SettingView);
    return SettingView;
}());

//# sourceMappingURL=setting-view.js.map

/***/ }),

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

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SETTTING_TEMPLATE_HTML; });
/**
 * Created by dilshan on 7/5/18.
 */
var SETTTING_TEMPLATE_HTML = "\n<ion-header>\n      <common-main-header [title]=\"pagetitle\"></common-main-header>\n</ion-header>\n<!-- <ion-content>\n<ion-grid class=\"bdy-cnt\">\n\t<ion-row class=\"spc-row\"></ion-row>\n\t<ion-row class=\"sting-btn\">\n\t\t<ion-col col-12 col-md-6 col-sm-6>\n\t\t\t<button ion-button>Advanced Behind</button>\n\t\t</ion-col>\n\t\t<ion-col col-12 col-md-6 col-sm-6>\n\t\t\t<button ion-button>App Sync</button>\n\t\t</ion-col>\n\t</ion-row>\n</ion-grid>\n</ion-content> -->\n\n\n\n<ion-content>\n<ion-grid class=\"syc-list\">\n\n\t<ion-row no-padding class=\"info-row\">\n\t\t<div class=\"info-msg r-align-flx\"><ion-icon name=\"information-circle\"></ion-icon> Please click<ion-icon class=\"ref-btn\" name=\"refresh\">\n</ion-icon> button to load application data</div>\n\t</ion-row>\n\t<ion-row class=\"sty-lst-wpr\">\n\t\t<ion-col>\n\t\t<ion-row class=\"syc-lst-itm\" *ngFor=\"let item of sync_components; let i=index\">\n\t\t\t<ion-icon *ngIf=\"item.check\" class=\"syced\" name=\"checkmark-circle\"></ion-icon>\n\t\t\t<ion-icon *ngIf=\"item.close && item.type !='file' \" class=\"sycfl\" name=\"close-circle\"></ion-icon>\n\t\t\t<ion-spinner *ngIf=\"item.bubble\" name=\"bubbles\"></ion-spinner>\n\t\t\t<div class=\"r-align-flx\" (click)=\"syncClick(item.value, i, item.type)\">{{item.name}}</div>\n\t\t\t<button ion-button (click)=\"syncClick(item.value, i, item.type)\"><ion-icon name=\"refresh\"></ion-icon></button>\n\t\t</ion-row>\n\t\t</ion-col>\n\t</ion-row>\n\t<ion-row class=\"app-syc-btn\">\n\t<button ion-button clear color=\"warning\" (click)=\"appStatusSync()\"><ion-spinner *ngIf=\"loading\"></ion-spinner>Restore Application Data\n\t</button>\n\t<button ion-button class=\"lod-all-btn\" (click)=\"syncAll()\"><ion-icon name=\"refresh\"></ion-icon> Load All App Data </button>\n\t</ion-row>\n\n</ion-grid>\n</ion-content>\n<ion-footer></ion-footer>\n";
//# sourceMappingURL=setting-template.js.map

/***/ })

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