/**
 * Created by shadeeka on 12/13/15.
 */
angular.module('app.services')
  .factory('propertyCache', ['$log', 'dataPersistenceService', function ($log, dataPersistenceService) {
    //var ipAddress="unknown";
    //var macAddress="unknown";
    //var networkStatus="unknown";

    var propertyCache = this;

    return {

      plans: {
        sessionsPlans: []
      },

      config: {
        dataIp: "",
        syncIp: "",
        factory: "",
        cluster :"",
        line: "",
        tenant: "",
        license:""
      },

      factoryConfigs: {
        rwtogoodRectificationSteps: false,
        operator_change: false,
        operator_capturing: false,
        helper_capturing: false,
        member_capture : true,
        bulk_capturing : false,
        size_wise_events : [],
        default_bundle_sizes:[10,15,20,25]
      },

      day_start: {
        sessionPlan: "",
        style: "",
        members: 0,
        key1: "",
        key2: "",
        siluhoutteid: ""
      },

      optional_day_start_data:{
        operators: 0,
        helpers: 0,
        buyerId: "",
        categoryId: "",
        sizeId: ""
      },

      siluhouttes: {
        silihoutteNames: []
      },

      planedStyles: {
        styleNames: []
      },

      startedStyles: {
        styleNames: []
      },

      pos: {
        poNames: []
      },

      colours: {
        colorCodes: []
      },

      operators: 0,
      helpers: 0,

      triggeredEvent :"",

      ipAddress: 'unknown',
      macAddress: 'unknown',
      networkStatus: 'unknown',
      currentUser: '',

      isAddStyleUserLoggedIn: false,

      setIpAddress: function (data) {
        this.ipAddress = angular.extend(data)
      },
      setNetworkStatus: function (data) {
        this.networkStatus = angular.extend(data)
      },

      setCurrentUser: function (data) {
        this.currentUser = angular.extend(data);
      },
      setMacAddress: function (data) {
        this.macAddress = angular.extend(data)
      },

      setNetworkStatus: function (data) {
        this.networkStatus = angular.extend(data);
      },

      setConfig: function (data) {

        this.config = angular.extend(data);
        $log.debug(this.config);

      },

      setDayStart: function (data) {
        this.day_start = angular.extend(data);
        $log.debug(this.day_start);

      },

      setOptionalDayStart: function (data) {
        this.optional_day_start_data = angular.extend(data);
        $log.debug(this.optional_day_start_data);

      },

      setPlans: function (data) {

        this.plans = angular.extend(data);
        $log.debug("cache set plans ", this.plans);

      },

      setSiluhouttes: function (data) {
        this.siluhouttes = angular.extend(data);
        $log.debug("cache set siluhouttes ", this.siluhouttes);
      }, clearCacheData: function () {
        $log.debug("clearCacheData ");
        this.day_start["sessionPlan"] = "";
        this.day_start["style"] = "";
        this.day_start["members"] = 0;
        this.day_start["key1"] = "";
        this.day_start["key2"] = "";
        this.day_start["siluhoutteid"] = "";
      }, updateDayStartStyle: function (style) {
        $log.debug("Old style in cache ", this.day_start["style"] + " new " + style);
        if (style != undefined) {
          this.day_start["style"] = style;
          $log.debug("Cache set style ", this.day_start["style"]);
        }
      },

      setOperators: function (data) {
        this.operators = angular.extend(data);
        $log.debug(this.operators);
      },

      setHelpers: function (data) {
        this.helpers = angular.extend(data);
        $log.debug(this.helpers);
      },

      setTriggeredEvent: function (data) {
        this.triggeredEvent = angular.extend(data);
        $log.debug(this.triggeredEvent);
      },

      setSelectedStyles: function (data) {
        this.startedStyles.styleNames.push(data);
      }

    };
  }]);
