[Frontend] Refactoring glyphs to classes

Fixes #1047
In-progress; indicators, notifications, actions,
tests
This commit is contained in:
Charles Hacskaylo
2016-06-28 14:47:52 -07:00
parent 53ed0bfb22
commit 8bb8db69e6
29 changed files with 72 additions and 46 deletions

View File

@ -1,9 +1,9 @@
<span class="status block ok" ng-controller="DialogLaunchController"> <span class="status block" ng-controller="DialogLaunchController">
<!-- DO NOT ADD SPACES BETWEEN THE SPANS - IT ADDS WHITE SPACE!! --> <!-- DO NOT ADD SPACES BETWEEN THE SPANS - IT ADDS WHITE SPACE!! -->
<span class="ui-symbol status-indicator">&#xe600;</span><span class="label"> <span class="status-indicator icon-box-with-arrow"></span><span class="label">
<a ng-click="launchProgress(true)">Known</a> | <a ng-click="launchProgress(true)">Known</a> |
<a ng-click="launchProgress(false)">Unknown</a> | <a ng-click="launchProgress(false)">Unknown</a> |
<a ng-click="launchError()">Error</a> | <a ng-click="launchError()">Error</a> |
<a ng-click="launchInfo()">Info</a> <a ng-click="launchInfo()">Info</a>
</span><span class="count">Dialogs</span> </span><span class="count"></span>
</span> </span>

View File

@ -1,9 +1,9 @@
<span class="status block ok" ng-controller="NotificationLaunchController"> <span class="status block" ng-controller="NotificationLaunchController">
<!-- DO NOT ADD SPACES BETWEEN THE SPANS - IT ADDS WHITE SPACE!! --> <!-- DO NOT ADD SPACES BETWEEN THE SPANS - IT ADDS WHITE SPACE!! -->
<span class="ui-symbol status-indicator">&#xe600;</span><span class="label"> <span class="status-indicator icon-bell"></span><span class="label">
<a ng-click="newInfo()">Success</a> | <a ng-click="newInfo()">Success</a> |
<a ng-click="newError()">Error</a> | <a ng-click="newError()">Error</a> |
<a ng-click="newAlert()">Alert</a> | <a ng-click="newAlert()">Alert</a> |
<a ng-click="newProgress()">Progress</a> <a ng-click="newProgress()">Progress</a>
</span><span class="count">Notifications</span> </span><span class="count"></span>
</span> </span>

View File

@ -32,17 +32,15 @@ define(
* launched for demonstration and testing purposes. * launched for demonstration and testing purposes.
* @constructor * @constructor
*/ */
function DialogLaunchIndicator() { function DialogLaunchIndicator() {
} }
DialogLaunchIndicator.template = 'dialogLaunchTemplate'; DialogLaunchIndicator.template = 'dialogLaunchTemplate';
DialogLaunchIndicator.prototype.getGlyph = function () {
return "i";
};
DialogLaunchIndicator.prototype.getGlyphClass = function () { DialogLaunchIndicator.prototype.getGlyphClass = function () {
return 'caution'; return 'ok';
}; };
DialogLaunchIndicator.prototype.getText = function () { DialogLaunchIndicator.prototype.getText = function () {
return "Launch test dialog"; return "Launch test dialog";

View File

@ -26,17 +26,21 @@ define(
function () { function () {
"use strict"; "use strict";
/**
* A tool for manually invoking notifications. When included this
* indicator will allow for notifications of different types to be
* launched for demonstration and testing purposes.
* @constructor
*/
function NotificationLaunchIndicator() { function NotificationLaunchIndicator() {
} }
NotificationLaunchIndicator.template = 'notificationLaunchTemplate'; NotificationLaunchIndicator.template = 'notificationLaunchTemplate';
NotificationLaunchIndicator.prototype.getGlyph = function () {
return "i";
};
NotificationLaunchIndicator.prototype.getGlyphClass = function () { NotificationLaunchIndicator.prototype.getGlyphClass = function () {
return 'caution'; return 'ok';
}; };
NotificationLaunchIndicator.prototype.getText = function () { NotificationLaunchIndicator.prototype.getText = function () {
return "Launch notification"; return "Launch notification";

View File

@ -59,8 +59,14 @@ define(
update(); update();
return { return {
getGlyph: function () { /**
return "."; * Get the glyph CSS class (single character used as an icon)
* to display in this indicator. This will return ".",
* which should appear as a dataflow icon.
* @returns {string} the character of the dataflow icon
*/
getCssClass: function () {
return "icon-connectivity";
}, },
getGlyphClass: function () { getGlyphClass: function () {
return undefined; return undefined;

View File

@ -55,13 +55,13 @@ define(
return { return {
/** /**
* Get the glyph (single character used as an icon) * Get the glyph CSS class (single character used as an icon)
* to display in this indicator. This will return ".", * to display in this indicator. This will return ".",
* which should appear as a dataflow icon. * which should appear as a database icon.
* @returns {string} the character of the database icon * @returns {string} the character of the database icon
*/ */
getGlyph: function () { getCssClass: function () {
return "E"; return "icon-database";
}, },
/** /**
* Get the name of the CSS class to apply to the glyph. * Get the name of the CSS class to apply to the glyph.

View File

@ -50,8 +50,8 @@ define(
requestNext(); requestNext();
return { return {
getGlyph: function () { getCssClass: function () {
return "?"; return "icon-object-unknown";
}, },
getText: function () { getText: function () {
return latest; return latest;

View File

@ -52,6 +52,7 @@ define(
this.metadata = { this.metadata = {
key: 'add', key: 'add',
glyph: type.getGlyph(), glyph: type.getGlyph(),
cssclass: type.getCssClass(),
name: type.getName(), name: type.getName(),
type: type.getKey(), type: type.getKey(),
description: type.getDescription(), description: type.getDescription(),

View File

@ -45,6 +45,7 @@ define(
[ [
"getKey", "getKey",
"getGlyph", "getGlyph",
"getCssClass",
"getName", "getName",
"getDescription", "getDescription",
"getProperties", "getProperties",

View File

@ -41,6 +41,7 @@ define(
[ [
"getKey", "getKey",
"getGlyph", "getGlyph",
"getCssClass",
"getName", "getName",
"getDescription", "getDescription",
"getProperties", "getProperties",

View File

@ -51,6 +51,7 @@ define(
[ [
"getKey", "getKey",
"getGlyph", "getGlyph",
"getCssClass",
"getName", "getName",
"getDescription", "getDescription",
"getProperties", "getProperties",
@ -120,6 +121,7 @@ define(
mockType.getKey.andReturn("test"); mockType.getKey.andReturn("test");
mockType.getGlyph.andReturn("T"); mockType.getGlyph.andReturn("T");
mockType.getCssClass.andReturn("icon-telemetry");
mockType.getDescription.andReturn("a test type"); mockType.getDescription.andReturn("a test type");
mockType.getName.andReturn("Test"); mockType.getName.andReturn("Test");
mockType.getProperties.andReturn([]); mockType.getProperties.andReturn([]);
@ -138,6 +140,7 @@ define(
expect(metadata.name).toEqual("Test"); expect(metadata.name).toEqual("Test");
expect(metadata.description).toEqual("a test type"); expect(metadata.description).toEqual("a test type");
expect(metadata.glyph).toEqual("T"); expect(metadata.glyph).toEqual("T");
expect(metadata.cssclass).toEqual("icon-telemetry");
}); });
describe("the perform function", function () { describe("the perform function", function () {

View File

@ -54,6 +54,7 @@ define(
[ [
"getKey", "getKey",
"getGlyph", "getGlyph",
"getCssClass",
"getName", "getName",
"getDescription", "getDescription",
"getProperties", "getProperties",
@ -75,6 +76,7 @@ define(
mockType.getKey.andReturn("test"); mockType.getKey.andReturn("test");
mockType.getGlyph.andReturn("T"); mockType.getGlyph.andReturn("T");
mockType.getCssClass.andReturn("icon-telemetry");
mockType.getDescription.andReturn("a test type"); mockType.getDescription.andReturn("a test type");
mockType.getName.andReturn("Test"); mockType.getName.andReturn("Test");
mockType.getInitialModel.andReturn(testModel); mockType.getInitialModel.andReturn(testModel);

View File

@ -24,12 +24,10 @@
title="{{ngModel.getDescription()}}" title="{{ngModel.getDescription()}}"
ng-click='ngModel.configure()' ng-click='ngModel.configure()'
ng-show="ngModel.getText().length > 0"> ng-show="ngModel.getText().length > 0">
<span class="ui-symbol status-indicator"> <span class="status-indicator {{ngModel.getCssClass()}}"></span><span class="label"
{{ngModel.getGlyph()}}
</span><span class="label"
ng-class='ngModel.getTextClass()'> ng-class='ngModel.getTextClass()'>
{{ngModel.getText()}} {{ngModel.getText()}}
<a class="s-btn ui-symbol" ng-if="ngModel.configure">G</a> <a class="s-btn icon-gear" ng-if="ngModel.configure"></a>
</span><span class="count"> </span><span class="count">
</span> </span>
</div> </div>

View File

@ -35,7 +35,7 @@ define(
beforeEach(function () { beforeEach(function () {
mockIndicator = jasmine.createSpyObj( mockIndicator = jasmine.createSpyObj(
"indicator", "indicator",
["getGlyph", "getText"] ["getGlyph", "getCssClass", "getText"]
); );
testIndicatorA = {}; testIndicatorA = {};

View File

@ -107,6 +107,7 @@ define([
return { return {
context: jasmine.createSpyObj('context', ['getPath']), context: jasmine.createSpyObj('context', ['getPath']),
type: jasmine.createSpyObj('type', ['getGlyph']), type: jasmine.createSpyObj('type', ['getGlyph']),
cssclass: jasmine.createSpyObj('cssclass', ['getCssClass']),
location: jasmine.createSpyObj('location', ['isLink']), location: jasmine.createSpyObj('location', ['isLink']),
mutation: jasmine.createSpyObj('mutation', ['listen']), mutation: jasmine.createSpyObj('mutation', ['listen']),
status: mockStatus status: mockStatus

View File

@ -2,7 +2,7 @@
<span ng-show="notifications.length > 0" class="status block" <span ng-show="notifications.length > 0" class="status block"
ng-class="highest.severity" ng-class="highest.severity"
ng-controller="NotificationIndicatorController"> ng-controller="NotificationIndicatorController">
<span class="ui-symbol status-indicator">&#xe610;</span><span class="label"> <span class="status-indicator icon-bell"></span><span class="label">
<a ng-click="showNotificationsList()">{{notifications.length}} <a ng-click="showNotificationsList()">{{notifications.length}}
Notifications</a> Notifications</a>
</span><span class="count">{{notifications.length}}</span> </span><span class="count">{{notifications.length}}</span>

View File

@ -145,6 +145,7 @@ define(
}; };
TypeImpl.prototype.getGlyph = function () { TypeImpl.prototype.getGlyph = function () {
// TO-DO: remove this function
return this.typeDef.glyph; return this.typeDef.glyph;
}; };

View File

@ -34,6 +34,7 @@ define(
name: 'Test Type', name: 'Test Type',
description: 'A type, for testing', description: 'A type, for testing',
glyph: 't', glyph: 't',
cssclass: 'icon-telemetry-panel',
inherits: ['test-parent-1', 'test-parent-2'], inherits: ['test-parent-1', 'test-parent-2'],
features: ['test-feature-1'], features: ['test-feature-1'],
properties: [{}], properties: [{}],
@ -58,6 +59,10 @@ define(
expect(type.getGlyph()).toEqual('t'); expect(type.getGlyph()).toEqual('t');
}); });
it("exposes glyph CSS class from definition", function() {
expect(type.getCssClass()).toEqual('icon-telemetry-panel');
});
it("exposes its underlying type definition", function () { it("exposes its underlying type definition", function () {
expect(type.getDefinition()).toEqual(testTypeDef); expect(type.getDefinition()).toEqual(testTypeDef);
}); });

View File

@ -31,17 +31,20 @@ define(
{ {
key: 'basic', key: 'basic',
glyph: "X", glyph: "X",
cssclass: "icon-magnify-in",
name: "Basic Type" name: "Basic Type"
}, },
{ {
key: 'multi1', key: 'multi1',
glyph: "Z", glyph: "Z",
cssclass: "icon-trash",
description: "Multi1 Description", description: "Multi1 Description",
capabilities: ['a1', 'b1'] capabilities: ['a1', 'b1']
}, },
{ {
key: 'multi2', key: 'multi2',
glyph: "Y", glyph: "Y",
cssclass: "icon-magnify-out",
capabilities: ['a2', 'b2', 'c2'] capabilities: ['a2', 'b2', 'c2']
}, },
{ {
@ -71,6 +74,7 @@ define(
captured.type = provider.getType('basic'); captured.type = provider.getType('basic');
expect(captured.type.getGlyph()).toEqual("X"); expect(captured.type.getGlyph()).toEqual("X");
expect(captured.type.getCssClass()).toEqual("icon-magnify-in");
expect(captured.type.getName()).toEqual("Basic Type"); expect(captured.type.getName()).toEqual("Basic Type");
expect(captured.type.getDescription()).toBeUndefined(); expect(captured.type.getDescription()).toBeUndefined();
}); });
@ -79,6 +83,7 @@ define(
captured.type = provider.getType('single-subtype'); captured.type = provider.getType('single-subtype');
expect(captured.type.getGlyph()).toEqual("X"); expect(captured.type.getGlyph()).toEqual("X");
expect(captured.type.getCssClass()).toEqual("icon-magnify-in");
expect(captured.type.getName()).toEqual("Basic Subtype"); expect(captured.type.getName()).toEqual("Basic Subtype");
expect(captured.type.getDescription()).toEqual("A test subtype"); expect(captured.type.getDescription()).toEqual("A test subtype");
}); });
@ -87,6 +92,7 @@ define(
captured.type = provider.getType('multi-subtype'); captured.type = provider.getType('multi-subtype');
expect(captured.type.getGlyph()).toEqual("Y"); expect(captured.type.getGlyph()).toEqual("Y");
expect(captured.type.getCssClass()).toEqual("icon-magnify-out");
expect(captured.type.getName()).toEqual("Multi-parent Subtype"); expect(captured.type.getName()).toEqual("Multi-parent Subtype");
expect(captured.type.getDescription()).toEqual("Multi1 Description"); expect(captured.type.getDescription()).toEqual("Multi1 Description");
}); });

View File

@ -44,8 +44,8 @@ define(
}); });
} }
ClockIndicator.prototype.getGlyph = function () { ClockIndicator.prototype.getCssClass = function () {
return "C"; return "icon-clock";
}; };
ClockIndicator.prototype.getGlyphClass = function () { ClockIndicator.prototype.getGlyphClass = function () {

View File

@ -48,7 +48,7 @@ define(
}); });
it("implements the Indicator interface", function () { it("implements the Indicator interface", function () {
expect(indicator.getGlyph()).toEqual(jasmine.any(String)); expect(indicator.getCssClass()).toEqual(jasmine.any(String));
expect(indicator.getGlyphClass()).toEqual(jasmine.any(String)); expect(indicator.getGlyphClass()).toEqual(jasmine.any(String));
expect(indicator.getText()).toEqual(jasmine.any(String)); expect(indicator.getText()).toEqual(jasmine.any(String));
expect(indicator.getDescription()).toEqual(jasmine.any(String)); expect(indicator.getDescription()).toEqual(jasmine.any(String));

View File

@ -43,8 +43,8 @@ define(
}); });
} }
IdentityIndicator.prototype.getGlyph = function () { IdentityIndicator.prototype.getCssClass = function () {
return this.text && "P"; return "icon-person";
}; };
IdentityIndicator.prototype.getGlyphClass = function () { IdentityIndicator.prototype.getGlyphClass = function () {
return undefined; return undefined;

View File

@ -46,8 +46,7 @@ define(
key: "testuserid", key: "testuserid",
name: "A User" name: "A User"
}); });
// Should have a single character glyph expect(indicator.getCssClass()).toEqual("icon-person");
expect(indicator.getGlyph().length).toEqual(1);
expect(indicator.getGlyphClass()).toBeUndefined(); expect(indicator.getGlyphClass()).toBeUndefined();
expect(indicator.getText()).toEqual("A User"); expect(indicator.getText()).toEqual("A User");
expect(indicator.getDescription().indexOf("testuserid")) expect(indicator.getDescription().indexOf("testuserid"))
@ -55,7 +54,7 @@ define(
}); });
it("shows nothing while no user information is available", function () { it("shows nothing while no user information is available", function () {
expect(indicator.getGlyph()).toBeUndefined(); expect(indicator.getCssClass()).toBeUndefined();
expect(indicator.getGlyphClass()).toBeUndefined(); expect(indicator.getGlyphClass()).toBeUndefined();
expect(indicator.getText()).toBeUndefined(); expect(indicator.getText()).toBeUndefined();
expect(indicator.getDescription()).toBeUndefined(); expect(indicator.getDescription()).toBeUndefined();
@ -63,7 +62,7 @@ define(
it("shows nothing when there is no identity information", function () { it("shows nothing when there is no identity information", function () {
mockPromise.then.mostRecentCall.args[0](undefined); mockPromise.then.mostRecentCall.args[0](undefined);
expect(indicator.getGlyph()).toBeUndefined(); expect(indicator.getCssClass()).toBeUndefined();
expect(indicator.getGlyphClass()).toBeUndefined(); expect(indicator.getGlyphClass()).toBeUndefined();
expect(indicator.getText()).toBeUndefined(); expect(indicator.getText()).toBeUndefined();
expect(indicator.getDescription()).toBeUndefined(); expect(indicator.getDescription()).toBeUndefined();

View File

@ -95,8 +95,8 @@ define(
$interval(updateIndicator, interval); $interval(updateIndicator, interval);
} }
CouchIndicator.prototype.getGlyph = function () { CouchIndicator.prototype.getCssClass = function () {
return "D"; return "icon-database";
}; };
CouchIndicator.prototype.getGlyphClass = function () { CouchIndicator.prototype.getGlyphClass = function () {

View File

@ -57,7 +57,7 @@ define(
}); });
it("has a database icon", function () { it("has a database icon", function () {
expect(indicator.getGlyph()).toEqual("D"); expect(indicator.getCssClass()).toEqual("icon-database");
}); });
it("consults the database at the configured path", function () { it("consults the database at the configured path", function () {

View File

@ -81,8 +81,8 @@ define(
$interval(updateIndicator, interval, 0, false); $interval(updateIndicator, interval, 0, false);
} }
ElasticIndicator.prototype.getGlyph = function () { ElasticIndicator.prototype.getCssClass = function () {
return "D"; return "icon-database";
}; };
ElasticIndicator.prototype.getGlyphClass = function () { ElasticIndicator.prototype.getGlyphClass = function () {
return this.state.glyphClass; return this.state.glyphClass;

View File

@ -59,7 +59,7 @@ define(
}); });
it("has a database icon", function () { it("has a database icon", function () {
expect(indicator.getGlyph()).toEqual("D"); expect(indicator.getCssClass()).toEqual("icon-database");
}); });
it("consults the database at the configured path", function () { it("consults the database at the configured path", function () {

View File

@ -40,8 +40,8 @@ define(
function LocalStorageIndicator() { function LocalStorageIndicator() {
} }
LocalStorageIndicator.prototype.getGlyph = function () { LocalStorageIndicator.prototype.getCssClass = function () {
return "D"; return "icon-database";
}; };
LocalStorageIndicator.prototype.getGlyphClass = function () { LocalStorageIndicator.prototype.getGlyphClass = function () {
return 'caution'; return 'caution';

View File

@ -38,7 +38,7 @@ define(
}); });
it("has a database icon", function () { it("has a database icon", function () {
expect(indicator.getGlyph()).toEqual("D"); expect(indicator.getCssClass()).toEqual("icon-database");
}); });
it("has a 'caution' class to draw attention", function () { it("has a 'caution' class to draw attention", function () {