cds-caching 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -1114
- package/app/dashboard/Component-dbg.js +59 -0
- package/app/dashboard/Component-dbg.js.map +1 -0
- package/app/dashboard/Component.js +2 -0
- package/app/dashboard/Component.js.map +1 -0
- package/app/dashboard/Component.ts +59 -0
- package/app/dashboard/controller/App-dbg.controller.js +132 -0
- package/app/dashboard/controller/App-dbg.controller.js.map +1 -0
- package/app/dashboard/controller/App.controller.js +2 -0
- package/app/dashboard/controller/App.controller.js.map +1 -0
- package/app/dashboard/controller/App.controller.ts +147 -0
- package/app/dashboard/controller/BaseController-dbg.js +75 -0
- package/app/dashboard/controller/BaseController-dbg.js.map +1 -0
- package/app/dashboard/controller/BaseController.js +2 -0
- package/app/dashboard/controller/BaseController.js.map +1 -0
- package/app/dashboard/controller/BaseController.ts +88 -0
- package/app/dashboard/controller/Cache-dbg.controller.js +421 -0
- package/app/dashboard/controller/Cache-dbg.controller.js.map +1 -0
- package/app/dashboard/controller/Cache.controller.js +2 -0
- package/app/dashboard/controller/Cache.controller.js.map +1 -0
- package/app/dashboard/controller/Cache.controller.ts +490 -0
- package/app/dashboard/controller/Main-dbg.controller.js +32 -0
- package/app/dashboard/controller/Main-dbg.controller.js.map +1 -0
- package/app/dashboard/controller/Main.controller.js +2 -0
- package/app/dashboard/controller/Main.controller.js.map +1 -0
- package/app/dashboard/controller/Main.controller.ts +31 -0
- package/app/dashboard/controller/SingleMetric-dbg.controller.js +306 -0
- package/app/dashboard/controller/SingleMetric-dbg.controller.js.map +1 -0
- package/app/dashboard/controller/SingleMetric.controller.js +2 -0
- package/app/dashboard/controller/SingleMetric.controller.js.map +1 -0
- package/app/dashboard/controller/SingleMetric.controller.ts +335 -0
- package/app/dashboard/i18n/i18n.properties +61 -0
- package/app/dashboard/i18n/i18n_de.properties +3 -0
- package/app/dashboard/i18n/i18n_en.properties +3 -0
- package/app/dashboard/index-cdn.html +28 -0
- package/app/dashboard/index.html +19 -0
- package/app/dashboard/manifest.json +145 -0
- package/app/dashboard/model/formatter-dbg.js +253 -0
- package/app/dashboard/model/formatter-dbg.js.map +1 -0
- package/app/dashboard/model/formatter.js +2 -0
- package/app/dashboard/model/formatter.js.map +1 -0
- package/app/dashboard/model/formatter.ts +275 -0
- package/app/dashboard/model/models-dbg.js +13 -0
- package/app/dashboard/model/models-dbg.js.map +1 -0
- package/app/dashboard/model/models.js +2 -0
- package/app/dashboard/model/models.js.map +1 -0
- package/app/dashboard/model/models.ts +13 -0
- package/app/dashboard/resources/sap-ui-custom-dbg.js +4695 -0
- package/app/dashboard/resources/sap-ui-custom-dbg.js.map +1 -0
- package/app/dashboard/resources/sap-ui-custom.js +5794 -0
- package/app/dashboard/resources/sap-ui-custom.js.map +1 -0
- package/app/dashboard/service/CacheStatisticsService-dbg.js +267 -0
- package/app/dashboard/service/CacheStatisticsService-dbg.js.map +1 -0
- package/app/dashboard/service/CacheStatisticsService.js +2 -0
- package/app/dashboard/service/CacheStatisticsService.js.map +1 -0
- package/app/dashboard/service/CacheStatisticsService.ts +397 -0
- package/app/dashboard/view/App.view.xml +18 -0
- package/app/dashboard/view/Cache.view.xml +777 -0
- package/app/dashboard/view/Main.view.xml +57 -0
- package/app/dashboard/view/SingleMetric.view.xml +337 -0
- package/cds-plugin.js +52 -0
- package/db/cache-store.cds +12 -0
- package/db/statistics.cds +128 -0
- package/index.cds +2 -128
- package/lib/CachingService.js +13 -0
- package/lib/add.js +17 -0
- package/lib/operations/AsyncOperations.js +162 -111
- package/lib/operations/BasicOperations.js +35 -0
- package/lib/operations/CapOperations.js +92 -40
- package/lib/support/CacheStatisticsHandler.js +35 -10
- package/lib/support/CacheStoreManager.js +29 -0
- package/lib/support/KeyvCDS.js +149 -0
- package/lib/support/MultitenancyDetector.js +25 -0
- package/lib/support/RuntimeConfigurationManager.js +69 -37
- package/lib/support/StatisticsPersistenceManager.js +18 -2
- package/lib/support/Telemetry.js +137 -0
- package/lib/util.js +29 -11
- package/package.json +43 -11
- package/srv/caching-api-service.js +47 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
sap.ui.define(["sap/ui/core/UIComponent", "./model/models", "sap/ui/Device", "./model/formatter", "sap/ui/model/json/JSONModel"], function (UIComponent, __models, Device, __formatter, JSONModel) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
function _interopRequireDefault(obj) {
|
|
5
|
+
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
6
|
+
}
|
|
7
|
+
const models = _interopRequireDefault(__models);
|
|
8
|
+
const formatter = _interopRequireDefault(__formatter);
|
|
9
|
+
/**
|
|
10
|
+
* @namespace cds.plugin.caching.dashboard
|
|
11
|
+
*/
|
|
12
|
+
const Component = UIComponent.extend("cds.plugin.caching.dashboard.Component", {
|
|
13
|
+
metadata: {
|
|
14
|
+
manifest: "json",
|
|
15
|
+
interfaces: ["sap.ui.core.IAsyncContentCreation"]
|
|
16
|
+
},
|
|
17
|
+
init: function _init() {
|
|
18
|
+
// call the base component's init function
|
|
19
|
+
UIComponent.prototype.init.call(this);
|
|
20
|
+
|
|
21
|
+
// create the device model
|
|
22
|
+
this.setModel(models.createDeviceModel(), "device");
|
|
23
|
+
this.setModel(new JSONModel({
|
|
24
|
+
selectedCache: null,
|
|
25
|
+
selectedTab: "main",
|
|
26
|
+
layout: "OneColumn"
|
|
27
|
+
}), "app");
|
|
28
|
+
|
|
29
|
+
// create the formatter model
|
|
30
|
+
this.setModel(new JSONModel(formatter), "formatter");
|
|
31
|
+
|
|
32
|
+
// create the views based on the url/hash
|
|
33
|
+
this.getRouter().initialize();
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* This method can be called to determine whether the sapUiSizeCompact or sapUiSizeCozy
|
|
37
|
+
* design mode class should be set, which influences the size appearance of some controls.
|
|
38
|
+
* @public
|
|
39
|
+
* @returns css class, either 'sapUiSizeCompact' or 'sapUiSizeCozy' - or an empty string if no css class should be set
|
|
40
|
+
*/
|
|
41
|
+
getContentDensityClass: function _getContentDensityClass() {
|
|
42
|
+
if (this.contentDensityClass === undefined) {
|
|
43
|
+
// check whether FLP has already set the content density class; do nothing in this case
|
|
44
|
+
if (document.body.classList.contains("sapUiSizeCozy") || document.body.classList.contains("sapUiSizeCompact")) {
|
|
45
|
+
this.contentDensityClass = "";
|
|
46
|
+
} else if (!Device.support.touch) {
|
|
47
|
+
// apply "compact" mode if touch is not supported
|
|
48
|
+
this.contentDensityClass = "sapUiSizeCompact";
|
|
49
|
+
} else {
|
|
50
|
+
// "cozy" in case of touch support; default for most sap.m controls, but needed for desktop-first controls like sap.ui.table.Table
|
|
51
|
+
this.contentDensityClass = "sapUiSizeCozy";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return this.contentDensityClass;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return Component;
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=Component-dbg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component-dbg.js","names":["models","_interopRequireDefault","__models","formatter","__formatter","Component","UIComponent","extend","metadata","manifest","interfaces","init","_init","UIComponent.prototype.init.call","setModel","createDeviceModel","JSONModel","selectedCache","selectedTab","layout","getRouter","initialize","getContentDensityClass","_getContentDensityClass","contentDensityClass","undefined","document","body","classList","contains","Device","support","touch"],"sources":["Component.ts"],"sourcesContent":["import UIComponent from \"sap/ui/core/UIComponent\";\nimport models from \"./model/models\";\nimport Device from \"sap/ui/Device\";\nimport formatter from \"./model/formatter\";\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\n\n/**\n * @namespace cds.plugin.caching.dashboard\n */\nexport default class Component extends UIComponent {\n\tpublic static metadata = {\n\t\tmanifest: \"json\",\n\t\tinterfaces: [\"sap.ui.core.IAsyncContentCreation\"]\n\t};\n\n\tprivate contentDensityClass: string;\n\n\tpublic init(): void {\n\t\t// call the base component's init function\n\t\tsuper.init();\n\n\t\t// create the device model\n\t\tthis.setModel(models.createDeviceModel(), \"device\");\n\n\t\tthis.setModel(new JSONModel({\n\t\t\tselectedCache: null,\n\t\t\tselectedTab: \"main\",\n\t\t\tlayout: \"OneColumn\"\n\t\t}), \"app\");\n\n\t\t// create the formatter model\n\t\tthis.setModel(new JSONModel(formatter), \"formatter\");\n\n\t\t// create the views based on the url/hash\n\t\tthis.getRouter().initialize();\n\t}\n\n\t/**\n\t * This method can be called to determine whether the sapUiSizeCompact or sapUiSizeCozy\n\t * design mode class should be set, which influences the size appearance of some controls.\n\t * @public\n\t * @returns css class, either 'sapUiSizeCompact' or 'sapUiSizeCozy' - or an empty string if no css class should be set\n\t */\n\tpublic getContentDensityClass(): string {\n\t\tif (this.contentDensityClass === undefined) {\n\t\t\t// check whether FLP has already set the content density class; do nothing in this case\n\t\t\tif (document.body.classList.contains(\"sapUiSizeCozy\") || document.body.classList.contains(\"sapUiSizeCompact\")) {\n\t\t\t\tthis.contentDensityClass = \"\";\n\t\t\t} else if (!Device.support.touch) {\n\t\t\t\t// apply \"compact\" mode if touch is not supported\n\t\t\t\tthis.contentDensityClass = \"sapUiSizeCompact\";\n\t\t\t} else {\n\t\t\t\t// \"cozy\" in case of touch support; default for most sap.m controls, but needed for desktop-first controls like sap.ui.table.Table\n\t\t\t\tthis.contentDensityClass = \"sapUiSizeCozy\";\n\t\t\t}\n\t\t}\n\t\treturn this.contentDensityClass;\n\t}\n}\n"],"mappings":";;;;;;QACOA,MAAM,GAAAC,sBAAA,CAAAC,QAAA;EAAA,MAENC,SAAS,GAAAF,sBAAA,CAAAG,WAAA;EAGhB;AACA;AACA;EAFA,MAGqBC,SAAS,GAASC,WAAW,CAAAC,MAAA;IACnCC,QAAQ,EAAG;MACxBC,QAAQ,EAAE,MAAM;MAChBC,UAAU,EAAE,CAAC,mCAAmC;IACjD,CAAC;IAIMC,IAAI,WAAAC,MAAA,EAAS;MACnB;MACAC,+BAAA;;MAEA;MACA,IAAI,CAACC,QAAQ,CAACd,MAAM,CAACe,iBAAiB,CAAC,CAAC,EAAE,QAAQ,CAAC;MAEnD,IAAI,CAACD,QAAQ,CAAC,IAAIE,SAAS,CAAC;QAC3BC,aAAa,EAAE,IAAI;QACnBC,WAAW,EAAE,MAAM;QACnBC,MAAM,EAAE;MACT,CAAC,CAAC,EAAE,KAAK,CAAC;;MAEV;MACA,IAAI,CAACL,QAAQ,CAAC,IAAIE,SAAS,CAACb,SAAS,CAAC,EAAE,WAAW,CAAC;;MAEpD;MACA,IAAI,CAACiB,SAAS,CAAC,CAAC,CAACC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED;AACD;AACA;AACA;AACA;AACA;IACQC,sBAAsB,WAAAC,wBAAA,EAAW;MACvC,IAAI,IAAI,CAACC,mBAAmB,KAAKC,SAAS,EAAE;QAC3C;QACA,IAAIC,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC,eAAe,CAAC,IAAIH,QAAQ,CAACC,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;UAC9G,IAAI,CAACL,mBAAmB,GAAG,EAAE;QAC9B,CAAC,MAAM,IAAI,CAACM,MAAM,CAACC,OAAO,CAACC,KAAK,EAAE;UACjC;UACA,IAAI,CAACR,mBAAmB,GAAG,kBAAkB;QAC9C,CAAC,MAAM;UACN;UACA,IAAI,CAACA,mBAAmB,GAAG,eAAe;QAC3C;MACD;MACA,OAAO,IAAI,CAACA,mBAAmB;IAChC;EAAC;EAAA,OAhDmBnB,SAAS;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define(["sap/ui/core/UIComponent","./model/models","sap/ui/Device","./model/formatter","sap/ui/model/json/JSONModel"],function(e,t,n,s,i){"use strict";function o(e){return e&&e.__esModule&&typeof e.default!=="undefined"?e.default:e}const a=o(t);const c=o(s);const l=e.extend("cds.plugin.caching.dashboard.Component",{metadata:{manifest:"json",interfaces:["sap.ui.core.IAsyncContentCreation"]},init:function t(){e.prototype.init.call(this);this.setModel(a.createDeviceModel(),"device");this.setModel(new i({selectedCache:null,selectedTab:"main",layout:"OneColumn"}),"app");this.setModel(new i(c),"formatter");this.getRouter().initialize()},getContentDensityClass:function e(){if(this.contentDensityClass===undefined){if(document.body.classList.contains("sapUiSizeCozy")||document.body.classList.contains("sapUiSizeCompact")){this.contentDensityClass=""}else if(!n.support.touch){this.contentDensityClass="sapUiSizeCompact"}else{this.contentDensityClass="sapUiSizeCozy"}}return this.contentDensityClass}});return l});
|
|
2
|
+
//# sourceMappingURL=Component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.js","names":["models","_interopRequireDefault","__models","formatter","__formatter","Component","UIComponent","extend","metadata","manifest","interfaces","init","_init","UIComponent.prototype.init.call","this","setModel","createDeviceModel","JSONModel","selectedCache","selectedTab","layout","getRouter","initialize","getContentDensityClass","_getContentDensityClass","contentDensityClass","undefined","document","body","classList","contains","Device","support","touch"],"sources":["Component.ts"],"sourcesContent":["import UIComponent from \"sap/ui/core/UIComponent\";\nimport models from \"./model/models\";\nimport Device from \"sap/ui/Device\";\nimport formatter from \"./model/formatter\";\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\n\n/**\n * @namespace cds.plugin.caching.dashboard\n */\nexport default class Component extends UIComponent {\n\tpublic static metadata = {\n\t\tmanifest: \"json\",\n\t\tinterfaces: [\"sap.ui.core.IAsyncContentCreation\"]\n\t};\n\n\tprivate contentDensityClass: string;\n\n\tpublic init(): void {\n\t\t// call the base component's init function\n\t\tsuper.init();\n\n\t\t// create the device model\n\t\tthis.setModel(models.createDeviceModel(), \"device\");\n\n\t\tthis.setModel(new JSONModel({\n\t\t\tselectedCache: null,\n\t\t\tselectedTab: \"main\",\n\t\t\tlayout: \"OneColumn\"\n\t\t}), \"app\");\n\n\t\t// create the formatter model\n\t\tthis.setModel(new JSONModel(formatter), \"formatter\");\n\n\t\t// create the views based on the url/hash\n\t\tthis.getRouter().initialize();\n\t}\n\n\t/**\n\t * This method can be called to determine whether the sapUiSizeCompact or sapUiSizeCozy\n\t * design mode class should be set, which influences the size appearance of some controls.\n\t * @public\n\t * @returns css class, either 'sapUiSizeCompact' or 'sapUiSizeCozy' - or an empty string if no css class should be set\n\t */\n\tpublic getContentDensityClass(): string {\n\t\tif (this.contentDensityClass === undefined) {\n\t\t\t// check whether FLP has already set the content density class; do nothing in this case\n\t\t\tif (document.body.classList.contains(\"sapUiSizeCozy\") || document.body.classList.contains(\"sapUiSizeCompact\")) {\n\t\t\t\tthis.contentDensityClass = \"\";\n\t\t\t} else if (!Device.support.touch) {\n\t\t\t\t// apply \"compact\" mode if touch is not supported\n\t\t\t\tthis.contentDensityClass = \"sapUiSizeCompact\";\n\t\t\t} else {\n\t\t\t\t// \"cozy\" in case of touch support; default for most sap.m controls, but needed for desktop-first controls like sap.ui.table.Table\n\t\t\t\tthis.contentDensityClass = \"sapUiSizeCozy\";\n\t\t\t}\n\t\t}\n\t\treturn this.contentDensityClass;\n\t}\n}\n"],"mappings":"qPACOA,EAAMC,EAAAC,GAAA,MAENC,EAASF,EAAAG,GAGhB,MAGqBC,EAAkBC,EAAWC,OAAA,0CACnCC,SAAW,CACxBC,SAAU,OACVC,WAAY,CAAC,sCAKPC,KAAI,SAAAC,IAEVC,sBAAAC,MAGAA,KAAKC,SAASf,EAAOgB,oBAAqB,UAE1CF,KAAKC,SAAS,IAAIE,EAAU,CAC3BC,cAAe,KACfC,YAAa,OACbC,OAAQ,cACL,OAGJN,KAAKC,SAAS,IAAIE,EAAUd,GAAY,aAGxCW,KAAKO,YAAYC,YAClB,EAQOC,uBAAsB,SAAAC,IAC5B,GAAIV,KAAKW,sBAAwBC,UAAW,CAE3C,GAAIC,SAASC,KAAKC,UAAUC,SAAS,kBAAoBH,SAASC,KAAKC,UAAUC,SAAS,oBAAqB,CAC9GhB,KAAKW,oBAAsB,EAC5B,MAAO,IAAKM,EAAOC,QAAQC,MAAO,CAEjCnB,KAAKW,oBAAsB,kBAC5B,KAAO,CAENX,KAAKW,oBAAsB,eAC5B,CACD,CACA,OAAOX,KAAKW,mBACb,IAAC,OAhDmBpB,CAAS","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import UIComponent from "sap/ui/core/UIComponent";
|
|
2
|
+
import models from "./model/models";
|
|
3
|
+
import Device from "sap/ui/Device";
|
|
4
|
+
import formatter from "./model/formatter";
|
|
5
|
+
import JSONModel from "sap/ui/model/json/JSONModel";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @namespace cds.plugin.caching.dashboard
|
|
9
|
+
*/
|
|
10
|
+
export default class Component extends UIComponent {
|
|
11
|
+
public static metadata = {
|
|
12
|
+
manifest: "json",
|
|
13
|
+
interfaces: ["sap.ui.core.IAsyncContentCreation"]
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
private contentDensityClass: string;
|
|
17
|
+
|
|
18
|
+
public init(): void {
|
|
19
|
+
// call the base component's init function
|
|
20
|
+
super.init();
|
|
21
|
+
|
|
22
|
+
// create the device model
|
|
23
|
+
this.setModel(models.createDeviceModel(), "device");
|
|
24
|
+
|
|
25
|
+
this.setModel(new JSONModel({
|
|
26
|
+
selectedCache: null,
|
|
27
|
+
selectedTab: "main",
|
|
28
|
+
layout: "OneColumn"
|
|
29
|
+
}), "app");
|
|
30
|
+
|
|
31
|
+
// create the formatter model
|
|
32
|
+
this.setModel(new JSONModel(formatter), "formatter");
|
|
33
|
+
|
|
34
|
+
// create the views based on the url/hash
|
|
35
|
+
this.getRouter().initialize();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This method can be called to determine whether the sapUiSizeCompact or sapUiSizeCozy
|
|
40
|
+
* design mode class should be set, which influences the size appearance of some controls.
|
|
41
|
+
* @public
|
|
42
|
+
* @returns css class, either 'sapUiSizeCompact' or 'sapUiSizeCozy' - or an empty string if no css class should be set
|
|
43
|
+
*/
|
|
44
|
+
public getContentDensityClass(): string {
|
|
45
|
+
if (this.contentDensityClass === undefined) {
|
|
46
|
+
// check whether FLP has already set the content density class; do nothing in this case
|
|
47
|
+
if (document.body.classList.contains("sapUiSizeCozy") || document.body.classList.contains("sapUiSizeCompact")) {
|
|
48
|
+
this.contentDensityClass = "";
|
|
49
|
+
} else if (!Device.support.touch) {
|
|
50
|
+
// apply "compact" mode if touch is not supported
|
|
51
|
+
this.contentDensityClass = "sapUiSizeCompact";
|
|
52
|
+
} else {
|
|
53
|
+
// "cozy" in case of touch support; default for most sap.m controls, but needed for desktop-first controls like sap.ui.table.Table
|
|
54
|
+
this.contentDensityClass = "sapUiSizeCozy";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return this.contentDensityClass;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
sap.ui.define(["sap/m/MessageBox", "./BaseController", "sap/m/MessageToast"], function (MessageBox, __BaseController, MessageToast) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
function _interopRequireDefault(obj) {
|
|
5
|
+
return obj && obj.__esModule && typeof obj.default !== "undefined" ? obj.default : obj;
|
|
6
|
+
}
|
|
7
|
+
const BaseController = _interopRequireDefault(__BaseController);
|
|
8
|
+
/**
|
|
9
|
+
* @namespace cds.plugin.caching.dashboard.controller
|
|
10
|
+
*/
|
|
11
|
+
const App = BaseController.extend("cds.plugin.caching.dashboard.controller.App", {
|
|
12
|
+
onInit: function _onInit() {
|
|
13
|
+
// apply content density mode to root view
|
|
14
|
+
this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass());
|
|
15
|
+
},
|
|
16
|
+
onSelectionChange: function _onSelectionChange(oEvent) {
|
|
17
|
+
const key = oEvent.getParameter("selectedKey");
|
|
18
|
+
this.getRouter().navTo(key);
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* Handle cache selection change
|
|
22
|
+
*/
|
|
23
|
+
onCacheChange: async function _onCacheChange() {
|
|
24
|
+
const selectedCache = this.getModel("app").getProperty("/selectedCache");
|
|
25
|
+
if (selectedCache) {
|
|
26
|
+
await this.loadRuntimeConfiguration(selectedCache);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Load runtime configuration for the selected cache
|
|
31
|
+
*/
|
|
32
|
+
loadRuntimeConfiguration: async function _loadRuntimeConfiguration(cacheName) {
|
|
33
|
+
try {
|
|
34
|
+
const config = await this.statisticsService.getRuntimeConfiguration(cacheName);
|
|
35
|
+
this.getModel("app").setProperty("/enableStatistics", config.enableStatistics);
|
|
36
|
+
this.getModel("app").setProperty("/enableKeyTracking", config.enableKeyTracking);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("Error loading runtime configuration:", error);
|
|
39
|
+
// Set defaults if loading fails
|
|
40
|
+
this.getModel("app").setProperty("/enableStatistics", false);
|
|
41
|
+
this.getModel("app").setProperty("/enableKeyTracking", false);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Handle statistics enable/disable switch change
|
|
46
|
+
*/
|
|
47
|
+
onEnableStatisticsChange: async function _onEnableStatisticsChange(oEvent) {
|
|
48
|
+
const enabled = oEvent.getParameter("state");
|
|
49
|
+
const cacheName = this.getModel("app").getProperty("/selectedCache");
|
|
50
|
+
if (!cacheName) {
|
|
51
|
+
MessageBox.warning("No cache selected");
|
|
52
|
+
// Revert the switch
|
|
53
|
+
this.getModel("app").setProperty("/enableStatistics", !enabled);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
// Show loading state
|
|
58
|
+
MessageToast.show("Updating statistics configuration...");
|
|
59
|
+
const success = await this.statisticsService.setStatisticsEnabled(cacheName, enabled);
|
|
60
|
+
if (success) {
|
|
61
|
+
MessageToast.show(`Statistics ${enabled ? 'enabled' : 'disabled'} successfully`);
|
|
62
|
+
// Reload the configuration to reflect the change
|
|
63
|
+
await this.loadRuntimeConfiguration(cacheName);
|
|
64
|
+
} else {
|
|
65
|
+
MessageToast.show("Failed to update statistics configuration");
|
|
66
|
+
// Revert the switch
|
|
67
|
+
this.getModel("app").setProperty("/enableStatistics", !enabled);
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error("Error updating statistics configuration:", error);
|
|
71
|
+
MessageToast.show("Error updating statistics configuration");
|
|
72
|
+
// Revert the switch
|
|
73
|
+
this.getModel("app").setProperty("/enableStatistics", !enabled);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Handle key tracking enable/disable switch change
|
|
78
|
+
*/
|
|
79
|
+
onEnableKeyTrackingChange: async function _onEnableKeyTrackingChange(oEvent) {
|
|
80
|
+
const enabled = oEvent.getParameter("state");
|
|
81
|
+
const cacheName = this.getModel("app").getProperty("/selectedCache");
|
|
82
|
+
if (!cacheName) {
|
|
83
|
+
MessageBox.warning("No cache selected");
|
|
84
|
+
// Revert the switch
|
|
85
|
+
this.getModel("app").setProperty("/enableKeyTracking", !enabled);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
// Show loading state
|
|
90
|
+
MessageToast.show("Updating key tracking configuration...");
|
|
91
|
+
const success = await this.statisticsService.setKeyTrackingEnabled(cacheName, enabled);
|
|
92
|
+
if (success) {
|
|
93
|
+
MessageToast.show(`Key tracking ${enabled ? 'enabled' : 'disabled'} successfully`);
|
|
94
|
+
// Reload the configuration to reflect the change
|
|
95
|
+
await this.loadRuntimeConfiguration(cacheName);
|
|
96
|
+
} else {
|
|
97
|
+
MessageToast.show("Failed to update key tracking configuration");
|
|
98
|
+
// Revert the switch
|
|
99
|
+
this.getModel("app").setProperty("/enableKeyTracking", !enabled);
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error("Error updating key tracking configuration:", error);
|
|
103
|
+
MessageToast.show("Error updating key tracking configuration");
|
|
104
|
+
// Revert the switch
|
|
105
|
+
this.getModel("app").setProperty("/enableKeyTracking", !enabled);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Persist statistics to database
|
|
110
|
+
*/
|
|
111
|
+
onPersistStatistics: async function _onPersistStatistics() {
|
|
112
|
+
try {
|
|
113
|
+
const cacheName = this.getModel("app").getProperty("/selectedCache");
|
|
114
|
+
if (!cacheName) {
|
|
115
|
+
MessageBox.warning("No cache selected");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const success = await this.statisticsService.persistStatistics(cacheName);
|
|
119
|
+
if (success) {
|
|
120
|
+
MessageToast.show("Statistics persisted successfully");
|
|
121
|
+
} else {
|
|
122
|
+
MessageToast.show("Failed to persist statistics");
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error("Error persisting statistics:", error);
|
|
126
|
+
MessageToast.show("Error persisting statistics");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return App;
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=App-dbg.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App-dbg.controller.js","names":["BaseController","_interopRequireDefault","__BaseController","App","extend","onInit","_onInit","getView","addStyleClass","getOwnerComponent","getContentDensityClass","onSelectionChange","_onSelectionChange","oEvent","key","getParameter","getRouter","navTo","onCacheChange","_onCacheChange","selectedCache","getModel","getProperty","loadRuntimeConfiguration","_loadRuntimeConfiguration","cacheName","config","statisticsService","getRuntimeConfiguration","setProperty","enableStatistics","enableKeyTracking","error","console","onEnableStatisticsChange","_onEnableStatisticsChange","enabled","MessageBox","warning","MessageToast","show","success","setStatisticsEnabled","onEnableKeyTrackingChange","_onEnableKeyTrackingChange","setKeyTrackingEnabled","onPersistStatistics","_onPersistStatistics","persistStatistics"],"sources":["App.controller.ts"],"sourcesContent":["import MessageBox from \"sap/m/MessageBox\";\nimport BaseController from \"./BaseController\";\nimport { IconTabBar$SelectEvent } from \"sap/m/IconTabBar\";\nimport CacheStatisticsService from \"../service/CacheStatisticsService\";\nimport ODataModel from \"sap/ui/model/odata/v4/ODataModel\";\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\nimport MessageToast from \"sap/m/MessageToast\";\n\n/**\n * @namespace cds.plugin.caching.dashboard.controller\n */\nexport default class App extends BaseController {\n\tprivate statisticsService: CacheStatisticsService;\n\n\n\tpublic onInit(): void {\n\t\t// apply content density mode to root view\n\t\tthis.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass());\n\t}\n\n\tpublic onSelectionChange(oEvent: IconTabBar$SelectEvent): void {\n\t\tconst key = oEvent.getParameter(\"selectedKey\");\n\t\tthis.getRouter().navTo(key);\n\t}\n\n\t/**\n\t * Handle cache selection change\n\t */\n\tpublic async onCacheChange(): Promise<void> {\n\t\tconst selectedCache = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\tif (selectedCache) {\n\t\t\tawait this.loadRuntimeConfiguration(selectedCache);\n\t\t}\n\t}\n\n\t/**\n\t * Load runtime configuration for the selected cache\n\t */\n\tprivate async loadRuntimeConfiguration(cacheName: string): Promise<void> {\n\t\ttry {\n\t\t\tconst config = await this.statisticsService.getRuntimeConfiguration(cacheName);\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", config.enableStatistics);\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", config.enableKeyTracking);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error loading runtime configuration:\", error);\n\t\t\t// Set defaults if loading fails\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", false);\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", false);\n\t\t}\n\t}\n\n\t/**\n\t * Handle statistics enable/disable switch change\n\t */\n\tpublic async onEnableStatisticsChange(oEvent: any): Promise<void> {\n\t\tconst enabled = oEvent.getParameter(\"state\");\n\t\tconst cacheName = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\t\n\t\tif (!cacheName) {\n\t\t\tMessageBox.warning(\"No cache selected\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", !enabled);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Show loading state\n\t\t\tMessageToast.show(\"Updating statistics configuration...\");\n\t\t\t\n\t\t\tconst success = await this.statisticsService.setStatisticsEnabled(cacheName, enabled);\n\t\t\tif (success) {\n\t\t\t\tMessageToast.show(`Statistics ${enabled ? 'enabled' : 'disabled'} successfully`);\n\t\t\t\t// Reload the configuration to reflect the change\n\t\t\t\tawait this.loadRuntimeConfiguration(cacheName);\n\t\t\t} else {\n\t\t\t\tMessageToast.show(\"Failed to update statistics configuration\");\n\t\t\t\t// Revert the switch\n\t\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", !enabled);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error updating statistics configuration:\", error);\n\t\t\tMessageToast.show(\"Error updating statistics configuration\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", !enabled);\n\t\t}\n\t}\n\n\t/**\n\t * Handle key tracking enable/disable switch change\n\t */\n\tpublic async onEnableKeyTrackingChange(oEvent: any): Promise<void> {\n\t\tconst enabled = oEvent.getParameter(\"state\");\n\t\tconst cacheName = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\t\n\t\tif (!cacheName) {\n\t\t\tMessageBox.warning(\"No cache selected\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", !enabled);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Show loading state\n\t\t\tMessageToast.show(\"Updating key tracking configuration...\");\n\t\t\t\n\t\t\tconst success = await this.statisticsService.setKeyTrackingEnabled(cacheName, enabled);\n\t\t\tif (success) {\n\t\t\t\tMessageToast.show(`Key tracking ${enabled ? 'enabled' : 'disabled'} successfully`);\n\t\t\t\t// Reload the configuration to reflect the change\n\t\t\t\tawait this.loadRuntimeConfiguration(cacheName);\n\t\t\t} else {\n\t\t\t\tMessageToast.show(\"Failed to update key tracking configuration\");\n\t\t\t\t// Revert the switch\n\t\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", !enabled);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error updating key tracking configuration:\", error);\n\t\t\tMessageToast.show(\"Error updating key tracking configuration\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", !enabled);\n\t\t}\n\t}\n\n\t/**\n\t * Persist statistics to database\n\t */\n\tpublic async onPersistStatistics(): Promise<void> {\n\t\ttry {\n\t\t\tconst cacheName = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\t\tif (!cacheName) {\n\t\t\t\tMessageBox.warning(\"No cache selected\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst success = await this.statisticsService.persistStatistics(cacheName);\n\t\t\tif (success) {\n\t\t\t\tMessageToast.show(\"Statistics persisted successfully\");\n\t\t\t} else {\n\t\t\t\tMessageToast.show(\"Failed to persist statistics\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error persisting statistics:\", error);\n\t\t\tMessageToast.show(\"Error persisting statistics\");\n\t\t}\n\t}\n\n}\n"],"mappings":";;;;;;QACOA,cAAc,GAAAC,sBAAA,CAAAC,gBAAA;EAOrB;AACA;AACA;EAFA,MAGqBC,GAAG,GAASH,cAAc,CAAAI,MAAA;IAIvCC,MAAM,WAAAC,QAAA,EAAS;MACrB;MACA,IAAI,CAACC,OAAO,CAAC,CAAC,CAACC,aAAa,CAAC,IAAI,CAACC,iBAAiB,CAAC,CAAC,CAACC,sBAAsB,CAAC,CAAC,CAAC;IA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EA,MAAMG,OAAO,GAAG,MAAM,IAAI,CAACd,iBAAiB,CAACqB,iBAAiB,CAACvB,SAAS,CAAC;QACzE,IAAIgB,OAAO,EAAE;UACZF,YAAY,CAACC,IAAI,CAAC,mCAAmC,CAAC;QACvD,CAAC,MAAM;UACND,YAAY,CAACC,IAAI,CAAC,8BAA8B,CAAC;QAClD;MACD,CAAC,CAAC,OAAOR,KAAK,EAAE;QACfC,OAAO,CAACD,KAAK,CAAC,8BAA8B,EAAEA,KAAK,CAAC;QACpDO,YAAY,CAACC,IAAI,CAAC,6BAA6B,CAAC;MACjD;IACD;EAAC;EAAA,OArImBrC,GAAG;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define(["sap/m/MessageBox","./BaseController","sap/m/MessageToast"],function(t,e,s){"use strict";function i(t){return t&&t.__esModule&&typeof t.default!=="undefined"?t.default:t}const a=i(e);const n=a.extend("cds.plugin.caching.dashboard.controller.App",{onInit:function t(){this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass())},onSelectionChange:function t(e){const s=e.getParameter("selectedKey");this.getRouter().navTo(s)},onCacheChange:async function t(){const e=this.getModel("app").getProperty("/selectedCache");if(e){await this.loadRuntimeConfiguration(e)}},loadRuntimeConfiguration:async function t(e){try{const t=await this.statisticsService.getRuntimeConfiguration(e);this.getModel("app").setProperty("/enableStatistics",t.enableStatistics);this.getModel("app").setProperty("/enableKeyTracking",t.enableKeyTracking)}catch(t){console.error("Error loading runtime configuration:",t);this.getModel("app").setProperty("/enableStatistics",false);this.getModel("app").setProperty("/enableKeyTracking",false)}},onEnableStatisticsChange:async function e(i){const a=i.getParameter("state");const n=this.getModel("app").getProperty("/selectedCache");if(!n){t.warning("No cache selected");this.getModel("app").setProperty("/enableStatistics",!a);return}try{s.show("Updating statistics configuration...");const t=await this.statisticsService.setStatisticsEnabled(n,a);if(t){s.show(`Statistics ${a?"enabled":"disabled"} successfully`);await this.loadRuntimeConfiguration(n)}else{s.show("Failed to update statistics configuration");this.getModel("app").setProperty("/enableStatistics",!a)}}catch(t){console.error("Error updating statistics configuration:",t);s.show("Error updating statistics configuration");this.getModel("app").setProperty("/enableStatistics",!a)}},onEnableKeyTrackingChange:async function e(i){const a=i.getParameter("state");const n=this.getModel("app").getProperty("/selectedCache");if(!n){t.warning("No cache selected");this.getModel("app").setProperty("/enableKeyTracking",!a);return}try{s.show("Updating key tracking configuration...");const t=await this.statisticsService.setKeyTrackingEnabled(n,a);if(t){s.show(`Key tracking ${a?"enabled":"disabled"} successfully`);await this.loadRuntimeConfiguration(n)}else{s.show("Failed to update key tracking configuration");this.getModel("app").setProperty("/enableKeyTracking",!a)}}catch(t){console.error("Error updating key tracking configuration:",t);s.show("Error updating key tracking configuration");this.getModel("app").setProperty("/enableKeyTracking",!a)}},onPersistStatistics:async function e(){try{const e=this.getModel("app").getProperty("/selectedCache");if(!e){t.warning("No cache selected");return}const i=await this.statisticsService.persistStatistics(e);if(i){s.show("Statistics persisted successfully")}else{s.show("Failed to persist statistics")}}catch(t){console.error("Error persisting statistics:",t);s.show("Error persisting statistics")}}});return n});
|
|
2
|
+
//# sourceMappingURL=App.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.controller.js","names":["BaseController","_interopRequireDefault","__BaseController","App","extend","onInit","_onInit","this","getView","addStyleClass","getOwnerComponent","getContentDensityClass","onSelectionChange","_onSelectionChange","oEvent","key","getParameter","getRouter","navTo","onCacheChange","async","_onCacheChange","selectedCache","getModel","getProperty","loadRuntimeConfiguration","_loadRuntimeConfiguration","cacheName","config","statisticsService","getRuntimeConfiguration","setProperty","enableStatistics","enableKeyTracking","error","console","onEnableStatisticsChange","_onEnableStatisticsChange","enabled","MessageBox","warning","MessageToast","show","success","setStatisticsEnabled","onEnableKeyTrackingChange","_onEnableKeyTrackingChange","setKeyTrackingEnabled","onPersistStatistics","_onPersistStatistics","persistStatistics"],"sources":["App.controller.ts"],"sourcesContent":["import MessageBox from \"sap/m/MessageBox\";\nimport BaseController from \"./BaseController\";\nimport { IconTabBar$SelectEvent } from \"sap/m/IconTabBar\";\nimport CacheStatisticsService from \"../service/CacheStatisticsService\";\nimport ODataModel from \"sap/ui/model/odata/v4/ODataModel\";\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\nimport MessageToast from \"sap/m/MessageToast\";\n\n/**\n * @namespace cds.plugin.caching.dashboard.controller\n */\nexport default class App extends BaseController {\n\tprivate statisticsService: CacheStatisticsService;\n\n\n\tpublic onInit(): void {\n\t\t// apply content density mode to root view\n\t\tthis.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass());\n\t}\n\n\tpublic onSelectionChange(oEvent: IconTabBar$SelectEvent): void {\n\t\tconst key = oEvent.getParameter(\"selectedKey\");\n\t\tthis.getRouter().navTo(key);\n\t}\n\n\t/**\n\t * Handle cache selection change\n\t */\n\tpublic async onCacheChange(): Promise<void> {\n\t\tconst selectedCache = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\tif (selectedCache) {\n\t\t\tawait this.loadRuntimeConfiguration(selectedCache);\n\t\t}\n\t}\n\n\t/**\n\t * Load runtime configuration for the selected cache\n\t */\n\tprivate async loadRuntimeConfiguration(cacheName: string): Promise<void> {\n\t\ttry {\n\t\t\tconst config = await this.statisticsService.getRuntimeConfiguration(cacheName);\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", config.enableStatistics);\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", config.enableKeyTracking);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error loading runtime configuration:\", error);\n\t\t\t// Set defaults if loading fails\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", false);\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", false);\n\t\t}\n\t}\n\n\t/**\n\t * Handle statistics enable/disable switch change\n\t */\n\tpublic async onEnableStatisticsChange(oEvent: any): Promise<void> {\n\t\tconst enabled = oEvent.getParameter(\"state\");\n\t\tconst cacheName = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\t\n\t\tif (!cacheName) {\n\t\t\tMessageBox.warning(\"No cache selected\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", !enabled);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Show loading state\n\t\t\tMessageToast.show(\"Updating statistics configuration...\");\n\t\t\t\n\t\t\tconst success = await this.statisticsService.setStatisticsEnabled(cacheName, enabled);\n\t\t\tif (success) {\n\t\t\t\tMessageToast.show(`Statistics ${enabled ? 'enabled' : 'disabled'} successfully`);\n\t\t\t\t// Reload the configuration to reflect the change\n\t\t\t\tawait this.loadRuntimeConfiguration(cacheName);\n\t\t\t} else {\n\t\t\t\tMessageToast.show(\"Failed to update statistics configuration\");\n\t\t\t\t// Revert the switch\n\t\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", !enabled);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error updating statistics configuration:\", error);\n\t\t\tMessageToast.show(\"Error updating statistics configuration\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableStatistics\", !enabled);\n\t\t}\n\t}\n\n\t/**\n\t * Handle key tracking enable/disable switch change\n\t */\n\tpublic async onEnableKeyTrackingChange(oEvent: any): Promise<void> {\n\t\tconst enabled = oEvent.getParameter(\"state\");\n\t\tconst cacheName = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\t\n\t\tif (!cacheName) {\n\t\t\tMessageBox.warning(\"No cache selected\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", !enabled);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Show loading state\n\t\t\tMessageToast.show(\"Updating key tracking configuration...\");\n\t\t\t\n\t\t\tconst success = await this.statisticsService.setKeyTrackingEnabled(cacheName, enabled);\n\t\t\tif (success) {\n\t\t\t\tMessageToast.show(`Key tracking ${enabled ? 'enabled' : 'disabled'} successfully`);\n\t\t\t\t// Reload the configuration to reflect the change\n\t\t\t\tawait this.loadRuntimeConfiguration(cacheName);\n\t\t\t} else {\n\t\t\t\tMessageToast.show(\"Failed to update key tracking configuration\");\n\t\t\t\t// Revert the switch\n\t\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", !enabled);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error updating key tracking configuration:\", error);\n\t\t\tMessageToast.show(\"Error updating key tracking configuration\");\n\t\t\t// Revert the switch\n\t\t\t(this.getModel(\"app\") as JSONModel).setProperty(\"/enableKeyTracking\", !enabled);\n\t\t}\n\t}\n\n\t/**\n\t * Persist statistics to database\n\t */\n\tpublic async onPersistStatistics(): Promise<void> {\n\t\ttry {\n\t\t\tconst cacheName = this.getModel(\"app\").getProperty(\"/selectedCache\");\n\t\t\tif (!cacheName) {\n\t\t\t\tMessageBox.warning(\"No cache selected\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst success = await this.statisticsService.persistStatistics(cacheName);\n\t\t\tif (success) {\n\t\t\t\tMessageToast.show(\"Statistics persisted successfully\");\n\t\t\t} else {\n\t\t\t\tMessageToast.show(\"Failed to persist statistics\");\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error persisting statistics:\", error);\n\t\t\tMessageToast.show(\"Error persisting statistics\");\n\t\t}\n\t}\n\n}\n"],"mappings":"+LACOA,EAAcC,EAAAC,GAOrB,MAGqBC,EAAYH,EAAcI,OAAA,+CAIvCC,OAAM,SAAAC,IAEZC,KAAKC,UAAUC,cAAcF,KAAKG,oBAAoBC,yBACvD,EAEOC,kBAAiB,SAAAC,EAACC,GACxB,MAAMC,EAAMD,EAAOE,aAAa,eAChCT,KAAKU,YAAYC,MAAMH,EACxB,EAKa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,EAAWC,QAAQ,qBAElBjC,KAAKgB,SAAS,OAAqBQ,YAAY,sBAAuBO,GACvE,MACD,CAEA,IAECG,EAAaC,KAAK,0CAElB,MAAMC,QAAgBpC,KAAKsB,kBAAkBkB,sBAAsBpB,EAAWW,GAC9E,GAAIK,EAAS,CACZF,EAAaC,KAAK,gBAAgBJ,EAAU,UAAY,iCAElD/B,KAAKkB,yBAAyBE,EACrC,KAAO,CACNc,EAAaC,KAAK,+CAEjBnC,KAAKgB,SAAS,OAAqBQ,YAAY,sBAAuBO,EACxE,CACD,CAAE,MAAOJ,GACRC,QAAQD,MAAM,6CAA8CA,GAC5DO,EAAaC,KAAK,6CAEjBnC,KAAKgB,SAAS,OAAqBQ,YAAY,sBAAuBO,EACxE,CACD,EAKaU,oBAAmB5B,eAAA6B,IAC/B,IACC,MAAMtB,EAAYpB,KAAKgB,SAAS,OAAOC,YAAY,kBACnD,IAAKG,EAAW,CACfY,EAAWC,QAAQ,qBACnB,MACD,CAEA,MAAMG,QAAgBpC,KAAKsB,kBAAkBqB,kBAAkBvB,GAC/D,GAAIgB,EAAS,CACZF,EAAaC,KAAK,oCACnB,KAAO,CACND,EAAaC,KAAK,+BACnB,CACD,CAAE,MAAOR,GACRC,QAAQD,MAAM,+BAAgCA,GAC9CO,EAAaC,KAAK,8BACnB,CACD,IAAC,OArImBvC,CAAG","ignoreList":[]}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import MessageBox from "sap/m/MessageBox";
|
|
2
|
+
import BaseController from "./BaseController";
|
|
3
|
+
import { IconTabBar$SelectEvent } from "sap/m/IconTabBar";
|
|
4
|
+
import CacheStatisticsService from "../service/CacheStatisticsService";
|
|
5
|
+
import ODataModel from "sap/ui/model/odata/v4/ODataModel";
|
|
6
|
+
import JSONModel from "sap/ui/model/json/JSONModel";
|
|
7
|
+
import MessageToast from "sap/m/MessageToast";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @namespace cds.plugin.caching.dashboard.controller
|
|
11
|
+
*/
|
|
12
|
+
export default class App extends BaseController {
|
|
13
|
+
private statisticsService: CacheStatisticsService;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
public onInit(): void {
|
|
17
|
+
// apply content density mode to root view
|
|
18
|
+
this.getView().addStyleClass(this.getOwnerComponent().getContentDensityClass());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public onSelectionChange(oEvent: IconTabBar$SelectEvent): void {
|
|
22
|
+
const key = oEvent.getParameter("selectedKey");
|
|
23
|
+
this.getRouter().navTo(key);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Handle cache selection change
|
|
28
|
+
*/
|
|
29
|
+
public async onCacheChange(): Promise<void> {
|
|
30
|
+
const selectedCache = this.getModel("app").getProperty("/selectedCache");
|
|
31
|
+
if (selectedCache) {
|
|
32
|
+
await this.loadRuntimeConfiguration(selectedCache);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Load runtime configuration for the selected cache
|
|
38
|
+
*/
|
|
39
|
+
private async loadRuntimeConfiguration(cacheName: string): Promise<void> {
|
|
40
|
+
try {
|
|
41
|
+
const config = await this.statisticsService.getRuntimeConfiguration(cacheName);
|
|
42
|
+
(this.getModel("app") as JSONModel).setProperty("/enableStatistics", config.enableStatistics);
|
|
43
|
+
(this.getModel("app") as JSONModel).setProperty("/enableKeyTracking", config.enableKeyTracking);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Error loading runtime configuration:", error);
|
|
46
|
+
// Set defaults if loading fails
|
|
47
|
+
(this.getModel("app") as JSONModel).setProperty("/enableStatistics", false);
|
|
48
|
+
(this.getModel("app") as JSONModel).setProperty("/enableKeyTracking", false);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Handle statistics enable/disable switch change
|
|
54
|
+
*/
|
|
55
|
+
public async onEnableStatisticsChange(oEvent: any): Promise<void> {
|
|
56
|
+
const enabled = oEvent.getParameter("state");
|
|
57
|
+
const cacheName = this.getModel("app").getProperty("/selectedCache");
|
|
58
|
+
|
|
59
|
+
if (!cacheName) {
|
|
60
|
+
MessageBox.warning("No cache selected");
|
|
61
|
+
// Revert the switch
|
|
62
|
+
(this.getModel("app") as JSONModel).setProperty("/enableStatistics", !enabled);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
// Show loading state
|
|
68
|
+
MessageToast.show("Updating statistics configuration...");
|
|
69
|
+
|
|
70
|
+
const success = await this.statisticsService.setStatisticsEnabled(cacheName, enabled);
|
|
71
|
+
if (success) {
|
|
72
|
+
MessageToast.show(`Statistics ${enabled ? 'enabled' : 'disabled'} successfully`);
|
|
73
|
+
// Reload the configuration to reflect the change
|
|
74
|
+
await this.loadRuntimeConfiguration(cacheName);
|
|
75
|
+
} else {
|
|
76
|
+
MessageToast.show("Failed to update statistics configuration");
|
|
77
|
+
// Revert the switch
|
|
78
|
+
(this.getModel("app") as JSONModel).setProperty("/enableStatistics", !enabled);
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error("Error updating statistics configuration:", error);
|
|
82
|
+
MessageToast.show("Error updating statistics configuration");
|
|
83
|
+
// Revert the switch
|
|
84
|
+
(this.getModel("app") as JSONModel).setProperty("/enableStatistics", !enabled);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Handle key tracking enable/disable switch change
|
|
90
|
+
*/
|
|
91
|
+
public async onEnableKeyTrackingChange(oEvent: any): Promise<void> {
|
|
92
|
+
const enabled = oEvent.getParameter("state");
|
|
93
|
+
const cacheName = this.getModel("app").getProperty("/selectedCache");
|
|
94
|
+
|
|
95
|
+
if (!cacheName) {
|
|
96
|
+
MessageBox.warning("No cache selected");
|
|
97
|
+
// Revert the switch
|
|
98
|
+
(this.getModel("app") as JSONModel).setProperty("/enableKeyTracking", !enabled);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
// Show loading state
|
|
104
|
+
MessageToast.show("Updating key tracking configuration...");
|
|
105
|
+
|
|
106
|
+
const success = await this.statisticsService.setKeyTrackingEnabled(cacheName, enabled);
|
|
107
|
+
if (success) {
|
|
108
|
+
MessageToast.show(`Key tracking ${enabled ? 'enabled' : 'disabled'} successfully`);
|
|
109
|
+
// Reload the configuration to reflect the change
|
|
110
|
+
await this.loadRuntimeConfiguration(cacheName);
|
|
111
|
+
} else {
|
|
112
|
+
MessageToast.show("Failed to update key tracking configuration");
|
|
113
|
+
// Revert the switch
|
|
114
|
+
(this.getModel("app") as JSONModel).setProperty("/enableKeyTracking", !enabled);
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error("Error updating key tracking configuration:", error);
|
|
118
|
+
MessageToast.show("Error updating key tracking configuration");
|
|
119
|
+
// Revert the switch
|
|
120
|
+
(this.getModel("app") as JSONModel).setProperty("/enableKeyTracking", !enabled);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Persist statistics to database
|
|
126
|
+
*/
|
|
127
|
+
public async onPersistStatistics(): Promise<void> {
|
|
128
|
+
try {
|
|
129
|
+
const cacheName = this.getModel("app").getProperty("/selectedCache");
|
|
130
|
+
if (!cacheName) {
|
|
131
|
+
MessageBox.warning("No cache selected");
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const success = await this.statisticsService.persistStatistics(cacheName);
|
|
136
|
+
if (success) {
|
|
137
|
+
MessageToast.show("Statistics persisted successfully");
|
|
138
|
+
} else {
|
|
139
|
+
MessageToast.show("Failed to persist statistics");
|
|
140
|
+
}
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error("Error persisting statistics:", error);
|
|
143
|
+
MessageToast.show("Error persisting statistics");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/UIComponent", "sap/ui/core/routing/History"], function (Controller, UIComponent, History) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @namespace cds.plugin.caching.dashboard.controller
|
|
6
|
+
*/
|
|
7
|
+
const BaseController = Controller.extend("cds.plugin.caching.dashboard.controller.BaseController", {
|
|
8
|
+
onInit: function _onInit() {},
|
|
9
|
+
/**
|
|
10
|
+
* Convenience method for accessing the component of the controller's view.
|
|
11
|
+
* @returns The component of the controller's view
|
|
12
|
+
*/
|
|
13
|
+
getOwnerComponent: function _getOwnerComponent() {
|
|
14
|
+
return Controller.prototype.getOwnerComponent.call(this);
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Convenience method to get the components' router instance.
|
|
18
|
+
* @returns The router instance
|
|
19
|
+
*/
|
|
20
|
+
getRouter: function _getRouter() {
|
|
21
|
+
return UIComponent.getRouterFor(this);
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Convenience method for getting the i18n resource bundle of the component.
|
|
25
|
+
* @returns {Promise<sap.base.i18n.ResourceBundle>} The i18n resource bundle of the component
|
|
26
|
+
*/
|
|
27
|
+
getResourceBundle: function _getResourceBundle() {
|
|
28
|
+
const oModel = this.getOwnerComponent().getModel("i18n");
|
|
29
|
+
return oModel.getResourceBundle();
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Convenience method for getting the view model by name in every controller of the application.
|
|
33
|
+
* @param [sName] The model name
|
|
34
|
+
* @returns The model instance
|
|
35
|
+
*/
|
|
36
|
+
getModel: function _getModel(sName) {
|
|
37
|
+
return this.getView().getModel(sName);
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Convenience method for setting the view model in every controller of the application.
|
|
41
|
+
* @param oModel The model instance
|
|
42
|
+
* @param [sName] The model name
|
|
43
|
+
* @returns The current base controller instance
|
|
44
|
+
*/
|
|
45
|
+
setModel: function _setModel(oModel, sName) {
|
|
46
|
+
this.getView().setModel(oModel, sName);
|
|
47
|
+
return this;
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Convenience method for triggering the navigation to a specific target.
|
|
51
|
+
* @public
|
|
52
|
+
* @param sName Target name
|
|
53
|
+
* @param [oParameters] Navigation parameters
|
|
54
|
+
* @param [bReplace] Defines if the hash should be replaced (no browser history entry) or set (browser history entry)
|
|
55
|
+
*/
|
|
56
|
+
navTo: function _navTo(sName, oParameters, bReplace) {
|
|
57
|
+
this.getRouter().navTo(sName, oParameters, undefined, bReplace);
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Convenience event handler for navigating back.
|
|
61
|
+
* It there is a history entry we go one step back in the browser history
|
|
62
|
+
* If not, it will replace the current entry of the browser history with the main route.
|
|
63
|
+
*/
|
|
64
|
+
onNavBack: function _onNavBack() {
|
|
65
|
+
const sPreviousHash = History.getInstance().getPreviousHash();
|
|
66
|
+
if (sPreviousHash !== undefined) {
|
|
67
|
+
window.history.go(-1);
|
|
68
|
+
} else {
|
|
69
|
+
this.getRouter().navTo("main", {}, undefined, true);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return BaseController;
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=BaseController-dbg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseController-dbg.js","names":["BaseController","Controller","extend","onInit","_onInit","getOwnerComponent","_getOwnerComponent","Controller.prototype.getOwnerComponent.call","getRouter","_getRouter","UIComponent","getRouterFor","getResourceBundle","_getResourceBundle","oModel","getModel","_getModel","sName","getView","setModel","_setModel","navTo","_navTo","oParameters","bReplace","undefined","onNavBack","_onNavBack","sPreviousHash","History","getInstance","getPreviousHash","window","history","go"],"sources":["BaseController.ts"],"sourcesContent":["import Controller from \"sap/ui/core/mvc/Controller\";\nimport UIComponent from \"sap/ui/core/UIComponent\";\nimport AppComponent from \"../Component\";\nimport Model from \"sap/ui/model/Model\";\nimport ResourceModel from \"sap/ui/model/resource/ResourceModel\";\nimport ResourceBundle from \"sap/base/i18n/ResourceBundle\";\nimport Router from \"sap/ui/core/routing/Router\";\nimport History from \"sap/ui/core/routing/History\";\n\n/**\n * @namespace cds.plugin.caching.dashboard.controller\n */\nexport default abstract class BaseController extends Controller {\n\n\tpublic onInit(): void {\n\t\t\n\t}\n\n\t/**\n\t * Convenience method for accessing the component of the controller's view.\n\t * @returns The component of the controller's view\n\t */\n\tpublic getOwnerComponent(): AppComponent {\n\t\treturn super.getOwnerComponent() as AppComponent;\n\t}\n\n\t/**\n\t * Convenience method to get the components' router instance.\n\t * @returns The router instance\n\t */\n\tpublic getRouter(): Router {\n\t\treturn UIComponent.getRouterFor(this);\n\t}\n\n\t/**\n\t * Convenience method for getting the i18n resource bundle of the component.\n\t * @returns {Promise<sap.base.i18n.ResourceBundle>} The i18n resource bundle of the component\n\t */\n\tpublic getResourceBundle(): Promise<ResourceBundle> {\n\t\tconst oModel = this.getOwnerComponent().getModel(\"i18n\") as ResourceModel;\n\t\treturn oModel.getResourceBundle() as Promise<ResourceBundle>;\n\t}\n\n\t/**\n\t * Convenience method for getting the view model by name in every controller of the application.\n\t * @param [sName] The model name\n\t * @returns The model instance\n\t */\n\tpublic getModel(sName?: string): Model {\n\t\treturn this.getView().getModel(sName);\n\t}\n\n\t/**\n\t * Convenience method for setting the view model in every controller of the application.\n\t * @param oModel The model instance\n\t * @param [sName] The model name\n\t * @returns The current base controller instance\n\t */\n\tpublic setModel(oModel: Model, sName?: string): BaseController {\n\t\tthis.getView().setModel(oModel, sName);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Convenience method for triggering the navigation to a specific target.\n\t * @public\n\t * @param sName Target name\n\t * @param [oParameters] Navigation parameters\n\t * @param [bReplace] Defines if the hash should be replaced (no browser history entry) or set (browser history entry)\n\t */\n\tpublic navTo(sName: string, oParameters?: object, bReplace?: boolean): void {\n\t\tthis.getRouter().navTo(sName, oParameters, undefined, bReplace);\n\t}\n\n\t/**\n\t * Convenience event handler for navigating back.\n\t * It there is a history entry we go one step back in the browser history\n\t * If not, it will replace the current entry of the browser history with the main route.\n\t */\n\tpublic onNavBack(): void {\n\t\tconst sPreviousHash = History.getInstance().getPreviousHash();\n\t\tif (sPreviousHash !== undefined) {\n\t\t\twindow.history.go(-1);\n\t\t} else {\n\t\t\tthis.getRouter().navTo(\"main\", {}, undefined, true);\n\t\t}\n\t}\n}\n"],"mappings":";;;EASA;AACA;AACA;EAFA,MAG8BA,cAAc,GAASC,UAAU,CAAAC,MAAA;IAEvDC,MAAM,WAAAC,QAAA,EAAS,CAEtB,CAAC;IAED;AACD;AACA;AACA;IACQC,iBAAiB,WAAAC,mBAAA,EAAiB;MACxC,OAAAC,2CAAA;IACD,CAAC;IAED;AACD;AACA;AACA;IACQC,SAAS,WAAAC,WAAA,EAAW;MAC1B,OAAOC,WAAW,CAACC,YAAY,CAAC,IAAI,CAAC;IACtC,CAAC;IAED;AACD;AACA;AACA;IACQC,iBAAiB,WAAAC,mBAAA,EAA4B;MACnD,MAAMC,MAAM,GAAG,IAAI,CAACT,iBAAiB,CAAC,CAAC,CAACU,QAAQ,CAAC,MAAM,CAAkB;MACzE,OAAOD,MAAM,CAACF,iBAAiB,CAAC,CAAC;IAClC,CAAC;IAED;AACD;AACA;AACA;AACA;IACQG,QAAQ,WAAAC,UAACC,KAAc,EAAS;MACtC,OAAO,IAAI,CAACC,OAAO,CAAC,CAAC,CAACH,QAAQ,CAACE,KAAK,CAAC;IACtC,CAAC;IAED;AACD;AACA;AACA;AACA;AACA;IACQE,QAAQ,WAAAC,UAACN,MAAa,EAAEG,KAAc,EAAkB;MAC9D,IAAI,CAACC,OAAO,CAAC,CAAC,CAACC,QAAQ,CAACL,MAAM,EAAEG,KAAK,CAAC;MACtC,OAAO,IAAI;IACZ,CAAC;IAED;AACD;AACA;AACA;AACA;AACA;AACA;IACQI,KAAK,WAAAC,OAACL,KAAa,EAAEM,WAAoB,EAAEC,QAAkB,EAAQ;MAC3E,IAAI,CAAChB,SAAS,CAAC,CAAC,CAACa,KAAK,CAACJ,KAAK,EAAEM,WAAW,EAAEE,SAAS,EAAED,QAAQ,CAAC;IAChE,CAAC;IAED;AACD;AACA;AACA;AACA;IACQE,SAAS,WAAAC,WAAA,EAAS;MACxB,MAAMC,aAAa,GAAGC,OAAO,CAACC,WAAW,CAAC,CAAC,CAACC,eAAe,CAAC,CAAC;MAC7D,IAAIH,aAAa,KAAKH,SAAS,EAAE;QAChCO,MAAM,CAACC,OAAO,CAACC,EAAE,CAAC,CAAC,CAAC,CAAC;MACtB,CAAC,MAAM;QACN,IAAI,CAAC1B,SAAS,CAAC,CAAC,CAACa,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAEI,SAAS,EAAE,IAAI,CAAC;MACpD;IACD;EAAC;EAAA,OA1E4BzB,cAAc;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define(["sap/ui/core/mvc/Controller","sap/ui/core/UIComponent","sap/ui/core/routing/History"],function(e,t,n){"use strict";const o=e.extend("cds.plugin.caching.dashboard.controller.BaseController",{onInit:function e(){},getOwnerComponent:function t(){return e.prototype.getOwnerComponent.call(this)},getRouter:function e(){return t.getRouterFor(this)},getResourceBundle:function e(){const t=this.getOwnerComponent().getModel("i18n");return t.getResourceBundle()},getModel:function e(t){return this.getView().getModel(t)},setModel:function e(t,n){this.getView().setModel(t,n);return this},navTo:function e(t,n,o){this.getRouter().navTo(t,n,undefined,o)},onNavBack:function e(){const t=n.getInstance().getPreviousHash();if(t!==undefined){window.history.go(-1)}else{this.getRouter().navTo("main",{},undefined,true)}}});return o});
|
|
2
|
+
//# sourceMappingURL=BaseController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseController.js","names":["BaseController","Controller","extend","onInit","_onInit","getOwnerComponent","_getOwnerComponent","Controller.prototype.getOwnerComponent.call","this","getRouter","_getRouter","UIComponent","getRouterFor","getResourceBundle","_getResourceBundle","oModel","getModel","_getModel","sName","getView","setModel","_setModel","navTo","_navTo","oParameters","bReplace","undefined","onNavBack","_onNavBack","sPreviousHash","History","getInstance","getPreviousHash","window","history","go"],"sources":["BaseController.ts"],"sourcesContent":["import Controller from \"sap/ui/core/mvc/Controller\";\nimport UIComponent from \"sap/ui/core/UIComponent\";\nimport AppComponent from \"../Component\";\nimport Model from \"sap/ui/model/Model\";\nimport ResourceModel from \"sap/ui/model/resource/ResourceModel\";\nimport ResourceBundle from \"sap/base/i18n/ResourceBundle\";\nimport Router from \"sap/ui/core/routing/Router\";\nimport History from \"sap/ui/core/routing/History\";\n\n/**\n * @namespace cds.plugin.caching.dashboard.controller\n */\nexport default abstract class BaseController extends Controller {\n\n\tpublic onInit(): void {\n\t\t\n\t}\n\n\t/**\n\t * Convenience method for accessing the component of the controller's view.\n\t * @returns The component of the controller's view\n\t */\n\tpublic getOwnerComponent(): AppComponent {\n\t\treturn super.getOwnerComponent() as AppComponent;\n\t}\n\n\t/**\n\t * Convenience method to get the components' router instance.\n\t * @returns The router instance\n\t */\n\tpublic getRouter(): Router {\n\t\treturn UIComponent.getRouterFor(this);\n\t}\n\n\t/**\n\t * Convenience method for getting the i18n resource bundle of the component.\n\t * @returns {Promise<sap.base.i18n.ResourceBundle>} The i18n resource bundle of the component\n\t */\n\tpublic getResourceBundle(): Promise<ResourceBundle> {\n\t\tconst oModel = this.getOwnerComponent().getModel(\"i18n\") as ResourceModel;\n\t\treturn oModel.getResourceBundle() as Promise<ResourceBundle>;\n\t}\n\n\t/**\n\t * Convenience method for getting the view model by name in every controller of the application.\n\t * @param [sName] The model name\n\t * @returns The model instance\n\t */\n\tpublic getModel(sName?: string): Model {\n\t\treturn this.getView().getModel(sName);\n\t}\n\n\t/**\n\t * Convenience method for setting the view model in every controller of the application.\n\t * @param oModel The model instance\n\t * @param [sName] The model name\n\t * @returns The current base controller instance\n\t */\n\tpublic setModel(oModel: Model, sName?: string): BaseController {\n\t\tthis.getView().setModel(oModel, sName);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Convenience method for triggering the navigation to a specific target.\n\t * @public\n\t * @param sName Target name\n\t * @param [oParameters] Navigation parameters\n\t * @param [bReplace] Defines if the hash should be replaced (no browser history entry) or set (browser history entry)\n\t */\n\tpublic navTo(sName: string, oParameters?: object, bReplace?: boolean): void {\n\t\tthis.getRouter().navTo(sName, oParameters, undefined, bReplace);\n\t}\n\n\t/**\n\t * Convenience event handler for navigating back.\n\t * It there is a history entry we go one step back in the browser history\n\t * If not, it will replace the current entry of the browser history with the main route.\n\t */\n\tpublic onNavBack(): void {\n\t\tconst sPreviousHash = History.getInstance().getPreviousHash();\n\t\tif (sPreviousHash !== undefined) {\n\t\t\twindow.history.go(-1);\n\t\t} else {\n\t\t\tthis.getRouter().navTo(\"main\", {}, undefined, true);\n\t\t}\n\t}\n}\n"],"mappings":"kIASA,MAG8BA,EAAuBC,EAAUC,OAAA,0DAEvDC,OAAM,SAAAC,IAEb,EAMOC,kBAAiB,SAAAC,IACvB,OAAAC,mCAAAC,KACD,EAMOC,UAAS,SAAAC,IACf,OAAOC,EAAYC,aAAaJ,KACjC,EAMOK,kBAAiB,SAAAC,IACvB,MAAMC,EAASP,KAAKH,oBAAoBW,SAAS,QACjD,OAAOD,EAAOF,mBACf,EAOOG,SAAQ,SAAAC,EAACC,GACf,OAAOV,KAAKW,UAAUH,SAASE,EAChC,EAQOE,SAAQ,SAAAC,EAACN,EAAeG,GAC9BV,KAAKW,UAAUC,SAASL,EAAQG,GAChC,OAAOV,IACR,EASOc,MAAK,SAAAC,EAACL,EAAeM,EAAsBC,GACjDjB,KAAKC,YAAYa,MAAMJ,EAAOM,EAAaE,UAAWD,EACvD,EAOOE,UAAS,SAAAC,IACf,MAAMC,EAAgBC,EAAQC,cAAcC,kBAC5C,GAAIH,IAAkBH,UAAW,CAChCO,OAAOC,QAAQC,IAAI,EACpB,KAAO,CACN3B,KAAKC,YAAYa,MAAM,OAAQ,CAAC,EAAGI,UAAW,KAC/C,CACD,IAAC,OA1E4B1B,CAAc","ignoreList":[]}
|