Return-Path: X-Original-To: apmail-aurora-commits-archive@minotaur.apache.org Delivered-To: apmail-aurora-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3CB0610D03 for ; Fri, 17 Jan 2014 01:03:53 +0000 (UTC) Received: (qmail 19515 invoked by uid 500); 17 Jan 2014 01:03:52 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 19471 invoked by uid 500); 17 Jan 2014 01:03:52 -0000 Mailing-List: contact commits-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list commits@aurora.incubator.apache.org Received: (qmail 19463 invoked by uid 99); 17 Jan 2014 01:03:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jan 2014 01:03:51 +0000 X-ASF-Spam-Status: No, hits=-2000.1 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 17 Jan 2014 01:03:49 +0000 Received: (qmail 19165 invoked by uid 99); 17 Jan 2014 01:03:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jan 2014 01:03:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 91A51511A; Fri, 17 Jan 2014 01:03:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mansu@apache.org To: commits@aurora.incubator.apache.org Date: Fri, 17 Jan 2014 01:03:24 -0000 Message-Id: <48d10b1a6bb9475aaf938a6fb2b861cc@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/6] Scheduler home page new using AngularJS and UI client X-Virus-Checked: Checked by ClamAV on apache.org Updated Branches: refs/heads/master b493027e7 -> 35fcc545a http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java b/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java index a3faf6b..60ce15c 100644 --- a/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java +++ b/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java @@ -81,18 +81,20 @@ public class ServletModule extends AbstractModule { @Override protected void configureServlets() { bind(HttpStatsFilter.class).in(Singleton.class); filter("/scheduler*").through(HttpStatsFilter.class); + // Servlets may assign a special meaning to trailing /, but this confuses AngularJS's + // resource loader. So, removing them for /scheduler* URLs using a UIRedirectFilter. + // TODO (skarumuri): Remove UIRedirectFilter when the /scheduler servlets are removed. + bind(UIRedirectFilter.class).in(Singleton.class); + filter("/scheduler*").through(UIRedirectFilter.class); bind(LeaderRedirectFilter.class).in(Singleton.class); + registerJerseyEndpoint("/cron", Cron.class); registerJerseyEndpoint("/maintenance", Maintenance.class); registerJerseyEndpoint("/mname", Mname.class); registerJerseyEndpoint("/offers", Offers.class); registerJerseyEndpoint("/pendingtasks", PendingTasks.class); registerJerseyEndpoint("/quotas", Quotas.class); - registerJerseyEndpoint( - "/scheduler", - SchedulerzHome.class, - SchedulerzRole.class, - SchedulerzJob.class); + registerJerseyEndpoint("/scheduler/", SchedulerzRole.class, SchedulerzJob.class); registerJerseyEndpoint("/slaves", Slaves.class); registerJerseyEndpoint("/structdump", StructDump.class); registerJerseyEndpoint("/utilization", Utilization.class); @@ -146,6 +148,8 @@ public class ServletModule extends AbstractModule { "assets/datatables/js/dataTables.htmlNumberType.js", "/js/dataTables.htmlNumberType.js"); + registerUIClient(); + bind(LeaderRedirect.class).in(Singleton.class); LifecycleModule.bindStartupAction(binder(), RedirectMonitor.class); } @@ -170,12 +174,34 @@ public class ServletModule extends AbstractModule { false); } + /** + * A function to handle all assets related to the UI client. + */ + private void registerUIClient() { + registerAsset("bower_components/smart-table/Smart-Table.debug.js", "/js/smartTable.js", false); + registerAsset("bower_components/angular/angular.js", "/js/angular.js", false); + + registerAsset("ReadOnlyScheduler.js", "/js/readOnlyScheduler.js", false); + registerAsset("api_types.js", "/js/apiTypes.js", false); + registerAsset("thrift.js", "/js/thrift.js", false); + + registerAsset("ui/index.html", "/scheduler"); + registerAsset("ui/roleLink.html", "/roleLink.html"); + + registerAsset("ui/css/app.css", "/css/app.css"); + + registerAsset("ui/js/app.js", "/js/app.js"); + registerAsset("ui/js/controllers.js", "/js/controllers.js"); + registerAsset("ui/js/directives.js", "/js/directives.js"); + registerAsset("ui/js/services.js", "/js/services.js"); + } + private void registerAsset(String resourceLocation, String registerLocation) { registerAsset(resourceLocation, registerLocation, true); } private void registerAsset(String resourceLocation, String registerLocation, boolean isRelative) { - String mediaType = getMediaType(registerLocation).toString(); + String mediaType = getMediaType(resourceLocation).toString(); if (isRelative) { Registration.registerHttpAsset( http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/java/org/apache/aurora/scheduler/http/UIRedirectFilter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/http/UIRedirectFilter.java b/src/main/java/org/apache/aurora/scheduler/http/UIRedirectFilter.java new file mode 100644 index 0000000..b35aad8 --- /dev/null +++ b/src/main/java/org/apache/aurora/scheduler/http/UIRedirectFilter.java @@ -0,0 +1,43 @@ +/** + * Copyright 2013 Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.aurora.scheduler.http; + +import java.io.IOException; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.twitter.common.net.http.filters.AbstractHttpFilter; + +/** + * A filter that maps string template servlet paths to UI client pages. This is needed because + * AngularJS's resource loader is confused when there is a trailing / at the end of URL's. + */ +public class UIRedirectFilter extends AbstractHttpFilter { + + @Override + public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) + throws IOException, ServletException { + + if ("/scheduler/".equals(request.getRequestURI())) { + response.sendRedirect("/scheduler"); + } else { + chain.doFilter(request, response); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/schedulerzhome.st ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/schedulerzhome.st b/src/main/resources/org/apache/aurora/scheduler/http/schedulerzhome.st deleted file mode 100644 index 5e540f3..0000000 --- a/src/main/resources/org/apache/aurora/scheduler/http/schedulerzhome.st +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - Aurora $cluster_name$ scheduler - - - - - - - - - -
-
-
-

Scheduled Jobs

-
-
- - - - - - $owners:{ owner | - - - }$ - -
Role - Jobs - Cron Jobs -
$owner.role$ - $owner.jobCount$ - $owner.cronJobCount$ -
- $if(exception)$ - Exception: $exception$ - $endif$ -
- - - - http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/css/app.css ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/css/app.css b/src/main/resources/org/apache/aurora/scheduler/http/ui/css/app.css new file mode 100644 index 0000000..9a2fdf1 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/css/app.css @@ -0,0 +1,9 @@ +/* app css stylesheet */ + +[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { + display: none !important; +} + +.pagination { + text-align: center; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html b/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html new file mode 100644 index 0000000..c6706c1 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/index.html @@ -0,0 +1,43 @@ + + + + + Aurora UI + + + + +
+
+ +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js new file mode 100644 index 0000000..db6ea99 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/app.js @@ -0,0 +1,4 @@ +'use strict'; + +// Declare app level module which depends on filters, and services +var auroraUI = angular.module('auroraUI', ['auroraUI.controllers', 'smartTable.table']); http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js new file mode 100644 index 0000000..f1333f1 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js @@ -0,0 +1,24 @@ +'use strict'; + +/* Controllers */ + +angular.module('auroraUI.controllers', []). + controller('JobSummaryController', + function ($scope, $window, auroraClient) { + $scope.title = 'Scheduled Jobs Summary'; + + $scope.columnCollection = [ + {label : 'Role', map: 'role', cellTemplateUrl: 'roleLink.html'}, + {label : 'Jobs', map: 'jobCount'}, + {label : 'Cron Jobs', map: 'cronJobCount'} + ]; + + $scope.rowCollection = auroraClient.getJobSummary().summaries; + + $scope.globalConfig = { + isGlobalSearchActivated: true, + isPaginationEnabled: true, + itemsByPage: 25, + maxSize: 8 + }; + }); http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js new file mode 100644 index 0000000..d2b2017 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/directives.js @@ -0,0 +1,8 @@ +'use strict'; + +auroraUI.directive('roleLink', function () { + return { + restrict: 'C', + template: "{{formatedValue}}" + }; +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js new file mode 100644 index 0000000..16f22a7 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js @@ -0,0 +1,24 @@ +'use strict'; + +auroraUI.factory( + 'auroraClient', + function () { + return { + getJobSummary: function () { + var client = this.makeSchedulerClient(); + + var response; + console.log("querying server"); + response = client.getJobSummary(); + console.log(response); + return response.result.jobSummaryResult; + }, + + makeSchedulerClient: function () { + var transport = new Thrift.Transport("/api/"); + var protocol = new Thrift.Protocol(transport); + return new ReadOnlySchedulerClient(protocol); + } + }; + } +); http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/35fcc545/src/main/resources/org/apache/aurora/scheduler/http/ui/roleLink.html ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/roleLink.html b/src/main/resources/org/apache/aurora/scheduler/http/ui/roleLink.html new file mode 100644 index 0000000..fc25526 --- /dev/null +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/roleLink.html @@ -0,0 +1 @@ + \ No newline at end of file