<commit_before>(function (ng, app) {

    var subnav = [];

    app.directive('suggestNew', ['$http', 'growl', function ($http, growl) {
        return {
            scope: {
                url: '@'
            },
            templateUrl: 'partials/local-config/suggest-new.html',
            link: function (scope, element, attrs) {
                scope.suggest = function () {
                    if (scope.suggestForm.$invalid) return;

                    var data = {
                        'IsSuggestion': true,
                        'Name': scope.suggestion
                    };

                    $http.post(scope.url, data).success(function (result) {
                        growl.addSuccessMessage('Foreslag sendt!');
                        scope.suggestion = "";
                    }).error(function (result) {
                        growl.addErrorMessage('Kunne ikke sende foreslag!');
                    });
                };
            }
        };
    }]);

    app.directive('suggestNewRole', ['$http', 'growl', function ($http, growl) {
        return {
            scope: {
                url: '@'
            },
            templateUrl: 'partials/local-config/suggest-new-role.html',
            link: function (scope, element, attrs) {
                scope.suggest = function () {
                    if (scope.suggestForm.$invalid) return;

                    var data = {
                        'IsSuggestion': true,
                        'Name': scope.suggestion,
                        'HasReadAccess': true,
                        'HasWriteAccess': scope.writeAccess
                    };

                    $http.post(scope.url, data).success(function (result) {
                        growl.addSuccessMessage('Foreslag sendt!');
                        scope.suggestion = "";
                    }).error(function (result) {
                        growl.addErrorMessage('Kunne ikke sende foreslag!');
                    });
                };
            }
        };
    }]);

    app.directive('optionList', ['$http', function ($http) {
        return {
            scope: {
                optionsUrl: '@',
                title: '@',
            },
            templateUrl: 'partials/local-config/optionlist.html',
            link: function (scope, element, attrs) {

                scope.list = [];

                var optionsData = $http.get(scope.optionsUrl).success(function (result) {
                    _.each(result.Response, function (v) {
                        scope.list.push({
                            id: v.Id,
                            name: v.Name,
                            note: v.Note
                        });
                    });
                });
            }
        };
    }]);

    app.directive('optionLocaleList', ['$rootScope', '$q', '$http', 'growl', function ($rootScope, $q, $http, growl) {
        return {
            scope: {
                optionsUrl: '@',
                localesUrl: '@',
                title: '@',
                orgId: '='
            },
            templateUrl: 'partials/local-config/optionlocalelist.html',
            link: function (scope, element, attrs) {

                var orgId = parseInt(scope.orgId);

                scope.list = [];

                $q.all([
                    $http.get(scope.optionsUrl),
                    $http.get(scope.localesUrl + '/' + orgId)
                ]).then(function (result) {

                    var options = result[0].data.Response;
                    var locales = result[1].data.Response;

                    _.each(options, function (v) {

                        var locale = _.find(locales, function (loc) {
                            return loc.Original_Id == v.Id;
                        });

                        var isNew = _.isUndefined(locale);
                        var localeName = isNew ? '' : locale.Name;

                        scope.list.push({
                            id: v.Id,
                            name: v.Name,
                            note: v.Note,
                            localeName: localeName,
                            isNew: isNew
                        });
                    });
                });

                scope.updateLocale = function (value, option) {

                    var oId = option.id;

                    if (_.isEmpty(value)) {

                        return $http({ method: 'DELETE', url: scope.url + '?mId=' + orgId + '&oId=' + oId });

                    } else {

                        var method = option.isNew ? 'POST' : 'PUT';

                        var data = {
                            'Name': value,
                            'Original_Id': oId,
                            'Municipality_Id': orgId
                        };

                        return $http({ method: method, url: scope.localesUrl, data: data })
                            .success(function (result) {
                                growl.addSuccessMessage('Felt opdateret');
                            }).error(function (result) {
                                growl.addErrorMessage('Kunne ikke opdatere feltet med værdien: ' + value + '!');
                            });
                    }
                };
            }
        };
    }]);

    app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

        $stateProvider.state('local-config', {
            url: '/local-config',
            templateUrl: 'partials/local-config/index.html',
            adminRoles: ['LocalAdmin'],
            controller: 'localConfig.InitCtrl',

            resolve: {
                organizationsHttp: ['$http', function($http) {
                    return $http.get("api/organization");
                }]
            }

        }).state('local-config.Edit', {
            templateUrl: 'partials/local-config/config.html',
            url: '/:chosenId',
            adminRoles: ['LocalAdmin'],
            controller: 'localConfig.EditCtrl',
            resolve: {

                organizationHttp: ['$http', '$stateParams', function($http, $stateParams) {
                    return $http.get('api/organization/' + $stateParams.chosenId);
                }],

                supportNamesHttp: ['$http', function($http) {
                    return $http.get('api/itsupportnames');
                }],
                projectNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itprojectnames');
                }],
                systemNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itsystemnames');
                }],
                contractNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itcontractnames');
                }],

                configHttp: ['$http', '$stateParams', function($http, $stateParams) {
                    return $http.get('api/config/' + $stateParams.chosenId);
                }]
            }
        });

        /* .state('local-config-support', {
            url: '/local-config/:chosenId',
            templateUrl: 'partials/local-config/support.html',
            controller: 'localConfig.SupportCtrl',
            authRoles: ['LocalAdmin'],
            resolve: {
                moduleNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itsupportnames');
                }],

                configHttp: ['$http', '$stateParams', '$rootScope', function ($http, $stateParams) {
                    if (!$stateParams.chosenId) return true;

                    return $http.get('api/config/' + $stateParams.chosenId);
                }]
            }
        });.state('local-config-edt.project', {
            url: '/local-config/project',
            templateUrl: 'partials/local-config/project.html',
            controller: 'localConfig.ProjectCtrl',
            authRoles: ['LocalAdmin', 'GlobalAdmin'],
            resolve: {
                moduleNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itprojectnames');
                }],
                configHttp: ['$http', '$rootScope', function ($http, $rootScope) {
                    var munId = $rootScope.user.municipality;
                    return $http.get('api/config/' + chosenId);
                }]
            }
        }).state('local-config.system', {
            url: '/local-config/system',
            templateUrl: 'partials/local-config/system.html',
            controller: 'localConfig.SystemCtrl'
        }).state('local-config-contract', {
            url: '/local-config/contract',
            templateUrl: 'partials/local-config/contract.html',
            controller: 'localConfig.ContractCtrl'
        });
        */
    }]);

    var patch = function ($http, growl, url, value, fieldName) {
        var data = {};
        data[fieldName] = value;

        $http({ method: 'PATCH', url: url, data: data }).success(function (result) {
            growl.addSuccessMessage("Feltet er opdateret!");
        }).error(function (result) {
            growl.addErrorMessage("Feltet blev ikke opdateret!");
        });
    };

    app.controller('localConfig.InitCtrl',
        ['$rootScope', '$scope', '$http', '$state', 'organizationsHttp',
            function($rootScope, $scope, $http, $state, organizationsHttp) {
                $rootScope.page.title = 'Konfiguration';
                $rootScope.subnav = subnav;

                $scope.orgChooser = {
                    options: _.filter(organizationsHttp.data.Response,
                        function(org) {
                            return _.contains($rootScope.user.isLocalAdminFor,
                                org.Id);
                        })
                };

            $scope.choose = function () {
                $state.go("local-config.Edit", { chosenId: $scope.orgChooser.chosen });
            };
        }]);

    app.controller('localConfig.EditCtrl',
        ['$rootScope', '$scope', '$http', '$stateParams', 'growl', 'organizationHttp', 'supportNamesHttp', 'projectNamesHttp', 'systemNamesHttp', 'contractNamesHttp', 'configHttp',
            function ($rootScope, $scope, $http, $stateParams, growl, organizationHttp, supportNamesHttp, projectNamesHttp, systemNamesHttp, contractNamesHttp, configHttp) {
                $rootScope.page.title = 'Konfiguration';
                $rootScope.subnav = subnav;

                $scope.orgId = $stateParams.chosenId;
                $scope.orgChooser.chosen = $stateParams.chosenId;

                $scope.organization = organizationHttp.data.Response;

                var config = configHttp.data.Response;
                $scope.updateConfig = function (value, fieldName) {
                    return patch($http, growl, 'api/config/' + config.Id, value, fieldName);
                };

                $scope.support = {
                    show: true,
                    moduleNames: supportNamesHttp.data.Response,
                    chosenNameId: config.ItSupportModuleName_Id,
                    guideUrl: config.ItSupportGuide,
                    showTabOverview: config.ShowTabOverview,
                    showTechnology: config.ShowColumnTechnology,
                    showUsage: config.ShowColumnUsage,
                    showMandatory: config.ShowColumnMandatory
                };

                $scope.project = {
                    show: false,
                    moduleNames: projectNamesHttp.data.Response,
                    chosenNameId: config.ItProjectModuleName_Id,
                    guideUrl: config.ItProjectGuide,
                    showPortfolio: config.ShowPortfolio,
                    showBC: config.ShowBC
                };

                $scope.system = {
                    show: false,
                    moduleNames: systemNamesHttp.data.Response,
                    chosenNameId: config.ItSystemModuleName_Id,
                    guideUrl: config.ItSystemGuide
                };

                $scope.contract = {
                    show: false,
                    moduleNames: contractNamesHttp.data.Response,
                    chosenNameId: config.ItContractModuleName_Id,
                    guideUrl: config.ItContractGuide
                };

                $scope.toggle = function (object, s) {
                    console.log(s);
                    object.show = !object.show;
                };

            }]);

})(angular, app);
<commit_msg>Fixed sub navigation bug<commit_after>(function (ng, app) {

    var subnav = [];

    app.directive('suggestNew', ['$http', 'growl', function ($http, growl) {
        return {
            scope: {
                url: '@'
            },
            templateUrl: 'partials/local-config/suggest-new.html',
            link: function (scope, element, attrs) {
                scope.suggest = function () {
                    if (scope.suggestForm.$invalid) return;

                    var data = {
                        'IsSuggestion': true,
                        'Name': scope.suggestion
                    };

                    $http.post(scope.url, data).success(function (result) {
                        growl.addSuccessMessage('Foreslag sendt!');
                        scope.suggestion = "";
                    }).error(function (result) {
                        growl.addErrorMessage('Kunne ikke sende foreslag!');
                    });
                };
            }
        };
    }]);

    app.directive('suggestNewRole', ['$http', 'growl', function ($http, growl) {
        return {
            scope: {
                url: '@'
            },
            templateUrl: 'partials/local-config/suggest-new-role.html',
            link: function (scope, element, attrs) {
                scope.suggest = function () {
                    if (scope.suggestForm.$invalid) return;

                    var data = {
                        'IsSuggestion': true,
                        'Name': scope.suggestion,
                        'HasReadAccess': true,
                        'HasWriteAccess': scope.writeAccess
                    };

                    $http.post(scope.url, data).success(function (result) {
                        growl.addSuccessMessage('Foreslag sendt!');
                        scope.suggestion = "";
                    }).error(function (result) {
                        growl.addErrorMessage('Kunne ikke sende foreslag!');
                    });
                };
            }
        };
    }]);

    app.directive('optionList', ['$http', function ($http) {
        return {
            scope: {
                optionsUrl: '@',
                title: '@',
            },
            templateUrl: 'partials/local-config/optionlist.html',
            link: function (scope, element, attrs) {

                scope.list = [];

                var optionsData = $http.get(scope.optionsUrl).success(function (result) {
                    _.each(result.Response, function (v) {
                        scope.list.push({
                            id: v.Id,
                            name: v.Name,
                            note: v.Note
                        });
                    });
                });
            }
        };
    }]);

    app.directive('optionLocaleList', ['$rootScope', '$q', '$http', 'growl', function ($rootScope, $q, $http, growl) {
        return {
            scope: {
                optionsUrl: '@',
                localesUrl: '@',
                title: '@',
                orgId: '='
            },
            templateUrl: 'partials/local-config/optionlocalelist.html',
            link: function (scope, element, attrs) {

                var orgId = parseInt(scope.orgId);

                scope.list = [];

                $q.all([
                    $http.get(scope.optionsUrl),
                    $http.get(scope.localesUrl + '/' + orgId)
                ]).then(function (result) {

                    var options = result[0].data.Response;
                    var locales = result[1].data.Response;

                    _.each(options, function (v) {

                        var locale = _.find(locales, function (loc) {
                            return loc.Original_Id == v.Id;
                        });

                        var isNew = _.isUndefined(locale);
                        var localeName = isNew ? '' : locale.Name;

                        scope.list.push({
                            id: v.Id,
                            name: v.Name,
                            note: v.Note,
                            localeName: localeName,
                            isNew: isNew
                        });
                    });
                });

                scope.updateLocale = function (value, option) {

                    var oId = option.id;

                    if (_.isEmpty(value)) {

                        return $http({ method: 'DELETE', url: scope.url + '?mId=' + orgId + '&oId=' + oId });

                    } else {

                        var method = option.isNew ? 'POST' : 'PUT';

                        var data = {
                            'Name': value,
                            'Original_Id': oId,
                            'Municipality_Id': orgId
                        };

                        return $http({ method: method, url: scope.localesUrl, data: data })
                            .success(function (result) {
                                growl.addSuccessMessage('Felt opdateret');
                            }).error(function (result) {
                                growl.addErrorMessage('Kunne ikke opdatere feltet med værdien: ' + value + '!');
                            });
                    }
                };
            }
        };
    }]);

    app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {

        $stateProvider.state('local-config', {
            url: '/local-config',
            templateUrl: 'partials/local-config/index.html',
            adminRoles: ['LocalAdmin'],
            controller: 'localConfig.InitCtrl',

            resolve: {
                organizationsHttp: ['$http', function($http) {
                    return $http.get("api/organization");
                }]
            }

        }).state('local-config.Edit', {
            templateUrl: 'partials/local-config/config.html',
            url: '/:chosenId',
            adminRoles: ['LocalAdmin'],
            controller: 'localConfig.EditCtrl',
            resolve: {

                organizationHttp: ['$http', '$stateParams', function($http, $stateParams) {
                    return $http.get('api/organization/' + $stateParams.chosenId);
                }],

                supportNamesHttp: ['$http', function($http) {
                    return $http.get('api/itsupportnames');
                }],
                projectNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itprojectnames');
                }],
                systemNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itsystemnames');
                }],
                contractNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itcontractnames');
                }],

                configHttp: ['$http', '$stateParams', function($http, $stateParams) {
                    return $http.get('api/config/' + $stateParams.chosenId);
                }]
            }
        });

        /* .state('local-config-support', {
            url: '/local-config/:chosenId',
            templateUrl: 'partials/local-config/support.html',
            controller: 'localConfig.SupportCtrl',
            authRoles: ['LocalAdmin'],
            resolve: {
                moduleNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itsupportnames');
                }],

                configHttp: ['$http', '$stateParams', '$rootScope', function ($http, $stateParams) {
                    if (!$stateParams.chosenId) return true;

                    return $http.get('api/config/' + $stateParams.chosenId);
                }]
            }
        });.state('local-config-edt.project', {
            url: '/local-config/project',
            templateUrl: 'partials/local-config/project.html',
            controller: 'localConfig.ProjectCtrl',
            authRoles: ['LocalAdmin', 'GlobalAdmin'],
            resolve: {
                moduleNamesHttp: ['$http', function ($http) {
                    return $http.get('api/itprojectnames');
                }],
                configHttp: ['$http', '$rootScope', function ($http, $rootScope) {
                    var munId = $rootScope.user.municipality;
                    return $http.get('api/config/' + chosenId);
                }]
            }
        }).state('local-config.system', {
            url: '/local-config/system',
            templateUrl: 'partials/local-config/system.html',
            controller: 'localConfig.SystemCtrl'
        }).state('local-config-contract', {
            url: '/local-config/contract',
            templateUrl: 'partials/local-config/contract.html',
            controller: 'localConfig.ContractCtrl'
        });
        */
    }]);

    var patch = function ($http, growl, url, value, fieldName) {
        var data = {};
        data[fieldName] = value;

        $http({ method: 'PATCH', url: url, data: data }).success(function (result) {
            growl.addSuccessMessage("Feltet er opdateret!");
        }).error(function (result) {
            growl.addErrorMessage("Feltet blev ikke opdateret!");
        });
    };

    app.controller('localConfig.InitCtrl',
        ['$rootScope', '$scope', '$http', '$state', 'organizationsHttp',
            function($rootScope, $scope, $http, $state, organizationsHttp) {
                $rootScope.page.title = 'Konfiguration';
                $rootScope.page.subnav = [];

                $scope.orgChooser = {
                    options: _.filter(organizationsHttp.data.Response,
                        function(org) {
                            return _.contains($rootScope.user.isLocalAdminFor,
                                org.Id);
                        })
                };

            $scope.choose = function () {
                $state.go("local-config.Edit", { chosenId: $scope.orgChooser.chosen });
            };
        }]);

    app.controller('localConfig.EditCtrl',
        ['$rootScope', '$scope', '$http', '$stateParams', 'growl', 'organizationHttp', 'supportNamesHttp', 'projectNamesHttp', 'systemNamesHttp', 'contractNamesHttp', 'configHttp',
            function ($rootScope, $scope, $http, $stateParams, growl, organizationHttp, supportNamesHttp, projectNamesHttp, systemNamesHttp, contractNamesHttp, configHttp) {
                $rootScope.page.title = 'Konfiguration';
                $rootScope.page.subnav = [];

                $scope.orgId = $stateParams.chosenId;
                $scope.orgChooser.chosen = $stateParams.chosenId;

                $scope.organization = organizationHttp.data.Response;

                var config = configHttp.data.Response;
                $scope.updateConfig = function (value, fieldName) {
                    return patch($http, growl, 'api/config/' + config.Id, value, fieldName);
                };

                $scope.support = {
                    show: true,
                    moduleNames: supportNamesHttp.data.Response,
                    chosenNameId: config.ItSupportModuleName_Id,
                    guideUrl: config.ItSupportGuide,
                    showTabOverview: config.ShowTabOverview,
                    showTechnology: config.ShowColumnTechnology,
                    showUsage: config.ShowColumnUsage,
                    showMandatory: config.ShowColumnMandatory
                };

                $scope.project = {
                    show: false,
                    moduleNames: projectNamesHttp.data.Response,
                    chosenNameId: config.ItProjectModuleName_Id,
                    guideUrl: config.ItProjectGuide,
                    showPortfolio: config.ShowPortfolio,
                    showBC: config.ShowBC
                };

                $scope.system = {
                    show: false,
                    moduleNames: systemNamesHttp.data.Response,
                    chosenNameId: config.ItSystemModuleName_Id,
                    guideUrl: config.ItSystemGuide
                };

                $scope.contract = {
                    show: false,
                    moduleNames: contractNamesHttp.data.Response,
                    chosenNameId: config.ItContractModuleName_Id,
                    guideUrl: config.ItContractGuide
                };

                $scope.toggle = function (object, s) {
                    console.log(s);
                    object.show = !object.show;
                };

            }]);

})(angular, app);
<|endoftext|>


<commit_before>function Stage(context, imagem, colisor) {
  this.speed = .6;
  this.imagem = imagem;
  this.context = context;
  this.currentHeight = this.imagem.height - this.context.canvas.height;
  this.intervalo = 1000;
  this.ultimoTempo = null;
  colisor = colisor;
  this.gerouChefe = false;
};

Stage.prototype = {
  atualizar: function () {
    /*if (this.currentHeight >= this.speed) {
      this.currentHeight -= this.speed;
      this.gerarInimigos();
    } else { */
      if (!this.gerouChefe) {
        this.gerarChefe();
      }
   // }

  },
  desenhar: function () {
		this.context.drawImage(this.imagem, 0, -this.currentHeight, this.imagem.width, this.imagem.height);
  },

  gerarInimigos: function () {
    var agora = new Date().getTime();

    if (! this.ultimoTempo) this.ultimoTempo = agora;
    if (agora - this.ultimoTempo < this.intervalo) return;

    var enemy = new Enemy(this.context, imagens.enemy1, 4);
    animacao.novoSprite(enemy);
    colisor.novoSprite(enemy);
    this.ultimoTempo = agora;
  },

  gerarChefe: function () {
    var chefe = new Chefe(this.context, imagens.boss1, 1.6);
    animacao.novoSprite(chefe);
    colisor.novoSprite(chefe);
    this.gerouChefe = true;
  },

  initialConfig: function () {
    this.currentHeight = this.imagem.height - this.context.canvas.height;
    this.ultimoTempo = null;
    this.gerouChefe = false;
  }
}
<commit_msg>colision and damage to boss<commit_after>function Stage(context, imagem, colisor) {
  this.speed = .6;
  this.imagem = imagem;
  this.context = context;
  this.currentHeight = this.imagem.height - this.context.canvas.height;
  this.intervalo = 1000;
  this.ultimoTempo = null;
  colisor = colisor;
  this.gerouChefe = false;
};

Stage.prototype = {
  atualizar: function () {
    if (this.currentHeight >= this.speed) {
      this.currentHeight -= this.speed;
      this.gerarInimigos();
    } else {
      if (!this.gerouChefe) {
        this.gerarChefe();
      }
    }

  },
  desenhar: function () {
		this.context.drawImage(this.imagem, 0, -this.currentHeight, this.imagem.width, this.imagem.height);
  },

  gerarInimigos: function () {
    var agora = new Date().getTime();

    if (! this.ultimoTempo) this.ultimoTempo = agora;
    if (agora - this.ultimoTempo < this.intervalo) return;

    var enemy = new Enemy(this.context, imagens.enemy1, 4);
    animacao.novoSprite(enemy);
    colisor.novoSprite(enemy);
    this.ultimoTempo = agora;
  },

  gerarChefe: function () {
    var chefe = new Chefe(this.context, imagens.boss1, 1.6);
    animacao.novoSprite(chefe);
    colisor.novoSprite(chefe);
    this.gerouChefe = true;
  },

  initialConfig: function () {
    this.currentHeight = this.imagem.height - this.context.canvas.height;
    this.ultimoTempo = null;
    this.gerouChefe = false;
  }
}
<|endoftext|>


<commit_before>import Ember from "ember";
import config from '../config/environment';

export default Em.Controller.extend({
  emberCli: Em.inject.service('ember-cli'),
  version: config.version,
  revision: config.currentRevision.substring(0,7),

  /**
   * Output from the build, sets the `code` attr on the component
   * @type {String}
   */
  buildOutput: '',
  isBuilding: false,
  activeEditor: null,
  col1File: null,
  col2File: null,
  col1Active: Em.computed.equal('activeEditor.col','1'),
  col2Active: Em.computed.equal('activeEditor.col','2'),

  /**
   * Errors during build
   * @type {Array}     Array of errors
   */
  buildErrors: null,

  /**
   * Build the application and set the iframe code
   */
  buildApp () {
    this.set('isBuilding', true);
    this.set('buildErrors', []);

    this.get('emberCli').compileGist(this.get('model')).then((buildOutput) => {
      this.set('isBuilding', false);
      this.set('buildOutput', buildOutput);
    })
    .catch((errors) => {
      this.set('isBuilding', false);
      this.set('buildErrors', errors);
      errors.forEach(error => {
        console.error(error);
      });
    });
  },

  /**
   * Set the initial file columns
   */
  initializeColumns: Em.observer('model', function() {
    var files = this.get('model.files');

    if(files.objectAt(0)) {
      this.set('col1File', files.objectAt(0));
    }

    if(files.objectAt(1)) {
      this.set('col2File', files.objectAt(1));
    }
  }),

  rebuildApp: Em.observer('model.files.@each.content', function() {
    Em.run.debounce(this, this.buildApp, 500);
  }),

  actions: {
    focusEditor (editor) {
      this.set('activeEditor', editor);
    },

    deleteGist (gist) {
      gist.destroyRecord();
      this.transitionToRoute('gist.new');
      this.notify.info('Gist %@ was deleted from Github'.fmt(gist.get('id')));
    },

    share () {
      prompt('Ctrl + C ;-)', window.location.href);
    },

    addFile (type) {
      var template = '';
      var filePath = '';
      if(type==='component-hbs') {
        template = '{{yield}}';
        filePath = 'templates/components/foo-component.hbs';
      }
      if(type==='component-js') {
        template = 'export default Ember.Component.extend({\n});';
        filePath = 'components/foo-component.js';
      }
      else if(type==='controller') {
        template = 'export default Ember.Controller.extend({\n});';
        filePath = 'controllers/foo.js';
      }
      else if(type==='template') {
        template = 'Hi!';
        filePath = 'templates/foo.hbs';
      }

      filePath = prompt('File path', filePath);

      if (filePath) {
        if(this.get('model.files').findBy('filePath', filePath)) {
          alert('A file with the name %@ already exists'.fmt(filePath));
          return;
        }

        let file = this.store.createRecord('gistFile', {
          filePath: filePath,
          content: template
        });

        this.get('model.files').pushObject(file);
        this.notify.info('File %@ was added'.fmt(file.get('filePath')));
        this.set('col1File', file);
      }
    },

    renameFile (file) {
      let filePath = prompt('File path', file.get('filePath'));
      if (filePath) {
        if(this.get('model.files').findBy('filePath', filePath)) {
          alert('A file with the name %@ already exists'.fmt(filePath));
          return;
        }

        file.set('filePath', filePath);
        this.notify.info('File %@ was added'.fmt(file.get('filePath')));
      }
    },

    showErrors () {
      this.get('buildErrors').forEach((error) => {
        console.error(error);
      });
      this.notify.info('Errors were dumped to console');
    },

    fork (gist) {
      var newGistData = {
        description: 'Fork of %@'.fmt(gist.get('description'))
      };

      var filesBuffer = [];

      gist.get('files').forEach(file => {
        filesBuffer.pushObject({
          filePath: file.get('filePath'),
          content: file.get('content'),
        });
      });

      this.store.unloadAll('gistFile');

      var newGist = this.store.createRecord('gist', newGistData);
      filesBuffer.forEach(fileData => {
        newGist.get('files').pushObject(this.store.createRecord('gistFile', fileData));
      });

      this.controllerFor('gist').set('fork', newGist);
      this.notify.info('Succesfully created %@'.fmt(newGist.get('description')));
      this.transitionToRoute('gist.new');
    },

    removeFile (file) {
      if(confirm(`Are you sure you want to remove this file?\n\n${file.get('filePath')}`)) {
        file.deleteRecord();
        this.notify.info('File %@ was deleted'.fmt(file.get('filePath')));
        this._removeFileFromColumns(file);
      }
    }
  },

  _removeFileFromColumns (file) {
    if(this.get('col1File') === file) {
      this.set('col1File', null);
    }
    if(this.get('col2File') === file) {
      this.set('col2File', null);
    }
  },

  setupWindowUpdate: Ember.on('init', function() {
    window.updateDemoAppUrl = function() {
      this.set('applicationUrl', window.demoAppUrl || "/");
    }.bind(this)
  })
});
<commit_msg>Fix test<commit_after>import Ember from "ember";
import config from '../config/environment';

export default Em.Controller.extend({
  emberCli: Em.inject.service('ember-cli'),
  version: config.version,
  revision: config.currentRevision.substring(0,7),

  /**
   * Output from the build, sets the `code` attr on the component
   * @type {String}
   */
  buildOutput: '',
  isBuilding: false,
  activeEditor: null,
  col1File: null,
  col2File: null,
  col1Active: Em.computed.equal('activeEditor.col','1'),
  col2Active: Em.computed.equal('activeEditor.col','2'),

  /**
   * Errors during build
   * @type {Array}     Array of errors
   */
  buildErrors: null,

  /**
   * Build the application and set the iframe code
   */
  buildApp () {
    this.set('isBuilding', true);
    this.set('buildErrors', []);

    this.get('emberCli').compileGist(this.get('model')).then((buildOutput) => {
      this.set('isBuilding', false);
      this.set('buildOutput', buildOutput);
    })
    .catch((errors) => {
      this.set('isBuilding', false);
      this.set('buildErrors', errors);
      errors.forEach(error => {
        console.error(error);
      });
    });
  },

  /**
   * Set the initial file columns
   */
  initializeColumns: Em.observer('model', function() {
    var files = this.get('model.files');

    if(files.objectAt(0)) {
      this.set('col1File', files.objectAt(0));
    }

    if(files.objectAt(1)) {
      this.set('col2File', files.objectAt(1));
    }
  }),

  rebuildApp: Em.observer('model.files.@each.content', function() {
    Em.run.debounce(this, this.buildApp, 500);
  }),

  actions: {
    focusEditor (editor) {
      this.set('activeEditor', editor);
    },

    deleteGist (gist) {
      gist.destroyRecord();
      this.transitionToRoute('gist.new');
      this.notify.info('Gist %@ was deleted from Github'.fmt(gist.get('id')));
    },

    share () {
      prompt('Ctrl + C ;-)', window.location.href);
    },

    addFile (type) {
      var template = '';
      var filePath = '';
      if(type==='component-hbs') {
        template = '{{yield}}';
        filePath = 'templates/components/foo-component.hbs';
      }
      if(type==='component-js') {
        template = 'export default Ember.Component.extend({\n});';
        filePath = 'components/foo-component.js';
      }
      else if(type==='controller') {
        template = 'export default Ember.Controller.extend({\n});';
        filePath = 'controllers/foo.js';
      }
      else if(type==='template') {
        template = 'Hi!';
        filePath = 'templates/foo.hbs';
      }

      filePath = prompt('File path', filePath);

      if (filePath) {
        if(this.get('model.files').findBy('filePath', filePath)) {
          alert('A file with the name %@ already exists'.fmt(filePath));
          return;
        }

        let file = this.store.createRecord('gistFile', {
          filePath: filePath,
          content: template
        });

        this.get('model.files').pushObject(file);
        this.notify.info('File %@ was added'.fmt(file.get('filePath')));
        this.set('col1File', file);
      }
    },

    renameFile (file) {
      let filePath = prompt('File path', file.get('filePath'));
      if (filePath) {
        if(this.get('model.files').findBy('filePath', filePath)) {
          alert('A file with the name %@ already exists'.fmt(filePath));
          return;
        }

        file.set('filePath', filePath);
        this.notify.info('File %@ was added'.fmt(file.get('filePath')));
      }
    },

    showErrors () {
      this.get('buildErrors').forEach((error) => {
        console.error(error);
      });
      this.notify.info('Errors were dumped to console');
    },

    fork (gist) {
      var newGistData = {
        description: 'Fork of %@'.fmt(gist.get('description'))
      };

      var filesBuffer = [];

      gist.get('files').forEach(file => {
        filesBuffer.pushObject({
          filePath: file.get('filePath'),
          content: file.get('content'),
        });
      });

      this.store.unloadAll('gistFile');

      var newGist = this.store.createRecord('gist', newGistData);
      filesBuffer.forEach(fileData => {
        newGist.get('files').pushObject(this.store.createRecord('gistFile', fileData));
      });

      this.controllerFor('gist').set('fork', newGist);
      this.notify.info('Succesfully created %@'.fmt(newGist.get('description')));
      this.transitionToRoute('gist.new');
    },

    removeFile (file) {
      if(confirm(`Are you sure you want to remove this file?\n\n${file.get('filePath')}`)) {
        file.deleteRecord();
        this.notify.info('File %@ was deleted'.fmt(file.get('filePath')));
        this._removeFileFromColumns(file);
      }
    }
  },

  _removeFileFromColumns (file) {
    if(this.get('col1File') === file) {
      this.set('col1File', null);
    }
    if(this.get('col2File') === file) {
      this.set('col2File', null);
    }
  },

  setupWindowUpdate: Ember.on('init', function() {
    window.updateDemoAppUrl = function() {
      this.set('applicationUrl', window.demoAppUrl || "/");
    }.bind(this);
  })
});
<|endoftext|>


<commit_before>/**
 * @author jianzhe.ding
 * @homepage https://github.com/discipled/
 * @since 2016-07-25 11:50
 */

const customer = {
	title: '客户属性',
	name: 'customer',
	icon: '',
	attributeBlock: [{
		title: '基本信息',
		name: 'base',
		attributeList: [{
			attribute: 'full_name',
			name: '姓名',
			defaultValue: '无',
			unit: '',
			editable: false,
			type: 'text',
			validate: ['/^\\w{1, 50}$/'],
			isInListMode: true
		}, {
			attribute: 'sex',
			name: '性别',
			defaultValue: '',
			unit: '',
			editable: false,
			type: 'radio',
			valueMap: {
				m: '男',
				f: '女',
				'': '未知'
			},
			validate: [],
			isInListMode: true
		}, {
			attribute: 'birthday',
			name: '出生日期',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'date',
			validate: [],
			isInListMode: true
		}, {
			attribute: 'age',
			name: '年龄',
			defaultValue: '-',
			unit: '岁',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'mobile',
			name: '常用手机',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'text',
			validate: ['/^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9]){1}\\d{8}$/']
		}, {
			attribute: 'mobile',
			name: '支付手机',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'mobile',
			name: '最新收货手机',
			defaultValue: '-',
			unit: '',
			editable: false
		}, {
			attribute: 'buyer_email',
			name: 'email邮箱',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'text',
			validate: ['/^\\w{1, 50}$/', '/@.+(.com|.cn)$/']
		}, {
			attribute: 'address_zip',
			name: '常用地址',
			defaultValue: '-',
			unit: '',
			editable: false,
			attributes: [{
				attribute: 'receiver_state',
				name: '省份',
				defaultValue: '-',
				unit: '',
				type: 'select',
				isInListMode: true
			}, {
				attribute: 'receiver_city',
				name: '城市',
				defaultValue: '-',
				unit: '',
				type: 'select',
				isInListMode: true
			}, {
				attribute: 'receiver_district',
				name: '区县',
				defaultValue: '-',
				unit: '',
				type: 'select',
				isInListMode: true
			}, {
				attribute: 'receiver_address',
				type: 'text',
				defaultValue: '-',
				unit: '',
				validate: ['/^\\w{1, 50}$/']
			}, {
				attribute: 'receiver_zip',
				type: 'text',
				defaultValue: '-',
				unit: '',
				validate: ['/^\\d{1, 6}$/']
			}]
		}]
	}, {
		title: '更多个人信息',
		name: 'customerDefined',
		attributeList: [
		/* {
				attribute: 'job',
				name: '职业',
				defaultValue: '自由职业',
				editable: true,
				type: 'text',
				validate: ['/^\\w{1, 50}$/'],
				isInListMode: true
			}, {
				attribute: '',
				name: '身高/cm',
				defaultValue: '-',
				editable: true,
				type: 'text',
				validate: ['/^\\d{1, 5}$/'],
				isInListMode: true
			}, {
				attribute: '',
				name: '体重/kg',
				defaultValue: '-',
				editable: true,
				type: 'text',
				validate: ['/^\\d{1, 5}$/'],
				isInListMode: true
			}, {
				attribute: '',
				name: '星座',
				defaultValue: '-',
				editable: false,
				isInListMode: true
			}, {
				attribute: '',
				name: '血型',
				defaultValue: '',
				editable: true,
				type: 'radio',
				enum: [{
					name: 'A',
					value: 'a'
				}, {
					name: 'B',
					value: 'b'
				}, {
					name: 'AB',
					value: 'ab'
				}, {
					name: 'O',
					value: 'o'
				}, {
					name: '未知',
					value: ''
				}],
				isInListMode: true
			}*/
		]
	}]
};

const consumer = {
	title: '消费属性',
	name: 'consumer',
	icon: '',
	attributeBlock: [{
		title: '基本消费指标',
		name: 'base',
		attributeList: [{
			attribute: '',
			name: '客户来源',
			defaultValue: '淘宝',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: '',
			name: '客户类型',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: false
		}, {
			attribute: 'vip_info',
			name: '淘宝全站等级',
			defaultValue: '-',
			valueMap: {
				'asso_vip': '荣誉会员',
				'c': '普通会员',
				'vip1': 'VIP1',
				'vip2': 'VIP2',
				'vip3': 'VIP3',
				'vip4': 'VIP4',
				'vip5': 'VIP5',
				'vip6': 'VIP6',
				'-': '-'
			},
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'buyer_credit_lev',
			name: '信用等级',
			defaultValue: '-',
			unit: '',
			editable: false
		}, {
			attribute: '',
			name: '买家好评率',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}]
	}, {
		title: 'RFM指标',
		name: 'rfm',
		type: 'List',
		attributeList: [{
			attribute: 'trade_first_time',
			name: '第一次购买时间',
			defaultValue: '-',
			unit: '',
			editable: false
		}, {
			attribute: 'trade_first_amount',
			name: '第一次购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}, {
			attribute: 'trade_first_interval',
			name: '第一次购买间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_last_time',
			name: '最后一次购买时间',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_last_amount',
			name: '最后一次购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_last_interval',
			name: '最后一次购买间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_tidcount',
			name: '累计购买订单数',
			defaultValue: '-',
			unit: ' 单',
			editable: false
		}, {
			attribute: 'trade_count',
			name: '累计购买次数',
			defaultValue: '-',
			unit: ' 次',
			editable: false
		}, {
			attribute: 'trade_amount',
			name: '累计购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_item_num',
			name: '累计购买件数',
			defaultValue: '-',
			unit: ' 件',
			editable: false
		}, {
			attribute: 'trade_avg_amount',
			name: '平均每次购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_avg_item_num',
			name: '平均每次购买件数',
			defaultValue: '-',
			unit: ' 件',
			editable: false
		}, {
			attribute: 'trade_avg_buy_interval',
			name: '平均每次购买间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_refund_count',
			name: '退款次数',
			defaultValue: '-',
			unit: ' 次',
			editable: false
		}, {
			attribute: 'trade_refund_amount',
			name: '退款金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}, {
			attribute: 'trade_avg_confirm_interval',
			name: '平均发货到确认收货间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_max_amount',
			name: '最大单笔订单购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}, {
			attribute: 'trade_order_discount_fee',
			name: '订单级优惠费用',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}]
	}]
};

const other = {
	title: '会员互动',
	name: 'other',
	icon: '',
	attributeBlock: [{
		title: '会员互动',
		name: 'member',
		attributeList: [{
			attribute: 'cardGrade',
			name: '会员等级',
			defaultValue: '',
			unit: '',
			valueMap: {
				1: '普通会员',
				2: '高级会员',
				3: 'VIP会员',
				4: '至尊VIP',
				'': '未开通'
			},
			editable: false,
			isInListMode: true
		}, {
			attribute: 'effectTime',
			name: '等级生效日期',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'expireTime',
			name: '等级失效日期',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'currentPoint',
			name: '当前积分',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'totalGet',
			name: '历史积分',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'signCount',
			name: '签到次数',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'exchangeCount',
			name: '兑换次数',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}]
	}, {
		title: '社交绑定',
		name: 'social',
		attributeList: [{
			attribute: 'wechatNick',
			name: '微信昵称',
			defaultValue: '未认证',
			unit: '',
			editable: false,
			isInListMode: false
		}, {
			attribute: 'sinawbUserName',
			name: '微博昵称',
			defaultValue: '未认证',
			unit: '',
			editable: false,
			isInListMode: false
		}]
	}]
};

const CustomerAttributeSetting = [
	customer,
	consumer,
	other
];

export const TagsMapping = {
	'male': '男性用户',
	'female': '女性用户',
	'family': '家庭用户',
	// 'sex_unknown': '性别未识别', // don't display negative label
	'school': '学校人员',
	'company_employ': '公司白领',
	'gov_institute': '政府机构人员',
	'hospital': '医护人员',
	'mall': '商场职员',
	'finance_institute': '金融机构职员',
	// 'job_unknown': '职业未识别', // don't display negative label
	'yemaozi': '夜猫子',
	'wanjiangou': '晚间购',
	'shangbangou': '上班时段购',
	'zaochengou': '早晨购',
	// 'time_unknown': '购物时段偏好未识别', // don't display negative label
	'pingshigou': '平时购',
	'zhoumogou': '周末购',
	// 'date_unknown': '购物日期偏好未识别', // don't display negative label
	'sportman': '运动达人',
	'nbnm': '奶爸奶妈',
	'jyet': '家有儿童',
	'houseman': '居家能手',
	'ccc': '3C数码控',
	'bfm': '白富美',
	'foodlover': '美食家',
	// 'life_unknown': '生活方式未识别', // don't display negative label
	'shouji': '手机购',
	// 'non_shouji': '非手机购', // don't display negative label
	'jhs': '聚划算购',
	// 'non_jhs': '非聚划算购', // don't display negative label
	'discount_sense1': '打折敏感度指数1',
	'discount_sense2': '打折敏感度指数2',
	'discount_sense3': '打折敏感度指数3',
	'discount_sense4': '打折敏感度指数4',
	'discount_sense5': '打折敏感度指数5'
};

export const RfmLabel = {
	1: '最近30天',
	2: '最近60天',
	3: '最近90天',
	4: '最近180天',
	5: '最近360天',
	6: '时间不限'
};

export const DefinedTypeOptionList = [
	{
		name: '字符选择',
		value: 'CHAR_SELECT'
	}, {
		name: '数字选择',
		value: 'NUMBER_SELECT'
	}, {
		name: '日期选择',
		value: 'DATE_SELECT'
	}, {
		name: '字符输入',
		value: 'CHAR_INPUT'
	}, {
		name: '数字输入',
		value: 'NUMBER_INPUT'
	}
];

export const DEFAULT_ATTRIBUTE_SETTING = {
	attribute: '',
	name: '',
	defaultValue: '',
	editable: true,
	remark: '',
	isInListMode: false,
	isDisable: false,
	type: DefinedTypeOptionList[0].value,
	optional: []
};

export default CustomerAttributeSetting;
<commit_msg>fix(customer-profile-board): 【列表模式】基本信息-客户的姓名为空，应显示“-” (#208)<commit_after>/**
 * @author jianzhe.ding
 * @homepage https://github.com/discipled/
 * @since 2016-07-25 11:50
 */

const customer = {
	title: '客户属性',
	name: 'customer',
	icon: '',
	attributeBlock: [{
		title: '基本信息',
		name: 'base',
		attributeList: [{
			attribute: 'full_name',
			name: '姓名',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'text',
			validate: ['/^\\w{1, 50}$/'],
			isInListMode: true
		}, {
			attribute: 'sex',
			name: '性别',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'radio',
			valueMap: {
				m: '男',
				f: '女',
				'': '未知'
			},
			validate: [],
			isInListMode: true
		}, {
			attribute: 'birthday',
			name: '出生日期',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'date',
			validate: [],
			isInListMode: true
		}, {
			attribute: 'age',
			name: '年龄',
			defaultValue: '-',
			unit: '岁',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'mobile',
			name: '常用手机',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'text',
			validate: ['/^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9]){1}\\d{8}$/']
		}, {
			attribute: 'mobile',
			name: '支付手机',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'mobile',
			name: '最新收货手机',
			defaultValue: '-',
			unit: '',
			editable: false
		}, {
			attribute: 'buyer_email',
			name: 'email邮箱',
			defaultValue: '-',
			unit: '',
			editable: false,
			type: 'text',
			validate: ['/^\\w{1, 50}$/', '/@.+(.com|.cn)$/']
		}, {
			attribute: 'address_zip',
			name: '常用地址',
			defaultValue: '-',
			unit: '',
			editable: false,
			attributes: [{
				attribute: 'receiver_state',
				name: '省份',
				defaultValue: '-',
				unit: '',
				type: 'select',
				isInListMode: true
			}, {
				attribute: 'receiver_city',
				name: '城市',
				defaultValue: '-',
				unit: '',
				type: 'select',
				isInListMode: true
			}, {
				attribute: 'receiver_district',
				name: '区县',
				defaultValue: '-',
				unit: '',
				type: 'select',
				isInListMode: true
			}, {
				attribute: 'receiver_address',
				type: 'text',
				defaultValue: '-',
				unit: '',
				validate: ['/^\\w{1, 50}$/']
			}, {
				attribute: 'receiver_zip',
				type: 'text',
				defaultValue: '-',
				unit: '',
				validate: ['/^\\d{1, 6}$/']
			}]
		}]
	}, {
		title: '更多个人信息',
		name: 'customerDefined',
		attributeList: [
		/* {
				attribute: 'job',
				name: '职业',
				defaultValue: '自由职业',
				editable: true,
				type: 'text',
				validate: ['/^\\w{1, 50}$/'],
				isInListMode: true
			}, {
				attribute: '',
				name: '身高/cm',
				defaultValue: '-',
				editable: true,
				type: 'text',
				validate: ['/^\\d{1, 5}$/'],
				isInListMode: true
			}, {
				attribute: '',
				name: '体重/kg',
				defaultValue: '-',
				editable: true,
				type: 'text',
				validate: ['/^\\d{1, 5}$/'],
				isInListMode: true
			}, {
				attribute: '',
				name: '星座',
				defaultValue: '-',
				editable: false,
				isInListMode: true
			}, {
				attribute: '',
				name: '血型',
				defaultValue: '',
				editable: true,
				type: 'radio',
				enum: [{
					name: 'A',
					value: 'a'
				}, {
					name: 'B',
					value: 'b'
				}, {
					name: 'AB',
					value: 'ab'
				}, {
					name: 'O',
					value: 'o'
				}, {
					name: '未知',
					value: ''
				}],
				isInListMode: true
			}*/
		]
	}]
};

const consumer = {
	title: '消费属性',
	name: 'consumer',
	icon: '',
	attributeBlock: [{
		title: '基本消费指标',
		name: 'base',
		attributeList: [{
			attribute: '',
			name: '客户来源',
			defaultValue: '淘宝',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: '',
			name: '客户类型',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: false
		}, {
			attribute: 'vip_info',
			name: '淘宝全站等级',
			defaultValue: '-',
			valueMap: {
				'asso_vip': '荣誉会员',
				'c': '普通会员',
				'vip1': 'VIP1',
				'vip2': 'VIP2',
				'vip3': 'VIP3',
				'vip4': 'VIP4',
				'vip5': 'VIP5',
				'vip6': 'VIP6',
				'-': '-'
			},
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'buyer_credit_lev',
			name: '信用等级',
			defaultValue: '-',
			unit: '',
			editable: false
		}, {
			attribute: '',
			name: '买家好评率',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}]
	}, {
		title: 'RFM指标',
		name: 'rfm',
		type: 'List',
		attributeList: [{
			attribute: 'trade_first_time',
			name: '第一次购买时间',
			defaultValue: '-',
			unit: '',
			editable: false
		}, {
			attribute: 'trade_first_amount',
			name: '第一次购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}, {
			attribute: 'trade_first_interval',
			name: '第一次购买间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_last_time',
			name: '最后一次购买时间',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_last_amount',
			name: '最后一次购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_last_interval',
			name: '最后一次购买间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_tidcount',
			name: '累计购买订单数',
			defaultValue: '-',
			unit: ' 单',
			editable: false
		}, {
			attribute: 'trade_count',
			name: '累计购买次数',
			defaultValue: '-',
			unit: ' 次',
			editable: false
		}, {
			attribute: 'trade_amount',
			name: '累计购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_item_num',
			name: '累计购买件数',
			defaultValue: '-',
			unit: ' 件',
			editable: false
		}, {
			attribute: 'trade_avg_amount',
			name: '平均每次购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false,
			isInListMode: true
		}, {
			attribute: 'trade_avg_item_num',
			name: '平均每次购买件数',
			defaultValue: '-',
			unit: ' 件',
			editable: false
		}, {
			attribute: 'trade_avg_buy_interval',
			name: '平均每次购买间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_refund_count',
			name: '退款次数',
			defaultValue: '-',
			unit: ' 次',
			editable: false
		}, {
			attribute: 'trade_refund_amount',
			name: '退款金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}, {
			attribute: 'trade_avg_confirm_interval',
			name: '平均发货到确认收货间隔',
			defaultValue: '-',
			unit: ' 天',
			editable: false
		}, {
			attribute: 'trade_max_amount',
			name: '最大单笔订单购买金额',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}, {
			attribute: 'trade_order_discount_fee',
			name: '订单级优惠费用',
			defaultValue: '-',
			unit: ' 元',
			currency: true,
			editable: false
		}]
	}]
};

const other = {
	title: '会员互动',
	name: 'other',
	icon: '',
	attributeBlock: [{
		title: '会员互动',
		name: 'member',
		attributeList: [{
			attribute: 'cardGrade',
			name: '会员等级',
			defaultValue: '-',
			unit: '',
			valueMap: {
				1: '普通会员',
				2: '高级会员',
				3: 'VIP会员',
				4: '至尊VIP',
				'': '未开通'
			},
			editable: false,
			isInListMode: true
		}, {
			attribute: 'effectTime',
			name: '等级生效日期',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'expireTime',
			name: '等级失效日期',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'currentPoint',
			name: '当前积分',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'totalGet',
			name: '历史积分',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'signCount',
			name: '签到次数',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}, {
			attribute: 'exchangeCount',
			name: '兑换次数',
			defaultValue: '-',
			unit: '',
			editable: false,
			isInListMode: true
		}]
	}, {
		title: '社交绑定',
		name: 'social',
		attributeList: [{
			attribute: 'wechatNick',
			name: '微信昵称',
			defaultValue: '未认证',
			unit: '',
			editable: false,
			isInListMode: false
		}, {
			attribute: 'sinawbUserName',
			name: '微博昵称',
			defaultValue: '未认证',
			unit: '',
			editable: false,
			isInListMode: false
		}]
	}]
};

const CustomerAttributeSetting = [
	customer,
	consumer,
	other
];

export const TagsMapping = {
	'male': '男性用户',
	'female': '女性用户',
	'family': '家庭用户',
	// 'sex_unknown': '性别未识别', // don't display negative label
	'school': '学校人员',
	'company_employ': '公司白领',
	'gov_institute': '政府机构人员',
	'hospital': '医护人员',
	'mall': '商场职员',
	'finance_institute': '金融机构职员',
	// 'job_unknown': '职业未识别', // don't display negative label
	'yemaozi': '夜猫子',
	'wanjiangou': '晚间购',
	'shangbangou': '上班时段购',
	'zaochengou': '早晨购',
	// 'time_unknown': '购物时段偏好未识别', // don't display negative label
	'pingshigou': '平时购',
	'zhoumogou': '周末购',
	// 'date_unknown': '购物日期偏好未识别', // don't display negative label
	'sportman': '运动达人',
	'nbnm': '奶爸奶妈',
	'jyet': '家有儿童',
	'houseman': '居家能手',
	'ccc': '3C数码控',
	'bfm': '白富美',
	'foodlover': '美食家',
	// 'life_unknown': '生活方式未识别', // don't display negative label
	'shouji': '手机购',
	// 'non_shouji': '非手机购', // don't display negative label
	'jhs': '聚划算购',
	// 'non_jhs': '非聚划算购', // don't display negative label
	'discount_sense1': '打折敏感度指数1',
	'discount_sense2': '打折敏感度指数2',
	'discount_sense3': '打折敏感度指数3',
	'discount_sense4': '打折敏感度指数4',
	'discount_sense5': '打折敏感度指数5'
};

export const RfmLabel = {
	1: '最近30天',
	2: '最近60天',
	3: '最近90天',
	4: '最近180天',
	5: '最近360天',
	6: '时间不限'
};

export const DefinedTypeOptionList = [
	{
		name: '字符选择',
		value: 'CHAR_SELECT'
	}, {
		name: '数字选择',
		value: 'NUMBER_SELECT'
	}, {
		name: '日期选择',
		value: 'DATE_SELECT'
	}, {
		name: '字符输入',
		value: 'CHAR_INPUT'
	}, {
		name: '数字输入',
		value: 'NUMBER_INPUT'
	}
];

export const DEFAULT_ATTRIBUTE_SETTING = {
	attribute: '',
	name: '',
	defaultValue: '',
	editable: true,
	remark: '',
	isInListMode: false,
	isDisable: false,
	type: DefinedTypeOptionList[0].value,
	optional: []
};

export default CustomerAttributeSetting;
<|endoftext|>


<commit_before>var assert = require('assert');
var expect = require('chai').expect;
var waitForOncoprint = require('./../specUtils').waitForOncoprint;
var setOncoprintMutationsMenuOpen = require('./../specUtils').setOncoprintMutationsMenuOpen;
var goToUrlAndSetLocalStorage = require('./../specUtils').goToUrlAndSetLocalStorage;
var waitForNetworkQuiet = require('./../specUtils').waitForNetworkQuiet;
var sessionServiceIsEnabled = require('./../specUtils').sessionServiceIsEnabled;
var assertScreenShotMatch = require('../../lib/testUtils').assertScreenShotMatch;

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, "");

function waitForAndCheckPlotsTab() {
    browser.waitForVisible('div[data-test="PlotsTabPlotDiv"]', 10000);
    var res = browser.checkElement('div[data-test="PlotsTabEntireDiv"]', { hide:['.qtip'] });
    assertScreenShotMatch(res);
}

function runResultsTestSuite(prefix){

    it(`${prefix} render the oncoprint`, function(){
        waitForOncoprint(10000);
        var res = browser.checkElement('.oncoprintContainer', { hide:['.oncoprint__controls']}); // just hide the controls bc for some reason they keep showing up transparent in this test only
        assertScreenShotMatch(res);
    });

    // can't get it to pass reliably
    it.skip(`${prefix} igv_tab tab`, function(){
        browser.click("a.tabAnchor_cnSegments");
        browser.waitForExist('#cnSegmentsFrame', 20000);
        var res = browser.checkElement('.cnSegmentsMSKTabs',{hide:['.qtip'] });
        assertScreenShotMatch(res);
    });

    it(`${prefix} cancer type summary`, function(){
        browser.click("a.tabAnchor_cancerTypesSummary");
        browser.waitForVisible('[data-test="cancerTypeSummaryChart"]',10000);
        browser.waitForExist('[data-test="cancerTypeSummaryWrapper"]', 5000);
        var res = browser.checkElement('[data-test="cancerTypeSummaryWrapper"]', { hide:['.qtip'] });
        assertScreenShotMatch(res);
    });

    it(`${prefix} mutex tab`, function(){
        browser.click("a.tabAnchor_mutualExclusivity");
        var res = browser.checkElement('[data-test="mutualExclusivityTabDiv"]',{ hide:['.qtip'] });
        assertScreenShotMatch(res);
    });

    it(`${prefix} plots tab`, function(){
        browser.click("a.tabAnchor_plots");
        waitForAndCheckPlotsTab();
    });

    it.skip(`${prefix} mutation tab`, function(){
        browser.click("a.tabAnchor_mutations");
        browser.waitForVisible('.borderedChart svg',20000);
        var res = browser.checkElement('[data-test="mutationsTabDiv"]',{hide:['.qtip', '[data-test=view3DStructure]', '[data-test=GeneSummaryUniProt]'], viewportChangePause:4000}); // hide these things because the timing of data loading makes this test so flaky
        assertScreenShotMatch(res);
    });

    it(`${prefix} coexpression tab`, function(){
        browser.click("a.tabAnchor_coexpression");
        browser.waitForVisible('div[data-test="CoExpressionPlot"]',10000);
        var res = browser.checkElement('[data-test="coExpressionTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });

    it(`${prefix} enrichments tab`, function(){
        browser.click("a.tabAnchor_enrichments");
        browser.waitForVisible('div[data-test="MutationEnrichmentsTab"]',10000);
        browser.click('b=CDK14');
        browser.waitForExist('[data-test="enrichmentsTabDiv"]', 10000);
        var res = browser.checkElement('[data-test="enrichmentsTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });

    it(`${prefix} survival tab`, function(){
        browser.click("a.tabAnchor_survival");
        browser.waitForVisible('[data-test=SurvivalChart] svg',10000);
        var res = browser.checkElement('[data-test="survivalTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });

    it.skip(`${prefix} network tab`, function(){
        // TODO: unskip this when bug is fixed

        browser.click("a.tabAnchor_network");

        browser.waitForExist('iframe#networkFrame', 10000);

        browser.frame('networkFrame', function(err, result) {
                if (err) console.log(err);
            });
        browser.waitForVisible('#cytoscapeweb canvas',60000);
        browser.execute(function(){
            $("<style>canvas { visibility: hidden} </style>").appendTo("body");
        });
        browser.frame(null);
        var res = browser.checkElement("#networkFrame",{hide:['.qtip','canvas'] });

        assertScreenShotMatch(res);
    });

    it.skip(`${prefix} data_download tab`, function(){
        browser.click("a.tabAnchor_download");
        //  browser.pause(1000);
        browser.waitForExist("#text_area_gene_alteration_freq",20000);
        browser.waitUntil(function(){ return browser.getValue("#text_area_gene_alteration_freq").length > 0 },20000);
        var res = browser.checkElement('[data-test="downloadTabDiv"]',{hide:['.qtip'] });
        assertScreenShotMatch(res);
    });
}

describe('result page screenshot tests', function(){
    before(function(){
        var url = `${CBIOPORTAL_URL}/index.do?tab_index=tab_visualize&cancer_study_list=coadread_tcga_pub&cancer_study_id=coadread_tcga_pub&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&Z_SCORE_THRESHOLD=2.0&case_set_id=coadread_tcga_pub_nonhypermut&case_ids=&gene_list=KRAS+NRAS+BRAF&gene_set_choice=user-defined-list&Action=Submit&show_samples=false&`;
        goToUrlAndSetLocalStorage(url);
        waitForOncoprint(10000);
    });

    runResultsTestSuite('no session')

});

describe('expression tab', function() {
    it("expression tab with complex oql", ()=>{
        goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/results/expression?cancer_study_id=all&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=all&gene_list=TP53%3AMUT%3B&geneset_list=%20&tab_index=tab_visualize&Action=Submit&cancer_study_list=acc_tcga%2Cchol_tcga%2Cesca_tcga&show_samples=false`);
        browser.waitForExist(".borderedChart svg", 60000);
        var res = browser.checkElement('[data-test="expressionTabDiv"]');
        assertScreenShotMatch(res);
    });
});

describe("download tab screenshot tests", function() {
    it("download tab - msk_impact_2017 with ALK and SOS1 - SOS1 should be not sequenced", function() {
        var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=msk_impact_2017&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=msk_impact_2017_all&gene_list=ALK%2520SOS1&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=msk_impact_2017_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=msk_impact_2017_cna`;
        goToUrlAndSetLocalStorage(url);
        browser.waitForExist("a.tabAnchor_download", 10000);
        browser.click("a.tabAnchor_download");
        browser.waitForExist('[data-test="dataDownloadGeneAlterationTable"] tr > td > svg', 20000);
        browser.waitForExist('[data-test="downloadTabDiv"]', 5000);
        var res = browser.checkElement('[data-test="downloadTabDiv"]',{hide:['.qtip'] });
        assertScreenShotMatch(res);
    });
});

describe.skip('patient view page screenshot test', function(){
    before(function(){
        var url = `${CBIOPORTAL_URL}/patient?studyId=lgg_ucsf_2014&caseId=P04`;
        goToUrlAndSetLocalStorage(url);
    });

    it('patient view lgg_ucsf_2014 P04', function() {
        // find oncokb image
        var oncokbIndicator = $('[data-test="oncogenic-icon-image"]');
        oncokbIndicator.waitForExist(30000);
        // find vaf plot
        var vafPlot = $('.vafPlot');
        vafPlot.waitForExist(30000);

        var res = browser.checkElement('#mainColumn', {hide:['.qtip'] });
        assertScreenShotMatch(res);
    });
});

describe("enrichments tab screenshot tests", function() {
    before(function() {
        var url = `${CBIOPORTAL_URL}/results/enrichments?tab_index=tab_visualize&cancer_study_list=coadread_tcga_pub&cancer_study_id=coadread_tcga_pub&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&Z_SCORE_THRESHOLD=2.0&case_set_id=coadread_tcga_pub_nonhypermut&case_ids=&gene_list=KRAS+NRAS+BRAF&gene_set_choice=user-defined-list&Action=Submit`;
        goToUrlAndSetLocalStorage(url);
    });
    it('enrichments tab coadread_tcga_pub mRNA profile', function(){
        browser.waitForVisible('div[data-test="MutationEnrichmentsTab"]',10000);
        browser.waitForVisible('a=mRNA', 10000);
        browser.click('a=mRNA');
        browser.waitForVisible('div[data-test="MRNAEnrichmentsTab"]',20000);
        browser.waitForVisible('b=MERTK', 10000);
        browser.click('b=MERTK');
        browser.waitForVisible('div[data-test="MiniBoxPlot"]', 20000);
        var res = browser.checkElement('[data-test="enrichmentsTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });
});

describe('result page tabs, loading from session id', function(){
    before(function(){
        // only run these tests if session service is enabled
        if (sessionServiceIsEnabled() === false) {
            this.skip();
        }

        var url = `${CBIOPORTAL_URL}/results?session_id=5bbe8197498eb8b3d5684271`;
        goToUrlAndSetLocalStorage(url);
        waitForOncoprint(10000);
    });

    runResultsTestSuite('session');
});
<commit_msg>increase timeout<commit_after>var assert = require('assert');
var expect = require('chai').expect;
var waitForOncoprint = require('./../specUtils').waitForOncoprint;
var setOncoprintMutationsMenuOpen = require('./../specUtils').setOncoprintMutationsMenuOpen;
var goToUrlAndSetLocalStorage = require('./../specUtils').goToUrlAndSetLocalStorage;
var waitForNetworkQuiet = require('./../specUtils').waitForNetworkQuiet;
var sessionServiceIsEnabled = require('./../specUtils').sessionServiceIsEnabled;
var assertScreenShotMatch = require('../../lib/testUtils').assertScreenShotMatch;

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, "");

function waitForAndCheckPlotsTab() {
    browser.waitForVisible('div[data-test="PlotsTabPlotDiv"]', 10000);
    var res = browser.checkElement('div[data-test="PlotsTabEntireDiv"]', { hide:['.qtip'] });
    assertScreenShotMatch(res);
}

function runResultsTestSuite(prefix){

    it(`${prefix} render the oncoprint`, function(){
        waitForOncoprint(10000);
        var res = browser.checkElement('.oncoprintContainer', { hide:['.oncoprint__controls']}); // just hide the controls bc for some reason they keep showing up transparent in this test only
        assertScreenShotMatch(res);
    });

    // can't get it to pass reliably
    it.skip(`${prefix} igv_tab tab`, function(){
        browser.click("a.tabAnchor_cnSegments");
        browser.waitForExist('#cnSegmentsFrame', 20000);
        var res = browser.checkElement('.cnSegmentsMSKTabs',{hide:['.qtip'] });
        assertScreenShotMatch(res);
    });

    it(`${prefix} cancer type summary`, function(){
        browser.click("a.tabAnchor_cancerTypesSummary");
        browser.waitForVisible('[data-test="cancerTypeSummaryChart"]',10000);
        browser.waitForExist('[data-test="cancerTypeSummaryWrapper"]', 5000);
        var res = browser.checkElement('[data-test="cancerTypeSummaryWrapper"]', { hide:['.qtip'] });
        assertScreenShotMatch(res);
    });

    it(`${prefix} mutex tab`, function(){
        browser.click("a.tabAnchor_mutualExclusivity");
        var res = browser.checkElement('[data-test="mutualExclusivityTabDiv"]',{ hide:['.qtip'] });
        assertScreenShotMatch(res);
    });

    it(`${prefix} plots tab`, function(){
        browser.click("a.tabAnchor_plots");
        waitForAndCheckPlotsTab();
    });

    it.skip(`${prefix} mutation tab`, function(){
        browser.click("a.tabAnchor_mutations");
        browser.waitForVisible('.borderedChart svg',20000);
        var res = browser.checkElement('[data-test="mutationsTabDiv"]',{hide:['.qtip', '[data-test=view3DStructure]', '[data-test=GeneSummaryUniProt]'], viewportChangePause:4000}); // hide these things because the timing of data loading makes this test so flaky
        assertScreenShotMatch(res);
    });

    it(`${prefix} coexpression tab`, function(){
        browser.click("a.tabAnchor_coexpression");
        browser.waitForVisible('div[data-test="CoExpressionPlot"]',10000);
        var res = browser.checkElement('[data-test="coExpressionTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });

    it(`${prefix} enrichments tab`, function(){
        browser.click("a.tabAnchor_enrichments");
        browser.waitForVisible('div[data-test="MutationEnrichmentsTab"]',10000);
        browser.click('b=CDK14');
        browser.waitForExist('[data-test="enrichmentsTabDiv"]', 10000);
        var res = browser.checkElement('[data-test="enrichmentsTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });

    it(`${prefix} survival tab`, function(){
        browser.click("a.tabAnchor_survival");
        browser.waitForVisible('[data-test=SurvivalChart] svg',10000);
        var res = browser.checkElement('[data-test="survivalTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });

    it.skip(`${prefix} network tab`, function(){
        // TODO: unskip this when bug is fixed

        browser.click("a.tabAnchor_network");

        browser.waitForExist('iframe#networkFrame', 10000);

        browser.frame('networkFrame', function(err, result) {
                if (err) console.log(err);
            });
        browser.waitForVisible('#cytoscapeweb canvas',60000);
        browser.execute(function(){
            $("<style>canvas { visibility: hidden} </style>").appendTo("body");
        });
        browser.frame(null);
        var res = browser.checkElement("#networkFrame",{hide:['.qtip','canvas'] });

        assertScreenShotMatch(res);
    });

    it.skip(`${prefix} data_download tab`, function(){
        browser.click("a.tabAnchor_download");
        //  browser.pause(1000);
        browser.waitForExist("#text_area_gene_alteration_freq",20000);
        browser.waitUntil(function(){ return browser.getValue("#text_area_gene_alteration_freq").length > 0 },20000);
        var res = browser.checkElement('[data-test="downloadTabDiv"]',{hide:['.qtip'] });
        assertScreenShotMatch(res);
    });
}

describe('result page screenshot tests', function(){
    before(function(){
        var url = `${CBIOPORTAL_URL}/index.do?tab_index=tab_visualize&cancer_study_list=coadread_tcga_pub&cancer_study_id=coadread_tcga_pub&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&Z_SCORE_THRESHOLD=2.0&case_set_id=coadread_tcga_pub_nonhypermut&case_ids=&gene_list=KRAS+NRAS+BRAF&gene_set_choice=user-defined-list&Action=Submit&show_samples=false&`;
        goToUrlAndSetLocalStorage(url);
        waitForOncoprint(10000);
    });

    runResultsTestSuite('no session')

});

describe('expression tab', function() {
    it("expression tab with complex oql", ()=>{
        goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/results/expression?cancer_study_id=all&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=all&gene_list=TP53%3AMUT%3B&geneset_list=%20&tab_index=tab_visualize&Action=Submit&cancer_study_list=acc_tcga%2Cchol_tcga%2Cesca_tcga&show_samples=false`);
        browser.waitForExist(".borderedChart svg", 60000);
        var res = browser.checkElement('[data-test="expressionTabDiv"]');
        assertScreenShotMatch(res);
    });
});

describe("download tab screenshot tests", function() {
    it("download tab - msk_impact_2017 with ALK and SOS1 - SOS1 should be not sequenced", function() {
        var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=msk_impact_2017&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=msk_impact_2017_all&gene_list=ALK%2520SOS1&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=msk_impact_2017_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=msk_impact_2017_cna`;
        goToUrlAndSetLocalStorage(url);
        browser.waitForExist("a.tabAnchor_download", 10000);
        browser.click("a.tabAnchor_download");
        browser.waitForExist('[data-test="dataDownloadGeneAlterationTable"] tr > td > svg', 20000);
        browser.waitForExist('[data-test="downloadTabDiv"]', 5000);
        var res = browser.checkElement('[data-test="downloadTabDiv"]',{hide:['.qtip'] });
        assertScreenShotMatch(res);
    });
});

describe.skip('patient view page screenshot test', function(){
    before(function(){
        var url = `${CBIOPORTAL_URL}/patient?studyId=lgg_ucsf_2014&caseId=P04`;
        goToUrlAndSetLocalStorage(url);
    });

    it('patient view lgg_ucsf_2014 P04', function() {
        // find oncokb image
        var oncokbIndicator = $('[data-test="oncogenic-icon-image"]');
        oncokbIndicator.waitForExist(30000);
        // find vaf plot
        var vafPlot = $('.vafPlot');
        vafPlot.waitForExist(30000);

        var res = browser.checkElement('#mainColumn', {hide:['.qtip'] });
        assertScreenShotMatch(res);
    });
});

describe("enrichments tab screenshot tests", function() {
    before(function() {
        var url = `${CBIOPORTAL_URL}/results/enrichments?tab_index=tab_visualize&cancer_study_list=coadread_tcga_pub&cancer_study_id=coadread_tcga_pub&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&Z_SCORE_THRESHOLD=2.0&case_set_id=coadread_tcga_pub_nonhypermut&case_ids=&gene_list=KRAS+NRAS+BRAF&gene_set_choice=user-defined-list&Action=Submit`;
        goToUrlAndSetLocalStorage(url);
    });
    it('enrichments tab coadread_tcga_pub mRNA profile', function(){
        browser.waitForVisible('div[data-test="MutationEnrichmentsTab"]',10000);
        browser.waitForVisible('a=mRNA', 10000);
        browser.click('a=mRNA');
        browser.waitForVisible('div[data-test="MRNAEnrichmentsTab"]',20000);
        browser.waitForVisible('b=MERTK', 10000);
        browser.click('b=MERTK');
        browser.waitForVisible('div[data-test="MiniBoxPlot"]', 20000);
        var res = browser.checkElement('[data-test="enrichmentsTabDiv"]', { hide:['.qtip'] } );
        assertScreenShotMatch(res);
    });
});

describe('result page tabs, loading from session id', function(){
    before(function(){
        // only run these tests if session service is enabled
        if (sessionServiceIsEnabled() === false) {
            this.skip();
        }

        var url = `${CBIOPORTAL_URL}/results?session_id=5bbe8197498eb8b3d5684271`;
        goToUrlAndSetLocalStorage(url);
        waitForOncoprint(15000);
    });

    runResultsTestSuite('session');
});
<|endoftext|>


<commit_before>/*global __DEV__:true, self: true, document: true, window: true, Event: true, localStorage: true, expect: true, it: true, beforeEach: true, describe: true */
/*jshint
  browser: true,
  devel: true,
  node: true,
  nonstandard: true,
  browser:   true,
  regexp:    true,
  smarttabs: true,
  unused: true,
  bitwise:  true,
  curly:    true,
  eqeqeq:   false,
  forin:    false,
  immed:    false,
  latedef:  false,
  noarg:    true,
  noempty:  false,
  nonew:    false,
  plusplus: false,
  regexp:   false,
  undef:    true,
  strict:   false,
  trailing: false,
  asi:      false,
  debug:    true,
  es5:      false,
  esnext:   false,
  evil:     false,
  expr:     true,
  funcscope: false,
  globalstrict: false,
  iterator: false,
  lastsemic: false,
  laxbreak: false,
  laxcomma: false,
  loopfunc: false,
  multistr: false,
  onecase:  false,
  proto:    false,
  regexdash: false,
  scripturl: true,
  smarttabs: false,
  sub:      true,
  supernew: false,
  boss:     false,
  newcap:   false,
  eqnull:   false,
  shadow:   false
*/
<commit_msg>fix jshint config<commit_after>/*global __DEV__:true, self: true, document: true, window: true, Event: true, localStorage: true, expect: true, it: true, beforeEach: true, describe: true */
/*jshint
  browser: true,
  devel: true,
  node: true,
  nonstandard: true,
  browser:   true,
  regexp:    true,
  smarttabs: true,
  unused: true,
  bitwise:  true,
  curly:    true,
  eqeqeq:   false,
  forin:    false,
  immed:    false,
  latedef:  false,
  noarg:    true,
  noempty:  false,
  nonew:    false,
  plusplus: false,
  regexp:   false,
  undef:    true,
  strict:   false,
  trailing: false,
  asi:      false,
  debug:    true,
  es5:      true,
  esnext:   false,
  evil:     false,
  expr:     true,
  funcscope: false,
  globalstrict: false,
  iterator: false,
  lastsemic: false,
  laxbreak: false,
  laxcomma: false,
  loopfunc: false,
  multistr: false,
  onecase:  false,
  proto:    false,
  regexdash: false,
  scripturl: true,
  smarttabs: false,
  sub:      true,
  supernew: false,
  boss:     false,
  newcap:   false,
  eqnull:   false,
  shadow:   false
*/
<|endoftext|>


<commit_before>/*jslint node: true */
"use strict";

var Stopwatch = require('../lib/Stopwatch');
var defaultPrecision = 20;
var assert = require('assert');
// var TestHelper = require('./testhelper');
var should = require('should');

describe('stopwatch 2', function () {
    this.timeout(5000);

    it.skip('start and read (100ms)', function (done) {
        var testtime = 100;

        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            var delta = stopwatch.read();
            TestHelper.assertCloseEnough(testtime, delta, defaultPrecision);
            done();
        }, testtime);
    });

    it('autostart set to false does NOT automatically start stopwatch', function (done) {
        var testtime = 10;

        var stopwatch = new Stopwatch(false);
        setTimeout(function () {
            var delta = stopwatch.read();
            assert.ok(isNaN(delta));
            done();
        }, testtime);
    });

    it.skip('with two stopwatches, do independent reads of each', function (done) {
        var stopwatch1 = new Stopwatch();
        var stopwatch2 = new Stopwatch();

        stopwatch1.start();

        //start first stopwatch, then do a read .3s later
        var testtimeA = 300;
        setTimeout(function () {
            var delta1 = stopwatch1.read();
            TestHelper.assertCloseEnough(testtimeA, delta1, defaultPrecision);
        }, testtimeA);

        //start second stopwatch .1s second after the first, then do a read .5s later
        var testtimeB = 500;
        setTimeout(function () {
            stopwatch2.start();
            setTimeout(function () {
                var delta2 = stopwatch2.read();
                TestHelper.assertCloseEnough(testtimeB, delta2, defaultPrecision);
                done();
            }, testtimeB);
        }, 100);
    });

    it.skip('start, stop, and read should return the time at stop', function (done) {
        var testtime = 100;

        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            stopwatch.stop();

            setTimeout(function () {
                var delta = stopwatch.read();
                TestHelper.assertCloseEnough(testtime, delta, defaultPrecision);
                done();
            }, 500);
        }, testtime);
    });

    it('performing read without start() or stop() returns NaN', function (done) {
        var stopwatch = new Stopwatch();
        assert.ok(isNaN(stopwatch.read()));
        done();
    });

    it('performing read without start() returns NaN', function (done) {
        var stopwatch = new Stopwatch();
        stopwatch.stop();
        assert.ok(isNaN(stopwatch.read()));
        done();
    });

    it.skip('executing stop twice should return time at second stop', function (done) {
        //start(), wait .1s, stop(), wait .2s, stop(), wait .5s, read(), ensure delta = .3s
        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            stopwatch.stop();

            setTimeout(function () {
                TestHelper.assertCloseEnough(100 + 200, stopwatch.stop(), defaultPrecision);

                setTimeout(function () {
                    var delta = stopwatch.read();
                    TestHelper.assertCloseEnough(100 + 200, delta, defaultPrecision);
                    done();
                }, 500);
            }, 200);
        }, 100);
    });

    it.skip('ensure that stop() returns time', function (done) {
        var testtime = 100;
        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            var delta = stopwatch.stop();
            TestHelper.assertCloseEnough(testtime, delta, defaultPrecision);
            done();
        }, testtime);
    });
});

<commit_msg>migrating stopwatch back to child project<commit_after>/*jslint node: true */
"use strict";

var Stopwatch = require('../lib/Stopwatch');
var defaultPrecision = 20;
var assert = require('assert');
// var TestHelper = require('./testhelper');
var should = require('should');

describe('stopwatch 2', function () {
    this.timeout(5000);

    it.skip('start and read (100ms)', function (done) {
        var testtime = 100;

        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            var delta = stopwatch.read();
            TestHelper.assertCloseEnough(testtime, delta, defaultPrecision);
            done();
        }, testtime);
    });

    it.skip('with two stopwatches, do independent reads of each', function (done) {
        var stopwatch1 = new Stopwatch();
        var stopwatch2 = new Stopwatch();

        stopwatch1.start();

        //start first stopwatch, then do a read .3s later
        var testtimeA = 300;
        setTimeout(function () {
            var delta1 = stopwatch1.read();
            TestHelper.assertCloseEnough(testtimeA, delta1, defaultPrecision);
        }, testtimeA);

        //start second stopwatch .1s second after the first, then do a read .5s later
        var testtimeB = 500;
        setTimeout(function () {
            stopwatch2.start();
            setTimeout(function () {
                var delta2 = stopwatch2.read();
                TestHelper.assertCloseEnough(testtimeB, delta2, defaultPrecision);
                done();
            }, testtimeB);
        }, 100);
    });

    it.skip('start, stop, and read should return the time at stop', function (done) {
        var testtime = 100;

        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            stopwatch.stop();

            setTimeout(function () {
                var delta = stopwatch.read();
                TestHelper.assertCloseEnough(testtime, delta, defaultPrecision);
                done();
            }, 500);
        }, testtime);
    });

    it('performing read without start() or stop() returns NaN', function (done) {
        var stopwatch = new Stopwatch();
        assert.ok(isNaN(stopwatch.read()));
        done();
    });

    it('performing read without start() returns NaN', function (done) {
        var stopwatch = new Stopwatch();
        stopwatch.stop();
        assert.ok(isNaN(stopwatch.read()));
        done();
    });

    it.skip('executing stop twice should return time at second stop', function (done) {
        //start(), wait .1s, stop(), wait .2s, stop(), wait .5s, read(), ensure delta = .3s
        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            stopwatch.stop();

            setTimeout(function () {
                TestHelper.assertCloseEnough(100 + 200, stopwatch.stop(), defaultPrecision);

                setTimeout(function () {
                    var delta = stopwatch.read();
                    TestHelper.assertCloseEnough(100 + 200, delta, defaultPrecision);
                    done();
                }, 500);
            }, 200);
        }, 100);
    });

    it.skip('ensure that stop() returns time', function (done) {
        var testtime = 100;
        var stopwatch = new Stopwatch();
        stopwatch.start();
        setTimeout(function () {
            var delta = stopwatch.stop();
            TestHelper.assertCloseEnough(testtime, delta, defaultPrecision);
            done();
        }, testtime);
    });
});

<|endoftext|>