Fix mistakes made by resolving conflicts

This commit is contained in:
AhyoungRyu 2017-03-04 00:39:05 +09:00
parent 894a27e519
commit 95b0b87ffe
2 changed files with 80 additions and 40 deletions

View file

@ -17,7 +17,7 @@ import { HeliumType, } from '../../components/helium/helium-type';
export default function HeliumCtrl($scope, $rootScope, $sce,
baseUrlSrv, ngToast, heliumService) {
'ngInject';
$scope.pkgSearchResults = {};
$scope.defaultPackages = {};
$scope.showVersions = {};
@ -32,7 +32,7 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
$scope.pkgListByType = 'VISUALIZATION'
$scope.defaultPackageConfigs = {}; // { pkgName, [{name, type, desc, value, defaultValue}] }
$scope.intpDefaultIcon = $sce.trustAsHtml('<img src="../assets/images/maven_default_icon.png" style="width: 12px"/>');
function init() {
// get all package info and set config
heliumService.getAllPackageInfoAndDefaultPackages()
@ -45,7 +45,7 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
.then(defaultPackageConfigs => {
$scope.defaultPackageConfigs = defaultPackageConfigs;
});
// 2. get vis package order
heliumService.getVisualizationPackageOrder()
.then(visPackageOrder => {
@ -53,17 +53,17 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
$scope.bundleOrderChanged = false;
});
}
var classifyPkgType = function(packageInfos) {
var vizTypePkg = {}
var spellTypePkg = {}
var intpTypePkg = {}
var appTypePkg = {}
for (var name in packageInfos) {
var pkgs = packageInfos[name]
var pkgType = pkgs.pkg.type
switch (pkgType) {
case HeliumType.VISUALIZATION:
vizTypePkg[name] = pkgs;
@ -78,15 +78,14 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
appTypePkg[name] = pkgs;
break;
}
}
$scope.vizTypePkg = vizTypePkg
$scope.spellTypePkg = spellTypePkg
$scope.appTypePkg = appTypePkg
$scope.intpTypePkg = intpTypePkg
};
$scope.bundleOrderListeners = {
accept: function(sourceItemHandleScope, destSortableScope) {return true;},
itemMoved: function(event) {},
@ -94,7 +93,7 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
$scope.bundleOrderChanged = true;
}
};
$scope.saveBundleOrder = function() {
var confirm = BootstrapDialog.confirm({
closable: false,
@ -125,34 +124,34 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
}
});
};
var getLicense = function(name, artifact) {
var filteredPkgSearchResults = _.filter($scope.defaultPackages[name], function(p) {
return p.artifact === artifact;
});
var license;
if (filteredPkgSearchResults.length === 0) {
filteredPkgSearchResults = _.filter($scope.pkgSearchResults[name], function(p) {
return p.pkg.artifact === artifact;
});
if (filteredPkgSearchResults.length > 0) {
license = filteredPkgSearchResults[0].pkg.license;
}
} else {
license = filteredPkgSearchResults[0].license;
}
if (!license) {
license = 'Unknown';
}
return license;
}
$scope.enable = function(name, artifact) {
var license = getLicense(name, artifact);
var confirm = BootstrapDialog.confirm({
closable: false,
closeByBackdrop: false,
@ -185,7 +184,7 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
}
});
};
$scope.disable = function(name) {
var confirm = BootstrapDialog.confirm({
closable: false,
@ -216,7 +215,7 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
}
});
};
$scope.toggleVersions = function(pkgName) {
if ($scope.showVersions[pkgName]) {
$scope.showVersions[pkgName] = false;
@ -224,24 +223,24 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
$scope.showVersions[pkgName] = true;
}
};
$scope.isLocalPackage = function(pkgSearchResult) {
const pkg = pkgSearchResult.pkg;
return pkg.artifact && !pkg.artifact.includes('@');
};
$scope.hasNpmLink = function(pkgSearchResult) {
const pkg = pkgSearchResult.pkg;
return (pkg.type === HeliumType.SPELL || pkg.type === HeliumType.VISUALIZATION) &&
!$scope.isLocalPackage(pkgSearchResult);
};
$scope.hasMavenLink = function(pkgSearchResult) {
const pkg = pkgSearchResult.pkg;
return (pkg.type === HeliumType.APPLICATION || pkg.type === HeliumType.INTERPRETER) &&
!$scope.isLocalPackage(pkgSearchResult);
};
$scope.getPackageSize = function(pkgSearchResult, targetPkgType) {
var result = []
_.map(pkgSearchResult, function (pkg) {
@ -249,48 +248,48 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
})
return _.compact(result).length
}
$scope.configExists = function(pkgSearchResult) {
// helium package config is persisted per version
return pkgSearchResult.pkg.config && pkgSearchResult.pkg.artifact;
};
$scope.configOpened = function(pkgSearchResult) {
return pkgSearchResult.configOpened && !pkgSearchResult.configFetching;
};
$scope.getConfigButtonClass = function(pkgSearchResult) {
return (pkgSearchResult.configOpened && pkgSearchResult.configFetching) ?
'disabled' : '';
}
$scope.toggleConfigButton = function(pkgSearchResult) {
if (pkgSearchResult.configOpened) {
pkgSearchResult.configOpened = false;
return;
}
const pkg = pkgSearchResult.pkg;
const pkgName = pkg.name;
pkgSearchResult.configFetching = true;
pkgSearchResult.configOpened = true;
heliumService.getSinglePackageConfigs(pkg)
.then(confs => {
$scope.defaultPackageConfigs[pkgName] = confs;
pkgSearchResult.configFetching = false;
});
};
$scope.saveConfig = function(pkgSearchResult) {
const pkgName = pkgSearchResult.pkg.name;
const currentConf = $scope.defaultPackageConfigs[pkgName];
heliumService.saveConfig(pkgSearchResult.pkg, currentConf, () => {
// close after config is saved
pkgSearchResult.configOpened = false;
});
};
init();
}

View file

@ -63,7 +63,7 @@ limitations under the License.
<div class="box width-full heliumPackageContainer">
<div class="row"
style="padding-bottom: 15px"
ng-if="getPackageSize(defaultPackages, pkgListByType) === 0">
ng-if="getPackageSize(defaultVersions, pkgListByType) === 0">
<div class="col-md-12 gray40-message">
<em>Currently there is no available package to be listed</em>
</div>
@ -83,15 +83,15 @@ limitations under the License.
<span ng-if="hasNpmLink(pkgSearchResult)">
<a target="_blank" href="https://www.npmjs.com/package/{{pkgName}}">{{pkgName}}</a>
</span>
<span ng-if="!hasNpmLink(pkgSearchResult)" ng-class="{'heliumLocalPackage': isLocalPackage(pkgSearchResult)}">
{{pkgName}}
</span>
<span ng-if="hasMavenLink(pkgSearchResult)">
<a target="_blank"
href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22{{pkgSearchResult.pkg.artifact.split('@')[0]}}%22%20AND%20v%3A%22{{pkgSearchResult.pkg.artifact.split('@')[1]}}%22">
{{pkgName}}
</a>
</span>
<span ng-if="!hasNpmLink(pkgSearchResult) && !hasMavenLink(pkgSearchResult)" ng-class="{'heliumLocalPackage': isLocalPackage(pkgSearchResult)}">
{{pkgName}}
</span>
<span class="heliumType">{{pkgSearchResult.pkg.type}}</span>
</div>
<div ng-show="!pkgSearchResult.enabled"
@ -109,10 +109,15 @@ limitations under the License.
ng-if="pkgSearchResult.pkg.type === 'INTERPRETER'"
class="btn btn-success disabled btn-xs"
style="float:right">Coming soon</div>
<div ng-show="configExists(pkgSearchResult)"
ng-click="toggleConfigButton(pkgSearchResult)"
ng-class="getConfigButtonClass(pkgSearchResult)"
class="btn btn-default btn-xs spellConfigButton"
style="float:right; margin-right:5px;">Config</div>
</div>
<div ng-class="{heliumPackageDisabledArtifact: !pkgSearchResult.enabled, heliumPackageEnabledArtifact: pkgSearchResult.enabled}">
{{pkgSearchResult.pkg.artifact}}
<span ng-show="packageInfos[pkgName].length > 0"
<span ng-show="pkgSearchResults[pkgName].length > 0"
ng-click="toggleVersions(pkgName)">
versions
</span>
@ -120,9 +125,9 @@ limitations under the License.
<ul class="heliumPackageVersions"
ng-show="showVersions[pkgName]">
<li class="heliumPackageDisabledArtifact"
ng-repeat="pkg in packageInfos[pkgName]">
{{pkg.pkg.artifact}} -
<span ng-click="enable(pkgName, pkg.pkg.artifact)"
ng-repeat="pkgSearchResult in pkgSearchResults[pkgName]">
{{pkgSearchResult.pkg.artifact}} -
<span ng-click="enable(pkgName, pkgSearchResult.pkg.artifact)"
ng-if="pkgSearchResult.pkg.type !== 'INTERPRETER'"
style="margin-left:3px;cursor:pointer;text-decoration: underline;color:#3071a9">
enable
@ -130,7 +135,7 @@ limitations under the License.
<a target="_blank"
ng-if="pkgSearchResult.pkg.type === 'INTERPRETER'"
style="margin-left:3px;cursor:pointer;text-decoration: underline;color:#3071a9"
href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22{{pkg.pkg.artifact.split('@')[0]}}%22%20AND%20v%3A%22{{pkg.pkg.artifact.split('@')[1]}}%22">
href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22{{pkgSearchResult.pkg.artifact.split('@')[0]}}%22%20AND%20v%3A%22{{pkgSearchResult.pkg.artifact.split('@')[1]}}%22">
see more
</a>
</li>
@ -149,6 +154,42 @@ limitations under the License.
<pre class="spellUsage">{{pkgSearchResult.pkg.spell.usage}} </pre>
</div>
</div>
<!--start: config-->
<div class="heliumConfig" ng-if="configOpened(pkgSearchResult)">
<h5>Configuration</h5>
<table class="heliumConfigTable table table-striped">
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Value</th>
</tr>
<tr>
</tr>
<tr data-ng-repeat="cfg in defaultPackageConfigs[pkgSearchResult.pkg.name]">
<td style="vertical-align: middle;">{{cfg.name}}</td>
<td style="vertical-align: middle;">{{cfg.type}}</td>
<td style="vertical-align: middle;">{{cfg.description}}</td>
<td>
<div class="input-group">
<input type="text" class="form-control" style="border-radius: 5px;"
data-ng-model="cfg.value" placeholder="{{cfg.defaultValue}}" />
</div>
</td>
</tr>
</table>
<div>
<button class="btn btn-primary"
ng-click="saveConfig(pkgSearchResult)">Save</button>
<button class="btn btn-default"
ng-click="toggleConfigButton(pkgSearchResult)">Close</button>
</div>
</div>
<!--end: config-->
</div>
</div>
</div>