Skip to content

Commit

Permalink
Modify experiment initializatoin behavior
Browse files Browse the repository at this point in the history
Related-Issue: #30
  • Loading branch information
travelist committed Nov 4, 2015
1 parent f2d877c commit e8f3d56
Show file tree
Hide file tree
Showing 8 changed files with 269 additions and 254 deletions.
3 changes: 3 additions & 0 deletions cognitive/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class Experiment(models.Model):
execution_end_time = models.DateField(blank=True, null=True)
component_start_id = models.IntegerField(blank=True, null=True)

class Meta:
ordering = ['-modified_time']


class Component(models.Model):
COMPONENT_STATUS = (
Expand Down
10 changes: 5 additions & 5 deletions cognitive/app/static/app/experiment/experiment.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
CognitiveComponentService, CognitiveWorkspaceService, FileInputService, MessageService) {

var vm = this;
vm.components = CognitiveComponentService.getCognitiveComponents();
vm.detail_template_url = '';
vm.toggled_menu_idx = -1;
vm.workspaces = CognitiveWorkspaceService.getWorkspaces();

function initialize() {
vm.components = CognitiveComponentService.getCognitiveComponents();
vm.detail_template_url = '';
vm.toggled_menu_idx = -1;
vm.workspaces = CognitiveWorkspaceService.getWorkspaces();
vm.experimentId = $location.search()['id'];
vm.user = UserService.getCurrentUser();

if (typeof (vm.experimentId) == 'string') {
$http.get('/api/v1/experiments/' + vm.experimentId)
.success(function(data,status, headers, config){
// We needs to remove the multiple workspace support
vm.workspaces.push({
id: data.id,
name: data.name,
Expand Down
145 changes: 67 additions & 78 deletions cognitive/app/static/app/experiment/experiment.html
Original file line number Diff line number Diff line change
@@ -1,88 +1,77 @@
<ng-include src="'static/app/common/header.html'"></ng-include>

<md-content ng-controller="ExperimentController as vm" style="background: whitesmoke">
<md-toolbar class="md-menu-toolbar" style="border-bottom: solid 1px #3F51B5;">
<div layout="row">
<md-toolbar-filler layout layout-align="center center">
<a ui-sref="whiteboard">
<i class="fa fa-cube" style="color: white"></i>
</a>
</md-toolbar-filler>
<div>
<h2 class="md-toolbar-tools">{{ vm.workspaces[0].name }}</h2>
<md-menu-bar>
<md-menu>
<button>
File
</button>
<md-menu-content>
<md-menu-item>
<md-button>
Share...
</md-button>
</md-menu-item>
</md-menu-content>
</md-menu>
</md-menu-bar>
</div>
</div>
</md-toolbar>
<md-content layout="row" layout-align="center start" style="background: whitesmoke">
<md-card flex="20">
<md-card-content class="md-padding">
<md-input-container flex>
<label>Components</label>
<input ng-model="vm.search_components">
</md-input-container>
<md-list>
<md-list-item class="md-line" layout-fill ng-repeat="component in vm.components | filter:vm.search_components" ng-click="vm.showComponentCreationDialog($event, $index)" component="{{component.type}}">
<span flex="20">
<i class="{{component.icon_class}}"></i>
</span>
<span>{{ component.name }}</span>
</md-list-item>
</md-list>
<div id="component_arguments">
<div class="detail left-menu-detail-cognitive">
<ng-include src="vm.detail_template_url"></ng-include>
<div flex="20">
<md-card>
<md-card-content>
<md-list>
<h2 class="md-headline">{{ vm.workspaces[0].name }}</h2>
</md-list>
</md-card-content>
</md-card>

<md-card>
<md-card-content>
<md-input-container flex>
<label>Components</label>
<input ng-model="vm.search_components">
</md-input-container>
<md-list>
<md-list-item class="md-line" layout-fill ng-repeat="component in vm.components | filter:vm.search_components" ng-click="vm.showComponentCreationDialog($event, $index)" component="{{component.type}}">
<span flex="20">
<i class="{{component.icon_class}}"></i>
</span>
<span>{{ component.name }}</span>
</md-list-item>
</md-list>
<div id="component_arguments">
<div class="detail left-menu-detail-cognitive">
<ng-include src="vm.detail_template_url"></ng-include>
</div>
</div>
</div>
</md-card-content>
</md-card>
</md-card-content>
</md-card>
</div>
<div flex="75">
<md-content layout="column" style="background: whitesmoke">
<md-card style="height: calc(100vh - 180px);">
<md-card-content class="card-content--svgboard">
<!--Will not Support for workspace tabs, so ng-repead will be removed in the future. -->
<div ng-repeat="workspace in vm.workspaces" heading="{{workspace.name}}" workspace="{{workspace.id}}" ng-click="workspace[$index].active = true" active="workspace.active" style="height: 100%">

<md-content flex="75" layout="column" style="background: whitesmoke">
<md-card style="height: calc(100vh - 200px);">
<md-card-content style="height: 100%">
<!--Will not Support for workspace tabs, so ng-repead will be removed in the future. -->
<div ng-repeat="workspace in vm.workspaces" heading="{{workspace.name}}" workspace="{{workspace.id}}" ng-click="workspace[$index].active = true" active="workspace.active" style="height: 100%">
<svg class="root" workspace="{{workspace.id}}" style="width:100%; height:100%;" ng-click="vm.clickNone()">
<g class="layer layer-0" workspace="{{workspace.id}}"></g>
<g class="layer layer-1" workspace="{{workspace.id}}"></g>
<g class="layer layer-2" workspace="{{workspace.id}}">
<g ng-repeat="edge in workspace.edges|filter:edge.workspace_id=workspace.id">
<g cognitive-edge="" to="{{edge.to}}" from="{{edge.from}}" workspace="workspace.id"></g>
<svg class="root" workspace="{{workspace.id}}" style="width:100%; height:100%;" ng-click="vm.clickNone()">
<g class="layer layer-0" workspace="{{workspace.id}}"></g>
<g class="layer layer-1" workspace="{{workspace.id}}"></g>
<g class="layer layer-2" workspace="{{workspace.id}}">
<g ng-repeat="edge in workspace.edges|filter:edge.workspace_id=workspace.id">
<g cognitive-edge="" to="{{edge.to}}" from="{{edge.from}}" workspace="workspace.id"></g>
</g>
</g>
</g>
<g class="layer layer-3" workspace="{{workspace.id}}">
<g ng-repeat="node in workspace.nodes">
<g cognitive-node="">
<g class="layer layer-3" workspace="{{workspace.id}}">
<g ng-repeat="node in workspace.nodes">
<g cognitive-node="">
</g>
</g>
</g>
</g>
<g class="layer layer-4" workspace="{{workspace.id}}"></g>
</svg>
</div>
</md-card-content>
</md-card>
<md-card layout="row" layout-align="center center">
<md-button class="md-primary md-hue-1" ng-click="vm.run()">
<ng-md-icon icon="play_circle_outline" style="fill: steelblue;" size="27pt"></ng-md-icon>
<span>RUN</span>
</md-button>
<md-button class="md-primary md-hue-1" ng-click="vm.show()">
<ng-md-icon icon="equalizer" style="fill: steelblue;" size="27pt"></ng-md-icon>
<span>SHOW</span>
</md-button>
</md-card>
</md-content>
<g class="layer layer-4" workspace="{{workspace.id}}"></g>
</svg>

</div>
</md-card-content>
</md-card>
<md-card layout="row" layout-align="center center">
<md-button class="md-primary md-hue-1" ng-click="vm.run()">
<ng-md-icon icon="play_circle_outline" style="fill: steelblue;" size="27pt"></ng-md-icon>
<span>RUN</span>
</md-button>
<md-button class="md-primary md-hue-1" ng-click="vm.show()">
<ng-md-icon icon="equalizer" style="fill: steelblue;" size="27pt"></ng-md-icon>
<span>SHOW</span>
</md-button>
</md-card>
</md-content>
</div>
</md-content>
<div class="messages">
<div ng-include="'/static/app/common/message.html'"></div>
Expand Down
Loading

0 comments on commit e8f3d56

Please sign in to comment.