@@ -32,13 +32,11 @@ <h2 class="sectionTitle">Streamyfin</h2>
32
32
33
33
< div id ="yamleditor " style ="width: 800px; height: 600px; border: 0px solid grey "> </ div >
34
34
35
- <!-- <div id="yaml-editor"></div> -->
36
35
37
36
</ div >
38
37
< script id ="hljs " async
39
38
src ="
https://unpkg.com/@skrashevich/[email protected] /dist/monaco-editor.bundle.js "
> </ script >
40
39
41
- <!-- <script type="module" async src="configurationpage?name=config.js"></script> -->
42
40
< script >
43
41
const Streamyfin = {
44
42
pluginId : "1e9e5d38-6e67-4615-8719-e98a5c34f004" ,
@@ -51,25 +49,20 @@ <h2 class="sectionTitle">Streamyfin</h2>
51
49
Value : editor . getModel ( ) . getValue ( )
52
50
} ;
53
51
54
- //alert(window.editor.getModel().getValue());
55
52
const url = window . ApiClient . getUrl ( 'streamyfin/config/yaml' ) ;
56
53
const data = JSON . stringify ( config ) ;
57
- //console.log(data);
58
- //window.ApiClient.getPluginConfiguration(Streamyfin.pluginId)
54
+
59
55
window . ApiClient . ajax ( { type : 'POST' , url, data, contentType : 'application/json' } )
60
56
. then ( function ( response ) {
61
57
response . json ( ) . then ( res => {
62
58
if ( res . Error == true ) {
63
59
Dashboard . hideLoadingMsg ( ) ;
64
60
Dashboard . alert ( res . Message ) ;
65
- //response.statusText = res.Message;
66
- //Dashboard.processErrorResponse(response);
67
61
} else {
68
62
Dashboard . processPluginConfigurationUpdateResult ( ) ;
69
63
}
70
64
} )
71
65
}
72
- //processErrorResponse
73
66
74
67
)
75
68
. catch ( function ( error ) {
@@ -84,17 +77,10 @@ <h2 class="sectionTitle">Streamyfin</h2>
84
77
loadConfig : function ( ) {
85
78
Dashboard . showLoadingMsg ( ) ;
86
79
const url = window . ApiClient . getUrl ( 'streamyfin/config/yaml' ) ;
87
- //window.ApiClient.getPluginConfiguration(Streamyfin.pluginId)
88
80
window . ApiClient . ajax ( { type : 'GET' , url, contentType : 'application/json' } )
89
81
. then ( function ( response ) {
90
82
response . json ( ) . then ( res => {
91
83
const yamlModelUri = monaco . Uri . parse ( 'streamyfin.yaml' ) ;
92
- //monaco.value = "hello";
93
- //console.log(res);
94
- //console.log(config.Yaml);
95
- //const data = JSON.stringify({ Username: username, Password: password });
96
- //const yaml = window.ApiClient.getUrl('streamyfin/config/yaml');
97
- //editor.getModel().setValue(res.Value);
98
84
Streamyfin . editor = monaco . editor . create ( document . getElementById ( 'yamleditor' ) , {
99
85
automaticLayout : true ,
100
86
language : 'yaml' ,
@@ -106,10 +92,6 @@ <h2 class="sectionTitle">Streamyfin</h2>
106
92
model : monaco . editor . createModel ( res . Value , 'yaml' , yamlModelUri ) ,
107
93
} ) ;
108
94
} )
109
- //console.log(config);
110
- //for (let i = 0; i < config.ImportSets.length; i++) {
111
- // CollectionImport.addSet(config.ImportSets[i]);
112
- // }
113
95
} )
114
96
. catch ( function ( error ) {
115
97
console . error ( error ) ;
@@ -119,10 +101,7 @@ <h2 class="sectionTitle">Streamyfin</h2>
119
101
} ) ;
120
102
} ,
121
103
init : function ( ) {
122
-
123
104
monaco . editor . setTheme ( 'vs-dark' ) ;
124
-
125
-
126
105
const monaco_yaml = monacoYaml . configureMonacoYaml ( monaco , {
127
106
enableSchemaRequest : true ,
128
107
hover : true ,
@@ -136,34 +115,17 @@ <h2 class="sectionTitle">Streamyfin</h2>
136
115
} ,
137
116
] ,
138
117
} ) ;
139
- //alert("yo");
140
118
console . log ( "init" ) ;
141
119
Streamyfin . loadConfig ( ) ;
142
120
Streamyfin . btnSave . addEventListener ( "click" , Streamyfin . saveConfig ) ;
143
121
}
144
122
}
145
- //Streamyfin.init();
146
- //});
147
- //}
123
+
148
124
function waitForScript ( ) {
149
125
if ( typeof monaco === "undefined" ) {
150
- // Retry every 50ms
151
- console . log ( "waiting" ) ;
152
- // try {
153
- // console.log(monaco);
154
- // } catch (error) {
155
- // }
156
- // try {
157
- // console.log(Streamyfin);
158
- // } catch (error) {
159
- // }
160
-
161
126
setTimeout ( waitForScript , 50 ) ;
162
127
} else {
163
- // console.log("loaded");
164
- //if (typeof Streamyfin !== 'undefined') {
165
128
Streamyfin . init ( ) ;
166
- // }
167
129
}
168
130
}
169
131
waitForScript ( ) ;
0 commit comments