提交 775cd523 编写于 作者: baltery's avatar baltery

Update app terminal name to applications

上级 a8fa4d2f
...@@ -33,7 +33,7 @@ class TerminalRegisterView(ListCreateAPIView): ...@@ -33,7 +33,7 @@ class TerminalRegisterView(ListCreateAPIView):
terminal = serializer.save() terminal = serializer.save()
app_user, access_key = terminal.create_related_app_user() app_user, access_key = terminal.create_related_app_user()
data = {} data = {}
data['terminal'] = copy.deepcopy(serializer.data) data['applications'] = copy.deepcopy(serializer.data)
data['user'] = app_user.to_json() data['user'] = app_user.to_json()
data['access_key_id'] = access_key.id data['access_key_id'] = access_key.id
data['access_key_secret'] = access_key.secret data['access_key_secret'] = access_key.secret
......
...@@ -3,5 +3,5 @@ from __future__ import unicode_literals ...@@ -3,5 +3,5 @@ from __future__ import unicode_literals
from django.apps import AppConfig from django.apps import AppConfig
class TerminalConfig(AppConfig): class ApplicationsConfig(AppConfig):
name = 'terminal' name = 'applications'
...@@ -16,6 +16,7 @@ class Terminal(models.Model): ...@@ -16,6 +16,7 @@ class Terminal(models.Model):
type = models.CharField(choices=TYPE_CHOICES, max_length=2, blank=True, verbose_name=_('Terminal type')) type = models.CharField(choices=TYPE_CHOICES, max_length=2, blank=True, verbose_name=_('Terminal type'))
user = models.OneToOneField(User, verbose_name='Application user', null=True) user = models.OneToOneField(User, verbose_name='Application user', null=True)
url = models.CharField(max_length=100, blank=True, verbose_name=_('URL to login')) url = models.CharField(max_length=100, blank=True, verbose_name=_('URL to login'))
is_accepted = models.BooleanField(default=False, verbose_name='Is Accepted')
date_created = models.DateTimeField(auto_now_add=True) date_created = models.DateTimeField(auto_now_add=True)
comment = models.TextField(blank=True, verbose_name=_('Comment')) comment = models.TextField(blank=True, verbose_name=_('Comment'))
...@@ -31,19 +32,6 @@ class Terminal(models.Model): ...@@ -31,19 +32,6 @@ class Terminal(models.Model):
self.user.is_active = active self.user.is_active = active
self.user.save() self.user.save()
@property
def is_accepted(self):
if self.user:
return True
else:
return False
@is_accepted.setter
def is_accepted(self, active):
if active is True and self.user:
self.user.is_active = True
self.user.save()
def create_related_app_user(self): def create_related_app_user(self):
user, access_key = User.create_app_user(name=self.name, comment=self.comment) user, access_key = User.create_app_user(name=self.name, comment=self.comment)
self.user = user self.user = user
...@@ -65,7 +53,7 @@ class Terminal(models.Model): ...@@ -65,7 +53,7 @@ class Terminal(models.Model):
__str__ = __unicode__ __str__ = __unicode__
class Meta: class Meta:
db_table = 'terminal' db_table = 'applications'
class TerminalHeatbeat(models.Model): class TerminalHeatbeat(models.Model):
......
...@@ -14,7 +14,7 @@ class TerminalSerializer(serializers.ModelSerializer): ...@@ -14,7 +14,7 @@ class TerminalSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Terminal model = Terminal
fields = ['id', 'name', 'remote_addr', 'type', 'url', 'comment', fields = ['id', 'name', 'remote_addr', 'type', 'url', 'comment', 'is_accepted',
'is_active', 'get_type_display', 'proxy_online', 'is_alive'] 'is_active', 'get_type_display', 'proxy_online', 'is_alive']
@staticmethod @staticmethod
......
...@@ -65,16 +65,23 @@ $(document).ready(function(){ ...@@ -65,16 +65,23 @@ $(document).ready(function(){
}}, }},
{targets: 7, createdCell: function (td, cellData, rowData) { {targets: 7, createdCell: function (td, cellData, rowData) {
console.log(rowData.name); console.log(rowData.name);
var update_btn = '<a href="{% url "terminal:terminal-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>' var update_btn = '<a href="{% url "applications:terminal-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'
.replace('99991937', cellData); .replace('99991937', cellData);
var delete_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_delete" data-uid="99991937" data-name="99991938">{% trans "Delete" %}</a>' var delete_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_delete" data-uid="99991937" data-name="99991938">{% trans "Delete" %}</a>'
.replace('99991937', cellData) .replace('99991937', cellData)
.replace('99991938', rowData.name); .replace('99991938', rowData.name);
$(td).html(update_btn + delete_btn) var accept_btn = '<a href="" class="btn btn-xs btn-primary">{% trans "Accept" %}</a> '
.replace('99991937', cellData);
var reject_btn = '<a href="" class="btn btn-xs btn-danger">{% trans "Reject" %}</a>'
if (rowData.is_accepted) {
$(td).html(update_btn + delete_btn)
} else {
$(td).html(accept_btn + reject_btn)
}
}} }}
], ],
ajax_url: '{% url "api-terminal:terminal-list" %}', ajax_url: '{% url "api-applications:terminal-list" %}',
columns: [{data: function(){return ""}}, {data: "name" }, {data: "ip" }, {data: "get_type_display" }, columns: [{data: function(){return ""}}, {data: "name" }, {data: "remote_addr" }, {data: "get_type_display" },
{data: "proxy_online"}, {data: "is_active" }, {data: 'is_active'}, {data: "id"}], {data: "proxy_online"}, {data: "is_active" }, {data: 'is_active'}, {data: "id"}],
op_html: $('#actions').html() op_html: $('#actions').html()
}; };
...@@ -83,7 +90,7 @@ $(document).ready(function(){ ...@@ -83,7 +90,7 @@ $(document).ready(function(){
var $this = $(this); var $this = $(this);
var uid = $this.data('uid'); var uid = $this.data('uid');
var name = $(this).data('name'); var name = $(this).data('name');
var the_url = '{% url "api-terminal:terminal-detail" pk=99991937 %}'.replace('99991937', uid); var the_url = '{% url "api-applications:terminal-detail" pk=99991937 %}'.replace('99991937', uid);
objectDelete($this, name, the_url) objectDelete($this, name, the_url)
}) })
</script> </script>
......
...@@ -7,14 +7,14 @@ from rest_framework import routers ...@@ -7,14 +7,14 @@ from rest_framework import routers
from .. import api from .. import api
app_name = 'terminal' app_name = 'applications'
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register(r'v1/terminal/heatbeat', api.TerminalHeatbeatViewSet, 'terminal-heatbeat')
router.register(r'v1/terminal', api.TerminalViewSet, 'terminal') router.register(r'v1/terminal', api.TerminalViewSet, 'terminal')
router.register(r'v1/terminal/heatbeat', api.TerminalHeatbeatViewSet, 'terminal-heatbeat')
urlpatterns = [ urlpatterns = [
url(r'v1/register$', api.TerminalRegisterView.as_view(), name='api-terminal-register') url(r'v1/terminal/register$', api.TerminalRegisterView.as_view(), name='terminal-register')
] ]
urlpatterns += router.urls urlpatterns += router.urls
\ No newline at end of file
...@@ -6,7 +6,7 @@ from django.conf.urls import url ...@@ -6,7 +6,7 @@ from django.conf.urls import url
from .. import views from .. import views
app_name = 'terminal' app_name = 'applications'
urlpatterns = [ urlpatterns = [
url(r'^terminal$', views.TerminalListView.as_view(), name='terminal-list'), url(r'^terminal$', views.TerminalListView.as_view(), name='terminal-list'),
......
...@@ -11,7 +11,7 @@ from .forms import TerminalForm ...@@ -11,7 +11,7 @@ from .forms import TerminalForm
class TerminalListView(ListView): class TerminalListView(ListView):
model = Terminal model = Terminal
template_name = 'terminal/terminal_list.html' template_name = 'applications/terminal_list.html'
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(TerminalListView, self).get_context_data(**kwargs) context = super(TerminalListView, self).get_context_data(**kwargs)
...@@ -22,16 +22,16 @@ class TerminalListView(ListView): ...@@ -22,16 +22,16 @@ class TerminalListView(ListView):
class TerminalUpdateView(UpdateView): class TerminalUpdateView(UpdateView):
model = Terminal model = Terminal
form_class = TerminalForm form_class = TerminalForm
template_name = 'terminal/terminal_update.html' template_name = 'applications/terminal_update.html'
success_url = reverse_lazy('terminal:terminal-list') success_url = reverse_lazy('applications:applications-list')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(TerminalUpdateView, self).get_context_data(**kwargs) context = super(TerminalUpdateView, self).get_context_data(**kwargs)
context.update({'app': _('Terminal'), 'action': _('Update terminal')}) context.update({'app': _('Terminal'), 'action': _('Update applications')})
return context return context
class TerminalDeleteView(DeleteView): class TerminalDeleteView(DeleteView):
model = Terminal model = Terminal
template_name = 'assets/delete_confirm.html' template_name = 'assets/delete_confirm.html'
success_url = reverse_lazy('terminal:terminal-list') success_url = reverse_lazy('applications:applications-list')
\ No newline at end of file \ No newline at end of file
...@@ -738,7 +738,7 @@ class AssetExportView(View): ...@@ -738,7 +738,7 @@ class AssetExportView(View):
ws.append([self.get_asset_attr(asset, attr) for attr in header]) ws.append([self.get_asset_attr(asset, attr) for attr in header])
filename = 'assets-{}.xlsx'.format(timezone.localtime(timezone.now()).strftime('%Y-%m-%d_%H-%M-%S')) filename = 'assets-{}.xlsx'.format(timezone.localtime(timezone.now()).strftime('%Y-%m-%d_%H-%M-%S'))
response = HttpResponse(save_virtual_workbook(wb), content_type='application/vnd.ms-excel') response = HttpResponse(save_virtual_workbook(wb), content_type='applications/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename="%s"' % filename response['Content-Disposition'] = 'attachment; filename="%s"' % filename
return response return response
......
...@@ -18,7 +18,7 @@ class ProxyLogViewSet(viewsets.ModelViewSet): ...@@ -18,7 +18,7 @@ class ProxyLogViewSet(viewsets.ModelViewSet):
"name": "", "name": "",
"hostname": "", "hostname": "",
"ip": "", "ip": "",
"terminal", "", "applications", "",
"login_type": "", "login_type": "",
"system_user": "", "system_user": "",
"was_failed": "", "was_failed": "",
......
...@@ -5,4 +5,4 @@ from users.utils import AdminUserRequiredMixin ...@@ -5,4 +5,4 @@ from users.utils import AdminUserRequiredMixin
from users.models import User from users.models import User
from assets.models import Asset, SystemUser from assets.models import Asset, SystemUser
from users.permissions import IsSuperUserOrAppUser from users.permissions import IsSuperUserOrAppUser
from terminal.models import Terminal from applications.models import Terminal
...@@ -13,7 +13,7 @@ class ProxyLogSerializer(serializers.ModelSerializer): ...@@ -13,7 +13,7 @@ class ProxyLogSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = models.ProxyLog model = models.ProxyLog
fields = ['id', 'name', 'username', 'hostname', 'ip', 'system_user', 'login_type', 'terminal', fields = ['id', 'name', 'username', 'hostname', 'ip', 'system_user', 'login_type', 'applications',
'log_file', 'was_failed', 'is_finished', 'date_start', 'date_finished', 'time', 'log_file', 'was_failed', 'is_finished', 'date_start', 'date_finished', 'time',
'command_length', "commands_dict"] 'command_length', "commands_dict"]
......
...@@ -58,7 +58,7 @@ INSTALLED_APPS = [ ...@@ -58,7 +58,7 @@ INSTALLED_APPS = [
'ops.apps.OpsConfig', 'ops.apps.OpsConfig',
'audits.apps.AuditsConfig', 'audits.apps.AuditsConfig',
'common.apps.CommonConfig', 'common.apps.CommonConfig',
'terminal.apps.TerminalConfig', 'applications.apps.ApplicationsConfig',
'rest_framework', 'rest_framework',
'bootstrapform', 'bootstrapform',
'captcha', 'captcha',
...@@ -103,7 +103,7 @@ TEMPLATES = [ ...@@ -103,7 +103,7 @@ TEMPLATES = [
}, },
] ]
# WSGI_APPLICATION = 'jumpserver.wsgi.application' # WSGI_APPLICATION = 'jumpserver.wsgi.applications'
LOGIN_REDIRECT_URL = reverse_lazy('index') LOGIN_REDIRECT_URL = reverse_lazy('index')
LOGIN_URL = reverse_lazy('users:login') LOGIN_URL = reverse_lazy('users:login')
...@@ -277,7 +277,7 @@ REST_FRAMEWORK = { ...@@ -277,7 +277,7 @@ REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': (
'users.authentication.AccessKeyAuthentication', 'users.authentication.AccessKeyAuthentication',
'users.authentication.AccessTokenAuthentication', 'users.authentication.AccessTokenAuthentication',
'rest_framework.authentication.TokenAuthentication', 'users.authentication.PrivateTokenAuthentication',
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
), ),
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',), 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
...@@ -298,9 +298,9 @@ CELERY_RESULT_BACKEND = BROKER_URL ...@@ -298,9 +298,9 @@ CELERY_RESULT_BACKEND = BROKER_URL
# crontab job # crontab job
# CELERYBEAT_SCHEDULE = { # CELERYBEAT_SCHEDULE = {
# Check terminal is alive every 10m # Check applications is alive every 10m
# 'check_terminal_alive': { # 'check_terminal_alive': {
# 'task': 'terminal.tasks.check_terminal_alive', # 'task': 'applications.tasks.check_terminal_alive',
# 'schedule': timedelta(seconds=TERMINAL_HEATBEAT_INTERVAL), # 'schedule': timedelta(seconds=TERMINAL_HEATBEAT_INTERVAL),
# 'args': (), # 'args': (),
# }, # },
......
...@@ -29,14 +29,15 @@ urlpatterns = [ ...@@ -29,14 +29,15 @@ urlpatterns = [
url(r'^assets/', include('assets.urls.views_urls', namespace='assets')), url(r'^assets/', include('assets.urls.views_urls', namespace='assets')),
url(r'^perms/', include('perms.urls.views_urls', namespace='perms')), url(r'^perms/', include('perms.urls.views_urls', namespace='perms')),
url(r'^audits/', include('audits.urls.views_urls', namespace='audits')), url(r'^audits/', include('audits.urls.views_urls', namespace='audits')),
url(r'^terminal/', include('terminal.urls.views_urls', namespace='terminal')), url(r'^applications/', include('applications.urls.views_urls', namespace='applications')),
url('^ops/', include('ops.urls.view_urls', namespace='ops')), url(r'^ops/', include('ops.urls.view_urls', namespace='ops')),
# Api url view map
url(r'^api/users/', include('users.urls.api_urls', namespace='api-users')), url(r'^api/users/', include('users.urls.api_urls', namespace='api-users')),
url(r'^api/assets/', include('assets.urls.api_urls', namespace='api-assets')), url(r'^api/assets/', include('assets.urls.api_urls', namespace='api-assets')),
url(r'^api/perms/', include('perms.urls.api_urls', namespace='api-perms')), url(r'^api/perms/', include('perms.urls.api_urls', namespace='api-perms')),
url(r'^api/audits/', include('audits.urls.api_urls', namespace='api-audits')), url(r'^api/audits/', include('audits.urls.api_urls', namespace='api-audits')),
url(r'^api/terminal/', include('terminal.urls.api_urls', namespace='api-terminal')), url(r'^api/applications/', include('applications.urls.api_urls', namespace='api-applications')),
url(r'^api/ops/', include('ops.urls.api_urls', namespace='api-ops')), url(r'^api/ops/', include('ops.urls.api_urls', namespace='api-ops')),
] ]
......
...@@ -75,7 +75,7 @@ b)}:E;D.$$addScopeClass=k?function(a,b){I(a,b?"ng-isolate-scope":"ng-scope")}:E; ...@@ -75,7 +75,7 @@ b)}:E;D.$$addScopeClass=k?function(a,b){I(a,b?"ng-isolate-scope":"ng-scope")}:E;
"controller");J(a)?w(b,a):b[a]=c};this.allowGlobals=function(){a=!0};this.$get=["$injector","$window",function(d,e){function f(a,b,c,d){if(!a||!J(a.$scope))throw R("$controller")("noscp",d,b);a.$scope[b]=c}return function(g,h,l,k){var n,p,q;l=!0===l;k&&C(k)&&(q=k);if(C(g)){k=g.match(c);if(!k)throw rf("ctrlfmt",g);p=k[1];q=q||k[3];g=b.hasOwnProperty(p)?b[p]:xc(h.$scope,p,!0)||(a?xc(e,p,!0):t);sb(g,p,!0)}if(l)return l=(H(g)?g[g.length-1]:g).prototype,n=Object.create(l||null),q&&f(h,q,n,p||g.name),w(function(){d.invoke(g, "controller");J(a)?w(b,a):b[a]=c};this.allowGlobals=function(){a=!0};this.$get=["$injector","$window",function(d,e){function f(a,b,c,d){if(!a||!J(a.$scope))throw R("$controller")("noscp",d,b);a.$scope[b]=c}return function(g,h,l,k){var n,p,q;l=!0===l;k&&C(k)&&(q=k);if(C(g)){k=g.match(c);if(!k)throw rf("ctrlfmt",g);p=k[1];q=q||k[3];g=b.hasOwnProperty(p)?b[p]:xc(h.$scope,p,!0)||(a?xc(e,p,!0):t);sb(g,p,!0)}if(l)return l=(H(g)?g[g.length-1]:g).prototype,n=Object.create(l||null),q&&f(h,q,n,p||g.name),w(function(){d.invoke(g,
n,h,p);return n},{instance:n,identifier:q});n=d.instantiate(g,h,p);q&&f(h,q,n,p||g.name);return n}}]}function Ge(){this.$get=["$window",function(b){return A(b.document)}]}function He(){this.$get=["$log",function(b){return function(a,c){b.error.apply(b,arguments)}}]}function Zb(b,a){if(C(b)){var c=b.replace(sf,"").trim();if(c){var d=a("Content-Type");(d=d&&0===d.indexOf(Wc))||(d=(d=c.match(tf))&&uf[d[0]].test(c));d&&(b=qc(c))}}return b}function Xc(b){var a=ia(),c,d,e;if(!b)return a;r(b.split("\n"), n,h,p);return n},{instance:n,identifier:q});n=d.instantiate(g,h,p);q&&f(h,q,n,p||g.name);return n}}]}function Ge(){this.$get=["$window",function(b){return A(b.document)}]}function He(){this.$get=["$log",function(b){return function(a,c){b.error.apply(b,arguments)}}]}function Zb(b,a){if(C(b)){var c=b.replace(sf,"").trim();if(c){var d=a("Content-Type");(d=d&&0===d.indexOf(Wc))||(d=(d=c.match(tf))&&uf[d[0]].test(c));d&&(b=qc(c))}}return b}function Xc(b){var a=ia(),c,d,e;if(!b)return a;r(b.split("\n"),
function(b){e=b.indexOf(":");c=z(N(b.substr(0,e)));d=N(b.substr(e+1));c&&(a[c]=a[c]?a[c]+", "+d:d)});return a}function Yc(b){var a=J(b)?b:t;return function(c){a||(a=Xc(b));return c?(c=a[z(c)],void 0===c&&(c=null),c):a}}function Zc(b,a,c,d){if(G(d))return d(b,a,c);r(d,function(d){b=d(b,a,c)});return b}function Ke(){var b=this.defaults={transformResponse:[Zb],transformRequest:[function(a){return J(a)&&"[object File]"!==Ca.call(a)&&"[object Blob]"!==Ca.call(a)&&"[object FormData]"!==Ca.call(a)?$a(a): function(b){e=b.indexOf(":");c=z(N(b.substr(0,e)));d=N(b.substr(e+1));c&&(a[c]=a[c]?a[c]+", "+d:d)});return a}function Yc(b){var a=J(b)?b:t;return function(c){a||(a=Xc(b));return c?(c=a[z(c)],void 0===c&&(c=null),c):a}}function Zc(b,a,c,d){if(G(d))return d(b,a,c);r(d,function(d){b=d(b,a,c)});return b}function Ke(){var b=this.defaults={transformResponse:[Zb],transformRequest:[function(a){return J(a)&&"[object File]"!==Ca.call(a)&&"[object Blob]"!==Ca.call(a)&&"[object FormData]"!==Ca.call(a)?$a(a):
a}],headers:{common:{Accept:"application/json, text/plain, */*"},post:sa($b),put:sa($b),patch:sa($b)},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"},a=!1;this.useApplyAsync=function(b){return y(b)?(a=!!b,this):a};var c=this.interceptors=[];this.$get=["$httpBackend","$browser","$cacheFactory","$rootScope","$q","$injector",function(d,e,f,g,h,l){function k(a){function c(a){var b=w({},a);b.data=a.data?Zc(a.data,a.headers,a.status,e.transformResponse):a.data;a=a.status;return 200<=a&&300>a? a}],headers:{common:{Accept:"applications/json, text/plain, */*"},post:sa($b),put:sa($b),patch:sa($b)},xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"},a=!1;this.useApplyAsync=function(b){return y(b)?(a=!!b,this):a};var c=this.interceptors=[];this.$get=["$httpBackend","$browser","$cacheFactory","$rootScope","$q","$injector",function(d,e,f,g,h,l){function k(a){function c(a){var b=w({},a);b.data=a.data?Zc(a.data,a.headers,a.status,e.transformResponse):a.data;a=a.status;return 200<=a&&300>a?
b:h.reject(b)}function d(a){var b,c={};r(a,function(a,d){G(a)?(b=a(),null!=b&&(c[d]=b)):c[d]=a});return c}if(!ca.isObject(a))throw R("$http")("badreq",a);var e=w({method:"get",transformRequest:b.transformRequest,transformResponse:b.transformResponse},a);e.headers=function(a){var c=b.headers,e=w({},a.headers),f,g,c=w({},c.common,c[z(a.method)]);a:for(f in c){a=z(f);for(g in e)if(z(g)===a)continue a;e[f]=c[f]}return d(e)}(a);e.method=ub(e.method);var f=[function(a){var d=a.headers,e=Zc(a.data,Yc(d), b:h.reject(b)}function d(a){var b,c={};r(a,function(a,d){G(a)?(b=a(),null!=b&&(c[d]=b)):c[d]=a});return c}if(!ca.isObject(a))throw R("$http")("badreq",a);var e=w({method:"get",transformRequest:b.transformRequest,transformResponse:b.transformResponse},a);e.headers=function(a){var c=b.headers,e=w({},a.headers),f,g,c=w({},c.common,c[z(a.method)]);a:for(f in c){a=z(f);for(g in e)if(z(g)===a)continue a;e[f]=c[f]}return d(e)}(a);e.method=ub(e.method);var f=[function(a){var d=a.headers,e=Zc(a.data,Yc(d),
t,a.transformRequest);x(e)&&r(d,function(a,b){"content-type"===z(b)&&delete d[b]});x(a.withCredentials)&&!x(b.withCredentials)&&(a.withCredentials=b.withCredentials);return n(a,e).then(c,c)},t],g=h.when(e);for(r(u,function(a){(a.request||a.requestError)&&f.unshift(a.request,a.requestError);(a.response||a.responseError)&&f.push(a.response,a.responseError)});f.length;){a=f.shift();var k=f.shift(),g=g.then(a,k)}g.success=function(a){g.then(function(b){a(b.data,b.status,b.headers,e)});return g};g.error= t,a.transformRequest);x(e)&&r(d,function(a,b){"content-type"===z(b)&&delete d[b]});x(a.withCredentials)&&!x(b.withCredentials)&&(a.withCredentials=b.withCredentials);return n(a,e).then(c,c)},t],g=h.when(e);for(r(u,function(a){(a.request||a.requestError)&&f.unshift(a.request,a.requestError);(a.response||a.responseError)&&f.push(a.response,a.responseError)});f.length;){a=f.shift();var k=f.shift(),g=g.then(a,k)}g.success=function(a){g.then(function(b){a(b.data,b.status,b.headers,e)});return g};g.error=
function(a){g.then(null,function(b){a(b.data,b.status,b.headers,e)});return g};return g}function n(c,f){function l(b,c,d,e){function f(){m(c,b,d,e)}I&&(200<=b&&300>b?I.put(P,[b,c,Xc(d),e]):I.remove(P));a?g.$applyAsync(f):(f(),g.$$phase||g.$apply())}function m(a,b,d,e){b=Math.max(b,0);(200<=b&&300>b?L.resolve:L.reject)({data:a,status:b,headers:Yc(d),config:c,statusText:e})}function n(a){m(a.data,a.status,sa(a.headers()),a.statusText)}function u(){var a=k.pendingRequests.indexOf(c);-1!==a&&k.pendingRequests.splice(a, function(a){g.then(null,function(b){a(b.data,b.status,b.headers,e)});return g};return g}function n(c,f){function l(b,c,d,e){function f(){m(c,b,d,e)}I&&(200<=b&&300>b?I.put(P,[b,c,Xc(d),e]):I.remove(P));a?g.$applyAsync(f):(f(),g.$$phase||g.$apply())}function m(a,b,d,e){b=Math.max(b,0);(200<=b&&300>b?L.resolve:L.reject)({data:a,status:b,headers:Yc(d),config:c,statusText:e})}function n(a){m(a.data,a.status,sa(a.headers()),a.statusText)}function u(){var a=k.pendingRequests.indexOf(c);-1!==a&&k.pendingRequests.splice(a,
...@@ -176,7 +176,7 @@ d){var e=c+"-animation";if(c&&"."!=c.charAt(0))throw Tf("notcsel",c);this.$$sele ...@@ -176,7 +176,7 @@ d){var e=c+"-animation";if(c&&"."!=c.charAt(0))throw Tf("notcsel",c);this.$$sele
r((a.attr("class")||"").split(/\s+/),function(a){f[a]=!0});r(c,function(a,c){var g=f[c];!1===a&&g?e.push(c):!0!==a||g||d.push(c)});return 0<d.length+e.length&&[d.length?d:null,e.length?e:null]}function h(a,c,d){for(var e=0,f=c.length;e<f;++e)a[c[e]]=d}function l(){n||(n=a.defer(),d(function(){n.resolve();n=null}));return n.promise}function k(a,c){if(ca.isObject(c)){var d=w(c.from||{},c.to||{});a.css(d)}}var n;return{animate:function(a,c,d){k(a,{from:c,to:d});return l()},enter:function(a,c,d,e){k(a, r((a.attr("class")||"").split(/\s+/),function(a){f[a]=!0});r(c,function(a,c){var g=f[c];!1===a&&g?e.push(c):!0!==a||g||d.push(c)});return 0<d.length+e.length&&[d.length?d:null,e.length?e:null]}function h(a,c,d){for(var e=0,f=c.length;e<f;++e)a[c[e]]=d}function l(){n||(n=a.defer(),d(function(){n.resolve();n=null}));return n.promise}function k(a,c){if(ca.isObject(c)){var d=w(c.from||{},c.to||{});a.css(d)}}var n;return{animate:function(a,c,d){k(a,{from:c,to:d});return l()},enter:function(a,c,d,e){k(a,
e);d?d.after(a):c.prepend(a);return l()},leave:function(a,c){k(a,c);a.remove();return l()},move:function(a,c,d,e){return this.enter(a,c,d,e)},addClass:function(a,c,d){return this.setClass(a,c,[],d)},$$addClassImmediately:function(a,c,d){a=A(a);c=C(c)?c:H(c)?c.join(" "):"";r(a,function(a){Cb(a,c)});k(a,d);return l()},removeClass:function(a,c,d){return this.setClass(a,[],c,d)},$$removeClassImmediately:function(a,c,d){a=A(a);c=C(c)?c:H(c)?c.join(" "):"";r(a,function(a){Bb(a,c)});k(a,d);return l()},setClass:function(a, e);d?d.after(a):c.prepend(a);return l()},leave:function(a,c){k(a,c);a.remove();return l()},move:function(a,c,d,e){return this.enter(a,c,d,e)},addClass:function(a,c,d){return this.setClass(a,c,[],d)},$$addClassImmediately:function(a,c,d){a=A(a);c=C(c)?c:H(c)?c.join(" "):"";r(a,function(a){Cb(a,c)});k(a,d);return l()},removeClass:function(a,c,d){return this.setClass(a,[],c,d)},$$removeClassImmediately:function(a,c,d){a=A(a);c=C(c)?c:H(c)?c.join(" "):"";r(a,function(a){Bb(a,c)});k(a,d);return l()},setClass:function(a,
c,d,e){var k=this,l=!1;a=A(a);var m=a.data("$$animateClasses");m?e&&m.options&&(m.options=ca.extend(m.options||{},e)):(m={classes:{},options:e},l=!0);e=m.classes;c=H(c)?c:c.split(" ");d=H(d)?d:d.split(" ");h(e,c,!0);h(e,d,!1);l&&(m.promise=f(function(c){var d=a.data("$$animateClasses");a.removeData("$$animateClasses");if(d){var e=g(a,d.classes);e&&k.$$setClassImmediately(a,e[0],e[1],d.options)}c()}),a.data("$$animateClasses",m));return m.promise},$$setClassImmediately:function(a,c,d,e){c&&this.$$addClassImmediately(a, c,d,e){var k=this,l=!1;a=A(a);var m=a.data("$$animateClasses");m?e&&m.options&&(m.options=ca.extend(m.options||{},e)):(m={classes:{},options:e},l=!0);e=m.classes;c=H(c)?c:c.split(" ");d=H(d)?d:d.split(" ");h(e,c,!0);h(e,d,!1);l&&(m.promise=f(function(c){var d=a.data("$$animateClasses");a.removeData("$$animateClasses");if(d){var e=g(a,d.classes);e&&k.$$setClassImmediately(a,e[0],e[1],d.options)}c()}),a.data("$$animateClasses",m));return m.promise},$$setClassImmediately:function(a,c,d,e){c&&this.$$addClassImmediately(a,
c);d&&this.$$removeClassImmediately(a,d);k(a,e);return l()},enabled:E,cancel:E}}]}],la=R("$compile");yc.$inject=["$provide","$$sanitizeUriProvider"];var Sc=/^((?:x|data)[\:\-_])/i,rf=R("$controller"),Wc="application/json",$b={"Content-Type":Wc+";charset=utf-8"},tf=/^\[|^\{(?!\{)/,uf={"[":/]$/,"{":/}$/},sf=/^\)\]\}',?\n/,ac=R("$interpolate"),Uf=/^([^\?#]*)(\?([^#]*))?(#(.*))?$/,xf={http:80,https:443,ftp:21},Gb=R("$location"),Vf={$$html5:!1,$$replace:!1,absUrl:Hb("$$absUrl"),url:function(a){if(x(a))return this.$$url; c);d&&this.$$removeClassImmediately(a,d);k(a,e);return l()},enabled:E,cancel:E}}]}],la=R("$compile");yc.$inject=["$provide","$$sanitizeUriProvider"];var Sc=/^((?:x|data)[\:\-_])/i,rf=R("$controller"),Wc="applications/json",$b={"Content-Type":Wc+";charset=utf-8"},tf=/^\[|^\{(?!\{)/,uf={"[":/]$/,"{":/}$/},sf=/^\)\]\}',?\n/,ac=R("$interpolate"),Uf=/^([^\?#]*)(\?([^#]*))?(#(.*))?$/,xf={http:80,https:443,ftp:21},Gb=R("$location"),Vf={$$html5:!1,$$replace:!1,absUrl:Hb("$$absUrl"),url:function(a){if(x(a))return this.$$url;
var c=Uf.exec(a);(c[1]||""===a)&&this.path(decodeURIComponent(c[1]));(c[2]||c[1]||""===a)&&this.search(c[3]||"");this.hash(c[5]||"");return this},protocol:Hb("$$protocol"),host:Hb("$$host"),port:Hb("$$port"),path:dd("$$path",function(a){a=null!==a?a.toString():"";return"/"==a.charAt(0)?a:"/"+a}),search:function(a,c){switch(arguments.length){case 0:return this.$$search;case 1:if(C(a)||Y(a))a=a.toString(),this.$$search=sc(a);else if(J(a))a=Da(a,{}),r(a,function(c,e){null==c&&delete a[e]}),this.$$search= var c=Uf.exec(a);(c[1]||""===a)&&this.path(decodeURIComponent(c[1]));(c[2]||c[1]||""===a)&&this.search(c[3]||"");this.hash(c[5]||"");return this},protocol:Hb("$$protocol"),host:Hb("$$host"),port:Hb("$$port"),path:dd("$$path",function(a){a=null!==a?a.toString():"";return"/"==a.charAt(0)?a:"/"+a}),search:function(a,c){switch(arguments.length){case 0:return this.$$search;case 1:if(C(a)||Y(a))a=a.toString(),this.$$search=sc(a);else if(J(a))a=Da(a,{}),r(a,function(c,e){null==c&&delete a[e]}),this.$$search=
a;else throw Gb("isrcharg");break;default:x(c)||null===c?delete this.$$search[a]:this.$$search[a]=c}this.$$compose();return this},hash:dd("$$hash",function(a){return null!==a?a.toString():""}),replace:function(){this.$$replace=!0;return this}};r([cd,ec,dc],function(a){a.prototype=Object.create(Vf);a.prototype.state=function(c){if(!arguments.length)return this.$$state;if(a!==dc||!this.$$html5)throw Gb("nostate");this.$$state=x(c)?null:c;return this}});var na=R("$parse"),Wf=Function.prototype.call, a;else throw Gb("isrcharg");break;default:x(c)||null===c?delete this.$$search[a]:this.$$search[a]=c}this.$$compose();return this},hash:dd("$$hash",function(a){return null!==a?a.toString():""}),replace:function(){this.$$replace=!0;return this}};r([cd,ec,dc],function(a){a.prototype=Object.create(Vf);a.prototype.state=function(c){if(!arguments.length)return this.$$state;if(a!==dc||!this.$$html5)throw Gb("nostate");this.$$state=x(c)?null:c;return this}});var na=R("$parse"),Wf=Function.prototype.call,
Xf=Function.prototype.apply,Yf=Function.prototype.bind,mb=ia();r({"null":function(){return null},"true":function(){return!0},"false":function(){return!1},undefined:function(){}},function(a,c){a.constant=a.literal=a.sharedGetter=!0;mb[c]=a});mb["this"]=function(a){return a};mb["this"].sharedGetter=!0;var nb=w(ia(),{"+":function(a,c,d,e){d=d(a,c);e=e(a,c);return y(d)?y(e)?d+e:d:y(e)?e:t},"-":function(a,c,d,e){d=d(a,c);e=e(a,c);return(y(d)?d:0)-(y(e)?e:0)},"*":function(a,c,d,e){return d(a,c)*e(a,c)}, Xf=Function.prototype.apply,Yf=Function.prototype.bind,mb=ia();r({"null":function(){return null},"true":function(){return!0},"false":function(){return!1},undefined:function(){}},function(a,c){a.constant=a.literal=a.sharedGetter=!0;mb[c]=a});mb["this"]=function(a){return a};mb["this"].sharedGetter=!0;var nb=w(ia(),{"+":function(a,c,d,e){d=d(a,c);e=e(a,c);return y(d)?y(e)?d+e:d:y(e)?e:t},"-":function(a,c,d,e){d=d(a,c);e=e(a,c);return(y(d)?d:0)-(y(e)?e:0)},"*":function(a,c,d,e){return d(a,c)*e(a,c)},
......
此差异已折叠。
...@@ -195,7 +195,7 @@ function APIUpdateAttr(props) { ...@@ -195,7 +195,7 @@ function APIUpdateAttr(props) {
url: props.url, url: props.url,
type: props.method || "PATCH", type: props.method || "PATCH",
data: props.body, data: props.body,
contentType: props.content_type || "application/json; charset=utf-8", contentType: props.content_type || "applications/json; charset=utf-8",
dataType: props.data_type || "json" dataType: props.data_type || "json"
}).done(function(data, textStatue, jqXHR) { }).done(function(data, textStatue, jqXHR) {
toastr.success(success_message); toastr.success(success_message);
......
...@@ -1370,7 +1370,7 @@ ...@@ -1370,7 +1370,7 @@
return; return;
} }
response = xhr.responseText; response = xhr.responseText;
if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("applications/json")) {
try { try {
response = JSON.parse(response); response = JSON.parse(response);
} catch (_error) { } catch (_error) {
...@@ -1397,7 +1397,7 @@ ...@@ -1397,7 +1397,7 @@
progressObj = (_ref = xhr.upload) != null ? _ref : xhr; progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
progressObj.onprogress = updateProgress; progressObj.onprogress = updateProgress;
headers = { headers = {
"Accept": "application/json", "Accept": "applications/json",
"Cache-Control": "no-cache", "Cache-Control": "no-cache",
"X-Requested-With": "XMLHttpRequest" "X-Requested-With": "XMLHttpRequest"
}; };
......
...@@ -423,7 +423,7 @@ c.setTooltipPoints(),c.render()},c.wrap(c.Axis.prototype,"render",function(c){c. ...@@ -423,7 +423,7 @@ c.setTooltipPoints(),c.render()},c.wrap(c.Axis.prototype,"render",function(c){c.
*/ */
(function(f){var A=f.Chart,t=f.addEvent,B=f.removeEvent,l=f.createElement,o=f.discardElement,v=f.css,k=f.merge,r=f.each,p=f.extend,D=Math.max,j=document,C=window,E=f.isTouchDevice,F=f.Renderer.prototype.symbols,s=f.getOptions(),y;p(s.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});s.navigation={menuStyle:{border:"1px solid #A0A0A0", (function(f){var A=f.Chart,t=f.addEvent,B=f.removeEvent,l=f.createElement,o=f.discardElement,v=f.css,k=f.merge,r=f.each,p=f.extend,D=Math.max,j=document,C=window,E=f.isTouchDevice,F=f.Renderer.prototype.symbols,s=f.getOptions(),y;p(s.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});s.navigation={menuStyle:{border:"1px solid #A0A0A0",
background:"#FFFFFF",padding:"5px 0"},menuItemStyle:{padding:"0 10px",background:"none",color:"#303030",fontSize:E?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{symbolFill:"#E0E0E0",symbolSize:14,symbolStroke:"#666",symbolStrokeWidth:3,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,theme:{fill:"white",stroke:"none"},verticalAlign:"top",width:24}};s.exporting={type:"image/png",url:"http://export.highcharts.com/",buttons:{contextButton:{menuClassName:"highcharts-contextmenu", background:"#FFFFFF",padding:"5px 0"},menuItemStyle:{padding:"0 10px",background:"none",color:"#303030",fontSize:E?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{symbolFill:"#E0E0E0",symbolSize:14,symbolStroke:"#666",symbolStrokeWidth:3,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,theme:{fill:"white",stroke:"none"},verticalAlign:"top",width:24}};s.exporting={type:"image/png",url:"http://export.highcharts.com/",buttons:{contextButton:{menuClassName:"highcharts-contextmenu",
symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(b,a,d){var c,b=l("form",k({method:"post", symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"applications/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(b,a,d){var c,b=l("form",k({method:"post",
action:b,enctype:"multipart/form-data"},d),{display:"none"},j.body);for(c in a)l("input",{type:"hidden",name:c,value:a[c]},null,b);b.submit();o(b)};p(A.prototype,{getSVG:function(b){var a=this,d,c,z,h,g=k(a.options,b);if(!j.createElementNS)j.createElementNS=function(a,b){return j.createElement(b)};b=l("div",null,{position:"absolute",top:"-9999em",width:a.chartWidth+"px",height:a.chartHeight+"px"},j.body);c=a.renderTo.style.width;h=a.renderTo.style.height;c=g.exporting.sourceWidth||g.chart.width|| action:b,enctype:"multipart/form-data"},d),{display:"none"},j.body);for(c in a)l("input",{type:"hidden",name:c,value:a[c]},null,b);b.submit();o(b)};p(A.prototype,{getSVG:function(b){var a=this,d,c,z,h,g=k(a.options,b);if(!j.createElementNS)j.createElementNS=function(a,b){return j.createElement(b)};b=l("div",null,{position:"absolute",top:"-9999em",width:a.chartWidth+"px",height:a.chartHeight+"px"},j.body);c=a.renderTo.style.width;h=a.renderTo.style.height;c=g.exporting.sourceWidth||g.chart.width||
/px$/.test(c)&&parseInt(c,10)||600;h=g.exporting.sourceHeight||g.chart.height||/px$/.test(h)&&parseInt(h,10)||400;p(g.chart,{animation:!1,renderTo:b,forExport:!0,width:c,height:h});g.exporting.enabled=!1;g.series=[];r(a.series,function(a){z=k(a.options,{animation:!1,showCheckbox:!1,visible:a.visible});z.isInternal||g.series.push(z)});d=new f.Chart(g,a.callback);r(["xAxis","yAxis"],function(b){r(a[b],function(a,c){var g=d[b][c],f=a.getExtremes(),h=f.userMin,f=f.userMax;g&&(h!==void 0||f!==void 0)&& /px$/.test(c)&&parseInt(c,10)||600;h=g.exporting.sourceHeight||g.chart.height||/px$/.test(h)&&parseInt(h,10)||400;p(g.chart,{animation:!1,renderTo:b,forExport:!0,width:c,height:h});g.exporting.enabled=!1;g.series=[];r(a.series,function(a){z=k(a.options,{animation:!1,showCheckbox:!1,visible:a.visible});z.isInternal||g.series.push(z)});d=new f.Chart(g,a.callback);r(["xAxis","yAxis"],function(b){r(a[b],function(a,c){var g=d[b][c],f=a.getExtremes(),h=f.userMin,f=f.userMax;g&&(h!==void 0||f!==void 0)&&
g.setExtremes(h,f,!0,!1)})});c=d.container.innerHTML;g=null;d.destroy();o(b);c=c.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/&nbsp;/g," ").replace(/&shy;/g,"­").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g, g.setExtremes(h,f,!0,!1)})});c=d.container.innerHTML;g=null;d.destroy();o(b);c=c.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/&nbsp;/g," ").replace(/&shy;/g,"­").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g,
......
...@@ -4447,7 +4447,7 @@ extend(SVGRenderer.prototype, { ...@@ -4447,7 +4447,7 @@ extend(SVGRenderer.prototype, {
* START OF INTERNET EXPLORER <= 8 SPECIFIC CODE * * START OF INTERNET EXPLORER <= 8 SPECIFIC CODE *
* * * *
* For applications and websites that don't need IE support, like platform * * For applications and websites that don't need IE support, like platform *
* targeted mobile terminal and web terminal, this code can be removed. * * targeted mobile applications and web applications, this code can be removed. *
* * * *
*****************************************************************************/ *****************************************************************************/
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
*/ */
(function(f){var A=f.Chart,t=f.addEvent,B=f.removeEvent,l=f.createElement,o=f.discardElement,v=f.css,k=f.merge,r=f.each,p=f.extend,D=Math.max,j=document,C=window,E=f.isTouchDevice,F=f.Renderer.prototype.symbols,s=f.getOptions(),y;p(s.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});s.navigation={menuStyle:{border:"1px solid #A0A0A0", (function(f){var A=f.Chart,t=f.addEvent,B=f.removeEvent,l=f.createElement,o=f.discardElement,v=f.css,k=f.merge,r=f.each,p=f.extend,D=Math.max,j=document,C=window,E=f.isTouchDevice,F=f.Renderer.prototype.symbols,s=f.getOptions(),y;p(s.lang,{printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});s.navigation={menuStyle:{border:"1px solid #A0A0A0",
background:"#FFFFFF",padding:"5px 0"},menuItemStyle:{padding:"0 10px",background:"none",color:"#303030",fontSize:E?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{symbolFill:"#E0E0E0",symbolSize:14,symbolStroke:"#666",symbolStrokeWidth:3,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,theme:{fill:"white",stroke:"none"},verticalAlign:"top",width:24}};s.exporting={type:"image/png",url:"http://export.highcharts.com/",buttons:{contextButton:{menuClassName:"highcharts-contextmenu", background:"#FFFFFF",padding:"5px 0"},menuItemStyle:{padding:"0 10px",background:"none",color:"#303030",fontSize:E?"14px":"11px"},menuItemHoverStyle:{background:"#4572A5",color:"#FFFFFF"},buttonOptions:{symbolFill:"#E0E0E0",symbolSize:14,symbolStroke:"#666",symbolStrokeWidth:3,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,theme:{fill:"white",stroke:"none"},verticalAlign:"top",width:24}};s.exporting={type:"image/png",url:"http://export.highcharts.com/",buttons:{contextButton:{menuClassName:"highcharts-contextmenu",
symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(b,a,d){var c,b=l("form",k({method:"post", symbol:"menu",_titleKey:"contextButtonTitle",menuItems:[{textKey:"printChart",onclick:function(){this.print()}},{separator:!0},{textKey:"downloadPNG",onclick:function(){this.exportChart()}},{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"applications/pdf"})}},{textKey:"downloadSVG",onclick:function(){this.exportChart({type:"image/svg+xml"})}}]}}};f.post=function(b,a,d){var c,b=l("form",k({method:"post",
action:b,enctype:"multipart/form-data"},d),{display:"none"},j.body);for(c in a)l("input",{type:"hidden",name:c,value:a[c]},null,b);b.submit();o(b)};p(A.prototype,{getSVG:function(b){var a=this,d,c,z,h,g=k(a.options,b);if(!j.createElementNS)j.createElementNS=function(a,b){return j.createElement(b)};b=l("div",null,{position:"absolute",top:"-9999em",width:a.chartWidth+"px",height:a.chartHeight+"px"},j.body);c=a.renderTo.style.width;h=a.renderTo.style.height;c=g.exporting.sourceWidth||g.chart.width|| action:b,enctype:"multipart/form-data"},d),{display:"none"},j.body);for(c in a)l("input",{type:"hidden",name:c,value:a[c]},null,b);b.submit();o(b)};p(A.prototype,{getSVG:function(b){var a=this,d,c,z,h,g=k(a.options,b);if(!j.createElementNS)j.createElementNS=function(a,b){return j.createElement(b)};b=l("div",null,{position:"absolute",top:"-9999em",width:a.chartWidth+"px",height:a.chartHeight+"px"},j.body);c=a.renderTo.style.width;h=a.renderTo.style.height;c=g.exporting.sourceWidth||g.chart.width||
/px$/.test(c)&&parseInt(c,10)||600;h=g.exporting.sourceHeight||g.chart.height||/px$/.test(h)&&parseInt(h,10)||400;p(g.chart,{animation:!1,renderTo:b,forExport:!0,width:c,height:h});g.exporting.enabled=!1;g.series=[];r(a.series,function(a){z=k(a.options,{animation:!1,showCheckbox:!1,visible:a.visible});z.isInternal||g.series.push(z)});d=new f.Chart(g,a.callback);r(["xAxis","yAxis"],function(b){r(a[b],function(a,c){var g=d[b][c],f=a.getExtremes(),h=f.userMin,f=f.userMax;g&&(h!==void 0||f!==void 0)&& /px$/.test(c)&&parseInt(c,10)||600;h=g.exporting.sourceHeight||g.chart.height||/px$/.test(h)&&parseInt(h,10)||400;p(g.chart,{animation:!1,renderTo:b,forExport:!0,width:c,height:h});g.exporting.enabled=!1;g.series=[];r(a.series,function(a){z=k(a.options,{animation:!1,showCheckbox:!1,visible:a.visible});z.isInternal||g.series.push(z)});d=new f.Chart(g,a.callback);r(["xAxis","yAxis"],function(b){r(a[b],function(a,c){var g=d[b][c],f=a.getExtremes(),h=f.userMin,f=f.userMax;g&&(h!==void 0||f!==void 0)&&
g.setExtremes(h,f,!0,!1)})});c=d.container.innerHTML;g=null;d.destroy();o(b);c=c.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/&nbsp;/g," ").replace(/&shy;/g,"­").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g, g.setExtremes(h,f,!0,!1)})});c=d.container.innerHTML;g=null;d.destroy();o(b);c=c.replace(/zIndex="[^"]+"/g,"").replace(/isShadow="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g," xlink:href=").replace(/\n/," ").replace(/<\/svg>.*?$/,"</svg>").replace(/&nbsp;/g," ").replace(/&shy;/g,"­").replace(/<IMG /g,"<image ").replace(/height=([^" ]+)/g,'height="$1"').replace(/width=([^" ]+)/g,
......
...@@ -128,7 +128,7 @@ defaultOptions.exporting = { ...@@ -128,7 +128,7 @@ defaultOptions.exporting = {
textKey: 'downloadPDF', textKey: 'downloadPDF',
onclick: function () { onclick: function () {
this.exportChart({ this.exportChart({
type: 'application/pdf' type: 'applications/pdf'
}); });
} }
}, { }, {
......
...@@ -16,7 +16,7 @@ NgApp.config(['$httpProvider', function ($httpProvider) { ...@@ -16,7 +16,7 @@ NgApp.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
$httpProvider.defaults.headers.post = { $httpProvider.defaults.headers.post = {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'applications/x-www-form-urlencoded'
} }
}]); }]);
NgApp.controller('TerminalRecordCtrl', function ($scope, $http) { NgApp.controller('TerminalRecordCtrl', function ($scope, $http) {
...@@ -121,7 +121,7 @@ NgApp.controller('TerminalRecordCtrl', function ($scope, $http) { ...@@ -121,7 +121,7 @@ NgApp.controller('TerminalRecordCtrl', function ($scope, $http) {
timelist = timelist.sort(function(a, b){return a-b}); timelist = timelist.sort(function(a, b){return a-b});
totalTime = totalTime * 1000; totalTime = totalTime * 1000;
document.getElementById("afterScrubberText").innerHTML = buildTimeString(totalTime); document.getElementById("afterScrubberText").innerHTML = buildTimeString(totalTime);
term.open(document.getElementById('terminal')); term.open(document.getElementById('apps'));
timer = setInterval(advance, TICK); timer = setInterval(advance, TICK);
}) })
......
...@@ -588,7 +588,7 @@ Terminal.bindKeys = function(document) { ...@@ -588,7 +588,7 @@ Terminal.bindKeys = function(document) {
}, true); }, true);
// If we click somewhere other than a // If we click somewhere other than a
// terminal, unfocus the terminal. // applications, unfocus the applications.
on(document, 'mousedown', function(ev) { on(document, 'mousedown', function(ev) {
if (!Terminal.focus) return; if (!Terminal.focus) return;
...@@ -742,7 +742,7 @@ Terminal.insertStyle = function(document, bg, fg) { ...@@ -742,7 +742,7 @@ Terminal.insertStyle = function(document, bg, fg) {
// textContent doesn't work well with IE for <style> elements. // textContent doesn't work well with IE for <style> elements.
style.innerHTML = '' style.innerHTML = ''
+ '.terminal {\n' + '.applications {\n'
+ ' float: left;\n' + ' float: left;\n'
+ ' border: ' + bg + ' solid 5px;\n' + ' border: ' + bg + ' solid 5px;\n'
+ ' font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;\n' + ' font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;\n'
...@@ -751,7 +751,7 @@ Terminal.insertStyle = function(document, bg, fg) { ...@@ -751,7 +751,7 @@ Terminal.insertStyle = function(document, bg, fg) {
+ ' background: ' + bg + ';\n' + ' background: ' + bg + ';\n'
+ '}\n' + '}\n'
+ '\n' + '\n'
+ '.terminal-cursor {\n' + '.applications-cursor {\n'
+ ' color: ' + bg + ';\n' + ' color: ' + bg + ';\n'
+ ' background: ' + fg + ';\n' + ' background: ' + fg + ';\n'
+ '}\n'; + '}\n';
...@@ -802,7 +802,7 @@ Terminal.prototype.open = function(parent) { ...@@ -802,7 +802,7 @@ Terminal.prototype.open = function(parent) {
this.isMSIE = !!~this.context.navigator.userAgent.indexOf('MSIE'); this.isMSIE = !!~this.context.navigator.userAgent.indexOf('MSIE');
} }
// Create our main terminal element. // Create our main applications element.
this.element = this.document.createElement('div'); this.element = this.document.createElement('div');
this.element.className = 'terminal'; this.element.className = 'terminal';
this.element.style.outline = 'none'; this.element.style.outline = 'none';
...@@ -811,7 +811,7 @@ Terminal.prototype.open = function(parent) { ...@@ -811,7 +811,7 @@ Terminal.prototype.open = function(parent) {
this.element.style.backgroundColor = this.colors[256]; this.element.style.backgroundColor = this.colors[256];
this.element.style.color = this.colors[257]; this.element.style.color = this.colors[257];
// Create the lines for our terminal. // Create the lines for our applications.
this.children = []; this.children = [];
for (; i < this.rows; i++) { for (; i < this.rows; i++) {
div = this.document.createElement('div'); div = this.document.createElement('div');
...@@ -1020,7 +1020,7 @@ Terminal.prototype.open = function(parent) { ...@@ -1020,7 +1020,7 @@ Terminal.prototype.open = function(parent) {
if (!('useMouse' in this.options) || this.options.useMouse) { if (!('useMouse' in this.options) || this.options.useMouse) {
// Listen for mouse events and translate // Listen for mouse events and translate
// them into terminal mouse protocols. // them into applications mouse protocols.
this.bindMouse(); this.bindMouse();
} }
...@@ -1549,7 +1549,7 @@ Terminal.prototype.refresh = function(start, end) { ...@@ -1549,7 +1549,7 @@ Terminal.prototype.refresh = function(start, end) {
} }
if (data !== this.defAttr) { if (data !== this.defAttr) {
if (data === -1) { if (data === -1) {
out += '<span class="reverse-video terminal-cursor">'; out += '<span class="reverse-video applications-cursor">';
} else { } else {
out += '<span style="'; out += '<span style="';
...@@ -1660,7 +1660,7 @@ Terminal.prototype.refresh = function(start, end) { ...@@ -1660,7 +1660,7 @@ Terminal.prototype.refresh = function(start, end) {
} }
if (this._textarea) { if (this._textarea) {
var cursorElement = this.element.querySelector('.terminal-cursor'); var cursorElement = this.element.querySelector('.applications-cursor');
if(cursorElement){ if(cursorElement){
var cursor_x = cursorElement.offsetLeft; var cursor_x = cursorElement.offsetLeft;
var cursor_y = cursorElement.offsetTop; var cursor_y = cursorElement.offsetTop;
...@@ -2031,7 +2031,7 @@ Terminal.prototype.write = function(data) { ...@@ -2031,7 +2031,7 @@ Terminal.prototype.write = function(data) {
// ESC = Application Keypad (DECPAM). // ESC = Application Keypad (DECPAM).
case '=': case '=':
this.log('Serial port requested application keypad.'); this.log('Serial port requested applications keypad.');
this.applicationKeypad = true; this.applicationKeypad = true;
this.state = normal; this.state = normal;
break; break;
...@@ -2474,7 +2474,7 @@ Terminal.prototype.write = function(data) { ...@@ -2474,7 +2474,7 @@ Terminal.prototype.write = function(data) {
// break; // break;
// CSI > Ps p Set pointer mode. // CSI > Ps p Set pointer mode.
// CSI ! p Soft terminal reset (DECSTR). // CSI ! p Soft applications reset (DECSTR).
// CSI Ps$ p // CSI Ps$ p
// Request ANSI mode (DECRQM). // Request ANSI mode (DECRQM).
// CSI ? Ps$ p // CSI ? Ps$ p
...@@ -3959,7 +3959,7 @@ Terminal.prototype.HPositionRelative = function(params) { ...@@ -3959,7 +3959,7 @@ Terminal.prototype.HPositionRelative = function(params) {
}; };
// CSI Ps c Send Device Attributes (Primary DA). // CSI Ps c Send Device Attributes (Primary DA).
// Ps = 0 or omitted -> request attributes from terminal. The // Ps = 0 or omitted -> request attributes from applications. The
// response depends on the decTerminalID resource setting. // response depends on the decTerminalID resource setting.
// -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'') // -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'')
// -> CSI ? 1 ; 0 c (``VT101 with No Options'') // -> CSI ? 1 ; 0 c (``VT101 with No Options'')
...@@ -3967,7 +3967,7 @@ Terminal.prototype.HPositionRelative = function(params) { ...@@ -3967,7 +3967,7 @@ Terminal.prototype.HPositionRelative = function(params) {
// -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'') // -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'')
// The VT100-style response parameters do not mean anything by // The VT100-style response parameters do not mean anything by
// themselves. VT220 parameters do, telling the host what fea- // themselves. VT220 parameters do, telling the host what fea-
// tures the terminal supports: // tures the applications supports:
// Ps = 1 -> 132-columns. // Ps = 1 -> 132-columns.
// Ps = 2 -> Printer. // Ps = 2 -> Printer.
// Ps = 6 -> Selective erase. // Ps = 6 -> Selective erase.
...@@ -3978,12 +3978,12 @@ Terminal.prototype.HPositionRelative = function(params) { ...@@ -3978,12 +3978,12 @@ Terminal.prototype.HPositionRelative = function(params) {
// Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode). // Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode).
// CSI > Ps c // CSI > Ps c
// Send Device Attributes (Secondary DA). // Send Device Attributes (Secondary DA).
// Ps = 0 or omitted -> request the terminal's identification // Ps = 0 or omitted -> request the applications's identification
// code. The response depends on the decTerminalID resource set- // code. The response depends on the decTerminalID resource set-
// ting. It should apply only to VT220 and up, but xterm extends // ting. It should apply only to VT220 and up, but xterm extends
// this to VT100. // this to VT100.
// -> CSI > Pp ; Pv ; Pc c // -> CSI > Pp ; Pv ; Pc c
// where Pp denotes the terminal type // where Pp denotes the applications type
// Pp = 0 -> ``VT100''. // Pp = 0 -> ``VT100''.
// Pp = 1 -> ``VT220''. // Pp = 1 -> ``VT220''.
// and Pv is the firmware version (for xterm, this was originally // and Pv is the firmware version (for xterm, this was originally
...@@ -3992,7 +3992,7 @@ Terminal.prototype.HPositionRelative = function(params) { ...@@ -3992,7 +3992,7 @@ Terminal.prototype.HPositionRelative = function(params) {
// always zero. // always zero.
// More information: // More information:
// xterm/charproc.c - line 2012, for more information. // xterm/charproc.c - line 2012, for more information.
// vim responds with ^[[?0c or ^[[?1c after the terminal's response (?) // vim responds with ^[[?0c or ^[[?1c after the applications's response (?)
Terminal.prototype.sendDeviceAttributes = function(params) { Terminal.prototype.sendDeviceAttributes = function(params) {
if (params[0] > 0) return; if (params[0] > 0) return;
...@@ -4193,7 +4193,7 @@ Terminal.prototype.setMode = function(params) { ...@@ -4193,7 +4193,7 @@ Terminal.prototype.setMode = function(params) {
// this.cursorBlink = true; // this.cursorBlink = true;
break; break;
case 66: case 66:
this.log('Serial port requested application keypad.'); this.log('Serial port requested applications keypad.');
this.applicationKeypad = true; this.applicationKeypad = true;
break; break;
case 9: // X10 Mouse case 9: // X10 Mouse
...@@ -4217,19 +4217,19 @@ Terminal.prototype.setMode = function(params) { ...@@ -4217,19 +4217,19 @@ Terminal.prototype.setMode = function(params) {
// focusout: ^[[O // focusout: ^[[O
this.sendFocus = true; this.sendFocus = true;
break; break;
case 1005: // utf8 terminal mode mouse case 1005: // utf8 applications mode mouse
this.utfMouse = true; this.utfMouse = true;
// for wide terminals // for wide terminals
// simply encodes large values as utf8 characters // simply encodes large values as utf8 characters
break; break;
case 1006: // sgr terminal mode mouse case 1006: // sgr applications mode mouse
this.sgrMouse = true; this.sgrMouse = true;
// for wide terminals // for wide terminals
// does not add 32 to fields // does not add 32 to fields
// press: ^[[<b;x;yM // press: ^[[<b;x;yM
// release: ^[[<b;x;ym // release: ^[[<b;x;ym
break; break;
case 1015: // urxvt terminal mode mouse case 1015: // urxvt applications mode mouse
this.urxvtMouse = true; this.urxvtMouse = true;
// for wide terminals // for wide terminals
// numbers for fields // numbers for fields
...@@ -4406,13 +4406,13 @@ Terminal.prototype.resetMode = function(params) { ...@@ -4406,13 +4406,13 @@ Terminal.prototype.resetMode = function(params) {
case 1004: // send focusin/focusout events case 1004: // send focusin/focusout events
this.sendFocus = false; this.sendFocus = false;
break; break;
case 1005: // utf8 terminal mode mouse case 1005: // utf8 applications mode mouse
this.utfMouse = false; this.utfMouse = false;
break; break;
case 1006: // sgr terminal mode mouse case 1006: // sgr applications mode mouse
this.sgrMouse = false; this.sgrMouse = false;
break; break;
case 1015: // urxvt terminal mode mouse case 1015: // urxvt applications mode mouse
this.urxvtMouse = false; this.urxvtMouse = false;
break; break;
case 25: // hide cursor case 25: // hide cursor
...@@ -4622,7 +4622,7 @@ Terminal.prototype.setPointerMode = function(params) { ...@@ -4622,7 +4622,7 @@ Terminal.prototype.setPointerMode = function(params) {
; ;
}; };
// CSI ! p Soft terminal reset (DECSTR). // CSI ! p Soft applications reset (DECSTR).
// http://vt100.net/docs/vt220-rm/table4-10.html // http://vt100.net/docs/vt220-rm/table4-10.html
Terminal.prototype.softReset = function(params) { Terminal.prototype.softReset = function(params) {
this.cursorHidden = false; this.cursorHidden = false;
...@@ -4870,7 +4870,7 @@ Terminal.prototype.enableFilterRectangle = function(params) { ...@@ -4870,7 +4870,7 @@ Terminal.prototype.enableFilterRectangle = function(params) {
// CSI Ps x Request Terminal Parameters (DECREQTPARM). // CSI Ps x Request Terminal Parameters (DECREQTPARM).
// if Ps is a "0" (default) or "1", and xterm is emulating VT100, // if Ps is a "0" (default) or "1", and xterm is emulating VT100,
// the control sequence elicits a response of the same form whose // the control sequence elicits a response of the same form whose
// parameters describe the terminal: // parameters describe the applications:
// Ps -> the given Ps incremented by 2. // Ps -> the given Ps incremented by 2.
// Pn = 1 <- no parity. // Pn = 1 <- no parity.
// Pn = 1 <- eight bits. // Pn = 1 <- eight bits.
...@@ -6030,7 +6030,7 @@ Terminal.charsets = {}; ...@@ -6030,7 +6030,7 @@ Terminal.charsets = {};
// DEC Special Character and Line Drawing Set. // DEC Special Character and Line Drawing Set.
// http://vt100.net/docs/vt102-ug/table5-13.html // http://vt100.net/docs/vt102-ug/table5-13.html
// A lot of curses terminal use this if they see TERM=xterm. // A lot of curses applications use this if they see TERM=xterm.
// testing: echo -e '\e(0a\e(B' // testing: echo -e '\e(0a\e(B'
// The xterm output sometimes seems to conflict with the // The xterm output sometimes seems to conflict with the
// reference above. xterm seems in line with the reference // reference above. xterm seems in line with the reference
...@@ -6113,7 +6113,7 @@ function inherits(child, parent) { ...@@ -6113,7 +6113,7 @@ function inherits(child, parent) {
} }
// if bold is broken, we can't // if bold is broken, we can't
// use it in the terminal. // use it in the applications.
function isBoldBroken(document) { function isBoldBroken(document) {
var body = document.getElementsByTagName('body')[0]; var body = document.getElementsByTagName('body')[0];
var terminal = document.createElement('div'); var terminal = document.createElement('div');
......
...@@ -13,7 +13,7 @@ WSSHClient.prototype._generateEndpoint = function (options) { ...@@ -13,7 +13,7 @@ WSSHClient.prototype._generateEndpoint = function (options) {
var protocol = 'ws://'; var protocol = 'ws://';
} }
var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/ws/terminal' + document.URL.match(/(\?.*)/); var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/ws/applications' + document.URL.match(/(\?.*)/);
return endpoint; return endpoint;
}; };
WSSHClient.prototype.connect = function (options) { WSSHClient.prototype.connect = function (options) {
...@@ -81,7 +81,7 @@ function openTerminal(options) { ...@@ -81,7 +81,7 @@ function openTerminal(options) {
term.on('data', function (data) { term.on('data', function (data) {
client.send(data) client.send(data)
}); });
$('.terminal').detach().appendTo('#term'); $('.applications').detach().appendTo('#term');
//term.resize(colWidth, rowHeight); //term.resize(colWidth, rowHeight);
term.write('Connecting...'); term.write('Connecting...');
client.connect($.extend(options, { client.connect($.extend(options, {
...@@ -100,13 +100,13 @@ function openTerminal(options) { ...@@ -100,13 +100,13 @@ function openTerminal(options) {
term.write(data); term.write(data);
} }
})); }));
//rowHeight = 0.0 + 1.00 * $('.terminal').height() / 24; //rowHeight = 0.0 + 1.00 * $('.applications').height() / 24;
//colWidth = 0.0 + 1.00 * $('.terminal').width() / 80; //colWidth = 0.0 + 1.00 * $('.applications').width() / 80;
return {'term': term, 'client': client}; return {'term': term, 'client': client};
} }
//function resize() { //function resize() {
// $('.terminal').css('width', window.innerWidth - 25); // $('.applications').css('width', window.innerWidth - 25);
// console.log(window.innerWidth); // console.log(window.innerWidth);
// console.log(window.innerWidth - 10); // console.log(window.innerWidth - 10);
// var rows = Math.floor(window.innerHeight / rowHeight) - 2; // var rows = Math.floor(window.innerHeight / rowHeight) - 2;
...@@ -145,10 +145,10 @@ $(document).ready(function () { ...@@ -145,10 +145,10 @@ $(document).ready(function () {
term_client.client.send({'resize': {'rows': row, 'cols': col}}); term_client.client.send({'resize': {'rows': row, 'cols': col}});
$('#ssh').show(); $('#ssh').show();
}); });
$(".terminal").mouseleave(function () { $(".applications").mouseleave(function () {
$(".termChangBar").slideDown(); $(".termChangBar").slideDown();
}); });
$(".terminal").mouseenter(function () { $(".applications").mouseenter(function () {
$(".termChangBar").slideUp(); $(".termChangBar").slideUp();
}) })
}); });
\ No newline at end of file
...@@ -47,7 +47,7 @@ WSSHClient.prototype._generateEndpoint = function(options) { ...@@ -47,7 +47,7 @@ WSSHClient.prototype._generateEndpoint = function(options) {
var protocol = 'ws://'; var protocol = 'ws://';
} }
var endpoint = protocol + window.location.host + ':8080' + '/terminal'; var endpoint = protocol + window.location.host + ':8080' + '/applications';
return endpoint; return endpoint;
}; };
......
...@@ -35,10 +35,13 @@ ...@@ -35,10 +35,13 @@
</ul> </ul>
</li> </li>
<li id="terminal"> <li id="applications">
<a href="{% url 'terminal:terminal-list' %}"> <a>
<i class="fa fa-desktop"></i><span class="nav-label">{% trans 'Terminal' %}</span><span class="label label-info pull-right"></span> <i class="fa fa-coffee"></i> <span class="nav-label">{% trans 'Applications' %}</span><span class="fa arrow"></span>
  </a> </a>
<ul class="nav nav-second-level">
<li id="terminal"><a href="{% url 'applications:terminal-list' %}">{% trans 'Terminal' %}</a></li>
</ul>
</li> </li>
<li id="ops"> <li id="ops">
......
...@@ -13,7 +13,7 @@ from django_filters.rest_framework import DjangoFilterBackend ...@@ -13,7 +13,7 @@ from django_filters.rest_framework import DjangoFilterBackend
from common.mixins import IDInFilterMixin from common.mixins import IDInFilterMixin
from common.utils import get_logger from common.utils import get_logger
from .utils import check_user_valid, get_or_refresh_token from .utils import check_user_valid, generate_token
from .models import User, UserGroup from .models import User, UserGroup
from .hands import write_login_log_async from .hands import write_login_log_async
from .permissions import IsSuperUser, IsAppUser, IsValidUser, IsSuperUserOrAppUser from .permissions import IsSuperUser, IsAppUser, IsValidUser, IsSuperUserOrAppUser
...@@ -91,7 +91,7 @@ class UserToken(APIView): ...@@ -91,7 +91,7 @@ class UserToken(APIView):
def get(self, request): def get(self, request):
if not request.user: if not request.user:
return Response({'error': 'unauthorized'}) return Response({'error': 'unauthorized'})
token = get_token(request) token = generate_token(request)
return Response({'token': token}) return Response({'token': token})
...@@ -111,14 +111,14 @@ class UserAuthApi(APIView): ...@@ -111,14 +111,14 @@ class UserAuthApi(APIView):
password = request.data.get('password', '') password = request.data.get('password', '')
public_key = request.data.get('public_key', '') public_key = request.data.get('public_key', '')
remote_addr = request.data.get('remote_addr', '') remote_addr = request.data.get('remote_addr', '')
terminal = request.data.get('terminal', '') terminal = request.data.get('applications', '')
login_type = request.data.get('login_type', 'T') login_type = request.data.get('login_type', 'T')
user = check_user_valid(username=username, password=password, public_key=public_key) user = check_user_valid(username=username, password=password, public_key=public_key)
if user: if user:
token = cache.get('%s_%s' % (user.id, remote_addr)) token = cache.get('%s_%s' % (user.id, remote_addr))
if not token: if not token:
token = token_gen(user) token = generate_token(request)
cache.set(token, user.id, self.expiration) cache.set(token, user.id, self.expiration)
cache.set('%s_%s' % (user.id, remote_addr), token, self.expiration) cache.set('%s_%s' % (user.id, remote_addr), token, self.expiration)
......
...@@ -9,14 +9,13 @@ from django.core.cache import cache ...@@ -9,14 +9,13 @@ from django.core.cache import cache
from django.conf import settings from django.conf import settings
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from rest_framework import authentication, exceptions, permissions from rest_framework import authentication, exceptions, permissions
from rest_framework.compat import is_authenticated
from django.utils.six import text_type from django.utils.six import text_type
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import HTTP_HEADER_ENCODING from rest_framework import HTTP_HEADER_ENCODING
from common.utils import get_object_or_none, make_signature, http_to_unixtime from common.utils import get_object_or_none, make_signature, http_to_unixtime
from .utils import get_or_refresh_token from .utils import refresh_token
from .models import User, AccessKey from .models import User, AccessKey, PrivateToken
def get_request_date_header(request): def get_request_date_header(request):
...@@ -93,7 +92,6 @@ class AccessTokenAuthentication(authentication.BaseAuthentication): ...@@ -93,7 +92,6 @@ class AccessTokenAuthentication(authentication.BaseAuthentication):
def authenticate(self, request): def authenticate(self, request):
auth = authentication.get_authorization_header(request).split() auth = authentication.get_authorization_header(request).split()
if not auth or auth[0].lower() != self.keyword.lower().encode(): if not auth or auth[0].lower() != self.keyword.lower().encode():
return None return None
...@@ -109,14 +107,18 @@ class AccessTokenAuthentication(authentication.BaseAuthentication): ...@@ -109,14 +107,18 @@ class AccessTokenAuthentication(authentication.BaseAuthentication):
except UnicodeError: except UnicodeError:
msg = _('Invalid token header. Sign string should not contain invalid characters.') msg = _('Invalid token header. Sign string should not contain invalid characters.')
raise exceptions.AuthenticationFailed(msg) raise exceptions.AuthenticationFailed(msg)
return self.authenticate_credentials(token, request) return self.authenticate_credentials(token)
def authenticate_credentials(self, token, request): def authenticate_credentials(self, token):
user_id = cache.get(token) user_id = cache.get(token)
print('Auth id: %s' % user_id)
user = get_object_or_none(User, id=user_id) user = get_object_or_none(User, id=user_id)
if not user: if not user:
return None msg = _('Invalid token or cache refreshed.')
get_or_refresh_token(request, user) raise exceptions.AuthenticationFailed(msg)
refresh_token(token, user)
return user, None return user, None
class PrivateTokenAuthentication(authentication.TokenAuthentication):
model = PrivateToken
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
:license: GPL v2, see LICENSE for more details. :license: GPL v2, see LICENSE for more details.
""" """
from terminal.models import Terminal from applications.models import Terminal
from audits.tasks import write_login_log_async from audits.tasks import write_login_log_async
from users.models import User from users.models import User
# from perms.models import AssetPermission # from perms.models import AssetPermission
......
...@@ -8,10 +8,7 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -8,10 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
from . import User from . import User
__all__ = ['AccessKey'] __all__ = ['AccessKey', 'PrivateToken']
def get_uuid_string():
return uuid.uuid4().__str__()
class AccessKey(models.Model): class AccessKey(models.Model):
......
...@@ -12,7 +12,6 @@ from django.db import models, IntegrityError ...@@ -12,7 +12,6 @@ from django.db import models, IntegrityError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils import timezone from django.utils import timezone
from django.shortcuts import reverse from django.shortcuts import reverse
from rest_framework.authtoken.models import Token
from common.utils import signer, date_expired_default from common.utils import signer, date_expired_default
from . import UserGroup from . import UserGroup
...@@ -100,10 +99,6 @@ class User(AbstractUser): ...@@ -100,10 +99,6 @@ class User(AbstractUser):
else: else:
return False return False
@property
def is_app(self):
return self.role == 'App'
@is_superuser.setter @is_superuser.setter
def is_superuser(self, value): def is_superuser(self, value):
if value is True: if value is True:
...@@ -111,6 +106,10 @@ class User(AbstractUser): ...@@ -111,6 +106,10 @@ class User(AbstractUser):
else: else:
self.role = 'User' self.role = 'User'
@property
def is_app(self):
return self.role == 'App'
@property @property
def is_staff(self): def is_staff(self):
if self.is_authenticated and self.is_valid: if self.is_authenticated and self.is_valid:
...@@ -134,18 +133,20 @@ class User(AbstractUser): ...@@ -134,18 +133,20 @@ class User(AbstractUser):
@property @property
def private_token(self): def private_token(self):
return self.get_private_token() return self.create_private_token()
def get_private_token(self): def create_private_token(self):
from .authentication import PrivateToken
try: try:
token = Token.objects.get(user=self) token = PrivateToken.objects.get(user=self)
except Token.DoesNotExist: except PrivateToken.DoesNotExist:
token = Token.objects.create(user=self) token = PrivateToken.objects.create(user=self)
return token.key return token.key
def refresh_private_token(self): def refresh_private_token(self):
Token.objects.filter(user=self).delete() from .authentication import PrivateToken
return Token.objects.create(user=self) PrivateToken.objects.filter(user=self).delete()
return PrivateToken.objects.create(user=self)
def is_member_of(self, user_group): def is_member_of(self, user_group):
if user_group in self.groups.all(): if user_group in self.groups.all():
......
...@@ -197,13 +197,21 @@ def check_user_valid(**kwargs): ...@@ -197,13 +197,21 @@ def check_user_valid(**kwargs):
return None return None
def get_or_refresh_token(request, user): def refresh_token(token, user):
expiration = settings.CONFIG.TOKEN_EXPIRATION or 3600
cache.set(token, user.id, expiration)
def generate_token(request):
expiration = settings.CONFIG.TOKEN_EXPIRATION or 3600 expiration = settings.CONFIG.TOKEN_EXPIRATION or 3600
remote_addr = request.META.get('REMOTE_ADDR', '') remote_addr = request.META.get('REMOTE_ADDR', '')
remote_addr = base64.b16encode(remote_addr).replace('=', '') remote_addr = base64.b16encode(remote_addr).replace('=', '')
token = cache.get('%s_%s' % (user.id, remote_addr)) token = cache.get('%s_%s' % (request.user.id, remote_addr))
if not token: if not token:
token = uuid.uuid4().get_hex() token = uuid.uuid4().get_hex()
print('Set cache: %s' % token)
cache.set(token, request.user.id, expiration) cache.set(token, request.user.id, expiration)
cache.set('%s_%s' % (request.user.id, remote_addr), token, expiration) cache.set('%s_%s' % (request.user.id, remote_addr), token, expiration)
return uuid.uuid4().get_hex() return token
...@@ -577,7 +577,7 @@ class UserExportView(View): ...@@ -577,7 +577,7 @@ class UserExportView(View):
user.role, user.phone, user.wechat, user.comment]) user.role, user.phone, user.wechat, user.comment])
filename = 'users-{}.xlsx'.format(timezone.localtime(timezone.now()).strftime('%Y-%m-%d_%H-%M-%S')) filename = 'users-{}.xlsx'.format(timezone.localtime(timezone.now()).strftime('%Y-%m-%d_%H-%M-%S'))
response = HttpResponse(save_virtual_workbook(wb), content_type='application/vnd.ms-excel') response = HttpResponse(save_virtual_workbook(wb), content_type='applications/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename="%s"' % filename response['Content-Disposition'] = 'attachment; filename="%s"' % filename
return response return response
......
#!/bin/bash #!/bin/bash
# #
for app in users assets perms audits teminal ops;do for app in users assets perms audits ops applications;do
rm -f ../apps/$app/migrations/000* rm -f ../apps/$app/migrations/000*
done done
#!/bin/bash
#
python ../apps/manage.py loaddata fake
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册