<commit_before>// Ember controller for list vm into html array
var VmsListController = Ember.ArrayController.extend({
  // Show / hide on html side
  isShowingDeleteConfirmation: false,
  isAllDelete: false,

  // Return model array sorted
  sortModel: function() {
    var model = this.get('model') ;
    var self = this;
  
    // sort vms by id
    var vmsSort = model.sort(function(a, b) {
        return Ember.compare(parseInt(a.id, 10), parseInt(b.id, 10)); 
    }).reverse() ;

    this.set('vms', vmsSort.map(function(model){
      var textStatus = '';
      var warnStatus = false;
      var dangStatus = false;
      var sucStatus = false;
      var status = model.get('status');

      model.set('todelete', false) ;
      model.set('created_at_short', model.get('created_at').getDate() + "/" + (model.get('created_at').getMonth() + 1) + " " +  + model.get('created_at').getHours() + ":" +  + model.get('created_at').getMinutes()) ;

      if (status < 1) {
        textStatus = 'SETUP'; 
        warnStatus = true;
        //if status is negative => setup in progress
        model.set('timeStatus', -parseInt(status)); 
        setTimeout(self.getStatus(model), 1500); 
      }
      if (status > 1) { textStatus = 'RUNNING'; sucStatus = true; model.set('timeStatus', (status)); }
      if (status == 1) { textStatus = 'ERROR'; dangStatus = true; }

      model.set('textStatus', textStatus);
      model.set('sucStatus', sucStatus);
      model.set('warnStatus', warnStatus);
      model.set('dangStatus', dangStatus);
      return model ;
    })) ;

  }.observes('model'),

  getStatus: function(model) {
    $.get("/api/v1/vms/" + model.get('id') + "/setupcomplete")
        .done(function(data) {
          model.set('status', data);
          model.set('timeStatus', data);
          model.set('textStatus', 'RUNNING');
          model.set('sucStatus', true);
          model.set('warnStatus', false);
        })
        .fail(function(data) {
          model.set('status', data.responseText);
          model.set('timeStatus', -parseInt(data.responseText));
        })
  },

  // Check if current user is admin
  isAdmin: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level == 50) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // Check if current user at least a dev
  isDev: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level >= 30) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // Check if current user is admin
  isLead: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level >= 40) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // Check if current user can launch vm
  isVm: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level >= 20) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // actions binding with user event
  actions: {
    // ajax call to get current status
    checkStatus: function(model) {
      var vm_id = model.get('id') ;
      //loader for display an action on the screen
      $('#waitingModal').modal();

      // jquery get setupcomplete
      $.get("/api/v1/vms/" + vm_id + "/setupcomplete")
        .done(function(data) {
          model.set('status', data);
          model.set('timeStatus', data);
          model.set('textStatus', 'RUNNING');
          model.set('sucStatus', true);
          model.set('warnStatus', false);
          model.set('dangStatus', false);
        })
        .fail(function(data) {
          model.set('status', data.responseText);
          model.set('timeStatus', -parseInt(data.responseText));
          
          // check if error or setup
          if (parseInt(data.responseText) == 1) {
            model.set('textStatus', 'ERROR');
            model.set('sucStatus', false);
            model.set('warnStatus', false);
            model.set('dangStatus', true);
          } else {
            model.set('textStatus', 'SETUP');
            model.set('sucStatus', false);
            model.set('warnStatus', true);
            model.set('dangStatus', false);
          }
        })
        .always(function() {
          setTimeout($('#waitingModal').modal('hide'), 2000);
        });
    },

    // action to show vm uri and tools into popin modal
    showUri: function(model) {
      var uri = model.get('name');
      var login = model.get('project.login');
      var password = model.get('project.password');
      var technos = model.get('project.technos');
      var framework = model.get('project.framework.name');
      var sucstatus = model.get('sucStatus');

      var authcredentials = '';
      var linepmtools = '';
      var linesystem = '';
      var linejs = '';
      var modal = $('#textModal');
      var access_level = App.AuthManager.get('apiKey.accessLevel') ;
      
      if (!sucstatus) {
        modal.find('.modal-title').text('Please try again later');
        modal.find('.modal-body').html("<b>Vm is not on running status.</b>") ;
        modal.modal();
        return
      }

      // no tools if login is empty
      if (login && login != '') {
        modal.find('.modal-title').text('Urls & Tools');
        // system details are displaying only for at least dev user
        if (access_level >= 30) {
          modal.find('.modal-title').text('System & Urls & Tools');
        }

        authcredentials = login + ':' + password + '@';
        linepmtools = '<b>Tools</b><br>' + '<a href="http://' + authcredentials + uri + '/pm_tools/gitsync/" target="_blank">Gitpull</a><br/>';
        if (technos.findBy('name', 'mysql')) {
          linepmtools = linepmtools + '<a href="http://' + authcredentials + uri + '/pm_tools/phpmyadmin/" target="_blank">Phpmyadmin (s_bdd/s_bdd)</a><br/>';<commit_msg>remove tools bloc for user < developper group<commit_after>// Ember controller for list vm into html array
var VmsListController = Ember.ArrayController.extend({
  // Show / hide on html side
  isShowingDeleteConfirmation: false,
  isAllDelete: false,

  // Return model array sorted
  sortModel: function() {
    var model = this.get('model') ;
    var self = this;
  
    // sort vms by id
    var vmsSort = model.sort(function(a, b) {
        return Ember.compare(parseInt(a.id, 10), parseInt(b.id, 10)); 
    }).reverse() ;

    this.set('vms', vmsSort.map(function(model){
      var textStatus = '';
      var warnStatus = false;
      var dangStatus = false;
      var sucStatus = false;
      var status = model.get('status');

      model.set('todelete', false) ;
      model.set('created_at_short', model.get('created_at').getDate() + "/" + (model.get('created_at').getMonth() + 1) + " " +  + model.get('created_at').getHours() + ":" +  + model.get('created_at').getMinutes()) ;

      if (status < 1) {
        textStatus = 'SETUP'; 
        warnStatus = true;
        //if status is negative => setup in progress
        model.set('timeStatus', -parseInt(status)); 
        setTimeout(self.getStatus(model), 1500); 
      }
      if (status > 1) { textStatus = 'RUNNING'; sucStatus = true; model.set('timeStatus', (status)); }
      if (status == 1) { textStatus = 'ERROR'; dangStatus = true; }

      model.set('textStatus', textStatus);
      model.set('sucStatus', sucStatus);
      model.set('warnStatus', warnStatus);
      model.set('dangStatus', dangStatus);
      return model ;
    })) ;

  }.observes('model'),

  getStatus: function(model) {
    $.get("/api/v1/vms/" + model.get('id') + "/setupcomplete")
        .done(function(data) {
          model.set('status', data);
          model.set('timeStatus', data);
          model.set('textStatus', 'RUNNING');
          model.set('sucStatus', true);
          model.set('warnStatus', false);
        })
        .fail(function(data) {
          model.set('status', data.responseText);
          model.set('timeStatus', -parseInt(data.responseText));
        })
  },

  // Check if current user is admin
  isAdmin: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level == 50) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // Check if current user at least a dev
  isDev: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level >= 30) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // Check if current user is admin
  isLead: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level >= 40) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // Check if current user can launch vm
  isVm: function() {
    var access_level = App.AuthManager.get('apiKey.accessLevel') ;

    if (access_level >= 20) return true ;
    return false ;
  }.property('App.AuthManager.apiKey'),

  // actions binding with user event
  actions: {
    // ajax call to get current status
    checkStatus: function(model) {
      var vm_id = model.get('id') ;
      //loader for display an action on the screen
      $('#waitingModal').modal();

      // jquery get setupcomplete
      $.get("/api/v1/vms/" + vm_id + "/setupcomplete")
        .done(function(data) {
          model.set('status', data);
          model.set('timeStatus', data);
          model.set('textStatus', 'RUNNING');
          model.set('sucStatus', true);
          model.set('warnStatus', false);
          model.set('dangStatus', false);
        })
        .fail(function(data) {
          model.set('status', data.responseText);
          model.set('timeStatus', -parseInt(data.responseText));
          
          // check if error or setup
          if (parseInt(data.responseText) == 1) {
            model.set('textStatus', 'ERROR');
            model.set('sucStatus', false);
            model.set('warnStatus', false);
            model.set('dangStatus', true);
          } else {
            model.set('textStatus', 'SETUP');
            model.set('sucStatus', false);
            model.set('warnStatus', true);
            model.set('dangStatus', false);
          }
        })
        .always(function() {
          setTimeout($('#waitingModal').modal('hide'), 2000);
        });
    },

    // action to show vm uri and tools into popin modal
    showUri: function(model) {
      var uri = model.get('name');
      var login = model.get('project.login');
      var password = model.get('project.password');
      var technos = model.get('project.technos');
      var framework = model.get('project.framework.name');
      var sucstatus = model.get('sucStatus');

      var authcredentials = '';
      var linepmtools = '';
      var linesystem = '';
      var linejs = '';
      var modal = $('#textModal');
      var access_level = App.AuthManager.get('apiKey.accessLevel') ;
      
      if (!sucstatus) {
        modal.find('.modal-title').text('Please try again later');
        modal.find('.modal-body').html("<b>Vm is not on running status.</b>") ;
        modal.modal();
        return
      }

      // no tools if login is empty or current user < dev
      if (access_level >= 30 && login && login != '') {
        modal.find('.modal-title').text('Urls & Tools');

        authcredentials = login + ':' + password + '@';
        linepmtools = '<b>Tools</b><br>' + '<a href="http://' + authcredentials + uri + '/pm_tools/gitsync/" target="_blank">Gitpull</a><br/>';
        if (technos.findBy('name', 'mysql')) {
          linepmtools = linepmtools + '<a href="http://' + authcredentials + uri + '/pm_tools/phpmyadmin/" target="_blank">Phpmyadmin (s_bdd/s_bdd)</a><br/>';
{'fraction_non_alphanumeric': 0.16213229042679816, 'fraction_numerical': 0.004931134160856997, 'mean_word_length': 2.5082016104980616, 'pattern_counts': {'":': 2, '<': 29, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2003890', 'n_tokens_mistral': 3607, 'n_tokens_neox': 3495, 'n_words': 799}