<commit_before>/** @ngInject */
export function NavigationController (Text, Navigation, Session, API_BASE, ShoppingCart, $scope, $uibModal, $state,
                                      EventNotifications, ApplianceInfo, CollectionsApi, RBAC, Language, lodash, Polling) {
  const vm = this
  vm.language = ''
  const destroy = $scope.$on('shoppingCartUpdated', refresh)
  const destroyCart = $scope.$on('shoppingCartUpdated', refreshCart)
  vm.$doCheck = () => {
    const currentLanguage = Language.chosen.code
    if (!lodash.isEqual(vm.language, currentLanguage)) {
      vm.language = lodash.cloneDeep(currentLanguage)
      vm.items = Navigation.init()
    }
  }
  const destroyNotifications = $scope.$watch(
    function () {
      return EventNotifications.state().groups
    },
    refreshNotifications, true)
  const destroyToast = $scope.$watch(
    function () {
      return EventNotifications.state().toastNotifications
    },
    refreshToast, true)
  const applianceInfo = ApplianceInfo.get()
  vm.language = Language.chosen.code

  $scope.$on('destroy', function () {
    destroyCart()
    destroyNotifications()
    destroyToast()
    destroy()
    Polling.stop('lnavPolling')
  })

  activate()

  function activate () {
    vm.permissions = {
      help: {
        about: RBAC.has('about'),
        documentation: RBAC.has('documentation')
      },
      suiAppLauncher: RBAC.has(RBAC.FEATURES.CORE.APP_LAUNCHER),
      suiNotifications: RBAC.has(RBAC.FEATURES.CORE.NOTIFICATIONS),
      suiLanguage: RBAC.has(RBAC.FEATURES.CORE.LANGUAGE),
      helpMenu: RBAC.hasAny(['about', 'product', 'documentation'])
    }
    EventNotifications.setToastDisplay(vm.permissions.suiNotifications)
    angular.extend(vm, {
      state: Navigation.state,
      text: Text.app,
      user: Session.currentUser,
      API_BASE: API_BASE,
      switchGroup: switchGroup,
      items: [],
      notificationsDrawerShown: false,
      newNotifications: false,
      titleHtml: 'app/components/notifications/drawer-title.html',
      headingHTML: 'app/components/notifications/heading.html',
      notificationHTML: 'app/components/notifications/notification-body.html',
      notificationFooterHTML: 'app/components/notifications/notification-footer.html',
      handleItemClick: handleItemClick,
      toggleNotificationsList: toggleNotificationsList,
      updateViewingToast: updateViewingToast,
      handleDismissToast: handleDismissToast,
      getNotficationStatusIconClass: getNotficationStatusIconClass,
      markNotificationRead: markNotificationRead,
      clearNotification: clearNotification,
      clearAllNotifications: clearAllNotifications,
      markAllRead: markAllRead,
      shoppingCart: shoppingCart(),
      about: about(),
      sites: sites()
    })
    vm.items = Navigation.init()
    refresh()
    if (ShoppingCart.allowed()) {
      ShoppingCart.reload()
    }

    Polling.start('lnavPolling', getNavigation, 500)
  }

  function getNavigation () {
    if (!RBAC.suiAuthorized()) {
      Session.privilegesError = true
      $state.go('logout')
    }
    vm.items = Navigation.get()
  }

  function shoppingCart () {
    return {
      count: 0,
      open: function () {<commit_msg>Refactor nav ctrl to leverage in place docheck<commit_after>/** @ngInject */
export function NavigationController (Text, Navigation, Session, API_BASE, ShoppingCart, $scope, $uibModal, $state,
                                      EventNotifications, ApplianceInfo, CollectionsApi, RBAC, Language, lodash) {
  const vm = this
  vm.language = ''
  const destroy = $scope.$on('shoppingCartUpdated', refresh)
  const destroyCart = $scope.$on('shoppingCartUpdated', refreshCart)
  vm.$doCheck = () => {
    const currentLanguage = Language.chosen.code
    if (!lodash.isEqual(vm.language, currentLanguage)) {
      vm.language = lodash.cloneDeep(currentLanguage)
      vm.items = Navigation.init()
    }

    if (!lodash.isEqual(vm.items, Navigation.get())) {
      if (!RBAC.suiAuthorized()) {
        Session.privilegesError = true
        $state.go('logout')
      }
      vm.items = Navigation.get()
    }
  }
  const destroyNotifications = $scope.$watch(
    function () {
      return EventNotifications.state().groups
    },
    refreshNotifications, true)
  const destroyToast = $scope.$watch(
    function () {
      return EventNotifications.state().toastNotifications
    },
    refreshToast, true)
  const applianceInfo = ApplianceInfo.get()
  vm.language = Language.chosen.code

  $scope.$on('destroy', function () {
    destroyCart()
    destroyNotifications()
    destroyToast()
    destroy()
  })

  activate()

  function activate () {
    vm.permissions = {
      help: {
        about: RBAC.has('about'),
        documentation: RBAC.has('documentation')
      },
      suiAppLauncher: RBAC.has(RBAC.FEATURES.CORE.APP_LAUNCHER),
      suiNotifications: RBAC.has(RBAC.FEATURES.CORE.NOTIFICATIONS),
      suiLanguage: RBAC.has(RBAC.FEATURES.CORE.LANGUAGE),
      helpMenu: RBAC.hasAny(['about', 'product', 'documentation'])
    }
    EventNotifications.setToastDisplay(vm.permissions.suiNotifications)
    angular.extend(vm, {
      state: Navigation.state,
      text: Text.app,
      user: Session.currentUser,
      API_BASE: API_BASE,
      switchGroup: switchGroup,
      items: [],
      notificationsDrawerShown: false,
      newNotifications: false,
      titleHtml: 'app/components/notifications/drawer-title.html',
      headingHTML: 'app/components/notifications/heading.html',
      notificationHTML: 'app/components/notifications/notification-body.html',
      notificationFooterHTML: 'app/components/notifications/notification-footer.html',
      handleItemClick: handleItemClick,
      toggleNotificationsList: toggleNotificationsList,
      updateViewingToast: updateViewingToast,
      handleDismissToast: handleDismissToast,
      getNotficationStatusIconClass: getNotficationStatusIconClass,
      markNotificationRead: markNotificationRead,
      clearNotification: clearNotification,
      clearAllNotifications: clearAllNotifications,
      markAllRead: markAllRead,
      shoppingCart: shoppingCart(),
      about: about(),
      sites: sites()
    })
    vm.items = Navigation.init()
    refresh()
    if (ShoppingCart.allowed()) {
      ShoppingCart.reload()
    }
  }

  function shoppingCart () {
    return {
      count: 0,
      open: function () {
{'fraction_non_alphanumeric': 0.11459797033567526, 'fraction_numerical': 0.00078064012490242, 'mean_word_length': 3.308002689979825, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '366503', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1862, 'n_words': 331}