diff --git a/apps/terminal/__init__.py b/apps/apps/__init__.py similarity index 100% rename from apps/terminal/__init__.py rename to apps/apps/__init__.py diff --git a/apps/terminal/admin.py b/apps/apps/admin.py similarity index 100% rename from apps/terminal/admin.py rename to apps/apps/admin.py diff --git a/apps/apps/api.py b/apps/apps/api.py new file mode 100644 index 000000000..7232ad5ea --- /dev/null +++ b/apps/apps/api.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# + +from rest_framework.generics import ListCreateAPIView + +from .models import Terminal +from .serializers import TerminalSerializer + + +class TerminalApi(ListCreateAPIView): + queryset = Terminal.objects.all() + serializer_class = TerminalSerializer + + diff --git a/apps/terminal/apps.py b/apps/apps/apps.py similarity index 58% rename from apps/terminal/apps.py rename to apps/apps/apps.py index c81fa232b..b5d690ba9 100644 --- a/apps/terminal/apps.py +++ b/apps/apps/apps.py @@ -3,5 +3,5 @@ from __future__ import unicode_literals from django.apps import AppConfig -class TerminalConfig(AppConfig): - name = 'terminal' +class AppsConfig(AppConfig): + name = 'apps' diff --git a/apps/terminal/models.py b/apps/apps/models.py similarity index 87% rename from apps/terminal/models.py rename to apps/apps/models.py index 48caef6f5..e11b457bf 100644 --- a/apps/terminal/models.py +++ b/apps/apps/models.py @@ -17,14 +17,13 @@ class Terminal(models.Model): is_bound_ip = models.BooleanField(default=False, verbose_name=_('Is bound ip')) heatbeat_interval = models.IntegerField(default=60, verbose_name=_('Heatbeat interval')) type = models.CharField(choices=TYPE_CHOICES, max_length=2, verbose_name=_('Terminal type')) - ssh_host = models.CharField(max_length=100, verbose_name=_('SSH host')) - ssh_port = models.IntegerField(verbose_name=_('SSH port')) + url = models.CharField(max_length=100, verbose_name=_('URL to login')) mail_to = models.ManyToManyField(User, verbose_name=_('Mail to')) date_created = models.DateTimeField(auto_now_add=True) comment = models.TextField(verbose_name=_('Comment')) class Meta: - db_table = 'terminal' + db_table = 'apps' ordering = ['name'] diff --git a/apps/apps/serializers.py b/apps/apps/serializers.py new file mode 100644 index 000000000..8f786abcc --- /dev/null +++ b/apps/apps/serializers.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# + +from rest_framework import serializers + +from .models import Terminal + + +class TerminalSerializer(serializers.ModelSerializer): + class Meta: + model = Terminal + fields = ['name', 'ip', 'type', 'url', 'comment', 'is_active', + 'get_type_display'] + + +if __name__ == '__main__': + pass diff --git a/apps/apps/templates/terminal/terminal_list.html b/apps/apps/templates/terminal/terminal_list.html new file mode 100644 index 000000000..e6f63f3b3 --- /dev/null +++ b/apps/apps/templates/terminal/terminal_list.html @@ -0,0 +1,79 @@ +{% extends '_base_list.html' %} +{% load i18n static %} +{% block custom_head_css_js %} +{{ block.super }} + +{% endblock %} +{% block table_search %}{% endblock %} +{% block table_container %} +{#
{% trans "Create user" %}
#} + + + + + + + + + + + + + + +
+
+ +
+
{% trans 'Name' %}{% trans 'IP' %}{% trans 'Type' %}{% trans 'url' %}{% trans 'Active' %}{% trans 'Action' %}
+{% endblock %} +{% block content_bottom_left %}{% endblock %} +{% block custom_foot_js %} + + +{% endblock %} diff --git a/apps/terminal/tests.py b/apps/apps/tests.py similarity index 100% rename from apps/terminal/tests.py rename to apps/apps/tests.py diff --git a/apps/apps/urls.py b/apps/apps/urls.py new file mode 100644 index 000000000..2d6afd518 --- /dev/null +++ b/apps/apps/urls.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# + +from django.conf.urls import url + +import views +import api + +app_name = 'apps' + +urlpatterns = [ + url(r'^apps$', views.TerminalListView.as_view(), name='apps-list'), +] + +urlpatterns += [ + url(r'^v1/apps/$', api.TerminalApi.as_view(), name='apps-list-create-api'), +] diff --git a/apps/apps/views.py b/apps/apps/views.py new file mode 100644 index 000000000..720232109 --- /dev/null +++ b/apps/apps/views.py @@ -0,0 +1,17 @@ +# ~*~ coding: utf-8 ~*~ +# + +from django.views.generic import ListView +from django.utils.translation import ugettext as _ + +from .models import Terminal + + +class TerminalListView(ListView): + model = Terminal + template_name = 'apps/terminal_list.html' + + def get_context_data(self, **kwargs): + context = super(TerminalListView, self).get_context_data(**kwargs) + context.update({'app': _('Terminal'), 'action': _('Terminal list')}) + return context diff --git a/apps/assets/models.py b/apps/assets/models.py index 2f7daf361..5ceca9647 100644 --- a/apps/assets/models.py +++ b/apps/assets/models.py @@ -366,7 +366,7 @@ class Asset(models.Model): class Tag(models.Model): name = models.CharField(max_length=64, unique=True, verbose_name=_('Name')) - created_time = models.DateTimeField(auto_now_add_add=True, verbose_name=_('Create time')) + created_time = models.DateTimeField(auto_now_add=True, verbose_name=_('Create time')) created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by')) def __unicode__(self): diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index 1a7b8b72e..28c8b7820 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -54,10 +54,10 @@ INSTALLED_APPS = [ 'users.apps.UsersConfig', 'assets.apps.AssetsConfig', 'perms.apps.PermsConfig', - 'terminal.apps.TerminalConfig', 'ops.apps.OpsConfig', 'audits.apps.AuditsConfig', 'common.apps.CommonConfig', + 'apps.apps.TerminalConfig', 'rest_framework', 'rest_framework.authtoken', 'bootstrapform', diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py index f4222aa49..912b3c5e3 100644 --- a/apps/jumpserver/urls.py +++ b/apps/jumpserver/urls.py @@ -26,6 +26,7 @@ urlpatterns = [ url(r'^assets/', include('assets.urls')), url(r'^perms/', include('perms.urls')), url(r'^(api/)?audits/', include('audits.urls')), + url(r'^(api/)?apps/', include('apps.urls')), ] diff --git a/apps/static/js/record.js b/apps/static/js/record.js index ba334e0c2..ad24c4ab0 100644 --- a/apps/static/js/record.js +++ b/apps/static/js/record.js @@ -121,7 +121,7 @@ NgApp.controller('TerminalRecordCtrl', function ($scope, $http) { timelist = timelist.sort(function(a, b){return a-b}); totalTime = totalTime * 1000; document.getElementById("afterScrubberText").innerHTML = buildTimeString(totalTime); - term.open(document.getElementById('terminal')); + term.open(document.getElementById('apps')); timer = setInterval(advance, TICK); }) diff --git a/apps/static/js/term.js b/apps/static/js/term.js index c29cad454..45850da2e 100644 --- a/apps/static/js/term.js +++ b/apps/static/js/term.js @@ -588,7 +588,7 @@ Terminal.bindKeys = function(document) { }, true); // If we click somewhere other than a - // terminal, unfocus the terminal. + // apps, unfocus the apps. on(document, 'mousedown', function(ev) { if (!Terminal.focus) return; @@ -742,7 +742,7 @@ Terminal.insertStyle = function(document, bg, fg) { // textContent doesn't work well with IE for