Browse Source

Moved to new wording to access external services.

Martin Edenhofer 9 years ago
parent
commit
ae4f48a954

+ 8 - 8
app/assets/javascripts/app/controllers/settings.js.coffee

@@ -16,10 +16,10 @@ class System extends App.ControllerTabs
     return if !@authenticate()
     @title 'System', true
     @tabs = [
-      { name: 'Base',         'target': 'base',     controller: App.SettingsArea, params: { area: 'System::Base' } },
-      { name: 'Storage',      'target': 'storage',  controller: App.SettingsArea, params: { area: 'System::Storage' } },
-      { name: 'Geo Services', 'target': 'geo',      controller: App.SettingsArea, params: { area: 'System::Geo' } },
-      { name: 'Frontend',     'target': 'ui',       controller: App.SettingsArea, params: { area: 'System::UI' } },
+      { name: 'Base',       'target': 'base',     controller: App.SettingsArea, params: { area: 'System::Base' } },
+      { name: 'Services',   'target': 'services', controller: App.SettingsArea, params: { area: 'System::Services' } },
+      { name: 'Storage',    'target': 'storage',  controller: App.SettingsArea, params: { area: 'System::Storage' } },
+      { name: 'Frontend',   'target': 'ui',       controller: App.SettingsArea, params: { area: 'System::UI' } },
     ]
     @render()
 
@@ -64,8 +64,8 @@ class Ticket extends App.ControllerTabs
     @render()
 
 App.Config.set( 'SettingBranding',  { prio: 1200, parent: '#settings', name: 'Branding', target: '#settings/branding', controller: Branding, role: ['Admin'] }, 'NavBarAdmin' )
-App.Config.set( 'SettingSystem',    { prio: 1400, parent: '#settings', name: 'System',   target: '#settings/system', controller: System, role: ['Admin'] }, 'NavBarAdmin' )
-App.Config.set( 'SettingSecurity',  { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', controller: Security, role: ['Admin'] }, 'NavBarAdmin' )
-App.Config.set( 'SettingTicket',    { prio: 1600, parent: '#settings', name: 'Ticket',   target: '#settings/ticket', controller: Ticket, role: ['Admin'] }, 'NavBarAdmin' )
-App.Config.set( 'SettingImport',    { prio: 1700, parent: '#settings', name: 'Import',   target: '#settings/import', controller: Import, role: ['Admin'] }, 'NavBarAdmin' )
+App.Config.set( 'SettingSystem',    { prio: 1400, parent: '#settings', name: 'System',   target: '#settings/system',   controller: System,   role: ['Admin'] }, 'NavBarAdmin' )
+App.Config.set( 'SettingSecurity',  { prio: 1600, parent: '#settings', name: 'Security', target: '#settings/security', controller: Security, role: ['Admin'] }, 'NavBarAdmin' )
+App.Config.set( 'SettingTicket',    { prio: 1700, parent: '#settings', name: 'Ticket',   target: '#settings/ticket',   controller: Ticket,   role: ['Admin'] }, 'NavBarAdmin' )
+App.Config.set( 'SettingImport',    { prio: 1800, parent: '#settings', name: 'Import',   target: '#settings/import',   controller: Import,   role: ['Admin'] }, 'NavBarAdmin' )
 

+ 1 - 1
app/controllers/application_controller.rb

@@ -86,7 +86,7 @@ class ApplicationController < ActionController::Base
     # check if remote ip need to be updated
     if !session[:remote_id] || session[:remote_id] != request.remote_ip
       session[:remote_id]  = request.remote_ip
-      session[:geo]        = GeoIp.location( request.remote_ip )
+      session[:geo]        = Service::GeoIp.location( request.remote_ip )
     end
 
     # fill user agent

+ 1 - 1
app/controllers/users_controller.rb

@@ -130,7 +130,7 @@ class UsersController < ApplicationController
 
         # fetch org logo
         if user.email
-          Zammad::BigData::Organization.suggest_system_image(user.email)
+          Service::Image.organization_suggest(user.email)
         end
       end
 

+ 1 - 1
app/models/avatar.rb

@@ -146,7 +146,7 @@ add a avatar
       end
 
       # fetch image
-      image = Zammad::BigData::User.image(data[:url])
+      image = Service::Image.user(data[:url])
       return if !image
       if !data[:resize]
         data[:resize] = {}

+ 1 - 1
app/models/observer/user/geo.rb

@@ -54,7 +54,7 @@ class Observer::User::Geo < ActiveRecord::Observer
     return if address == ''
 
     # lookup
-    latlng = GeoLocation.geocode( address )
+    latlng = Service::GeoLocation.geocode( address )
     return if !latlng
 
     # store data

+ 76 - 0
db/migrate/20150715000001_update_services.rb

@@ -0,0 +1,76 @@
+class UpdateServices < ActiveRecord::Migration
+  def up
+
+    Setting.create_or_update(
+      title: 'Image Service',
+      name: 'image_backend',
+      area: 'System::Services',
+      description: 'Defines the backend for user and organization image lookups.',
+      options: {
+        form: [
+          {
+            display: '',
+            null: true,
+            name: 'image_backend',
+            tag: 'select',
+            options: {
+              '' => '-',
+              'Service::Image::Zammad' => 'Zammad Image Service',
+            },
+          },
+        ],
+      },
+      state: 'Service::Image::Zammad',
+      preferences: { prio: 1 },
+      frontend: false
+    )
+
+    Setting.create_or_update(
+      title: 'Geo IP Service',
+      name: 'geo_ip_backend',
+      area: 'System::Services',
+      description: 'Defines the backend for geo IP lookups. Show also location of an IP address if an IP address is shown.',
+      options: {
+        form: [
+          {
+            display: '',
+            null: true,
+            name: 'geo_ip_backend',
+            tag: 'select',
+            options: {
+              '' => '-',
+              'Service::GeoIp::Zammad' => 'Zammad GeoIP Service',
+            },
+          },
+        ],
+      },
+      state: 'Service::GeoIp::Zammad',
+      preferences: { prio: 2 },
+      frontend: false
+    )
+
+    Setting.create_or_update(
+      title: 'Geo Location Service',
+      name: 'geo_location_backend',
+      area: 'System::Services',
+      description: 'Defines the backend for geo location lookups to store geo locations for addresses.',
+      options: {
+        form: [
+          {
+            display: '',
+            null: true,
+            name: 'geo_location_backend',
+            tag: 'select',
+            options: {
+              '' => '-',
+              'Service::GeoLocation::Gmaps' => 'Google Maps',
+            },
+          },
+        ],
+      },
+      state: 'Service::GeoLocation::Gmaps',
+      preferences: { prio: 3 },
+      frontend: false
+    )
+  end
+end

+ 41 - 13
db/seeds.rb

@@ -49,7 +49,7 @@ Setting.create_if_not_exists(
     ],
   },
   preferences: { render: true, session_check: true, prio: 1 },
-  state: 'Zammad',
+  state: 'Zammad Helpdesk',
   frontend: true
 )
 Setting.create_if_not_exists(
@@ -196,33 +196,36 @@ Setting.create_if_not_exists(
   state: 'DB',
   frontend: false
 )
+
 Setting.create_if_not_exists(
-  title: 'Geo Location Backend',
-  name: 'geo_location_backend',
-  area: 'System::Geo',
-  description: 'Defines the backend for geo location lookups.',
+  title: 'Image Service',
+  name: 'image_backend',
+  area: 'System::Services',
+  description: 'Defines the backend for user and organization image lookups.',
   options: {
     form: [
       {
         display: '',
         null: true,
-        name: 'geo_location_backend',
+        name: 'image_backend',
         tag: 'select',
         options: {
           '' => '-',
-          'GeoLocation::Gmaps' => 'Google Maps',
+          'Service::Image::Zammad' => 'Zammad Image Service',
         },
       },
     ],
   },
-  state: 'GeoLocation::Gmaps',
+  state: 'Service::Image::Zammad',
+  preferences: { prio: 1 },
   frontend: false
 )
+
 Setting.create_if_not_exists(
-  title: 'Geo IP Backend',
+  title: 'Geo IP Service',
   name: 'geo_ip_backend',
-  area: 'System::Geo',
-  description: 'Defines the backend for geo ip lookups.',
+  area: 'System::Services',
+  description: 'Defines the backend for geo IP lookups. Show also location of an IP address if an IP address is shown.',
   options: {
     form: [
       {
@@ -232,12 +235,37 @@ Setting.create_if_not_exists(
         tag: 'select',
         options: {
           '' => '-',
-          'GeoIp::ZammadGeoIp' => 'Zammad GeoIP Service',
+          'Service::GeoIp::Zammad' => 'Zammad GeoIP Service',
+        },
+      },
+    ],
+  },
+  state: 'Service::GeoIp::Zammad',
+  preferences: { prio: 2 },
+  frontend: false
+)
+
+Setting.create_if_not_exists(
+  title: 'Geo Location Service',
+  name: 'geo_location_backend',
+  area: 'System::Services',
+  description: 'Defines the backend for geo location lookups to store geo locations for addresses.',
+  options: {
+    form: [
+      {
+        display: '',
+        null: true,
+        name: 'geo_location_backend',
+        tag: 'select',
+        options: {
+          '' => '-',
+          'Service::GeoLocation::Gmaps' => 'Google Maps',
         },
       },
     ],
   },
-  state: 'GeoIp::ZammadGeoIp',
+  state: 'Service::GeoLocation::Gmaps',
+  preferences: { prio: 3 },
   frontend: false
 )
 

+ 1 - 1
lib/auto_wizard.rb

@@ -111,7 +111,7 @@ returns
 
         # fetch org logo
         if admin_user.email
-          Zammad::BigData::Organization.suggest_system_image(admin_user.email)
+          Service::Image.organization_suggest(admin_user.email)
         end
       }
     end

+ 0 - 49
lib/geo_location.rb

@@ -1,49 +0,0 @@
-# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
-
-class GeoLocation
-  include ApplicationLib
-
-=begin
-
-lookup lat and lng for address
-
-  result = GeoLocation.geocode( 'Marienstrasse 13, 10117 Berlin' )
-
-returns
-
-  result = [ 4.21312, 1.3123 ]
-
-=end
-
-  def self.geocode(address)
-
-    # load backend
-    backend = load_adapter_by_setting( 'geo_location_backend' )
-    return if !backend
-
-    # db lookup
-    backend.geocode(address)
-  end
-
-=begin
-
-lookup address for lat and lng
-
-  result = GeoLocation.reverse_geocode( 4.21312, 1.3123 )
-
-returns
-
-  result = 'some address'
-
-=end
-
-  def self.reverse_geocode(lat, lng)
-
-    # load backend
-    backend = load_adapter_by_setting( 'geo_location_backend' )
-    return if !backend
-
-    # db lookup
-    backend.reverse_geocode(lat, lng)
-  end
-end

+ 11 - 9
lib/geo_ip.rb → lib/service/geo_ip.rb

@@ -1,13 +1,14 @@
 # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
 
-class GeoIp
-  include ApplicationLib
+module Service
+  class GeoIp
+    include ApplicationLib
 
 =begin
 
 lookup location based on ip or hostname
 
-  result = GeoIp.location( '172.0.0.1' )
+  result = Service::GeoIp.location( '172.0.0.1' )
 
 returns
 
@@ -27,13 +28,14 @@ returns
 
 =end
 
-  def self.location(address)
+    def self.location(address)
 
-    # load backend
-    backend = load_adapter_by_setting( 'geo_ip_backend' )
-    return if !backend
+      # load backend
+      backend = load_adapter_by_setting( 'geo_ip_backend' )
+      return if !backend
 
-    # db lookup
-    backend.location(address)
+      # db lookup
+      backend.location(address)
+    end
   end
 end

Some files were not shown because too many files changed in this diff