本文整理匯總了TypeScript中sp-pnp-js.log類的典型用法代碼示例。如果您正苦於以下問題:TypeScript log類的具體用法?TypeScript log怎麽用?TypeScript log使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了log類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getNavigationNodes
private getNavigationNodes(termSetId: string): void {
if (!termSetId) {
pnp.log.write("The term set id for the header links is null. Please specify a valid term set id in the configuration list", pnp.LogLevel.Error);
} else {
// Ensure all SP dependencies are loaded before retrieving navigation nodes
this.taxonomyModule.init().then(() => {
// Initialize the main menu with taxonomy terms
this.taxonomyModule.getNavigationTaxonomyNodes(new SP.Guid(termSetId)).then(navigationTree => {
// Initialize the mainMenu view model
this.initialize(navigationTree);
this.wait(false);
let now: Date = new Date();
// Set the navigation tree in the local storage of the browser
pnp.storage.local.put(this.localStorageKey, this.utilityModule.stringifyTreeObject(navigationTree), new Date(now.setDate(now.getDate() + 7)));
}).catch(errorMesssage => {
pnp.log.write(errorMesssage, pnp.LogLevel.Error);
});
}).catch(errorMesssage => {
pnp.log.write(errorMesssage, pnp.LogLevel.Error);
});
}
}
示例2: getTermById
/**
* Get a single term by its Id using the current taxonomy context.
* @param {SP.Guid} termId The taxonomy term Id
* @return {Promise<SP.Taxonomy.Term>} A promise containing the term infos.
*/
public getTermById(termId: SP.Guid): Promise<SP.Taxonomy.Term> {
if (termId) {
let context: SP.ClientContext = SP.ClientContext.get_current();
let taxSession: SP.Taxonomy.TaxonomySession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
let termStore: SP.Taxonomy.TermStore = taxSession.getDefaultSiteCollectionTermStore();
termStore.set_workingLanguage(this.workingLanguage);
let term: SP.Taxonomy.Term = termStore.getTerm(termId);
context.load(term, "Name");
let p = new Promise<SP.Taxonomy.Term>((resolve, reject) => {
context.executeQueryAsync(() => {
resolve(term);
}, (sender, args) => {
reject("Request failed. " + args.get_message() + "\n" + args.get_stackTrace());
});
});
return p;
} else {
pnp.log.write("TaxonomyModule.getTermById: the provided term id is null!", pnp.LogLevel.Error);
}
}
示例3:
pnp.sp.web.lists.getByTitle("Pages").items.getById(_spPageContextInfo.pageItemId).select(this.siteMapFieldName).get().then((item) => {
let siteMapTermGuid = item[this.siteMapFieldName];
let currentNode: NavigationNode = undefined;
if (siteMapTermGuid) {
// 1: Search for this guid in the site map
currentNode = this.utilityModule.getNodeByTermId(navigationTree, siteMapTermGuid.TermGuid);
}
if (currentNode === undefined) {
// 2: Get the navigation node according to the current URL
currentNode = this.utilityModule.getNodeByUrl(navigationTree, window.location.pathname);
}
if (currentNode !== undefined) {
// If there is no 'ParentId', this is a root term
if (currentNode.ParentId !== null) {
let parentNode = this.utilityModule.getNodeByTermId(navigationTree, new SP.Guid(currentNode.ParentId));
// Set the parent section
this.parentSection(parentNode);
if (parentNode.ChildNodes.length > 0) {
// Display all siblings and child nodes from the current node (just like the CSOM results)
// Siblings = children of my own parent ;)
navigationTree = parentNode.ChildNodes;
// Set the current node as first item
navigationTree = this.utilityModule.moveItem(navigationTree, navigationTree.indexOf(currentNode), 0);
}
}
} else {
pnp.log.write("[Contextual Menu] Unable to determine the current position in the site map", pnp.LogLevel.Warning);
}
this.initialize(navigationTree);
this.wait(false);
if (currentNode !== undefined) {
this.setCurrentNode(new SP.Guid(currentNode.Id));
}
}).catch((errorMesssage) => {
示例4:
pnp.sp.site.rootWeb.lists.getByTitle(configListName).items.filter(filterQuery).top(1).get().then((item) => {
if (item.length > 0) {
// Get the boolean value
let noCache: boolean = item[0].ForceCacheRefresh;
// Get the term set id
let termSetId = item[0].SiteMapTermSetId;
if (noCache) {
// Clear the local storage value
pnp.storage.local.delete(this.localStorageKey);
// Get navigation nodes
this.getNavigationNodes(termSetId);
} else {
let navigationTree = this.utilityModule.isCacheValueValid(this.localStorageKey);
// Check if the local storage value is still valid (i.e not null)
if (navigationTree) {
this.initialize(navigationTree);
this.wait(false);
// Publish the data to all subscribers (contextual menu and breadcrumb)
PubSub.publish("navigationNodes", { nodes: navigationTree } );
} else {
this.getNavigationNodes(termSetId);
}
}
} else {
pnp.log.write("There is no configuration item for the site map for the language '" + currentLanguage + "'", pnp.LogLevel.Error);
}
}).catch(errorMesssage => {
示例5:
pnp.sp.site.rootWeb.lists.getByTitle(configListName).items.filter(filterQuery).top(1).get().then((item) => {
if (item.length > 0) {
// Get the boolean value
let noCache: boolean = item[0].ForceCacheRefresh;
// Get the term set id
let termSetId = item[0].HeaderLinksTermSetId;
if (noCache) {
// Clear the local storage value
pnp.storage.local.delete(this.localStorageKey);
// Get navigation nodes
this.getNavigationNodes(termSetId);
} else {
let navigationTree = this.utilityModule.isCacheValueValid(this.localStorageKey);
// Check if the local storage value is still valid
if (navigationTree) {
this.initialize(navigationTree);
this.wait(false);
} else {
this.getNavigationNodes(termSetId);
}
}
} else {
pnp.log.write("There is no configuration item for this site", pnp.LogLevel.Warning);
}
}).catch(errorMesssage => {
示例6:
}).catch((errorMesssage) => {
pnp.log.write(errorMesssage, pnp.LogLevel.Error);
});