Skip to content

Commit

Permalink
Add a directive re-using the wiki view controller for #495
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Aug 30, 2013
1 parent 91d29aa commit 0e9d532
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 20 deletions.
16 changes: 8 additions & 8 deletions hawtio-web/src/main/webapp/app/fabric/html/profile.html
Expand Up @@ -6,7 +6,7 @@
<div ng-hide="loading">
<div class="container-title row-fluid">
<div class="pull-left">
<h1 class="inline"+>Profile: {{row.id}}</h1>
<h1 class="inline">Profile: {{row.id}}</h1>
&nbsp;
in version: <a ng-href="#/fabric/view?cv={{versionId}}&sp={{row.id}}">{{versionId}}</a>
&nbsp;
Expand All @@ -26,8 +26,6 @@ <h1 class="inline"+>Profile: {{row.id}}</h1>
<div class="pull-right">
<a class="btn" ng-href="#/fabric/containers/createContainer?versionId={{versionId}}&profileIds={{profileId}}" title="Deploy this profile to a new container"><i class="icon-truck"></i> Create Container</a>
<a class="btn" href="" title="Create a new profile that is a copy of this one" ng-click="copyProfileDialog = true"><i class="icon-copy"></i> Copy</a>
<a ng-href="{{configFolderLink}}" class="btn" ng-show="configFolderLink"
title="View, edit or create configuration files in this profile"><i class="icon-edit"></i> Advanced</a>
</div>
</div>

Expand Down Expand Up @@ -110,7 +108,7 @@ <h1 class="inline"+>Profile: {{row.id}}</h1>
</dd>
</dl>
</div>
<div class="span4">
<div class="span6">
<dl>
<dt>Feature Repositories ({{row.repositories.length}}):</dt>
<dd>
Expand All @@ -126,11 +124,10 @@ <h1 class="inline"+>Profile: {{row.id}}</h1>
</dd>
</dl>
<dl>
<dt>
<span ng-hide="configFolderLink">Configuration Files ({{row.configurations.length}})</span>
<a ng-hide="!configFolderLink" ng-href="{{configFolderLink}}" title="Go to folder view">Configuration Files ({{row.configurations.length}})</a>
<dt ng-hide="configFolderLink">
Configuration Files ({{row.configurations.length}})
</dt>
<dd>
<dd ng-hide="configFolderLink">
<ul class="unstyled">
<li ng-repeat="configuration in row.configurations">
<i ng-click="deleteFile(configuration)" title="Delete {{configuration}}" class="clickable red icon-remove"></i>
Expand All @@ -141,6 +138,9 @@ <h1 class="inline"+>Profile: {{row.id}}</h1>
</li>
</ul>
</dd>
<dd ng-show="configFolderLink" class="file-list">
<div wiki-file-list branch="{{versionId}}" page-id="/fabric/profiles/{{row.id}}" caption="Configuration Files ({{row.configurations.length}}):"></div>
</dd>
</dl>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
Expand Up @@ -5,7 +5,7 @@ module Fabric {
export var templatePath = 'app/fabric/html/';


angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop']).config(($routeProvider) => {
angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop', 'wiki']).config(($routeProvider) => {
$routeProvider.
when('/fabric/create', {templateUrl: templatePath + 'createFabric.html'}).
when('/fabric/containers/createContainer', {templateUrl: templatePath + 'createContainer.html' , reloadOnSearch: false }).
Expand Down
1 change: 1 addition & 0 deletions hawtio-web/src/main/webapp/app/wiki/exemplar/document.xml
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?>
@@ -0,0 +1 @@
# Add properties here
173 changes: 173 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/html/filelist.html
@@ -0,0 +1,173 @@
<div>
<div class="file-list-toolbar">
<ul class="nav nav-tabs" ng-controller="Wiki.NavBarController">
<li class="caption">
{{$parent.caption}}
</li>

<li class="pull-right dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Actions <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li ng-show="sourceLink()">
<a ng-href="{{sourceLink()}}" title="View source code"
data-placement="bottom">
<i class="icon-file-alt"></i> Source</a>
</li>
<li>
<a ng-href="{{historyLink}}{{hash}}" ng-hide="!historyLink" title="View the history of this file"
data-placement="bottom">
<i class="icon-comments-alt"></i> History</a>
</li>
<li class="divider">
</li>
<li>
<a ng-click="openRenameDialog()" ng-disabled="gridOptions.selectedItems.length !== 1"
title="Rename the selected document"
data-placement="bottom">
<i class="icon-adjust"></i> Rename</a>
</li>
<li>
<a ng-click="openMoveDialog()" ng-disabled="!gridOptions.selectedItems.length"
title="move the selected documents to a new folder"
data-placement="bottom">
<i class="icon-move"></i> Move</a>
</li>
<li class="divider">
</li>
<li>
<a ng-click="openDeleteDialog()" ng-disabled="!gridOptions.selectedItems.length"
title="Delete the selected document(s)"
data-placement="bottom">
<i class="icon-remove"></i> Delete</a>
</li>
</ul>
</li>
<li class="pull-right">
<a ng-href="{{editLink()}}{{hash}}" ng-hide="!editLink()" title="Edit this page"
data-placement="bottom">
<i class="icon-edit"></i> Edit</a>
</li>
<li class="pull-right">
<a title="Create new page" ng-click="openAddDialog()"
data-placement="bottom">
<i class="icon-plus"></i> Create</a>
</li>
</ul>
</div>

<div>
<div ng-hide="!children">
<div class="wikiGridStyle" ng-grid="gridOptions"></div>
</div>

<!--
<div ng-hide="!html">
<div ng-bind-html-unsafe="html"></div>
</div>
-->
<!--
<div ng-include="sourceView" class="editor-autoresize"></div>
-->
</div>

<div class="modal-large">
<div modal="addDialog.show" close="addDialog.close()" ng-options="addDialog.options">
<div class="modal-header"><h4>Create Document</h4></div>
<div class="modal-body">
<div class="control-group">
<div hawtio-tree="createDocumentTree" hideRoot="true" onSelect="onCreateDocumentSelect"
activateNodes="createDocumentTreeActivations"></div>
</div>

<div class="control-group">
<div class="well">
{{selectedCreateDocumentTemplate.tooltip}}
</div>
</div>

<form class="form-inline" ng-submit="addAndCloseDialog()">
<label class="control-label" for="fileName">Name: </label>

<input id="fileName" type="text" ng-model="newDocumentName"
placeholder="{{selectedCreateDocumentTemplate.exemplar}}"/>
</form>

<div class="control-group">
<div ng-show="fileExists.exists" class="alert">
Please choose a different name as <b>{{fileExists.name}}</b> already exists
</div>
</div>
</div>
<div class="modal-footer">
<input id="submit" class="btn btn-primary add" type="submit" ng-click="addAndCloseDialog()"
ng-disabled="!selectedCreateDocumentTemplate.exemplar || fileExists.exists"
value="Create">
<button class="btn btn-warning cancel" type="button" ng-click="addDialog.close()">Cancel</button>
</div>
</div>
</div>

<div hawtio-confirm-dialog="deleteDialog"
ok-button-text="Delete"
on-ok="deleteAndCloseDialog()">
<div class="dialog-body">
<p>You are about to delete
<ng-pluralize count="gridOptions.selectedItems.length"
when="{'1': 'this document!', 'other': 'these {} documents!'}">
</ng-pluralize>
</p>
<div ng-bind-html-unsafe="selectedFileHtml"></div>
</div>
</div>

<div modal="moveDialog.show" close="moveDialog.close()" ng-options="moveDialog.options">
<form class="form-horizontal" ng-submit="moveAndCloseDialog()">
<div class="modal-header"><h4>Move Document</h4></div>
<div class="modal-body">
<div class="control-group">
<label class="control-label" for="moveFolder">Folder</label>

<div class="controls">
<input type="text" id="moveFolder" ng-model="moveFolder"
typeahead="title for title in folderNames($viewValue) | filter:$viewValue" typeahead-editable='true'>
</div>
</div>
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit"
ng-disabled="!moveFolder"
value="Move">
<button class="btn btn-warning cancel" type="button" ng-click="moveDialog.close()">Cancel</button>
</div>
</form>
</div>

<div modal="renameDialog.show" close="renameDialog.close()" ng-options="renameDialog.options">
<form class="form-horizontal" ng-submit="renameAndCloseDialog()">
<div class="modal-header"><h4>Rename Document</h4></div>
<div class="modal-body">
<div class="control-group">
<label class="control-label" for="renameFileName">Name</label>

<div class="controls">
<input type="text" id="renameFileName" ng-model="fileName">
</div>
</div>

<div class="control-group">
<div ng-show="fileExists.exists" class="alert">
Please choose a different name as <b>{{fileExists.name}}</b> already exists
</div>
</div>
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit"
ng-disabled="!fileName || fileExists.exists"
value="Rename">
<button class="btn btn-warning cancel" type="button" ng-click="renameDialog.close()">Cancel</button>
</div>
</form>
</div>
</div>
45 changes: 45 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/fileListDirective.ts
@@ -0,0 +1,45 @@
module Wiki {

export class FileList {
public restrict = 'A';
public replace = true;
public templateUrl = Wiki.templatePath + 'filelist.html';

public scope = {
branch: '@',
pageId: '@',
caption: '@'
};

public controller = ($scope, $location, $routeParams, $http, $timeout, workspace:Workspace, marked, fileExtensionTypeRegistry, wikiRepository:GitWikiRepository, $compile) => {

$scope.nameOnly = true;

Wiki.ViewController($scope, $location, $routeParams, $http, $timeout, workspace, marked, fileExtensionTypeRegistry, wikiRepository, $compile);

};

public link = ($scope, $element, $attrs) => {

$scope.$watch('branch', (oldValue, newValue) => {
setTimeout(() => {
$scope.updateView();
Core.$apply($scope);
}, 50);
});

$scope.$watch('pageId', (oldValue, newValue) => {
setTimeout(() => {
$scope.updateView();
Core.$apply($scope);
}, 50);
});

$scope.branch = $attrs['branch'];
$scope.pageId = $attrs['pageId'];
$scope.caption = $attrs['caption'];
};

}

}
10 changes: 10 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/helpers.ts
Expand Up @@ -18,6 +18,11 @@ module Wiki {
icon: "/app/wiki/img/folder.gif",
exemplar: "New Folder"
},
{
label: "Properties File",
tooltip: "A properties file typically used to configure Java classes",
exemplar: "properties-file.properties"
},
{
label: "Markdown Document",
tooltip: "A basic markup document using the Markdown wiki markup, particularly useful for ReadMe files in directories",
Expand All @@ -28,6 +33,11 @@ module Wiki {
tooltip: "A HTML document you can edit directly using the HTML markup",
exemplar: "document.html"
},
{
label: "XML Document",
tooltip: "An empty XML document",
exemplar: "document.xml"
},
{
label: "Integration Flows",
tooltip: "Camel routes for defining your integration flows",
Expand Down
27 changes: 16 additions & 11 deletions hawtio-web/src/main/webapp/app/wiki/js/view.ts
Expand Up @@ -4,7 +4,7 @@ module Wiki {
var href = Core.trimLeading(link, "#");
$timeout(() => {
console.log("About to navigate to: " + href);
$location.path(href);
$location.url(href);
}, 100);
}

Expand Down Expand Up @@ -35,20 +35,23 @@ module Wiki {
displayName: 'Name',
cellTemplate: '<div class="ngCellText"><a href="{{childLink(row.entity)}}"><span class="file-icon" ng-bind-html-unsafe="fileIconHtml(row)"></span> {{row.getProperty(col.field)}}</a></div>',
cellFilter: ""
},
{
field: 'lastModified',
displayName: 'Modified',
cellFilter: "date:'EEE, MMM d, y : hh:mm:ss a'"
},
{
field: 'length',
displayName: 'Size',
cellFilter: "number"
}
]
};

if (!$scope.nameOnly) {
$scope.gridOptions.columnDefs.push({
field: 'lastModified',
displayName: 'Modified',
cellFilter: "date:'EEE, MMM d, y : hh:mm:ss a'"
});
$scope.gridOptions.columnDefs.push({
field: 'length',
displayName: 'Size',
cellFilter: "number"
});
}

$scope.childLink = (child) => {
var start = startLink($scope.branch);
var prefix = start + "/view";
Expand Down Expand Up @@ -340,6 +343,8 @@ module Wiki {
}
}

$scope.updateView = updateView;

function viewContents(pageName, contents) {
$scope.sourceView = null;
if ("markdown" === $scope.format) {
Expand Down
7 changes: 7 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/wikiPlugin.ts
@@ -1,5 +1,9 @@
module Wiki {

var pluginName = 'wiki';

export var templatePath = 'app/wiki/html/';

angular.module(pluginName, ['bootstrap', 'ui.bootstrap.dialog', 'ui.bootstrap.tabs', 'ngResource', 'hawtioCore', 'tree', 'camel']).
config(($routeProvider) => {

Expand Down Expand Up @@ -37,6 +41,9 @@ module Wiki {
};
}).
filter('fileIconClass',() => iconClass).
directive('wikiFileList', () => {
return new Wiki.FileList();
}).
run(($location:ng.ILocationService, workspace:Workspace, viewRegistry, jolokia, localStorage, layoutFull) => {

/*
Expand Down

0 comments on commit 0e9d532

Please sign in to comment.