Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Add web UI for mover and copy. #927

Merged
merged 26 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
96d1f02
merge the 'zeppelin' app.js to 'trunk'.
Jul 19, 2017
77d5648
Merge remote-tracking branch 'origin/trunk' into trunk
Jul 19, 2017
6d690cc
Change button style of rules (#747)
Jul 20, 2017
504a5ad
Add tooltip for action (#765)
Jul 26, 2017
bdbf424
Change home.html (#786)
Jul 27, 2017
9903862
Add help for actions (#794)
Jul 27, 2017
135a6ff
#778 Add Rule format description on UI (#810)
Jul 31, 2017
05e50d2
Add SmartNotebook (#831)
Aug 2, 2017
4d614d6
Merge branch 'trunk' into smart-notebook
Aug 3, 2017
7582b24
Fix build bugs and web UI
Aug 3, 2017
a641c08
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 3, 2017
68c0396
change the home page.
Aug 3, 2017
79fb8cb
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 3, 2017
37acaf2
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 4, 2017
a546f75
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 4, 2017
1cbf816
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 7, 2017
dbd7e1e
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 7, 2017
9d2948f
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 7, 2017
7160f99
remove 'zeppelin-web' from 'smart-zeppelin' default module.
Aug 8, 2017
3d9e6b5
Update the web UI "Smart Manager" to "Smart Storage Manager"
Aug 8, 2017
661af4e
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 8, 2017
8d74c9c
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 9, 2017
6741a66
Add mover and copy view.
Aug 10, 2017
7322f7e
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 10, 2017
2d4ed4d
Merge branch 'trunk' of https://github.com/Intel-bigdata/SSM into sma…
Aug 11, 2017
f3d603a
Merge trunk
Aug 14, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.smartdata.server.web

import java.util

import scala.collection.JavaConverters._
import akka.http.scaladsl.server.Directives.{complete, path, pathPrefix, _}
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.directives.ParameterDirectives.ParamMagnet
import akka.stream.Materializer
import com.google.gson.Gson
import org.smartdata.actions.ActionRegistry
import org.smartdata.model._
import org.smartdata.server.SmartEngine

import scala.util.Random

class ActionService(ssmServer: SmartEngine) extends BasicService {
private val gson: Gson = new Gson()
private val actions: util.Collection[ActionInfo] = new util.ArrayList[ActionInfo]()
val builder = new ActionInfo.Builder()
.setActionName("test")
.setCreateTime(1024)
.setFinished(true)
.setFinishTime(2048)
.setResult("this is result")
.setLog("this is log")
.setArgs(CmdletDescriptor.fromCmdletString("test -opt1 val1").getActionArgs(0))
.setProgress(0.5f)
.setResult("objc[41272]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin/java (0x1075fd4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1076d94e0). One of the two will be used. Which one is undefined.")
.setLog("objc[41272]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin/java (0x1075fd4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1076d94e0). One of the two will be used. Which one is undefined.")
actions.add(builder.build())

private val actionTypes: util.Collection[ActionDescriptor] = new util.ArrayList[ActionDescriptor]()
actionTypes.add(new ActionDescriptor("ls", "List files", "Comment", "Usage"))
actionTypes.add(new ActionDescriptor("write", "Write files", "Comment", "Usage"))

override protected def doRoute(implicit mat: Materializer): Route =
pathPrefix("actions" / LongNumber) { actionId =>
path("detail") {
complete(gson.toJson(actions.asScala.find(_.getActionId == actionId).get))
// complete(gson.toJson(ssmServer.getCommandExecutor.getActionInfo(actionId)))
}
} ~
path("cachedfiles") {
val status = new util.ArrayList[CachedFileStatus]()
status.add(new CachedFileStatus(1, "file1", 1023, 2048, 5))
status.add(new CachedFileStatus(2, "file2", 1023000, 2048000, 4))
complete(gson.toJson(status))
// complete(gson.toJson(ssmServer.getDBAdapter.getCachedFileStatus))
} ~
path("hotfiles") {
// val tables = ssmServer.getStatesManager.getTablesInLast(Constants.ONE_HOUR_IN_MILLIS)
// complete(gson.toJson(ssmServer.getDBAdapter.getHotFiles(tables, 20)))
val status = new util.ArrayList[FileAccessInfo]()
status.add(new FileAccessInfo(101L, "file1", 10))
status.add(new FileAccessInfo(102L, "file2", 20))
complete(gson.toJson(status))
} ~
path("actiontypes") {
complete(gson.toJson(ActionRegistry.supportedActions()))
} ~
path("actionlist") {
complete(gson.toJson(actions))
// complete(gson.toJson(ssmServer.getCommandExecutor.listNewCreatedActions(20)))
} ~
path("submitaction" / Segment) { actionType =>
post {
parameters(ParamMagnet("args")) { args: String =>
val rule = java.net.URLDecoder.decode(args, "UTF-8")
val action = new ActionInfo.Builder().setActionName(actionType)
.setActionId(Math.abs(Random.nextInt()))
.setArgs(CmdletDescriptor.fromCmdletString(actionType + " " + args).getActionArgs(0))
.setCreateTime(System.currentTimeMillis())
.setFinished(false)
.setSuccessful(false).build()
actions.add(action)
try {
// ssmServer.getCommandExecutor.submitCommand(actionType + " " + args)
complete("Success")
} catch {
case e: Exception => failWith(e)
}
}
}
}
}
119 changes: 119 additions & 0 deletions smart-server/src/main/scala/org/smartdata/server/web/RuleService.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.smartdata.server.web

import java.util

import akka.http.scaladsl.server.Directives.{complete, path, _}
import akka.http.scaladsl.server.Route
import akka.stream.Materializer
import com.google.gson.Gson
import org.smartdata.model.CmdletState
import org.smartdata.model.{CmdletInfo, RuleInfo}
import org.smartdata.model.RuleState
import org.smartdata.server.SmartEngine
import org.smartdata.server.utils.JsonUtil

import scala.collection.JavaConverters._
import scala.util.Random

class RuleService(ssmServer: SmartEngine) extends BasicService {
private val gson: Gson = new Gson()
private val rules: util.Collection[RuleInfo] = new util.ArrayList[RuleInfo]()

override protected def doRoute(implicit mat: Materializer): Route = pathPrefix("rules" / IntNumber) { ruleId =>
path("start") {
post {
try {
// ssmServer.getRuleManager.activateRule(ruleId)
rules.asScala.filter(_.getId == ruleId).foreach(_.setState(RuleState.ACTIVE))
complete("success")
} catch {
case e: Exception => failWith(e)
}
}
} ~
path("stop") {
delete {
try {
// ssmServer.getRuleManager.disableRule(ruleId, true)
rules.asScala.filter(_.getId == ruleId).foreach(_.setState(RuleState.DISABLED))
complete("success")
} catch {
case e: Exception => failWith(e)
}
}
} ~
path("detail") {
try {
complete(gson.toJson(rules.asScala.find(_.getId == ruleId).get))
// complete(gson.toJson(ssmServer.getRuleManager.getRuleInfo(ruleId)))
} catch {
case e: Exception => failWith(e)
}
} ~
path("errors") {
complete("{\"time\" : \"0\", \"error\" : \"\"}")
} ~
path("cmdlets") {
val smap1 = new util.HashMap[String, String]
smap1.put("_FILE_PATH_", "/testCacheFile")
val cmdlet1 = new CmdletInfo(0, 1,
CmdletState.PENDING, JsonUtil.toJsonString(smap1), 123123333l, 232444444l)
val cmdlet2 = new CmdletInfo(1, 1, CmdletState.PENDING,
JsonUtil.toJsonString(smap1), 123178333l, 232444994l)
try {
complete(gson.toJson(util.Arrays.asList(cmdlet1, cmdlet2)))
// complete(gson.toJson(ssmServer.getCommandExecutor.listCommandsInfo(ruleId, null)))
} catch {
case e: Exception => failWith(e)
}
}
} ~
path("rulelist") {
try {
complete(gson.toJson(rules))
// complete(gson.toJson(ssmServer.getRuleManager.listRulesInfo()))
} catch {
case e: Exception => failWith(e)
}
} ~
path("addrule") {
post {
entity(as[String]) { request =>
val rule = java.net.URLDecoder.decode(request, "UTF-8")
System.out.println("Adding rule: " + rule)
try {
addRuleInfo(rule)
// ssmServer.getRuleManager.submitRule(rule, RuleState.DISABLED)
complete("Success")
} catch {
case e: Exception => failWith(e)
}
}
}
}

private def addRuleInfo(rule: String): RuleInfo = {
val builder = RuleInfo.newBuilder
builder.setRuleText(rule).setId(Math.abs(Random.nextInt())).setState(RuleState.DISABLED)
val ruleInfo = builder.build
rules.add(ruleInfo)
ruleInfo
}
}
6 changes: 3 additions & 3 deletions smart-zeppelin/zeppelin-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
</prerequisites>

<properties>
<node.version>v6.9.1</node.version>
<yarn.version>v0.18.1</yarn.version>
<node.version>v6.11.0</node.version>
<yarn.version>v0.27.5</yarn.version>
<npm.version>4.2.0</npm.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Expand Down Expand Up @@ -138,7 +138,7 @@
<goal>yarn</goal>
</goals>
<configuration>
<arguments>run build</arguments>
<arguments>run build --force</arguments>
</configuration>
</execution>

Expand Down
38 changes: 34 additions & 4 deletions smart-zeppelin/zeppelin-web/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,36 @@ var zeppelinWebApp = angular.module('zeppelinWebApp', [
}]
}
})
.when('/mover', {
templateUrl: 'app/dashboard/views/mover/mover.html',
controller: 'MoverCtrl',
resolve: {
load: ['heliumService', function(heliumService) {
return heliumService.load;
}],
actions0: ['models', function (models) {
return models.$get.actions();
}],
actionTypes: ['models', function (models) {
return models.$get.actionTypes();
}]
}
})
.when('/copy', {
templateUrl: 'app/dashboard/views/copy/copy.html',
controller: 'CopyCtrl',
resolve: {
load: ['heliumService', function(heliumService) {
return heliumService.load;
}],
actions0: ['models', function (models) {
return models.$get.actions();
}],
actionTypes: ['models', function (models) {
return models.$get.actionTypes();
}]
}
})
.when('/actions/action/:actionId', {
templateUrl: 'app/dashboard/views/actions/action/action.html',
controller: 'ActionCtrl',
Expand Down Expand Up @@ -246,13 +276,13 @@ var zeppelinWebApp = angular.module('zeppelinWebApp', [
// constants
.constant('conf', {
restapiProtocol: 'v1',
restapiRoot: 'http://localhost:8080/',
// restapiRoot: rootPath,
// restapiRoot: 'http://localhost:8080/',
restapiRoot: rootPath,
restapiQueryInterval: 3 * 1000, // in milliseconds
restapiQueryTimeout: 30 * 1000, // in milliseconds
restapiTaskLevelMetricsQueryLimit: 100,
loginUrl: 'http://localhost:8080/' + 'login'
// loginUrl: rootPath + 'login'
// loginUrl: 'http://localhost:8080/' + 'login'
loginUrl: rootPath + 'login'
})
.constant('TRASH_FOLDER_ID', '~Trash');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you 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
Expand Down Expand Up @@ -41,15 +41,6 @@ html, body {
margin-left: 30px;
}

/* Emphasize active navbar element for dark background (2 rules) */
.navbar-inverse {
background-color: #373a3c;
}

.navbar-inverse .navbar-nav > li > a:hover {
background-color: #444;
}

/* A extra small breadcrumb (2 rules) */
.breadcrumb-sm {
margin-bottom: 8px;
Expand Down
48 changes: 48 additions & 0 deletions smart-zeppelin/zeppelin-web/src/app/dashboard/views/copy/copy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<div class="col-md-12">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<!-- control toolbar -->
<div class="row">
<div class="col-md-6 col-sm-6">
<span class="table-caption-ext pull-left">Copy</span>
</div>
<div class="col-md-3 col-sm-6 text-right">
<!--FILTER-->
</div>
<div class="col-md-3 hidden-sm hidden-xs">
<searchbox
ng-show="actionsTable.rows && actionsTable.rows.length > 0"
ng-model="search" placeholder="Search copy"></searchbox>
</div>
</div>
<!-- end of control toolbar -->
</div>

<div class="col-md-12">
<sortable-table
columns-bind="actionsTable.cols"
records-bind="actionsTable.rows"
search-bind="search"
pagination="10">
<div class="table-no-data">
<h2 class="glyphicon glyphicon-bullhorn"></h2>
<h4>No copy is running</h4>
</div>
</sortable-table>
</div>
Loading